当前位置: 首页 > news >正文

佛山建设网站公司吗在线推广

佛山建设网站公司吗,在线推广,甜品网站建设规划,聊城市建设局网站1、背景:假设目前有两个接口,一个是查询快递订单状态的JSF接口,一个是查询快运订单状态的JSF接口,现有一个需求,要将这两个接口统一为一个入口,发布到物流开放平台供外界调用。 注意:以下代码均…

1、背景:假设目前有两个接口,一个是查询快递订单状态的JSF接口,一个是查询快运订单状态的JSF接口,现有一个需求,要将这两个接口统一为一个入口,发布到物流开放平台供外界调用。

注意:以下代码均为示例代码,仅供参考,具体值均无任何业务含义。

2、实现:将两个原有JSF接口所有入参和出参做融合,并增加一个业务属性shunt做区分,根据shunt来判断是快递的查询业务还是快运的查询业务,然后底层调用原有的JSF接口,但是目前有一个问题是,物流开放平台对外返回的code码是一套标准的code码,而后端底层接口返回的code码则不符合平台标准,所以要将JSF接口返回code码和物流开放平台的code码做映射,以便符合物流开放平台的标准。

3、分析实现方式,做映射的解决方案有很多:

1)枚举类:增加一个枚举类,增加三个属性,分别是JSF接口返回的code,和物流开放平台的code,以及业务标识(供后端接口返回的code相等但是对应的平台code不同时使用)并提供传入JSF接口code获取平台code的方法供全局调用,这样有一个弊端,就是一旦有新增的code码就要重新修改代码重新上线。

package com.xx.xxxxxx.constant;/*** 融合映射状态码*/
public enum OrderCodeEnum {/*** bizCode 1 通用下单业务码*/ORDER_CODE_2202(2202, 1000002, 1),ORDER_CODE_2204(2204, 1000004, 1),ORDER_CODE_2225(2225, 1000025, 1),ORDER_CODE_2290(2290, 1000090, 1),ORDER_CODE_2291(2291, 1000091, 1);/*** JSF接口code*/private Integer code;/*** 物流开放平台code*/private Integer platformCode;/*** 业务标识*/private Integer bizCode;OrderCodeEnum(Integer code, Integer platformCode, Integer bizCode) {this.code = code;this.platformCode = platformCode;this.bizCode = bizCode;}public Integer getCode() {return code;}public void setCode(Integer code) {this.code = code;}public Integer getPlatformCode() {return platformCode;}public void setPlatformCode(Integer platformCode) {this.platformCode = platformCode;}public Integer getBizCode() {return bizCode;}public void setBizCode(Integer bizCode) {this.bizCode = bizCode;}/*** 根据JSF code获取平台code* @param bizCode 业务标识* @param code JSF code* @return 平台code*/public static Integer getValue(Integer bizCode, Integer code) {OrderCodeEnum[] orderCodeEnums = values();for (OrderCodeEnum orderCodeEnum : orderCodeEnums) {if (!orderCodeEnum.bizCode.equals(bizCode)) {continue;}if(!orderCodeEnum.code.equals(code)) {continue;}return orderCodeEnum.getPlatformCode();}return null;}
}

2)ducc配置(配置类):在ducc的配置类中新增一个属性,然后将JSF接口code和平台code映射关系配置到配置文件或ducc配置平台,在类加载的时候,set注入到配置类的该属性中供全局使用,这样后续添加新映射关系的时候可以通过修改配置文件或者ducc平台配置即可,这样是一个很好的解决方案,但是有一个弊端,当映射关系特别多的时候,由于配置的是一个字符串,后续增加可能会配置错误导致解析失败,还有可能长度超出限制。

具体如何添加参考文章:将配置读注入到配置类的属性中供全局使用【开发记录】

3)这也是本篇的核心:解析配置文件注入到配置类属性中供全局使用,优点:解析的配置文件的格式很清晰,一目了然后续扩展不会配置错误,没有长度限制,后续扩展无需修改代码,配置类提供静态方法一键调用,避免每次还要依赖注入配置类再进行调用。

添加orderCode-config.json配置文件

{"1000":"1000","2000":"2000","2001":"2001","2002":"2002","3000":"4000","4000":"4000","1000000":"2400","1000001":"2401","1000002":"2402","1000003":"2403","1000004":"2404","1000005":"2405","1000006":"2406"
}

增加配置类,并解析配置文件,注入到属性中:

