package com.njcn.system.controller;


import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.common.utils.LogUtil;
import com.njcn.system.pojo.param.CsWaveParam;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.service.IEleWaveParmService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 事件拓展表 前端控制器
 * </p>
 *
 * @author xuyang
 * @since 2023-07-31
 */
@Slf4j
@RestController
@RequestMapping("/eleWaveParm")
@RequiredArgsConstructor
@Api(tags = "波形字典录入")
@Validated
public class EleWaveParamController extends BaseController {

    private final IEleWaveParmService waveParamService;

    @PostMapping("/add")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("新增波形拓展数据")
    @ApiImplicitParam(name = "waveParam", value = "字典数据", required = true)
    public HttpResult<String> add(@RequestBody @Validated CsWaveParam waveParam){
        log.info("录入字典数据");
        String methodDescribe = getMethodDescribe("add");
        LogUtil.njcnDebug(log, "{}，模板当前解析字典数据为:", methodDescribe);
        waveParamService.add(waveParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @PostMapping("/delete")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("删除波形拓展数据")
    @ApiImplicitParam(name = "id", value = "id", required = true)
    public HttpResult<EleEpdPqd> delete(@RequestParam String id){
        String methodDescribe = getMethodDescribe("delete");
        LogUtil.njcnDebug(log, "{}，传递的id为:{}", methodDescribe,id);
        waveParamService.delete(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

}

