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.InspectionNewsAssociation;
import cn.iocoder.yudao.module.inspection.service.IInspectionNewsAssociationService;
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/association")
public class InspectionNewsAssociationController extends BaseController
{
    @Autowired
    private IInspectionNewsAssociationService inspectionNewsAssociationService;

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

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

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

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:association:add')")
    @PostMapping
    public CommonResult add(@RequestBody InspectionNewsAssociation inspectionNewsAssociation)
    {
        return toAjax(inspectionNewsAssociationService.insertInspectionNewsAssociation(inspectionNewsAssociation));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:association:edit')")
    @PutMapping
    public CommonResult edit(@RequestBody InspectionNewsAssociation inspectionNewsAssociation)
    {
        return toAjax(inspectionNewsAssociationService.updateInspectionNewsAssociation(inspectionNewsAssociation));
    }

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