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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuchen.saas.park.api.request.*;
import com.yuchen.saas.park.api.response.FireInspectListResponse;
import com.yuchen.saas.park.api.response.FireInspectPlanLogResponse;
import com.yuchen.saas.park.api.response.FireInspectResponse;
import com.yuchen.saas.park.api.response.FirePointPartResponse;
import com.yuchen.saas.park.service.service.FireInspectPointService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @ClassName FireInspectPointController
 * @Description 消防设施巡查点
 * @Author 肖祥
 * @Date 2022/10/18 15:30
 * @Version 1.0。0
 **/
@RestController
@AllArgsConstructor
@RequestMapping("/fire/inspect/point")
@Api(value = "消防设施巡查点控制器接口", tags = "消防设施巡查点控制器接口")
public class FireInspectPointController {

    @Resource
    private FireInspectPointService fireInspectPointService;

    /**
     * 消防设施巡查点新增
     */
    @ApiOperation(value = "消防设施巡查点新增")
    @PostMapping("/add")
    public R<Boolean> add(@Valid @RequestBody FireInspectAddRequest fireInspectAddRequest) {
        return fireInspectPointService.add(fireInspectAddRequest);
    }

    /**
     * 消防设施巡查点分页
     */
    @GetMapping("/list/page")
    @ApiOperation(value = "消防设施巡查点分页", notes = "消防设施巡查点分页")
    public R<IPage<FireInspectListResponse>> listPage(@Valid FireInspectPointQueryRequest fireFacilityQueryRequest, Query query) {
        return fireInspectPointService.listPage(fireFacilityQueryRequest,query);
    }

    /**
     * 消防设施巡查点删除
     */
    @ApiOperation(value = "消防设施巡查点删除")
    @PostMapping("/delete")
    public R<Boolean> delete(@Valid @RequestBody FireInspectDeleteRequest fireInspectDeleteRequest) {
        return  fireInspectPointService.delete(fireInspectDeleteRequest);
    }

    /**
     * 消防设施巡查点编辑
     */
    @ApiOperation(value = "消防设施巡查点编辑")
    @PostMapping("/update")
    public R<Boolean> update(@Valid @RequestBody FireInspectPointUpdateRequest fireInspectPointUpdateRequest) {
        return  fireInspectPointService.update(fireInspectPointUpdateRequest);
    }

    /**
     * 消防巡查点详情部件列表
     */
    @ApiOperation(value = "消防巡查点详情部件列表")
    @GetMapping("/part/list/page")
    public R<IPage<FirePointPartResponse>> searchInspectPointPartPage(@Valid FirePointPartListRequest request, Query query) {
        return fireInspectPointService.searchInspectPointPartPage(request,query);
    }

    /**
     * 消防巡查点详情任务记录列表
     */
    @ApiOperation(value = "消防巡查点详情任务记录列表")
    @GetMapping("/task/list/page")
    public R<IPage<FireInspectPlanLogResponse>> searchInspectPointPlanPage(@RequestParam(name = "id",required = false) Long id, Query query) {
        return fireInspectPointService.searchInspectPointPlanPage(id,query);
    }

    /**
     * 消防巡查点详情(不关联任务的详情)
     */
    @ApiOperation(value = "消防巡查点详情")
    @GetMapping("/detail")
    public R<FireInspectResponse> detail(@RequestParam(name = "id",required = false) Long id) {
        return fireInspectPointService.detail(id);
    }

    /**
     * 校验巡查点在计划中
     */
    @ApiOperation(value = "校验巡查点在计划中")
    @GetMapping("/verifyPatrolPointInPlan")
    public R<String> verifyPatrolPointInPlan(@RequestParam(name = "id",required = false) Long id) {
        return fireInspectPointService.verifyPatrolPointInPlan(id);
    }

    /**
     * 巡查点列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "消防设施巡查点列表", notes = "消防设施巡查点列表")
    public R<List<FireInspectListResponse>> list(FireInspectPointQueryRequest fireFacilityQueryRequest) {
        return fireInspectPointService.list(fireFacilityQueryRequest);
    }
}
