package com.fs.qw.controller;

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.FsAppContactWay;
import com.fs.qw.service.IFsAppContactWayService;
import com.fs.qw.vo.FsAppContactWayListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * app客服活码上架Controller
 *
 * @author fs
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/qw/appContactWay")
public class FsAppContactWayController extends BaseController
{
    @Autowired
    private IFsAppContactWayService fsAppContactWayService;

    /**
     * 查询app客服活码上架列表
     */
    @PreAuthorize("@ss.hasPermi('qw:appContactWay:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsAppContactWay fsAppContactWay)
    {
        startPage();
        List<FsAppContactWayListVO> list = fsAppContactWayService.selectFsAppContactWayListVO(fsAppContactWay);
        return getDataTable(list);
    }

    /**
     * 导出app客服活码上架列表
     */
    @PreAuthorize("@ss.hasPermi('qw:appContactWay:export')")
    @Log(title = "app客服活码上架", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsAppContactWay fsAppContactWay)
    {
        List<FsAppContactWay> list = fsAppContactWayService.selectFsAppContactWayList(fsAppContactWay);
        ExcelUtil<FsAppContactWay> util = new ExcelUtil<FsAppContactWay>(FsAppContactWay.class);
        return util.exportExcel(list, "app客服活码上架数据");
    }

    /**
     * 获取app客服活码上架详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:appContactWay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsAppContactWayService.selectFsAppContactWayById(id));
    }

    /**
     * 新增app客服活码上架
     */
    @PreAuthorize("@ss.hasPermi('qw:appContactWay:add')")
    @Log(title = "app客服活码上架", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsAppContactWay fsAppContactWay)
    {
        return toAjax(fsAppContactWayService.insertFsAppContactWay(fsAppContactWay));
    }

    /**
     * 修改app客服活码上架
     */
    @PreAuthorize("@ss.hasPermi('qw:appContactWay:edit')")
    @Log(title = "app客服活码上架", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsAppContactWay fsAppContactWay)
    {
        return toAjax(fsAppContactWayService.updateFsAppContactWay(fsAppContactWay));
    }

    /**
     * 删除app客服活码上架
     */
    @PreAuthorize("@ss.hasPermi('qw:appContactWay:remove')")
    @Log(title = "app客服活码上架", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsAppContactWayService.deleteFsAppContactWayByIds(ids));
    }


    @Log(title = "活码上架", businessType = BusinessType.UPDATE)
    @PostMapping("/updateIsShow")
    public AjaxResult updateIsShow(@RequestBody FsAppContactWay fsAppContactWay)
    {
        return toAjax(fsAppContactWayService.updateFsAppContactWay(fsAppContactWay));
    }
}
