package com.fs.company.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.company.domain.CompanyRedPacketBalanceLogs;
import com.fs.company.service.ICompanyRedPacketBalanceLogsService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 企业红包余额记录Controller
 * 
 * @author fs
 * @date 2025-11-19
 */
@RestController
@RequestMapping("/company/companyRedPacketBalanceLogs")
public class CompanyRedPacketBalanceLogsController extends BaseController
{
    @Autowired
    private ICompanyRedPacketBalanceLogsService companyRedPacketBalanceLogsService;

    /**
     * 查询企业红包余额记录列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyRedPacketBalanceLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyRedPacketBalanceLogs companyRedPacketBalanceLogs)
    {
        startPage();
        List<CompanyRedPacketBalanceLogs> list = companyRedPacketBalanceLogsService.selectCompanyRedPacketBalanceLogsList(companyRedPacketBalanceLogs);
        return getDataTable(list);
    }

    /**
     * 导出企业红包余额记录列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyRedPacketBalanceLogs:export')")
    @Log(title = "企业红包余额记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyRedPacketBalanceLogs companyRedPacketBalanceLogs)
    {
        List<CompanyRedPacketBalanceLogs> list = companyRedPacketBalanceLogsService.selectCompanyRedPacketBalanceLogsList(companyRedPacketBalanceLogs);
        ExcelUtil<CompanyRedPacketBalanceLogs> util = new ExcelUtil<CompanyRedPacketBalanceLogs>(CompanyRedPacketBalanceLogs.class);
        return util.exportExcel(list, "企业红包余额记录数据");
    }

    /**
     * 获取企业红包余额记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyRedPacketBalanceLogs:query')")
    @GetMapping(value = "/{logsId}")
    public AjaxResult getInfo(@PathVariable("logsId") Long logsId)
    {
        return AjaxResult.success(companyRedPacketBalanceLogsService.selectCompanyRedPacketBalanceLogsByLogsId(logsId));
    }

    /**
     * 新增企业红包余额记录
     */
    @PreAuthorize("@ss.hasPermi('company:companyRedPacketBalanceLogs:add')")
    @Log(title = "企业红包余额记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyRedPacketBalanceLogs companyRedPacketBalanceLogs)
    {
        return toAjax(companyRedPacketBalanceLogsService.insertCompanyRedPacketBalanceLogs(companyRedPacketBalanceLogs));
    }

    /**
     * 修改企业红包余额记录
     */
    @PreAuthorize("@ss.hasPermi('company:companyRedPacketBalanceLogs:edit')")
    @Log(title = "企业红包余额记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyRedPacketBalanceLogs companyRedPacketBalanceLogs)
    {
        return toAjax(companyRedPacketBalanceLogsService.updateCompanyRedPacketBalanceLogs(companyRedPacketBalanceLogs));
    }

    /**
     * 删除企业红包余额记录
     */
    @PreAuthorize("@ss.hasPermi('company:companyRedPacketBalanceLogs:remove')")
    @Log(title = "企业红包余额记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logsIds}")
    public AjaxResult remove(@PathVariable Long[] logsIds)
    {
        return toAjax(companyRedPacketBalanceLogsService.deleteCompanyRedPacketBalanceLogsByLogsIds(logsIds));
    }
}
