package com.fs.qw;

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.QwExternalContactInfo;
import com.fs.qw.service.IQwExternalContactInfoService;
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-11-22
 */
@RestController
@RequestMapping("/qw/externalContactInfo")
public class QwExternalContactInfoController extends BaseController
{
    @Autowired
    private IQwExternalContactInfoService qwExternalContactInfoService;

    /**
     * 查询外部联系人信息表列表
     */
    @PreAuthorize("@ss.hasPermi('qw:externalContactInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwExternalContactInfo qwExternalContactInfo)
    {
        startPage();
        List<QwExternalContactInfo> list = qwExternalContactInfoService.selectQwExternalContactInfoList(qwExternalContactInfo);
        return getDataTable(list);
    }

    /**
     * 导出外部联系人信息表列表
     */
    @PreAuthorize("@ss.hasPermi('qw:externalContactInfo:export')")
    @Log(title = "外部联系人信息表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwExternalContactInfo qwExternalContactInfo)
    {
        List<QwExternalContactInfo> list = qwExternalContactInfoService.selectQwExternalContactInfoList(qwExternalContactInfo);
        ExcelUtil<QwExternalContactInfo> util = new ExcelUtil<QwExternalContactInfo>(QwExternalContactInfo.class);
        return util.exportExcel(list, "外部联系人信息表数据");
    }

    /**
     * 获取外部联系人信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:externalContactInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qwExternalContactInfoService.selectQwExternalContactInfoById(id));
    }

    /**
     * 新增外部联系人信息表
     */
    @PreAuthorize("@ss.hasPermi('qw:externalContactInfo:add')")
    @Log(title = "外部联系人信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwExternalContactInfo qwExternalContactInfo)
    {
        return toAjax(qwExternalContactInfoService.insertQwExternalContactInfo(qwExternalContactInfo));
    }

    /**
     * 修改外部联系人信息表
     */
    @PreAuthorize("@ss.hasPermi('qw:externalContactInfo:edit')")
    @Log(title = "外部联系人信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwExternalContactInfo qwExternalContactInfo)
    {
        return toAjax(qwExternalContactInfoService.updateQwExternalContactInfo(qwExternalContactInfo));
    }

    /**
     * 删除外部联系人信息表
     */
    @PreAuthorize("@ss.hasPermi('qw:externalContactInfo:remove')")
    @Log(title = "外部联系人信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qwExternalContactInfoService.deleteQwExternalContactInfoByIds(ids));
    }




    @Log(title = "更改外部联系人信息表", businessType = BusinessType.UPDATE)
    @PutMapping("/editTalk/{ids}")
    public AjaxResult editTalk(@PathVariable Long[] ids)
    {
        return toAjax(qwExternalContactInfoService.updateQwExternalContactInfoByIds(ids));
    }

    @Log(title = "更改外部联系人信息表", businessType = BusinessType.UPDATE)
    @PutMapping("/editAllTalk/{id}")
    public AjaxResult editAllTalk(@PathVariable Long id)
    {
        return toAjax(qwExternalContactInfoService.updateQwExternalContactInfoByQwUserId(id));
    }
}
