package com.njcn.product.system.dict.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.product.system.dict.pojo.po.DictData;
import com.njcn.product.system.dict.service.IDictDataService;
import com.njcn.product.system.elequality.pojo.param.EleEpdPqdParam;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
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 springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @Author: cdf
 * @CreateTime: 2025-09-18
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/dicData")
@RequiredArgsConstructor
@Api(tags = "数据字典")
public class DicDataController extends BaseController {

    private final IDictDataService iDictDataService;

    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @GetMapping("/getDicDataByCodeAndType")
    @ApiOperation("根据字典Code和字典类型查询字典数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dicDataCode", value = "查询参数", required = true),
            @ApiImplicitParam(name = "dicTypeCode", value = "查询参数", required = true)
    })
    public HttpResult<DictData> getDicDataByCodeAndType(@RequestParam("dicDataCode") String dicCode, @RequestParam("dicTypeCode") String typeCode) {
        String methodDescribe = getMethodDescribe("getDicDataByCodeAndType");
        DictData result = iDictDataService.getDicDataByCodeAndType(dicCode,typeCode);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


    @OperateInfo(info = LogEnum.SYSTEM_COMMON)
    @GetMapping("/getDicDataByTypeCode")
    @ApiOperation("根据字典类型code查询字典数据")
    @ApiImplicitParam(name = "dictTypeCode", value = "查询参数", required = true)
    public HttpResult<List<DictData>> getDicDataByTypeCode(@RequestParam("dictTypeCode") String dictTypeCode) {
        String methodDescribe = getMethodDescribe("getDicDataByTypeCode");
        List<DictData> result = iDictDataService.getDicDataByTypeCode(dictTypeCode);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }


}
