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

/**
 * <p>
 * 预案管理 前端控制器
 * </p>
 *
 * @author JCB
 * @since 2022-09-05
 */
@RestController
@RequestMapping("/reservePlan")
public class ReservePlanController {

    @Autowired
    private ReservePlanService reservePlanService;

    /**
     * 预案管理-列表查询
     *
     * @param reserveName 预案名称
     * @param startDate   开始时间 格式：yyyy-MM-dd HH:mm:ss
     * @param endDate     结束时间 格式：yyyy-MM-dd HH:mm:ss
     * @param pageNum     当前页
     * @param pageSize    每页条数
     * @return
     */
    @GetMapping("reservePlanDataList")
    public ApiResult<CommonPage<Object>> reservePlanDataList(@RequestParam(value = "reserveName", required = false) String reserveName,
                                                             @RequestParam(value = "startDate", required = false) String startDate,
                                                             @RequestParam(value = "endDate", required = false) String endDate,
                                                             @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                             @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return ApiResult.success(reservePlanService.reservePlanDataList(reserveName, startDate, endDate, pageNum, pageSize));
    }

    /**
     * 预案管理-信息新增
     *
     * @param reservePlan
     * @return
     */
    @Log(title = "预案管理-信息新增", businessType = BusinessType.INSERT)
    @PostMapping("reservePlanDataAdd")
    public ApiResult<Void> reservePlanDataAdd(@RequestBody ReservePlan reservePlan) {
        reservePlanService.reservePlanDataAdd(reservePlan);
        return ApiResult.success();
    }

    /**
     * 预案管理-信息编辑
     *
     * @param reservePlan
     * @return
     */
    @Log(title = "预案管理-信息编辑", businessType = BusinessType.UPDATE)
    @PutMapping("reservePlanDataUpdate")
    public ApiResult<Void> reservePlanDataUpdate(@RequestBody ReservePlan reservePlan) {
        reservePlanService.reservePlanDataUpdate(reservePlan);
        return ApiResult.success();
    }

    /**
     * 预案管理-信息删除
     *
     * @param id 主键ID
     * @return
     */
    @Log(title = "预案管理-信息删除", businessType = BusinessType.DELETE)
    @DeleteMapping("reservePlanDataDelete")
    public ApiResult<Void> reservePlanDataDelete(@RequestParam(value = "id") Integer id) {
        reservePlanService.reservePlanDataDelete(id);
        return ApiResult.success();
    }
}

