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.DmsBillsInspectInstanceActivity;
import com.aucma.dms.service.IDmsBillsInspectInstanceActivityService;
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 Open Platform
 * @date 2024-01-23
 */
@RestController
@RequestMapping("/dms/dmsBillsInspectActivity")
public class DmsBillsInspectInstanceActivityController extends BaseController
{
    @Autowired
    private IDmsBillsInspectInstanceActivityService dmsBillsInspectInstanceActivityService;

    /**
     * 查询点巡检工单实例节点列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBillsInspectActivity:list')" )
    @GetMapping("/list")
    public TableDataInfo list(DmsBillsInspectInstanceActivity dmsBillsInspectInstanceActivity)
    {
        startPage();
        List<DmsBillsInspectInstanceActivity> list = dmsBillsInspectInstanceActivityService.selectDmsBillsInspectInstanceActivityList(dmsBillsInspectInstanceActivity);
        return getDataTable(list);
    }

    /**
     * 导出点巡检工单实例节点列表
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBillsInspectActivity:export')" )
    ////@Log(title = "点巡检工单实例节点", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmsBillsInspectInstanceActivity dmsBillsInspectInstanceActivity)
    {
        List<DmsBillsInspectInstanceActivity> list = dmsBillsInspectInstanceActivityService.selectDmsBillsInspectInstanceActivityList(dmsBillsInspectInstanceActivity);
        ExcelUtil<DmsBillsInspectInstanceActivity> util = new ExcelUtil<DmsBillsInspectInstanceActivity>(DmsBillsInspectInstanceActivity.class);
        util.exportExcel(response, list, "点巡检工单实例节点数据");
    }

    /**
     * 获取点巡检工单实例节点详细信息
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBillsInspectActivity:query')" )
    @GetMapping(value = "/{instanceActivityId}")
    public AjaxResult getInfo(@PathVariable("instanceActivityId") Long instanceActivityId)
    {
        return success(dmsBillsInspectInstanceActivityService.selectDmsBillsInspectInstanceActivityByInstanceActivityId(instanceActivityId));
    }

    /**
     * 新增点巡检工单实例节点
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBillsInspectActivity:add')" )
    ////@Log(title = "点巡检工单实例节点", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmsBillsInspectInstanceActivity dmsBillsInspectInstanceActivity)
    {
        return toAjax(dmsBillsInspectInstanceActivityService.insertDmsBillsInspectInstanceActivity(dmsBillsInspectInstanceActivity));
    }

    /**
     * 修改点巡检工单实例节点
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBillsInspectActivity:edit')" )
    ////@Log(title = "点巡检工单实例节点", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmsBillsInspectInstanceActivity dmsBillsInspectInstanceActivity)
    {
        return toAjax(dmsBillsInspectInstanceActivityService.updateDmsBillsInspectInstanceActivity(dmsBillsInspectInstanceActivity));
    }

    /**
     * 删除点巡检工单实例节点
     */
    //@PreAuthorize("@ss.hasPermi('dms:dmsBillsInspectActivity:remove')" )
    ////@Log(title = "点巡检工单实例节点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{instanceActivityIds}")
    public AjaxResult remove(@PathVariable Long[] instanceActivityIds)
    {
        return toAjax(dmsBillsInspectInstanceActivityService.deleteDmsBillsInspectInstanceActivityByInstanceActivityIds(instanceActivityIds));
    }

    @GetMapping("/selectUserIdByDmsBillsInspectInstanceActivityId/{lubeInstanceId}/userId/{userId}")
    public boolean selectUserIdByDmsBillsInspectInstanceActivityId(@PathVariable("lubeInstanceId") Long lubeInstanceId,@PathVariable("userId") Long userId){
        boolean b = dmsBillsInspectInstanceActivityService.selectUserIdByDmsBillsInspectInstanceActivityId(lubeInstanceId, userId);
        return true;
    }
}
