package com.fs.qw.controller;

import java.util.List;

import com.fs.common.core.domain.R;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.qw.domain.QwWorkShortLink;
import com.fs.qw.service.IQwWorkShortLinkService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 企微获客链接短链Controller
 * 
 * @author fs
 * @date 2025-03-27
 */
@RestController
@RequestMapping("/qw/QwWorkShortLink")
public class QwWorkShortLinkController extends BaseController
{
    @Autowired
    private IQwWorkShortLinkService qwWorkShortLinkService;

    /**
     * 查询企微获客链接短链列表
     */
    @PreAuthorize("@ss.hasPermi('qw:QwWorkShortLink:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwWorkShortLink qwWorkShortLink)
    {
        startPage();
        List<QwWorkShortLink> list = qwWorkShortLinkService.selectQwWorkShortLinkList(qwWorkShortLink);
        return getDataTable(list);
    }

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

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

    /**
     * 新增企微获客链接短链
     */
    @PreAuthorize("@ss.hasPermi('qw:QwWorkShortLink:add')")
    @Log(title = "企微获客链接短链", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwWorkShortLink qwWorkShortLink)
    {
        return toAjax(qwWorkShortLinkService.insertQwWorkShortLink(qwWorkShortLink));
    }

    /**
     * 修改企微获客链接短链
     */
    @PreAuthorize("@ss.hasPermi('qw:QwWorkShortLink:edit')")
    @Log(title = "企微获客链接短链", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwWorkShortLink qwWorkShortLink)
    {
        return toAjax(qwWorkShortLinkService.updateQwWorkShortLink(qwWorkShortLink));
    }

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

    /**
     * 删除企微获客链接短链
     */
	@GetMapping("/getUrl")
    public R getUrl(String no){
        return R.ok().put("url", qwWorkShortLinkService.getUrl(no));
    }
}
