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.domain.model.LoginUser;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.ServletUtils;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.framework.web.service.TokenService;
import com.fs.qw.domain.CustomerTransferApprovalQw;
import com.fs.qw.service.ICustomerTransferApprovalQwService;
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-10-24
 */
@RestController
@RequestMapping("qw/system/approval")
public class CustomerTransferApprovalQwController extends BaseController
{
    @Autowired
    private ICustomerTransferApprovalQwService customerTransferApprovalQwService;

    @Autowired
    private TokenService tokenService;
    /**
     * 查询客户转移审批-企微的列表
     */
    @PreAuthorize("@ss.hasPermi('qw:approval:list')")
    @GetMapping("/list")
    public TableDataInfo list(CustomerTransferApprovalQw customerTransferApprovalQw)
    {
        startPage();
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        customerTransferApprovalQw.setInitiatorUserId(loginUser.getUser().getUserId());
        List<CustomerTransferApprovalQw> list = customerTransferApprovalQwService.selectCustomerTransferApprovalQwList(customerTransferApprovalQw);
        return getDataTable(list);
    }

    /**
     * 导出客户转移审批-企微的列表
     */
    @PreAuthorize("@ss.hasPermi('qw:approval:export')")
    @Log(title = "客户转移审批-企微的", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CustomerTransferApprovalQw customerTransferApprovalQw)
    {
        List<CustomerTransferApprovalQw> list = customerTransferApprovalQwService.selectCustomerTransferApprovalQwList(customerTransferApprovalQw);
        ExcelUtil<CustomerTransferApprovalQw> util = new ExcelUtil<CustomerTransferApprovalQw>(CustomerTransferApprovalQw.class);
        return util.exportExcel(list, "客户转移审批-企微的数据");
    }

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

    /**
     * 新增客户转移审批-企微的
     */
    @PreAuthorize("@ss.hasPermi('qw:approval:add')")
    @Log(title = "客户转移审批-企微的", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CustomerTransferApprovalQw customerTransferApprovalQw)
    {
        return toAjax(customerTransferApprovalQwService.insertCustomerTransferApprovalQw(customerTransferApprovalQw));
    }

    /**
     * 修改客户转移审批-企微的
     */
    @PreAuthorize("@ss.hasPermi('qw:approval:edit') || @ss.hasPermi('qw:approval:revoke')")
    @Log(title = "客户转移审批-企微的", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CustomerTransferApprovalQw customerTransferApprovalQw)
    {
        return toAjax(customerTransferApprovalQwService.updateCustomerTransferApprovalQw(customerTransferApprovalQw));
    }

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