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

博客网站排名我要建企业营销型网站

博客网站排名,我要建企业营销型网站,服务器租用哪家好,太原中小学网站建设1. 业务背景 作者在工作中主要主导 A 业务线的系统建设#xff0c;A 业务线主要是零售场景酒水的售卖与即时配送服务。为了方便运营在自研系统中对多平台商品进行管理而开发的三方平台商品管理功能#xff0c;本次介绍的模版方法模式则是在该功能开发过程中的落地实践。 2.…1. 业务背景 作者在工作中主要主导 A 业务线的系统建设A 业务线主要是零售场景酒水的售卖与即时配送服务。为了方便运营在自研系统中对多平台商品进行管理而开发的三方平台商品管理功能本次介绍的模版方法模式则是在该功能开发过程中的落地实践。 2. 技术方案选型 该业务场景可选设计为三种 自研系统根据自身业务形态对商品领域进行抽象建模在自研系统里对商品领域的操作最终映射到三方平台 自研系统对三方平台商品进行抽象建模保存三方平台商品在某个时刻的快照所有操作均是对快照的操作进而最终映射到三方平台 自研系统充当一个适配器和转发层所有对商品的操作都直接映射到三方平台 从系统建设角度来说最好的选择是第一种但是对于一个业务方想要更快的提升运营效率来说更好的选择是第二种和第三种我们从自身业务情况、性能、后续向第一种方案演进的角度选择了第二种方案。 3. 模版方法应用 以下代码仅为演示对模版方法的应用和展示代码设计思路有部分方法并未实现但通过注释说明方法内做了什么操作。 3.1. 模版抽象类 Component public abstract class ThirdPlatformStoreGoodsOperations {/*** 商品上架* param storeGoodsShelvesParam 商品上架参数* return 新商品记录ID*/public Long shelves(StoreGoodsShelvesParam storeGoodsShelvesParam) {// 获取门店本地商品ThirdPlatformGoods localStoreGoods this.getLocalStoreGoods(storeGoodsShelvesParam.getId());if (localStoreGoods null) {throw new HistoricalDataException(商品数据已更新请刷新当前页面);}// 上架三方平台门店商品this.shelvesThirdPlatformStoreGoods(localStoreGoods);// 刷新本地商品StoreGoodsRefreshParam storeGoodsRefreshParam new StoreGoodsRefreshParam();BeanUtils.copyProperties(storeGoodsShelvesParam, storeGoodsRefreshParam);return this.refreshOne(storeGoodsRefreshParam);}/*** 商品下架* param storeGoodsWithdrawParam 商品下架参数* return 新商品记录ID*/public Long withdraw(StoreGoodsWithdrawParam storeGoodsWithdrawParam) {// 获取门店本地商品ThirdPlatformGoods localStoreGoods this.getLocalStoreGoods(storeGoodsWithdrawParam.getId());if (localStoreGoods null) {throw new HistoricalDataException(商品数据已更新请刷新当前页面);}// 下架三方平台门店商品this.withdrawThirdPlatformStoreGoods(localStoreGoods);// 刷新本地商品StoreGoodsRefreshParam storeGoodsRefreshParam new StoreGoodsRefreshParam();BeanUtils.copyProperties(storeGoodsWithdrawParam, storeGoodsRefreshParam);return this.refreshOne(storeGoodsRefreshParam);}/*** 增加商品库存* param storeGoodsIncreaseStockParam 增加商品库存参数* return 新商品记录ID*/public Long increaseStock(StoreGoodsIncreaseStockParam storeGoodsIncreaseStockParam) {// 获取门店本地商品ThirdPlatformGoods localStoreGoods this.getLocalStoreGoods(storeGoodsIncreaseStockParam.getId());if (localStoreGoods null) {throw new HistoricalDataException(商品数据已更新请刷新当前页面);}// 增加三方平台店铺商品库存this.increaseThirdPlatformStoreGoodsStock(storeGoodsIncreaseStockParam, localStoreGoods);// 刷新本地商品StoreGoodsRefreshParam storeGoodsRefreshParam new StoreGoodsRefreshParam();BeanUtils.copyProperties(storeGoodsIncreaseStockParam, storeGoodsRefreshParam);return this.refreshOne(storeGoodsRefreshParam);}/*** 增加商品库存* param storeGoodsDecreaseStockParam 减少商品库存参数* return 新商品记录ID*/public Long decreaseStock(StoreGoodsDecreaseStockParam storeGoodsDecreaseStockParam) {// 获取门店本地商品ThirdPlatformGoods localStoreGoods this.getLocalStoreGoods(storeGoodsDecreaseStockParam.getId());if (localStoreGoods null) {throw new HistoricalDataException(商品数据已更新请刷新当前页面);}// 减少三方平台店铺商品库存this.decreaseThirdPlatformStoreGoodsStock(storeGoodsDecreaseStockParam, localStoreGoods);// 刷新本地商品StoreGoodsRefreshParam storeGoodsRefreshParam new StoreGoodsRefreshParam();BeanUtils.copyProperties(storeGoodsDecreaseStockParam, storeGoodsRefreshParam);return this.refreshOne(storeGoodsRefreshParam);}/*** 刷新店铺单个商品* param storeGoodsRefreshParam 刷新店铺单个商品参数* return 新商品记录ID*/public Long refreshOne(StoreGoodsRefreshParam storeGoodsRefreshParam) {// 获取门店本地商品ThirdPlatformGoods localStoreGoods this.getLocalStoreGoods(storeGoodsRefreshParam.getId());if (localStoreGoods null) {throw new HistoricalDataException(商品数据已更新请刷新当前页面);}// 获取三方门店商品StoreGoodsInfoResult storeGoodsInfoResult this.getThirdPlatformStoreGoods(storeGoodsRefreshParam, localStoreGoods);// 刷新本地商品return this.refreshLocalStoreGoods(storeGoodsRefreshParam, storeGoodsInfoResult);}/*** 刷新店铺商品* param storeGoodsRefreshParam 刷新店铺单个商品参数* param storeGoodsInfoResult 三方门店商品*/private Long refreshLocalStoreGoods(StoreGoodsRefreshParam storeGoodsRefreshParam,StoreGoodsInfoResult storeGoodsInfoResult) {// 更新本地商品}/*** 获取本地店铺商品信息* param localStoreGoodsId 本地商品ID* return 本地店铺商品信息*/private ThirdPlatformGoods getLocalStoreGoods(Long localStoreGoodsId) {// 获取本地商品}/*** 上架三方店铺商品* param localStoreGoods 本地店铺商品信息*/protected abstract void shelvesThirdPlatformStoreGoods(ThirdPlatformGoods localStoreGoods);/*** 下架三方店铺商品* param localStoreGoods 本地店铺商品信息*/protected abstract void withdrawThirdPlatformStoreGoods(ThirdPlatformGoods localStoreGoods);/*** 获取三方平台店铺商品* param storeGoodsRefreshParam 刷新店铺单个商品参数* param localStoreGoods 本地商品* return 三方门店商品*/protected abstract StoreGoodsInfoResult getThirdPlatformStoreGoods(StoreGoodsRefreshParam storeGoodsRefreshParam,ThirdPlatformGoods localStoreGoods);/*** 增加三方平台店铺商品库存* param storeGoodsIncreaseStockParam 增加三方平台店铺商品库存参数* param localStoreGoods 本地店铺商品信息*/protected abstract void increaseThirdPlatformStoreGoodsStock(StoreGoodsIncreaseStockParam storeGoodsIncreaseStockParam,ThirdPlatformGoods localStoreGoods);/*** 减少三方平台店铺商品库存* param storeGoodsDecreaseStockParam 减少三方平台店铺商品库存参数* param localStoreGoods 本地店铺商品信息*/protected abstract void decreaseThirdPlatformStoreGoodsStock(StoreGoodsDecreaseStockParam storeGoodsDecreaseStockParam,ThirdPlatformGoods localStoreGoods);/*** 获取对应平台* return 平台枚举*/protected abstract ThirdPlatformEnums getPlatform(); } 3.2. 模版实现类 public class ELEStoreGoodsTemplate extends ThirdPlatformStoreGoodsOperations {Overrideprotected void shelvesThirdPlatformStoreGoods(ThirdPlatformGoods localStoreGoods) {// 饿了么平台商品上架}Overrideprotected void withdrawThirdPlatformStoreGoods(ThirdPlatformGoods localStoreGoods) {// 饿了么平台商品下架}Overrideprotected StoreGoodsInfoResult getThirdPlatformStoreGoods(StoreGoodsRefreshParam storeGoodsRefreshParam,ThirdPlatformGoods localStoreGoods) {// 获取饿了么平台商品信息return null;}Overrideprotected void increaseThirdPlatformStoreGoodsStock(StoreGoodsIncreaseStockParam storeGoodsIncreaseStockParam,ThirdPlatformGoods localStoreGoods) {// 增加饿了么平台商品库存}Overrideprotected void decreaseThirdPlatformStoreGoodsStock(StoreGoodsDecreaseStockParam storeGoodsDecreaseStockParam, ThirdPlatformGoods localStoreGoods) {// 减少饿了么平台商品库存}Overrideprotected ThirdPlatformEnums getPlatform() {return ThirdPlatformEnums.ELEMO;} }4. 与 Spring 结合管理模版实现类 4.1. 基于 Spring IoC 容器依赖查找管理模版 Component public class ThirdPlatformGoodsTemplateManage {public MapThirdPlatformEnums, ThirdPlatformStoreGoodsOperations templateMap new HashMap(5);public ThirdPlatformGoodsTemplateManage(ListableBeanFactory listableBeanFactory){ObjectProviderThirdPlatformStoreGoodsOperations beanProvider listableBeanFactory.getBeanProvider(ThirdPlatformStoreGoodsOperations.class);for (ThirdPlatformStoreGoodsOperations template : beanProvider) {templateMap.put(template.getPlatform(), template);}}public ThirdPlatformStoreGoodsOperations getTemplate(ThirdPlatformEnums thirdPlatformEnum) {ThirdPlatformStoreGoodsOperations thirdPlatformStoreGoodsOperations templateMap.get(thirdPlatformEnum);Assert.notNull(thirdPlatformStoreGoodsOperations, String.format(%s平台模版未找到, thirdPlatformEnum.getDesc()));return thirdPlatformStoreGoodsOperations;}public ThirdPlatformStoreGoodsOperations getTemplate(String platformCode) {ThirdPlatformEnums thirdPlatformEnum ThirdPlatformEnums.getInstanceByCode(platformCode);ThirdPlatformStoreGoodsOperations thirdPlatformStoreGoodsOperations templateMap.get(thirdPlatformEnum);Assert.notNull(thirdPlatformStoreGoodsOperations, String.format(%s平台模版未找到, platformCode));return thirdPlatformStoreGoodsOperations;} }4.2. 基于 BeanPostProcessor 注解方式管理模版 Component public class ThirdPlatformStoreGoodsOperationsInitialization implements BeanPostProcessor {Resourceprivate ThirdPlatformGoodsTemplateManage thirdPlatformGoodsTemplateManage;Overridepublic Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {return bean;}Overridepublic Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {if (bean instanceof ThirdPlatformStoreGoodsOperations bean.getClass().isAnnotationPresent(ThirdPlatformStoreGoodsOperationsTemplate.class)){ThirdPlatformStoreGoodsOperations thirdPlatformStoreGoodsOperations (ThirdPlatformStoreGoodsOperations) bean;thirdPlatformGoodsTemplateManage.templateMap.put(thirdPlatformStoreGoodsOperations.getPlatform(), thirdPlatformStoreGoodsOperations);}return bean;} }改进建议 模版CODE可通过注解属性获取 5. 为什么选择模版方法 看完代码实现再回过头来说说选择模版方法的原因 从功能角度来说对三方平台商品管理无非就是那么几个商品新增、商品编辑、商品库存调整、商品上下架等从商品领域建模对三方平台商品领域行为抽象可分为创建、修改、增加库存、减少库存、覆盖库存、上架、下架等从代码复用的角度来说不同平台商品的操作不同的只有最终调用三方平台的差异上其他代码都可复用假设第一次开发只先适配美团那么在美团适配后复用的代码理论上不需要做任何修改从代码可扩展角度来说如果增加其他平台仅需要继承模版抽象类实现抽象方法即可从关注点分离角度来说后续适配其他平台仅仅需要关注如何操作三方平台即可这对新人或者不了解的人来继续迭代有很大好处关注点集中在如何适配三方平台上
http://www.dnsts.com.cn/news/94984.html