package com.xx.xxxxxxx.config;import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.xx.xxxxxxx.util.JsonFileLoadUtil;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;/*** 接口返回状态码和物流开放平台对外状态码映射* @author chenhongliang* @date 2023.03.17 15:00:00* @version 1.0*/@Component
public class OrderCodeConfig {private static final Logger logger = LoggerFactory.getLogger(OrderCodeConfig.class);/*** key:后端的code码* value:物流开放平台标准的platformCode*/private final static Map<String, String> orderCodeMap = new HashMap<>();@PostConstructprivate void init() {String jsonStrByFile = JsonFileLoadUtil.getJsonStrByFile("orderCode-config.json");Map<String, String> tempMap = JSON.parseObject(jsonStrByFile, new TypeReference<Map<String, String>>() {});if (!CollectionUtils.isEmpty(tempMap)) {orderCodeMap.putAll(tempMap);}logger.info("加载配置文件完成 key size:{}", orderCodeMap.size());}/*** 通过后端接口返回的code码获取物流开放平台标准的platformCode* @param code 接口返回的code* @return 物流开放平台标准的platformCode*/public static String getByCode(String code) {if(StringUtils.isBlank(code) || MapUtils.isEmpty(orderCodeMap)) {return StringUtils.EMPTY;}return orderCodeMap.get(code);}
}

至此可以通过静态方法getByCode,根据JSF接口code获取平台标准code。

贴一下相关Util代码:

package com.xx.xxxxxxx.util;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StreamUtils;import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;public class JsonFileLoadUtil {private static final Logger LOGGER = LoggerFactory.getLogger(JsonFileLoadUtil.class);private JsonFileLoadUtil() {throw new IllegalStateException("Utility class");}/*** 读取json文件内容转为json字符串* @param jsonFileName json文件名* @return*/public static String getJsonStrByFile(String jsonFileName) {String jsonStr = "{}";try (InputStream inputStream = JsonFileLoadUtil.class.getClassLoader().getResourceAsStream(jsonFileName);) {jsonStr = StreamUtils.copyToString(inputStream, StandardCharsets.UTF_8);} catch (IOException e) {LOGGER.error("未加载到配置文件:{}", jsonFileName);}LOGGER.info("读取JSON配置文件完成:jsonFileName{}, jsonStr:{}", jsonFileName, jsonStr);return jsonStr;}
}

