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

/**
 * <p>
 * 天然水源信息表 前端控制器
 * </p>
 *
 * @author JCB
 * @since 2022-10-25
 */
@RestController
@RequestMapping("/demWaterSourceMaintain")
public class DemWaterSourceMaintainController {

    @Autowired
    private DemWaterSourceMaintainService demWaterSourceMaintainService;

    /**
     * 消防水源管理-天然水源维护-列表
     *
     * @param squadron 所属中队
     * @param id       主键ID
     * @param pageNum  当前页面
     * @param pageSize 每页条数
     * @return
     */
    @GetMapping("waterSourceMaintainList")
    public ApiResult<CommonPage<DemWaterSourceMaintain>> waterSourceMaintainList(@RequestParam(value = "squadron", required = false) String squadron,
                                                                                 @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(demWaterSourceMaintainService.waterSourceMaintainList(squadron, id, pageNum, pageSize));
    }

    /**
     * 消防水源管理-天然水源维护-新增
     *
     * @param demWaterSourceMaintain
     */
    @Log(title = "消防水源管理-天然水源维护-新增", businessType = BusinessType.INSERT)
    @PostMapping("addWaterSourceMaintain")
    public ApiResult<Void> addWaterSourceMaintain(@RequestBody DemWaterSourceMaintain demWaterSourceMaintain) {
        demWaterSourceMaintainService.addWaterSourceMaintain(demWaterSourceMaintain);
        return ApiResult.success();
    }

    /**
     * 消防水源管理-天然水源维护-修改
     *
     * @param demWaterSourceMaintain
     */
    @Log(title = "消防水源管理-天然水源维护-修改", businessType = BusinessType.UPDATE)
    @PutMapping("updateWaterSourceMaintain")
    public ApiResult<Void> updateWaterSourceMaintain(@RequestBody DemWaterSourceMaintain demWaterSourceMaintain) {
        demWaterSourceMaintainService.updateWaterSourceMaintain(demWaterSourceMaintain);
        return ApiResult.success();
    }

    /**
     * 消防水源管理-天然水源维护-删除
     *
     * @param id 主键ID
     */
    @Log(title = "消防水源管理-天然水源维护-删除", businessType = BusinessType.DELETE)
    @DeleteMapping("delWaterSourceMaintain")
    public ApiResult<Void> delWaterSourceMaintain(@RequestParam(value = "id") Integer id) {
        demWaterSourceMaintainService.delWaterSourceMaintain(id);
        return ApiResult.success();
    }
}

