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.QwContactWayLogs;
import com.fs.qw.service.IQwContactWayLogsService;
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/contactWayLogs")
public class QwContactWayLogsController extends BaseController
{
    @Autowired
    private IQwContactWayLogsService qwContactWayLogsService;

    /**
     * 查询联系我日志列表
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwContactWayLogs qwContactWayLogs)
    {
        startPage();
        List<QwContactWayLogs> list = qwContactWayLogsService.selectQwContactWayLogsList(qwContactWayLogs);
        return getDataTable(list);
    }

    /**
     * 导出联系我日志列表
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayLogs:export')")
    @Log(title = "联系我日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwContactWayLogs qwContactWayLogs)
    {
        List<QwContactWayLogs> list = qwContactWayLogsService.selectQwContactWayLogsList(qwContactWayLogs);
        ExcelUtil<QwContactWayLogs> util = new ExcelUtil<QwContactWayLogs>(QwContactWayLogs.class);
        return util.exportExcel(list, "联系我日志数据");
    }

    /**
     * 获取联系我日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayLogs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qwContactWayLogsService.selectQwContactWayLogsById(id));
    }

    /**
     * 新增联系我日志
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayLogs:add')")
    @Log(title = "联系我日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwContactWayLogs qwContactWayLogs)
    {
        return toAjax(qwContactWayLogsService.insertQwContactWayLogs(qwContactWayLogs));
    }

    /**
     * 修改联系我日志
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayLogs:edit')")
    @Log(title = "联系我日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwContactWayLogs qwContactWayLogs)
    {
        return toAjax(qwContactWayLogsService.updateQwContactWayLogs(qwContactWayLogs));
    }

    /**
     * 删除联系我日志
     */
    @PreAuthorize("@ss.hasPermi('qw:contactWayLogs:remove')")
    @Log(title = "联系我日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qwContactWayLogsService.deleteQwContactWayLogsByIds(ids));
    }
}
