package com.fs.transfer;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.qw.domain.CustomerTransferApproval;
import com.fs.qw.service.ICustomerTransferApprovalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 客户转移审批Controller
 *
 * @author fs
 * @date 2025-04-01
 */
@RestController
@RequestMapping("/system/approval")
public class CustomerTransferApprovalController extends BaseController
{
    @Autowired
    private ICustomerTransferApprovalService customerTransferApprovalService;

    /**
     * 查询客户转移审批列表
     */
    @PreAuthorize("@ss.hasPermi('system:approval:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomerTransferApproval customerTransferApproval)
    {
        startPage();
        List<CustomerTransferApproval> list = customerTransferApprovalService.selectCustomerTransferApprovalList(customerTransferApproval);
        return getDataTable(list);
    }

    /**
     * 导出客户转移审批列表
     */
    @PreAuthorize("@ss.hasPermi('system:approval:export')")
    @Log(title = "客户转移审批", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CustomerTransferApproval customerTransferApproval)
    {
        List<CustomerTransferApproval> list = customerTransferApprovalService.selectCustomerTransferApprovalList(customerTransferApproval);
        ExcelUtil<CustomerTransferApproval> util = new ExcelUtil<CustomerTransferApproval>(CustomerTransferApproval.class);
        return util.exportExcel(list, "approval");
    }

    /**
     * 获取客户转移审批详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:approval:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(customerTransferApprovalService.selectCustomerTransferApprovalById(id));
    }

    /**
     * 新增客户转移审批
     */
    @PreAuthorize("@ss.hasPermi('system:approval:add')")
    @Log(title = "客户转移审批", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerTransferApproval customerTransferApproval)
    {
        return toAjax(customerTransferApprovalService.insertCustomerTransferApproval(customerTransferApproval));
    }

    /**
     * 修改客户转移审批
     */
    @PreAuthorize("@ss.hasPermi('system:approval:edit')")
    @Log(title = "客户转移审批", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerTransferApproval customerTransferApproval)
    {
        return toAjax(customerTransferApprovalService.updateCustomerTransferApproval(customerTransferApproval));
    }

    /**
     * 删除客户转移审批
     */
    @PreAuthorize("@ss.hasPermi('system:approval:remove')")
    @Log(title = "客户转移审批", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(customerTransferApprovalService.deleteCustomerTransferApprovalByIds(ids));
    }
}
