package com.fs.crm.controller;

import java.util.List;

import com.fs.crm.param.CrmCustomerAssistDeLParam;
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.crm.domain.CrmCustomerAssist;
import com.fs.crm.service.ICrmCustomerAssistService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 客户员工协作Controller
 *
 * @author fs
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/crm/assist")
public class CrmCustomerAssistController extends BaseController
{
    @Autowired
    private ICrmCustomerAssistService crmCustomerAssistService;

    /**
     * 查询客户员工协作列表
     */
    @PreAuthorize("@ss.hasPermi('crm:assist:list')")
    @GetMapping("/list")
    public TableDataInfo list(CrmCustomerAssist crmCustomerAssist)
    {
        startPage();
        List<CrmCustomerAssist> list = crmCustomerAssistService.selectCrmCustomerAssistList(crmCustomerAssist);
        return getDataTable(list);
    }

    /**
     * 导出客户员工协作列表
     */
    @PreAuthorize("@ss.hasPermi('crm:assist:export')")
    @Log(title = "客户员工协作", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CrmCustomerAssist crmCustomerAssist)
    {
        List<CrmCustomerAssist> list = crmCustomerAssistService.selectCrmCustomerAssistList(crmCustomerAssist);
        ExcelUtil<CrmCustomerAssist> util = new ExcelUtil<CrmCustomerAssist>(CrmCustomerAssist.class);
        return util.exportExcel(list, "assist");
    }

    /**
     * 获取客户员工协作详细信息
     */
    @PreAuthorize("@ss.hasPermi('crm:assist:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(crmCustomerAssistService.selectCrmCustomerAssistById(id));
    }

    /**
     * 新增客户员工协作
     */
    @PreAuthorize("@ss.hasPermi('crm:assist:add')")
    @Log(title = "客户员工协作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CrmCustomerAssist crmCustomerAssist)
    {
        return toAjax(crmCustomerAssistService.insertCrmCustomerAssist(crmCustomerAssist));
    }

    /**
     * 修改客户员工协作
     */
    @PreAuthorize("@ss.hasPermi('crm:assist:edit')")
    @Log(title = "客户员工协作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CrmCustomerAssist crmCustomerAssist)
    {
        return toAjax(crmCustomerAssistService.updateCrmCustomerAssist(crmCustomerAssist));
    }

    /**
     * 删除客户员工协作
     */
    @Log(title = "客户员工协作", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public AjaxResult removeByCustomer(@RequestBody CrmCustomerAssistDeLParam param)
    {
        return toAjax(crmCustomerAssistService.removeByCustomer(param));
    }

    /**
     * 删除客户员工协作
     */
    @PreAuthorize("@ss.hasPermi('crm:assist:remove')")
    @Log(title = "客户员工协作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(crmCustomerAssistService.deleteCrmCustomerAssistByIds(ids));
    }
}
