package com.usky.fire.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.fire.domain.PatrolInspectionAbnormal;
import com.usky.fire.domain.PatrolInspectionRecord;
import com.usky.fire.domain.PatrolInspectionRoute;
import com.usky.fire.service.PatrolInspectionAbnormalService;
import com.usky.fire.service.vo.PatrolInspectionAbnormalVo;
import com.usky.fire.service.vo.PatrolInspectionRecordVo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 巡检异常记录表 前端控制器
 * </p>
 *
 * @author fu
 * @since 2024-06-13
 */
@RestController
@RequestMapping("/patrolInspectionAbnormal")
public class PatrolInspectionAbnormalController {

    @Autowired
    private PatrolInspectionAbnormalService patrolInspectionAbnormalService;


    @PostMapping("/addAbnormal")
    public ApiResult<Void> add(@RequestBody PatrolInspectionAbnormal patrolInspectionAbnormal) {
        patrolInspectionAbnormalService.addAbnormal(patrolInspectionAbnormal);
        return ApiResult.success();
    }

    @GetMapping("/abnormalList")
    public ApiResult<CommonPage<PatrolInspectionAbnormal>> recordList(@RequestParam(value = "areaName", required = false) String areaName,
                                                                                    @RequestParam(value = "siteName", required = false) String siteName,
                                                                                    @RequestParam(value = "name", required = false) String name,
                                                                                    @RequestParam(value = "planType", required = false) Integer planType,
                                                                                    @RequestParam(value = "routeId", required = false) Integer routeId,
                                                                                    @RequestParam(value = "startDateTime", required = false) String startDateTime,
                                                                                    @RequestParam(value = "endDateTime", required = false) String endDateTime,
                                                                                    @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                                                    @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return ApiResult.success(patrolInspectionAbnormalService.recordList(areaName, siteName, name, planType, routeId, startDateTime, endDateTime, pageNum, pageSize));
    }

    @GetMapping("/addAbnormalRecordDetails")
    public ApiResult<List<PatrolInspectionAbnormalVo>> recordDetails(@RequestParam(value = "id") Integer id) {
        return ApiResult.success(patrolInspectionAbnormalService.recordDetails(id));
    }
}

