package com.ruoyi.web.controller.checkPoint;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.checkPoint.CheckPointManage;
import com.ruoyi.system.service.ICheckPointManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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

/**
 * 巡更点管理Controller
 *
 * @author boman
 * @date 2025-02-14
 */
@RestController
@RequestMapping("/wuYe/checkPointManage")
public class CheckPointManageController extends BaseController {
    @Autowired
    private ICheckPointManageService checkPointManageService;

    /**
     * 查询巡更点管理列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:checkPointManage:list')")
    @GetMapping("/list")
    public TableDataInfo list(CheckPointManage checkPointManage) {
        startPage();
        List<CheckPointManage> list = checkPointManageService.selectCheckPointManageList(checkPointManage);
        return getDataTable(list);
    }

    /**
     * 查询巡更点管理列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:checkPointManage:listNoPage')")
    @GetMapping("/listNoPage")
    public TableDataInfo listNoPage(CheckPointManage checkPointManage) {

        List<CheckPointManage> list = checkPointManageService.selectCheckPointManageList(checkPointManage);
        return getDataTable(list);
    }

    /**
     * 导出巡更点管理列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:checkPointManage:export')")
    @Log(title = "巡更点管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CheckPointManage checkPointManage) {
        List<CheckPointManage> list = checkPointManageService.selectCheckPointManageList(checkPointManage);
        ExcelUtil<CheckPointManage> util = new ExcelUtil<CheckPointManage>(CheckPointManage.class);
        util.exportExcel(response, list, "巡更点管理数据");
    }

    /**
     * 获取巡更点管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuYe:checkPointManage:query')")
    @GetMapping(value = "/{checkPointManageId}")
    public AjaxResult getInfo(@PathVariable("checkPointManageId") Long checkPointManageId) {
        return success(checkPointManageService.selectCheckPointManageByCheckPointManageId(checkPointManageId));
    }

    /**
     * 新增巡更点管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:checkPointManage:add')")
    @Log(title = "巡更点管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CheckPointManage checkPointManage) {
        return toAjax(checkPointManageService.insertCheckPointManage(checkPointManage));
    }

    /**
     * 批量新增巡更点管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:checkPointManage:addList')")
    @PostMapping("/addList")
    public AjaxResult addList(@RequestBody CheckPointManage checkPointManage) {
        return toAjax(checkPointManageService.batchCheckPointManage(checkPointManage.getCheckPointManageList()));
    }

    /**
     * 修改巡更点管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:checkPointManage:edit')")
    @Log(title = "巡更点管理", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody CheckPointManage checkPointManage) {
        return toAjax(checkPointManageService.updateCheckPointManage(checkPointManage));
    }

    /**
     * 删除巡更点管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:checkPointManage:remove')")
    @Log(title = "巡更点管理", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{checkPointManageIds}")
    public AjaxResult remove(@PathVariable Long[] checkPointManageIds) {
        return toAjax(checkPointManageService.deleteCheckPointManageByCheckPointManageIds(checkPointManageIds));
    }
}
