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

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

import com.huashe.park.core.service.IParkInspectTaskUsrTrailService;
import com.huashe.park.domain.entity.ParkInspectTaskUsrTrail;
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-07
 */
@RestController
@RequestMapping("/park/inspectTaskTrail")
public class ParkInspectTaskUsrTrailController extends BaseController {
    @Autowired
    private IParkInspectTaskUsrTrailService parkInspectTaskUsrTrailService;

    /**
     * 查询巡检轨迹列表
     */
    @PreAuthorize("@ss.hasPermi('park:inspectTaskTrail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParkInspectTaskUsrTrail parkInspectTaskUsrTrail) {
        startPage();
        List<ParkInspectTaskUsrTrail> list = parkInspectTaskUsrTrailService.selectParkInspectTaskUsrTrailList(parkInspectTaskUsrTrail);
        return getDataTable(list);
    }

    /**
     * 导出巡检轨迹列表
     */
    @PreAuthorize("@ss.hasPermi('park:inspectTaskTrail:export')")
    @Log(title = "巡检轨迹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkInspectTaskUsrTrail parkInspectTaskUsrTrail) {
        List<ParkInspectTaskUsrTrail> list = parkInspectTaskUsrTrailService.selectParkInspectTaskUsrTrailList(parkInspectTaskUsrTrail);
        ExcelUtil<ParkInspectTaskUsrTrail> util = new ExcelUtil<ParkInspectTaskUsrTrail>(ParkInspectTaskUsrTrail.class);
        util.exportExcel(response, list, "巡检轨迹数据");
    }

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

    /**
     * 新增巡检轨迹
     */
    @PreAuthorize("@ss.hasPermi('park:inspectTaskTrail:add')")
    @Log(title = "巡检轨迹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkInspectTaskUsrTrail parkInspectTaskUsrTrail) {
        return toAjax(parkInspectTaskUsrTrailService.insertParkInspectTaskUsrTrail(parkInspectTaskUsrTrail));
    }

    /**
     * 修改巡检轨迹
     */
    @PreAuthorize("@ss.hasPermi('park:inspectTaskTrail:edit')")
    @Log(title = "巡检轨迹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkInspectTaskUsrTrail parkInspectTaskUsrTrail) {
        return toAjax(parkInspectTaskUsrTrailService.updateParkInspectTaskUsrTrail(parkInspectTaskUsrTrail));
    }

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