package com.unis.emergencySupportCenter.modular.esEpPlanTemplate.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.unis.common.annotation.CommonLog;
import com.unis.common.pojo.CommonResult;
import com.unis.common.pojo.CommonValidList;
import com.unis.emergencySupportCenter.modular.esEpPlanTemplate.entity.EsEpPlanTemplate;
import com.unis.emergencySupportCenter.modular.esEpPlanTemplate.param.EsEpPlanTemplateAddParam;
import com.unis.emergencySupportCenter.modular.esEpPlanTemplate.param.EsEpPlanTemplateEditParam;
import com.unis.emergencySupportCenter.modular.esEpPlanTemplate.param.EsEpPlanTemplateIdParam;
import com.unis.emergencySupportCenter.modular.esEpPlanTemplate.param.EsEpPlanTemplatePageParam;
import com.unis.emergencySupportCenter.modular.esEpPlanTemplate.service.EsEpPlanTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;

/**
 * @author qingsong.han
 * @description:
 * @create 2024-07-02 10:06
 */
@Api(tags = "IPad应急预案模板管理")
@ApiSupport(author = "UNIS_TEAM", order = 2)
@RestController
@Validated
@RequestMapping("/client/c")
public class IPadPlanTemplateController {

    @Resource
    private EsEpPlanTemplateService esEpPlanTemplateService;

    /**
     * 获取应急预案模板管理分页
     *
     * @author QSHan
     * @date  2024/06/28 09:47
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取应急预案模板管理分页")
    @GetMapping("/esEpPlanTemplate/page")
    public CommonResult<Page<EsEpPlanTemplate>> page(EsEpPlanTemplatePageParam esEpPlanTemplatePageParam) {
        return CommonResult.data(esEpPlanTemplateService.page(esEpPlanTemplatePageParam));
    }

    /**
     * 添加应急预案模板管理
     *
     * @author QSHan
     * @date  2024/06/28 09:47
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("添加应急预案模板管理")
    @CommonLog("添加应急预案模板管理")
    @PostMapping("/esEpPlanTemplate/add")
    public CommonResult<String> add(@RequestBody @Valid EsEpPlanTemplateAddParam esEpPlanTemplateAddParam) {
        esEpPlanTemplateService.add(esEpPlanTemplateAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑应急预案模板管理
     *
     * @author QSHan
     * @date  2024/06/28 09:47
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation("编辑应急预案模板管理")
    @CommonLog("编辑应急预案模板管理")
    @PostMapping("/esEpPlanTemplate/edit")
    public CommonResult<String> edit(@RequestBody @Valid EsEpPlanTemplateEditParam esEpPlanTemplateEditParam) {
        esEpPlanTemplateService.edit(esEpPlanTemplateEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除应急预案模板管理
     *
     * @author QSHan
     * @date  2024/06/28 09:47
     */
    @ApiOperationSupport(order = 4)
    @ApiOperation("删除应急预案模板管理")
    @CommonLog("删除应急预案模板管理")
    @PostMapping("/esEpPlanTemplate/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                               CommonValidList<EsEpPlanTemplateIdParam> esEpPlanTemplateIdParamList) {
        esEpPlanTemplateService.delete(esEpPlanTemplateIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取应急预案模板管理详情
     *
     * @author QSHan
     * @date  2024/06/28 09:47
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("获取应急预案模板管理详情")
    @GetMapping("/esEpPlanTemplate/detail")
    public CommonResult<EsEpPlanTemplate> detail(@Valid EsEpPlanTemplateIdParam esEpPlanTemplateIdParam) {
        return CommonResult.data(esEpPlanTemplateService.detail(esEpPlanTemplateIdParam));
    }
}