相关文章:

  • 怎么样推广网站专业做英文网站的公司
  • 做美缝在哪个网站接单企业网站源码wap
  • 如何制作外贸网站wordpress小说主题模板下载地址
  • 南宁大型网站建设什么网站流量大
  • c#网站购物车怎么做免费行业报告网站
  • 制作网站的技术揭阳网站制作机构
  • 山东省住房和建设网站广东公布最新传染了
  • 网站建设创意广告wordpress是可视化编辑
  • 网站怎么做支付wordpress 优酷免广告
  • 上海企业建设网站价格wordpress视频上传不
  • 服装厂家东莞网站建设企业公司网
  • 乌克兰服装网站建设宁夏建设职业技术学院成绩查询网站
  • 栾城seo整站排名大连做网站绍兴厂商
  • ftp是专门提供文件传输的网站在线做春节网站
  • 网站怎么被黑北京网络营销招聘
  • 企业做推广可以发哪些网站站长之家html模板
  • 门户网站建设公司咨询乐清网站建设推广
  • 查询类网站用什么做长沙公司建
  • 洛阳 网站建设公司专做教育网站拿站
  • wordpress时光轴插件关键词排名优化网站建设公司哪家好
  • 重庆网站建设坤思特前段模板的网站
  • 网站后台登陆验证码不显示微网站建设合同
  • 产品网站设计论文乐视网站建设目标
  • 文昌湖城乡建设局网站网站建设前景展望
  • 坪山附近公司做网站建设哪家技术好那个网站seo做的好的
  • 网站建设要购买服务器吗申请自媒体平台注册
  • 中国建设工程招标官方网站网站开发时图片加载慢怎么解决
  • 东莞百度提升优化seo整站优化网站建设
  • 天津市建设工程管理总队网站wordpress做支付宝小程序
  • 深泽网站制作重庆娱乐公司