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.QwWorkLinkUser;
import com.fs.qw.service.IQwWorkLinkUserService;
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/workLinkUser")
public class QwWorkLinkUserController extends BaseController
{
    @Autowired
    private IQwWorkLinkUserService qwWorkLinkUserService;

    /**
     * 查询企微获客链接用户关联列表
     */
    @PreAuthorize("@ss.hasPermi('qw:workLinkUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwWorkLinkUser qwWorkLinkUser)
    {
        startPage();
        List<QwWorkLinkUser> list = qwWorkLinkUserService.selectQwWorkLinkUserList(qwWorkLinkUser);
        return getDataTable(list);
    }

    /**
     * 导出企微获客链接用户关联列表
     */
    @PreAuthorize("@ss.hasPermi('qw:workLinkUser:export')")
    @Log(title = "企微获客链接用户关联", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwWorkLinkUser qwWorkLinkUser)
    {
        List<QwWorkLinkUser> list = qwWorkLinkUserService.selectQwWorkLinkUserList(qwWorkLinkUser);
        ExcelUtil<QwWorkLinkUser> util = new ExcelUtil<QwWorkLinkUser>(QwWorkLinkUser.class);
        return util.exportExcel(list, "企微获客链接用户关联数据");
    }

    /**
     * 获取企微获客链接用户关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:workLinkUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qwWorkLinkUserService.selectQwWorkLinkUserById(id));
    }

    /**
     * 新增企微获客链接用户关联
     */
    @PreAuthorize("@ss.hasPermi('qw:workLinkUser:add')")
    @Log(title = "企微获客链接用户关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwWorkLinkUser qwWorkLinkUser)
    {
        return toAjax(qwWorkLinkUserService.insertQwWorkLinkUser(qwWorkLinkUser));
    }

    /**
     * 修改企微获客链接用户关联
     */
    @PreAuthorize("@ss.hasPermi('qw:workLinkUser:edit')")
    @Log(title = "企微获客链接用户关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwWorkLinkUser qwWorkLinkUser)
    {
        return toAjax(qwWorkLinkUserService.updateQwWorkLinkUser(qwWorkLinkUser));
    }

    /**
     * 删除企微获客链接用户关联
     */
    @PreAuthorize("@ss.hasPermi('qw:workLinkUser:remove')")
    @Log(title = "企微获客链接用户关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qwWorkLinkUserService.deleteQwWorkLinkUserByIds(ids));
    }
}
