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.QwWorkLink;
import com.fs.qw.service.IQwWorkLinkService;
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-01-10
 */
@RestController
@RequestMapping("/qw/workLink")
public class QwWorkLinkController extends BaseController
{
    @Autowired
    private IQwWorkLinkService qwWorkLinkService;

    /**
     * 查询企微获客链接管理列表
     */
    @PreAuthorize("@ss.hasPermi('qw:workLink:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwWorkLink qwWorkLink)
    {
        startPage();
        List<QwWorkLink> list = qwWorkLinkService.selectQwWorkLinkList(qwWorkLink);
        return getDataTable(list);
    }

    /**
     * 查询企微获客链接管理列表-不分页
     */
    @PreAuthorize("@ss.hasPermi('qw:workLink:listAll')")
    @GetMapping("/listAll")
    public AjaxResult listAll(QwWorkLink qwWorkLink)
    {
        List<QwWorkLink> qwWorkLinks = qwWorkLinkService.selectQwWorkLinkListAll(qwWorkLink);
        return AjaxResult.success(qwWorkLinks);
    }

    /**
     * 导出企微获客链接管理列表
     */
    @PreAuthorize("@ss.hasPermi('qw:workLink:export')")
    @Log(title = "企微获客链接管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwWorkLink qwWorkLink)
    {
        List<QwWorkLink> list = qwWorkLinkService.selectQwWorkLinkList(qwWorkLink);
        ExcelUtil<QwWorkLink> util = new ExcelUtil<QwWorkLink>(QwWorkLink.class);
        return util.exportExcel(list, "企微获客链接管理数据");
    }

    /**
     * 获取企微获客链接管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:workLink:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qwWorkLinkService.selectQwWorkLinkById(id));
    }

    /**
     * 新增企微获客链接管理
     */
    @PreAuthorize("@ss.hasPermi('qw:workLink:add')")
    @Log(title = "企微获客链接管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwWorkLink qwWorkLink)
    {
        return toAjax(qwWorkLinkService.insertQwWorkLink(qwWorkLink));
    }

    /**
     * 修改企微获客链接管理
     */
    @PreAuthorize("@ss.hasPermi('qw:workLink:edit')")
    @Log(title = "企微获客链接管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwWorkLink qwWorkLink){
        return toAjax(qwWorkLinkService.updateQwWorkLink(qwWorkLink));
    }

    /**
     * 删除企微获客链接管理
     */
    @PreAuthorize("@ss.hasPermi('qw:workLink:remove')")
    @Log(title = "企微获客链接管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qwWorkLinkService.deleteQwWorkLinkByIds(ids));
    }
}