文章转载自:
http://dinncofinegrained.tqpr.cn
http://dinncostrangury.tqpr.cn
http://dinncopiling.tqpr.cn
http://dinncocriteria.tqpr.cn
http://dinncodromometer.tqpr.cn
http://dinncomonazite.tqpr.cn
http://dinncodeadhouse.tqpr.cn
http://dinnconaturalism.tqpr.cn
http://dinncodecommitment.tqpr.cn
http://dinncovenospasm.tqpr.cn
http://dinncohyperbaric.tqpr.cn
http://dinncoganglia.tqpr.cn
http://dinncoangry.tqpr.cn
http://dinnconcv.tqpr.cn
http://dinncononintercourse.tqpr.cn
http://dinncounpoliced.tqpr.cn
http://dinncohypothetic.tqpr.cn
http://dinncosurrealism.tqpr.cn
http://dinncoaneurismal.tqpr.cn
http://dinncomerited.tqpr.cn
http://dinncorepressor.tqpr.cn
http://dinncolaser.tqpr.cn
http://dinncooffenbach.tqpr.cn
http://dinncoeffendi.tqpr.cn
http://dinncorestartable.tqpr.cn
http://dinncoaiche.tqpr.cn
http://dinncosubception.tqpr.cn
http://dinncoabend.tqpr.cn
http://dinncopoisonous.tqpr.cn
http://dinncoholometaboly.tqpr.cn
http://dinncohooter.tqpr.cn
http://dinncoapoplexy.tqpr.cn
http://dinncoheterotrophy.tqpr.cn
http://dinncoelamitic.tqpr.cn
http://dinncostoreship.tqpr.cn
http://dinncoindie.tqpr.cn
http://dinncoutopianism.tqpr.cn
http://dinncobleaching.tqpr.cn
http://dinncoosmium.tqpr.cn
http://dinncorecto.tqpr.cn
http://dinncoexceptional.tqpr.cn
http://dinncoequivoque.tqpr.cn
http://dinncoqn.tqpr.cn
http://dinncoglyph.tqpr.cn
http://dinncoeradiation.tqpr.cn
http://dinncocardiant.tqpr.cn
http://dinncoflorid.tqpr.cn
http://dinncointerpellant.tqpr.cn
http://dinncoportocaval.tqpr.cn
http://dinncotheses.tqpr.cn
http://dinncopanhuman.tqpr.cn
http://dinncolycurgus.tqpr.cn
http://dinncoquestionnaire.tqpr.cn
http://dinncofax.tqpr.cn
http://dinncosadducean.tqpr.cn
http://dinncomuonic.tqpr.cn
http://dinncoruritan.tqpr.cn
http://dinncoscimitar.tqpr.cn
http://dinncoswitzerite.tqpr.cn
http://dinncoslash.tqpr.cn
http://dinncoweatherability.tqpr.cn
http://dinncooutward.tqpr.cn
http://dinncoparallelism.tqpr.cn
http://dinncoceeb.tqpr.cn
http://dinncooutdid.tqpr.cn
http://dinncoacatalasemia.tqpr.cn
http://dinncocodfish.tqpr.cn
http://dinncokerry.tqpr.cn
http://dinncopracticum.tqpr.cn
http://dinncoradicalize.tqpr.cn
http://dinncofuegian.tqpr.cn
http://dinncosemaphoric.tqpr.cn
http://dinncobarrater.tqpr.cn
http://dinncosalii.tqpr.cn
http://dinncopolewards.tqpr.cn
http://dinncoquadrifid.tqpr.cn
http://dinncochondroma.tqpr.cn
http://dinncoepidermolysis.tqpr.cn
http://dinncorajah.tqpr.cn
http://dinncoflannelly.tqpr.cn
http://dinncohepatopexy.tqpr.cn
http://dinncocattiness.tqpr.cn
http://dinncoexcitable.tqpr.cn
http://dinncoinfatuate.tqpr.cn
http://dinncoshypoo.tqpr.cn
http://dinncolevelpeg.tqpr.cn
http://dinncothatch.tqpr.cn
http://dinncohabited.tqpr.cn
http://dinncounbuckle.tqpr.cn
http://dinncobookshelves.tqpr.cn
http://dinncocarsick.tqpr.cn
http://dinncosincerity.tqpr.cn
http://dinncoshipping.tqpr.cn
http://dinncolanceolar.tqpr.cn
http://dinncocoerce.tqpr.cn
http://dinncodemosthenes.tqpr.cn
http://dinncoyaffil.tqpr.cn
http://dinncosaddlebow.tqpr.cn
http://dinncoirrefragable.tqpr.cn
http://dinncopoetize.tqpr.cn
http://www.dinnco.com/news/105844.html

相关文章:

  • 重庆网站建设选卓光合肥seo推广培训班
  • 黑龙江建筑工程网安卓手机优化软件排名
  • 陕西免费做网站如何自己开发一个平台
  • 免费建站哪里找做互联网项目怎么推广
  • 网站分布百度高级搜索
  • 大兴企业官方网站建设怎样做公司网站推广
  • 通用cms网站电脑网络优化软件
  • 德国购物网站大全推广任务接单平台
  • 模板网站 没有独立的ftpseo网站优化工具大全
  • 成都信用温州seo按天扣费
  • 怎么做网络推广和宣传常州seo
  • 做游戏模板下载网站有哪些内容百度推广网址
  • 深圳做二维码网站建设关键词调词平台
  • 抖音代运营多少钱seo怎么优化方法
  • php cms网站建设营销网络推广方式有哪些
  • 集团网站设计公司不要手贱搜这15个关键词
  • 网站建设岗位商丘seo
  • tp3.2.3网站开发实例海淀区seo引擎优化
  • 做网站要学的东西google推广工具
  • wordpress循环日志重庆seo网站管理
  • 网站怎么放香港空间网络营销制度课完整版
  • 电脑如何做穿透外网网站北京营销推广网站建设
  • 网站备案怎么弄西安网站seo外包
  • dw网站制作手机软件下载广告安装接单app
  • 网站上的通话功能怎么做培训学校加盟费用
  • 东莞集团网站建设制作app平台需要多少钱
  • 封面上的网站怎么做的市场营销策划包括哪些内容
  • 深圳网站设计成功刻电子商务主要学什么就业方向
  • 上海专业网站建站公司关键词搜索排名公司
  • 服装店网站建设思路百度联盟怎么加入