package com.usky.fire.controller.web;


import com.usky.common.core.bean.ApiResult;
import com.usky.common.core.bean.CommonPage;
import com.usky.common.log.annotation.Log;
import com.usky.common.log.enums.BusinessType;
import com.usky.fire.domain.DemFireInspect;
import com.usky.fire.domain.DemFireInspectPerson;
import com.usky.fire.service.DemFireInspectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 消防检查 前端控制器
 * </p>
 *
 * @author JCB
 * @since 2022-11-24
 */
@RestController
@RequestMapping("/demFireInspect")
public class DemFireInspectController {

    @Autowired
    private DemFireInspectService demFireInspectService;

    /**
     * 消防检查信息-检查计划-列表查询
     *
     * @param companyId 单位ID
     * @param pageNum   当前页
     * @param pageSize  每页条数
     * @return
     */
    @GetMapping("fireInspectList")
    public ApiResult<CommonPage<DemFireInspect>> fireInspectList(@RequestParam(value = "companyId", required = false) String companyId,
                                                                 @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                                 @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return ApiResult.success(demFireInspectService.fireInspectList(companyId, pageNum, pageSize));
    }

    /**
     * 消防检查信息-检查计划-新增
     *
     * @param demFireInspect
     * @return
     */
    @Log(title = "消防检查信息-检查计划-新增", businessType = BusinessType.INSERT)
    @PostMapping("addFireInspect")
    public ApiResult<DemFireInspectPerson> addFireInspect(@RequestBody DemFireInspect demFireInspect) {
        return ApiResult.success(demFireInspectService.addFireInspect(demFireInspect));
    }

    /**
     * 消防检查信息-检查计划-修改
     *
     * @param demFireInspect
     * @return
     */
    @Log(title = "消防检查信息-检查计划-修改", businessType = BusinessType.UPDATE)
    @PutMapping("updateFireInspect")
    public ApiResult<Void> updateFireInspect(@RequestBody DemFireInspect demFireInspect) {
        demFireInspectService.updateFireInspect(demFireInspect);
        return ApiResult.success();
    }

}

