package com.yuchen.saas.park.service.controller.fire.inspect;

import com.yuchen.saas.park.api.dto.fire.fight.CloseDangerReqDTO;
import com.yuchen.saas.park.api.dto.fire.fight.FireFightDangerReqDTO;
import com.yuchen.saas.park.api.dto.fire.fight.FireFightDangerSubmitReqDTO;
import com.yuchen.saas.park.api.dto.work.SaasWorkOrderDto;
import com.yuchen.saas.park.api.vo.fire.fight.FireFightDangerCountVO;
import com.yuchen.saas.park.api.vo.fire.fight.FireFightDangerVO;
import com.yuchen.saas.park.service.service.fire.fight.ISaasParkFireFightDangerService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.mp.support.NestPage;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 巡检异常信息接口
 *
 * @author zhouhanwei
 * @since 2024-04-29
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/fireFightDanger")
public class SaasParkFireFightDangerController {

    private final ISaasParkFireFightDangerService baseService;

    /**
     * 巡检异常信息分页列表 （各个业务侧需要必传业务id）
     */
    @PostMapping("/findFireFightDangerPage")
    @ApiOperation(value = "巡检异常信息分页列表", notes = "巡检异常信息分页列表")
    public R<NestPage<FireFightDangerVO>> findFireFightDangerPage(@RequestBody FireFightDangerReqDTO reqDTO) {
        return R.data(baseService.findFireFightDangerPage(reqDTO));
    }

    /**
     * 巡检异常详情
     */
    @GetMapping("/getFireFightDanger/{dangerId}")
    @ApiOperation(value = "巡检异常详情", notes = "巡检异常详情")
    public R<FireFightDangerVO> getFireFightDanger(@PathVariable Long dangerId) {
        return R.data(baseService.getFireFightDanger(dangerId));
    }

    /**
     * 消防隐患统计（各个业务侧需要必传业务id）
     */
    @PostMapping("/getFireFightDangerCount")
    @ApiOperation(value = "消防隐患统计", notes = "消防隐患统计")
    public R<FireFightDangerCountVO> getFireFightDangerCount(@RequestBody FireFightDangerReqDTO reqDTO) {
        return R.data(baseService.getFireFightDangerCount(reqDTO));
    }

    /**
     * 关闭巡检异常
     */
    @PostMapping("/closeFireFightDanger")
    @ApiOperation(value = "关闭巡检异常", notes = "关闭巡检异常")
    public R closeFireFightDanger(@Validated @RequestBody CloseDangerReqDTO reqDTO) {
        return R.status(baseService.closeFireFightDanger(reqDTO));
    }

    /**
     * 添加巡检异常-智慧巡检提交异常使用
     */
    @PostMapping("/addFireFightDanger")
    @ApiOperation(value = "添加消防隐患", notes = "添加消防隐患")
    public R addFireFightDanger(@Validated @RequestBody FireFightDangerSubmitReqDTO reqDTO) {
        return R.status(baseService.addFireFightDanger(reqDTO));
    }

    /**
     * 新增隐患工单
     * @param workOrderDto 工单Dto
     * @return TRUE/FALSE
     */
    @PostMapping("/addDangerWorkOrder/{dangerId}")
    @ApiOperation(value = "新增隐患工单", notes = "新增隐患工单")
    public R addDangerWorkOrder(@RequestBody @Validated SaasWorkOrderDto workOrderDto, @PathVariable Long dangerId) {
        return R.status(baseService.addDangerWorkOrder(workOrderDto, dangerId));
    }


}
