package com.huashe.park.application.web.controller.park;

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

import com.huashe.park.core.service.IParkInspectProjService;
import com.huashe.park.domain.entity.ParkInspectProj;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.huashe.common.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 巡检项Controller
 * 
 * @author ruoyi
 * @date 2025-01-06
 */
@RestController
@RequestMapping("/park/proj")
public class ParkInspectProjController extends BaseController
{
    @Autowired
    private IParkInspectProjService parkInspectProjService;

    /**
     * 查询巡检项列表
     */
    @PreAuthorize("@ss.hasPermi('park:proj:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParkInspectProj parkInspectProj)
    {
        startPage();
        List<ParkInspectProj> list = parkInspectProjService.selectParkInspectProjList(parkInspectProj);
        return getDataTable(list);
    }

    /**
     * 导出巡检项列表
     */
    @PreAuthorize("@ss.hasPermi('park:proj:export')")
    @Log(title = "巡检项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkInspectProj parkInspectProj)
    {
        List<ParkInspectProj> list = parkInspectProjService.selectParkInspectProjList(parkInspectProj);
        ExcelUtil<ParkInspectProj> util = new ExcelUtil<ParkInspectProj>(ParkInspectProj.class);
        util.exportExcel(response, list, "巡检项数据");
    }

    /**
     * 获取巡检项详细信息
     */
    @PreAuthorize("@ss.hasPermi('park:proj:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(parkInspectProjService.selectParkInspectProjById(id));
    }

    /**
     * 新增巡检项
     */
    @PreAuthorize("@ss.hasPermi('park:proj:add')")
    @Log(title = "巡检项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkInspectProj parkInspectProj)
    {
        return toAjax(parkInspectProjService.insertParkInspectProj(parkInspectProj));
    }

    /**
     * 修改巡检项
     */
    @PreAuthorize("@ss.hasPermi('park:proj:edit')")
    @Log(title = "巡检项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkInspectProj parkInspectProj)
    {
        return toAjax(parkInspectProjService.updateParkInspectProj(parkInspectProj));
    }

    /**
     * 删除巡检项
     */
    @PreAuthorize("@ss.hasPermi('park:proj:remove')")
    @Log(title = "巡检项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkInspectProjService.deleteParkInspectProjByIds(ids));
    }
}
