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.EleEvtParam;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.po.EleEvtParm;
import com.njcn.system.service.IEleEvtParmService;
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.*;

import com.njcn.web.controller.BaseController;

import java.util.List;

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

    private final IEleEvtParmService eleEvtParmService;

    @PostMapping("/add")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("新增事件拓展数据")
    @ApiImplicitParam(name = "evtParam", value = "字典数据", required = true)
    public HttpResult<EleEpdPqd> add(@RequestBody @Validated EleEvtParam evtParam){
        log.info("录入字典数据");
        String methodDescribe = getMethodDescribe("add");
        LogUtil.njcnDebug(log, "{}，模板当前解析字典数据为:", methodDescribe);
        eleEvtParmService.add(evtParam);
        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);
        eleEvtParmService.delete(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
    }

    @PostMapping("/queryByPid")
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @ApiOperation("删除事件拓展数据")
    @ApiImplicitParam(name = "pid", value = "pid", required = true)
    public HttpResult<List<EleEvtParm>> queryByPid(@RequestParam String pid){
        String methodDescribe = getMethodDescribe("queryByPid");
        LogUtil.njcnDebug(log, "{}，传递的id为:{}", methodDescribe,pid);
        List<EleEvtParm> list = eleEvtParmService.queryByPid(pid);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
    }



}

