package com.fs.company.controller.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.QwContactWayUser;
import com.fs.qw.service.IQwContactWayUserService;
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-07-23
 */
@RestController
@RequestMapping("/qw/contactWayUser")
public class QwContactWayUserController extends BaseController
{
    @Autowired
    private IQwContactWayUserService qwContactWayUserService;

    /**
     * 查询联系我限制列表
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayUser:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwContactWayUser qwContactWayUser)
    {
        startPage();
        List<QwContactWayUser> list = qwContactWayUserService.selectQwContactWayUserList(qwContactWayUser);
        return getDataTable(list);
    }

    /**
     * 导出联系我限制列表
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayUser:export')")
    @Log(title = "联系我限制", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwContactWayUser qwContactWayUser)
    {
        List<QwContactWayUser> list = qwContactWayUserService.selectQwContactWayUserList(qwContactWayUser);
        ExcelUtil<QwContactWayUser> util = new ExcelUtil<QwContactWayUser>(QwContactWayUser.class);
        return util.exportExcel(list, "联系我限制数据");
    }

    /**
     * 获取联系我限制详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayUser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qwContactWayUserService.selectQwContactWayUserById(id));
    }

    /**
     * 新增联系我限制
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayUser:add')")
    @Log(title = "联系我限制", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwContactWayUser qwContactWayUser)
    {
        return toAjax(qwContactWayUserService.insertQwContactWayUser(qwContactWayUser));
    }

    /**
     * 修改联系我限制
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayUser:edit')")
    @Log(title = "联系我限制", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwContactWayUser qwContactWayUser)
    {
        return toAjax(qwContactWayUserService.updateQwContactWayUser(qwContactWayUser));
    }

    /**
     * 删除联系我限制
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayUser:remove')")
    @Log(title = "联系我限制", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qwContactWayUserService.deleteQwContactWayUserByIds(ids));
    }
}
