package com.hw.dms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
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.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.dms.domain.DmsBillsInspectInstanceActivity;
import com.hw.dms.service.IDmsBillsInspectInstanceActivityService;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.utils.poi.ExcelUtil;
import com.hw.common.core.web.page.TableDataInfo;

/**
 * 点巡检工单实例节点Controller
 *
 * @author Open Platform
 * @date 2024-01-23
 */
@RestController
@RequestMapping("/dmsBillsInspectActivity")
public class DmsBillsInspectInstanceActivityController extends BaseController
{
    @Autowired
    private IDmsBillsInspectInstanceActivityService dmsBillsInspectInstanceActivityService;

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

    /**
     * 导出点巡检工单实例节点列表
     */
    @RequiresPermissions("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, "点巡检工单实例节点数据");
    }

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

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

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

    /**
     * 删除点巡检工单实例节点
     */
    @RequiresPermissions("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 b;
    }
}
