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.DemFireInspectPerson;
import com.usky.fire.service.DemFireInspectPersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

    @Autowired
    private DemFireInspectPersonService demFireInspectPersonService;

    /**
     * 消防检查信息-检查人员信息-列表查询
     *
     * @param personName     检查员名称
     * @param personPosition 检查员职位
     * @param id             主键ID
     * @param pageNum        当前页
     * @param pageSize       每页条数
     * @return
     */
    @GetMapping("fireInspectPersonList")
    public ApiResult<CommonPage<DemFireInspectPerson>> fireInspectPersonList(@RequestParam(value = "personName", required = false) String personName,
                                                                             @RequestParam(value = "personPosition", required = false) String personPosition,
                                                                             @RequestParam(value = "id", required = false, defaultValue = "0") Integer id,
                                                                             @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                                             @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return ApiResult.success(demFireInspectPersonService.fireInspectPersonList(personName, personPosition, id, pageNum, pageSize));
    }

    /**
     * 消防检查信息-检查人员信息-新增
     *
     * @param demFireInspectPerson
     * @return
     */
    @Log(title = "消防检查信息-检查人员信息-新增", businessType = BusinessType.INSERT)
    @PostMapping("addFireInspectPerson")
    public ApiResult<Void> addFireInspectPerson(@RequestBody DemFireInspectPerson demFireInspectPerson) {
        demFireInspectPersonService.addFireInspectPerson(demFireInspectPerson);
        return ApiResult.success();
    }

    /**
     * 消防检查信息-检查人员信息-修改
     *
     * @param demFireInspectPerson
     * @return
     */
    @Log(title = "消防检查信息-检查人员信息-修改", businessType = BusinessType.UPDATE)
    @PutMapping("updateFireInspectPerson")
    public ApiResult<Void> updateFireInspectPerson(@RequestBody DemFireInspectPerson demFireInspectPerson) {
        demFireInspectPersonService.updateFireInspectPerson(demFireInspectPerson);
        return ApiResult.success();
    }


    /**
     * 消防检查信息-检查人员信息-删除
     *
     * @param id 主键ID
     * @return
     */
    @Log(title = "消防检查信息-检查人员信息-删除", businessType = BusinessType.DELETE)
    @DeleteMapping("delFireInspectPerson")
    public ApiResult<Void> delFireInspectPerson(@RequestParam(value = "id") Integer id) {
        demFireInspectPersonService.delFireInspectPerson(id);
        return ApiResult.success();
    }

}

