package cn.iocoder.yudao.module.inspection.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.inspection.entity.InspectionNewsComment;
import cn.iocoder.yudao.module.inspection.service.IInspectionNewsCommentService;
import cn.iocoder.yudao.util.ExcelUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.iocoder.yudao.module.core.controller.BaseController;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2023-08-07
 */
@RestController
@RequestMapping("/admin-api/system/comment")
public class InspectionNewsCommentController extends BaseController
{
    @Autowired
    private IInspectionNewsCommentService inspectionNewsCommentService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:comment:list')")
    @GetMapping("/list")
    public CommonResult list(InspectionNewsComment inspectionNewsComment,
                             @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum,
                             @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize)
    {
        Page<InspectionNewsComment> page = new Page<>(pageNum, pageSize);
        IPage<InspectionNewsComment> list = inspectionNewsCommentService.selectInspectionNewsCommentList(page,inspectionNewsComment);
        return success(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:comment:export')")
    @PostMapping("/export")
    public void export(HttpServletResponse response, InspectionNewsComment inspectionNewsComment,
                       @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum,
                       @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize)
    {
        Page<InspectionNewsComment> page = new Page<>(pageNum, pageSize);
        IPage<InspectionNewsComment> list = inspectionNewsCommentService.selectInspectionNewsCommentList(page,inspectionNewsComment);
        ExcelUtil<InspectionNewsComment> util = new ExcelUtil<InspectionNewsComment>(InspectionNewsComment.class);
        util.exportExcel(response, list.getRecords(), "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:comment:query')")
    @GetMapping(value = "/{id}")
    public CommonResult getInfo(@PathVariable("id") Long id)
    {
        return success(inspectionNewsCommentService.selectInspectionNewsCommentById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:comment:add')")
    @PostMapping
    public CommonResult add(@RequestBody InspectionNewsComment inspectionNewsComment)
    {
        return toAjax(inspectionNewsCommentService.insertInspectionNewsComment(inspectionNewsComment));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:comment:edit')")
    @PutMapping
    public CommonResult edit(@RequestBody InspectionNewsComment inspectionNewsComment)
    {
        return toAjax(inspectionNewsCommentService.updateInspectionNewsComment(inspectionNewsComment));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:comment:remove')")
	@DeleteMapping("/{ids}")
    public CommonResult remove(@PathVariable Long[] ids)
    {
        return toAjax(inspectionNewsCommentService.deleteInspectionNewsCommentByIds(ids));
    }
}
