package com.changhong.epc.rely.api.epc.admin; import com.alibaba.fastjson.TypeReference; import com.changhong.epc.bean.admin.CorresElField; import com.changhong.epc.constter.admin.AdminUrlConst; import com.changhong.epc.constter.system.SystemClients; import com.changhong.epc.constter.system.run.EpcRestInterface; import com.changhong.epc.rely.api.epc.BaseApi; import com.iemsoft.framework.cloud.core.base.ResMsg; import com.iemsoft.framework.cloud.core.tools.JSONTool; import com.iemsoft.framework.cloud.core.tools.ObjectUtil; import com.iemsoft.framework.cloud.core.tools.SpringUtil; import com.iemsoft.framework.cloud.ribbon.RestInterface; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import java.util.List; import java.util.function.Function; /** * 常量表api */ @Service @Slf4j public class CorresElFieldApi extends BaseApi implements SystemClients{ public CorresElField getCorresElField(String businessMeaningCode){ CorresElField corresElField = new CorresElField(); corresElField.setBusinessMeaningCode(businessMeaningCode); ResMsg> resMsg = (ResMsg>) SpringUtil.getBean(SERVER_ADMIN.getBeanName(), RestInterface.class) .post(AdminUrlConst.GET_CORRESELFIELD , corresElField , new TypeReference>>(){}.getType() , EpcRestInterface.getEpcHeads() ); assertSuccess(resMsg); return ObjectUtil.empty(resMsg.getData()) ? new CorresElField() : JSONTool.toObj(JSONTool.toJson(resMsg.getData().get(0)), CorresElField.class); } public String getVal(String businessMeaningCode, Function mapper){ CorresElField result = getCorresElField(businessMeaningCode); if(ObjectUtil.notEmpty(result)){ return mapper.apply(result); } return ""; } }