package com.aucma.dms.controller;

import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.core.page.TableDataInfo;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.dms.domain.DmsBaseMaintProject;
import com.aucma.dms.service.IDmsBaseMaintProjectService;
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 zangch
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/dms/dmsBaseMaintProject")
public class DmsBaseMaintProjectController extends BaseController
{
    @Autowired
    private IDmsBaseMaintProjectService dmsBaseMaintProjectService;

    /**
     * 查询保养项目信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBaseMaintProject:list')" )
    @GetMapping("/list")
    public TableDataInfo list(DmsBaseMaintProject dmsBaseMaintProject)
    {
        startPage();
        List<DmsBaseMaintProject> list = dmsBaseMaintProjectService.selectDmsBaseMaintProjectList(dmsBaseMaintProject);
        return getDataTable(list);
    }

    /**
     * 导出保养项目信息列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBaseMaintProject:export')" )
    ////@Log(title = "保养项目信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsBaseMaintProject dmsBaseMaintProject)
    {
        List<DmsBaseMaintProject> list = dmsBaseMaintProjectService.selectDmsBaseMaintProjectList(dmsBaseMaintProject);
        ExcelUtil<DmsBaseMaintProject> util = new ExcelUtil<DmsBaseMaintProject>(DmsBaseMaintProject.class);
        util.exportExcel(response, list, "保养项目信息数据");
    }

    /**
     * 获取保养项目信息详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBaseMaintProject:query')" )
    @GetMapping(value = "/{maintProjectId}")
    public AjaxResult getInfo(@PathVariable("maintProjectId") Long maintProjectId)
    {
        return success(dmsBaseMaintProjectService.selectDmsBaseMaintProjectByMaintProjectId(maintProjectId));
    }

    /**
     * 新增保养项目信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBaseMaintProject:add')" )
    ////@Log(title = "保养项目信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsBaseMaintProject dmsBaseMaintProject)
    {
        return toAjax(dmsBaseMaintProjectService.insertDmsBaseMaintProject(dmsBaseMaintProject));
    }

    /**
     * 修改保养项目信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBaseMaintProject:edit')" )
    ////@Log(title = "保养项目信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsBaseMaintProject dmsBaseMaintProject)
    {
        return toAjax(dmsBaseMaintProjectService.updateDmsBaseMaintProject(dmsBaseMaintProject));
    }

    /**
     * 删除保养项目信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBaseMaintProject:remove')" )
    ////@Log(title = "保养项目信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{maintProjectIds}")
    public AjaxResult remove(@PathVariable Long[] maintProjectIds)
    {
        return toAjax(dmsBaseMaintProjectService.deleteDmsBaseMaintProjectByMaintProjectIds(maintProjectIds));
    }

    @GetMapping("/projectMenu")
//TODO 未完成
    public AjaxResult projectMenu(DmsBaseMaintProject dmsBaseMaintProject)
    {
        List<DmsBaseMaintProject> projectMenu = dmsBaseMaintProjectService.selectDmsBaseMaintProjectList(dmsBaseMaintProject);
        return success(projectMenu);
    }


    @GetMapping("/projectMenuByStaion/{maintStationId}")
    public AjaxResult projectMenuByStaion(@PathVariable("maintStationId") Long maintStationId)
    {
        List<DmsBaseMaintProject> projectMenu = dmsBaseMaintProjectService.selectProjectMenuByStationId(maintStationId);
        return success(projectMenu);
    }
}




