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.DmsInspectInstanceDetailProject;
import com.aucma.dms.service.IDmsInspectInstanceDetailProjectService;
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 xins
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/dms/inspectinstancedetailproject")
public class DmsInspectInstanceDetailProjectController extends BaseController
{

    @Autowired
    private IDmsInspectInstanceDetailProjectService dmsInspectInstanceDetailProjectService;

    /**
     * 查询点巡检工单明细项目信息;质检检查每个项目的质检结果详情列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:inspectinstancedetailproject:list')" )
    @GetMapping("/list")
    public TableDataInfo list(DmsInspectInstanceDetailProject dmsInspectInstanceDetailProject)
    {
        startPage();
        List<DmsInspectInstanceDetailProject> list = dmsInspectInstanceDetailProjectService.selectDmsInspectInstanceDetailProjectList(dmsInspectInstanceDetailProject);
        return getDataTable(list);
    }

    @GetMapping("/selectDmsInspectInstanceDetailProjectByInspectInstanceId/{inspectInstanceId}/{lineStep}")
    public TableDataInfo selectDmsInspectInstanceDetailProjectByInspectInstanceId(@PathVariable("inspectInstanceId") Long inspectInstanceId,@PathVariable("lineStep") Long lineStep){
        List<DmsInspectInstanceDetailProject> dmsInspectInstanceDetailProjects = dmsInspectInstanceDetailProjectService.selectDmsInspectInstanceDetailProjectByInspectInstanceId(inspectInstanceId, lineStep);
        return getDataTable(dmsInspectInstanceDetailProjects);
    }
    /**
     * 导出点巡检工单明细项目信息;质检检查每个项目的质检结果详情列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:inspectinstancedetailproject:export')" )
    ////@Log(title = "点巡检工单明细项目信息;质检检查每个项目的质检结果详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsInspectInstanceDetailProject dmsInspectInstanceDetailProject)
    {
        List<DmsInspectInstanceDetailProject> list = dmsInspectInstanceDetailProjectService.selectDmsInspectInstanceDetailProjectList(dmsInspectInstanceDetailProject);
        ExcelUtil<DmsInspectInstanceDetailProject> util = new ExcelUtil<DmsInspectInstanceDetailProject>(DmsInspectInstanceDetailProject.class);
        util.exportExcel(response, list, "点巡检工单明细项目信息;质检检查每个项目的质检结果详情数据");
    }

    /**
     * 获取点巡检工单明细项目信息;质检检查每个项目的质检结果详情详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:inspectinstancedetailproject:query')" )
    @GetMapping(value = "/{instanceDetailProjectId}")
    public AjaxResult getInfo(@PathVariable("instanceDetailProjectId") Long instanceDetailProjectId)
    {
        return success(dmsInspectInstanceDetailProjectService.selectDmsInspectInstanceDetailProjectByInstanceDetailProjectId(instanceDetailProjectId));
    }

    /**
     * 新增点巡检工单明细项目信息;质检检查每个项目的质检结果详情
     */
    //@PreAuthorize("@ss.hasPermi('dms:inspectinstancedetailproject:add')" )
    ////@Log(title = "点巡检工单明细项目信息;质检检查每个项目的质检结果详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsInspectInstanceDetailProject dmsInspectInstanceDetailProject)
    {
        return toAjax(dmsInspectInstanceDetailProjectService.insertDmsInspectInstanceDetailProject(dmsInspectInstanceDetailProject));
    }

    /**
     * 修改点巡检工单明细项目信息;质检检查每个项目的质检结果详情
     */
    //@PreAuthorize("@ss.hasPermi('dms:inspectinstancedetailproject:edit')" )
    ////@Log(title = "点巡检工单明细项目信息;质检检查每个项目的质检结果详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsInspectInstanceDetailProject dmsInspectInstanceDetailProject)
    {
        return toAjax(dmsInspectInstanceDetailProjectService.updateDmsInspectInstanceDetailProject(dmsInspectInstanceDetailProject));
    }

    /**
     * 删除点巡检工单明细项目信息;质检检查每个项目的质检结果详情
     */
    //@PreAuthorize("@ss.hasPermi('dms:inspectinstancedetailproject:remove')" )
    ////@Log(title = "点巡检工单明细项目信息;质检检查每个项目的质检结果详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{instanceDetailProjectIds}")
    public AjaxResult remove(@PathVariable Long[] instanceDetailProjectIds)
    {
        return toAjax(dmsInspectInstanceDetailProjectService.deleteDmsInspectInstanceDetailProjectByInstanceDetailProjectIds(instanceDetailProjectIds));
    }
}
