package com.fs.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.QwDrainageLinkLogs;
import com.fs.qw.service.IQwDrainageLinkLogsService;
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-29
 */
@RestController
@RequestMapping("/qw/drainageLinkLogs")
public class QwDrainageLinkLogsController extends BaseController
{
    @Autowired
    private IQwDrainageLinkLogsService qwDrainageLinkLogsService;

    /**
     * 查询链接日志列表
     */
    @PreAuthorize("@ss.hasPermi('qw:drainageLinkLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwDrainageLinkLogs qwDrainageLinkLogs)
    {
        startPage();
        List<QwDrainageLinkLogs> list = qwDrainageLinkLogsService.selectQwDrainageLinkLogsList(qwDrainageLinkLogs);
        return getDataTable(list);
    }

    /**
     * 导出链接日志列表
     */
    @PreAuthorize("@ss.hasPermi('qw:drainageLinkLogs:export')")
    @Log(title = "链接日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(QwDrainageLinkLogs qwDrainageLinkLogs)
    {
        List<QwDrainageLinkLogs> list = qwDrainageLinkLogsService.selectQwDrainageLinkLogsList(qwDrainageLinkLogs);
        ExcelUtil<QwDrainageLinkLogs> util = new ExcelUtil<QwDrainageLinkLogs>(QwDrainageLinkLogs.class);
        return util.exportExcel(list, "链接日志数据");
    }

    /**
     * 获取链接日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('qw:drainageLinkLogs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(qwDrainageLinkLogsService.selectQwDrainageLinkLogsById(id));
    }

    /**
     * 新增链接日志
     */
    @PreAuthorize("@ss.hasPermi('qw:drainageLinkLogs:add')")
    @Log(title = "链接日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwDrainageLinkLogs qwDrainageLinkLogs)
    {
        return toAjax(qwDrainageLinkLogsService.insertQwDrainageLinkLogs(qwDrainageLinkLogs));
    }

    /**
     * 修改链接日志
     */
    @PreAuthorize("@ss.hasPermi('qw:drainageLinkLogs:edit')")
    @Log(title = "链接日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwDrainageLinkLogs qwDrainageLinkLogs)
    {
        return toAjax(qwDrainageLinkLogsService.updateQwDrainageLinkLogs(qwDrainageLinkLogs));
    }

    /**
     * 删除链接日志
     */
    @PreAuthorize("@ss.hasPermi('qw:drainageLinkLogs:remove')")
    @Log(title = "链接日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qwDrainageLinkLogsService.deleteQwDrainageLinkLogsByIds(ids));
    }
}
