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

import java.util.List;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.inspection.entity.InspectionNews;
import cn.iocoder.yudao.module.inspection.service.IInspectionNewsService;
import cn.iocoder.yudao.module.shop.entity.ShopMallPartners;
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-03
 */
@RestController
@RequestMapping("/admin-api/system/inspectionNews")
public class InspectionNewsController extends BaseController
{
    @Autowired
    private IInspectionNewsService inspectionNewsService;

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

    /**
     * 新增【请填写功能名称】
     */
    @PostMapping("/add")
    public CommonResult add(@RequestBody InspectionNews inspectionNews)
    {
        return toAjax(inspectionNewsService.insertInspectionNews(inspectionNews));
    }

    @PostMapping("/edit")
    public CommonResult edit(@RequestBody InspectionNews inspectionNews)
    {
        return toAjax(inspectionNewsService.updateInspectionNews(inspectionNews));
    }

    /**
     * 删除【请填写功能名称】
     */
	@PostMapping("/del")
    public CommonResult remove(@RequestParam("idList") Long[] ids)
    {
        return toAjax(inspectionNewsService.deleteInspectionNewsByIds(ids));
    }
}
