package com.fs.company.controller.company;

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.R;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.company.domain.CompanyWxDialog;
import com.fs.company.service.ICompanyWxDialogService;
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 2024-12-06
 */
@RestController
@RequestMapping("/company/wxDialog")
public class CompanyWxDialogController extends BaseController
{
    @Autowired
    private ICompanyWxDialogService companyWxDialogService;

    /**
     * 查询添加微信话术列表
     */
    @PreAuthorize("@ss.hasPermi('company:wxDialog:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyWxDialog companyWxDialog)
    {
        startPage();
        List<CompanyWxDialog> list = companyWxDialogService.selectCompanyWxDialogList(companyWxDialog);
        return getDataTable(list);
    }

    @PreAuthorize("@ss.hasPermi('company:wxDialog:list')")
    @GetMapping("/listAll")
    public R listAll(CompanyWxDialog companyWxDialog){
        return R.ok().put("data", companyWxDialogService.selectCompanyWxDialogList(companyWxDialog));
    }

    /**
     * 导出添加微信话术列表
     */
    @PreAuthorize("@ss.hasPermi('company:wxDialog:export')")
    @Log(title = "添加微信话术", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyWxDialog companyWxDialog)
    {
        List<CompanyWxDialog> list = companyWxDialogService.selectCompanyWxDialogList(companyWxDialog);
        ExcelUtil<CompanyWxDialog> util = new ExcelUtil<CompanyWxDialog>(CompanyWxDialog.class);
        return util.exportExcel(list, "wxDialog");
    }

    /**
     * 获取添加微信话术详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:wxDialog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(companyWxDialogService.selectCompanyWxDialogById(id));
    }

    /**
     * 新增添加微信话术
     */
    @PreAuthorize("@ss.hasPermi('company:wxDialog:add')")
    @Log(title = "添加微信话术", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyWxDialog companyWxDialog)
    {
        return toAjax(companyWxDialogService.insertCompanyWxDialog(companyWxDialog));
    }

    /**
     * 修改添加微信话术
     */
    @PreAuthorize("@ss.hasPermi('company:wxDialog:edit')")
    @Log(title = "添加微信话术", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyWxDialog companyWxDialog)
    {
        return toAjax(companyWxDialogService.updateCompanyWxDialog(companyWxDialog));
    }

    /**
     * 删除添加微信话术
     */
    @PreAuthorize("@ss.hasPermi('company:wxDialog:remove')")
    @Log(title = "添加微信话术", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(companyWxDialogService.deleteCompanyWxDialogByIds(ids));
    }
}
