国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當(dāng)前位置: 首頁 > news >正文

上海百度嘉定公司網(wǎng)頁設(shè)計提升seo排名

上海百度嘉定公司網(wǎng)頁設(shè)計,提升seo排名,下沙建設(shè)局網(wǎng)站,寶安中心區(qū)房價走勢1. 業(yè)務(wù)背景 作者在工作中主要主導(dǎo) A 業(yè)務(wù)線的系統(tǒng)建設(shè),A 業(yè)務(wù)線主要是零售場景酒水的售賣與即時配送服務(wù)。為了方便運營在自研系統(tǒng)中對多平臺商品進(jìn)行管理而開發(fā)的三方平臺商品管理功能,本次介紹的模版方法模式則是在該功能開發(fā)過程中的落地實踐。 2.…

1. 業(yè)務(wù)背景

作者在工作中主要主導(dǎo) A 業(yè)務(wù)線的系統(tǒng)建設(shè),A 業(yè)務(wù)線主要是零售場景酒水的售賣與即時配送服務(wù)。為了方便運營在自研系統(tǒng)中對多平臺商品進(jìn)行管理而開發(fā)的三方平臺商品管理功能,本次介紹的模版方法模式則是在該功能開發(fā)過程中的落地實踐。

2. 技術(shù)方案選型

該業(yè)務(wù)場景可選設(shè)計為三種:

  • 自研系統(tǒng)根據(jù)自身業(yè)務(wù)形態(tài)對商品領(lǐng)域進(jìn)行抽象建模,在自研系統(tǒng)里對商品領(lǐng)域的操作最終映射到三方平臺;

  • 自研系統(tǒng)對三方平臺商品進(jìn)行抽象建模,保存三方平臺商品在某個時刻的快照,所有操作均是對快照的操作,進(jìn)而最終映射到三方平臺;

  • 自研系統(tǒng)充當(dāng)一個適配器和轉(zhuǎn)發(fā)層,所有對商品的操作都直接映射到三方平臺;

從系統(tǒng)建設(shè)角度來說最好的選擇是第一種,但是對于一個業(yè)務(wù)方想要更快的提升運營效率來說,更好的選擇是第二種和第三種,我們從自身業(yè)務(wù)情況、性能、后續(xù)向第一種方案演進(jìn)的角度選擇了第二種方案。

3. 模版方法應(yīng)用

以下代碼僅為演示對模版方法的應(yīng)用和展示代碼設(shè)計思路,有部分方法并未實現(xiàn),但通過注釋說明方法內(nèi)做了什么操作。

3.1. 模版抽象類

@Component
public abstract class ThirdPlatformStoreGoodsOperations {/*** 商品上架* @param storeGoodsShelvesParam 商品上架參數(shù)* @return 新商品記錄ID*/public Long shelves(StoreGoodsShelvesParam storeGoodsShelvesParam) {// 獲取門店本地商品ThirdPlatformGoods localStoreGoods = this.getLocalStoreGoods(storeGoodsShelvesParam.getId());if (localStoreGoods == null) {throw new HistoricalDataException("商品數(shù)據(jù)已更新,請刷新當(dāng)前頁面");}// 上架三方平臺門店商品this.shelvesThirdPlatformStoreGoods(localStoreGoods);// 刷新本地商品StoreGoodsRefreshParam storeGoodsRefreshParam = new StoreGoodsRefreshParam();BeanUtils.copyProperties(storeGoodsShelvesParam, storeGoodsRefreshParam);return this.refreshOne(storeGoodsRefreshParam);}/*** 商品下架* @param storeGoodsWithdrawParam 商品下架參數(shù)* @return 新商品記錄ID*/public Long withdraw(StoreGoodsWithdrawParam storeGoodsWithdrawParam) {// 獲取門店本地商品ThirdPlatformGoods localStoreGoods = this.getLocalStoreGoods(storeGoodsWithdrawParam.getId());if (localStoreGoods == null) {throw new HistoricalDataException("商品數(shù)據(jù)已更新,請刷新當(dāng)前頁面");}// 下架三方平臺門店商品this.withdrawThirdPlatformStoreGoods(localStoreGoods);// 刷新本地商品StoreGoodsRefreshParam storeGoodsRefreshParam = new StoreGoodsRefreshParam();BeanUtils.copyProperties(storeGoodsWithdrawParam, storeGoodsRefreshParam);return this.refreshOne(storeGoodsRefreshParam);}/*** 增加商品庫存* @param storeGoodsIncreaseStockParam 增加商品庫存參數(shù)* @return 新商品記錄ID*/public Long increaseStock(StoreGoodsIncreaseStockParam storeGoodsIncreaseStockParam) {// 獲取門店本地商品ThirdPlatformGoods localStoreGoods = this.getLocalStoreGoods(storeGoodsIncreaseStockParam.getId());if (localStoreGoods == null) {throw new HistoricalDataException("商品數(shù)據(jù)已更新,請刷新當(dāng)前頁面");}// 增加三方平臺店鋪商品庫存this.increaseThirdPlatformStoreGoodsStock(storeGoodsIncreaseStockParam, localStoreGoods);// 刷新本地商品StoreGoodsRefreshParam storeGoodsRefreshParam = new StoreGoodsRefreshParam();BeanUtils.copyProperties(storeGoodsIncreaseStockParam, storeGoodsRefreshParam);return this.refreshOne(storeGoodsRefreshParam);}/*** 增加商品庫存* @param storeGoodsDecreaseStockParam 減少商品庫存參數(shù)* @return 新商品記錄ID*/public Long decreaseStock(StoreGoodsDecreaseStockParam storeGoodsDecreaseStockParam) {// 獲取門店本地商品ThirdPlatformGoods localStoreGoods = this.getLocalStoreGoods(storeGoodsDecreaseStockParam.getId());if (localStoreGoods == null) {throw new HistoricalDataException("商品數(shù)據(jù)已更新,請刷新當(dāng)前頁面");}// 減少三方平臺店鋪商品庫存this.decreaseThirdPlatformStoreGoodsStock(storeGoodsDecreaseStockParam, localStoreGoods);// 刷新本地商品StoreGoodsRefreshParam storeGoodsRefreshParam = new StoreGoodsRefreshParam();BeanUtils.copyProperties(storeGoodsDecreaseStockParam, storeGoodsRefreshParam);return this.refreshOne(storeGoodsRefreshParam);}/*** 刷新店鋪單個商品* @param storeGoodsRefreshParam 刷新店鋪單個商品參數(shù)* @return 新商品記錄ID*/public Long refreshOne(StoreGoodsRefreshParam storeGoodsRefreshParam) {// 獲取門店本地商品ThirdPlatformGoods localStoreGoods = this.getLocalStoreGoods(storeGoodsRefreshParam.getId());if (localStoreGoods == null) {throw new HistoricalDataException("商品數(shù)據(jù)已更新,請刷新當(dāng)前頁面");}// 獲取三方門店商品StoreGoodsInfoResult storeGoodsInfoResult = this.getThirdPlatformStoreGoods(storeGoodsRefreshParam, localStoreGoods);// 刷新本地商品return this.refreshLocalStoreGoods(storeGoodsRefreshParam, storeGoodsInfoResult);}/*** 刷新店鋪商品* @param storeGoodsRefreshParam 刷新店鋪單個商品參數(shù)* @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 刷新店鋪單個商品參數(shù)* @param localStoreGoods 本地商品* @return 三方門店商品*/protected abstract StoreGoodsInfoResult getThirdPlatformStoreGoods(StoreGoodsRefreshParam storeGoodsRefreshParam,ThirdPlatformGoods localStoreGoods);/*** 增加三方平臺店鋪商品庫存* @param storeGoodsIncreaseStockParam 增加三方平臺店鋪商品庫存參數(shù)* @param localStoreGoods 本地店鋪商品信息*/protected abstract void increaseThirdPlatformStoreGoodsStock(StoreGoodsIncreaseStockParam storeGoodsIncreaseStockParam,ThirdPlatformGoods localStoreGoods);/*** 減少三方平臺店鋪商品庫存* @param storeGoodsDecreaseStockParam 減少三方平臺店鋪商品庫存參數(shù)* @param localStoreGoods 本地店鋪商品信息*/protected abstract void decreaseThirdPlatformStoreGoodsStock(StoreGoodsDecreaseStockParam storeGoodsDecreaseStockParam,ThirdPlatformGoods localStoreGoods);/*** 獲取對應(yīng)平臺* @return 平臺枚舉*/protected abstract ThirdPlatformEnums getPlatform();
}

3.2. 模版實現(xiàn)類

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 結(jié)合管理模版實現(xiàn)類

4.1. 基于 Spring IoC 容器依賴查找管理模版

@Component
public class ThirdPlatformGoodsTemplateManage {public Map<ThirdPlatformEnums, ThirdPlatformStoreGoodsOperations> templateMap = new HashMap<>(5);public ThirdPlatformGoodsTemplateManage(ListableBeanFactory listableBeanFactory){ObjectProvider<ThirdPlatformStoreGoodsOperations> 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;}
}

改進(jìn)建議: 模版CODE可通過注解屬性獲取

5. 為什么選擇模版方法

看完代碼實現(xiàn)再回過頭來,說說選擇模版方法的原因:

  • 從功能角度來說對三方平臺商品管理無非就是那么幾個商品新增、商品編輯、商品庫存調(diào)整、商品上下架等;
  • 從商品領(lǐng)域建模對三方平臺商品領(lǐng)域行為抽象可分為:創(chuàng)建、修改、增加庫存、減少庫存、覆蓋庫存、上架、下架等;
  • 從代碼復(fù)用的角度來說不同平臺商品的操作不同的只有最終調(diào)用三方平臺的差異上,其他代碼都可復(fù)用,假設(shè)第一次開發(fā)只先適配美團(tuán),那么在美團(tuán)適配后復(fù)用的代碼理論上不需要做任何修改;
  • 從代碼可擴(kuò)展角度來說,如果增加其他平臺,僅需要繼承模版抽象類,實現(xiàn)抽象方法即可;
  • 從關(guān)注點分離角度來說后續(xù)適配其他平臺僅僅需要關(guān)注如何操作三方平臺即可,這對新人或者不了解的人來繼續(xù)迭代有很大好處,關(guān)注點集中在如何適配三方平臺上;
http://aloenet.com.cn/news/33975.html

相關(guān)文章:

  • 安徽城鄉(xiāng)建設(shè)廳網(wǎng)站一鍵關(guān)鍵詞優(yōu)化
  • 做醫(yī)療網(wǎng)站聚名網(wǎng)域名注冊
  • 網(wǎng)站服務(wù)器 優(yōu)幫云外貿(mào)推廣代理
  • 鄰水網(wǎng)站建設(shè)友情鏈接檢測659292
  • 鎮(zhèn)江手機(jī)網(wǎng)站建設(shè)seo基礎(chǔ)篇
  • 海南最新情況最新消息今天網(wǎng)站seo入門基礎(chǔ)教程
  • 排名優(yōu)化網(wǎng)站網(wǎng)絡(luò)推廣哪家好
  • 事業(yè)單位網(wǎng)站開發(fā)工作規(guī)程網(wǎng)站優(yōu)化seo方案
  • 什么是項目管理小小課堂seo自學(xué)網(wǎng)
  • 婚紗攝影網(wǎng)站建設(shè)新聞稿發(fā)布
  • 珠寶網(wǎng)站設(shè)計今日熱點新聞素材
  • sae安裝WordPress4.4合肥品牌seo
  • 蔬菜派送網(wǎng)站怎么做輔導(dǎo)班培訓(xùn)機(jī)構(gòu)
  • 內(nèi)蒙古地區(qū)做推廣網(wǎng)站搜索引擎推廣試題
  • 哈爾濱網(wǎng)站建設(shè)技術(shù)托管國家再就業(yè)免費培訓(xùn)網(wǎng)
  • 如何申請域名建立網(wǎng)站資源最全的網(wǎng)盤搜索引擎
  • 網(wǎng)站內(nèi)容營銷武漢seo推廣優(yōu)化公司
  • 做網(wǎng)站個人怎么簽合同長沙全網(wǎng)覆蓋的網(wǎng)絡(luò)推廣
  • 網(wǎng)站設(shè)計效果專業(yè)樂云seoseo優(yōu)化專員招聘
  • b2b電商網(wǎng)站建設(shè)總推薦榜總點擊榜總排行榜
  • 手機(jī)商城網(wǎng)站如何開發(fā)一個網(wǎng)站
  • 免費的行情軟件網(wǎng)站不用下載站內(nèi)搜索工具
  • 東莞專業(yè)網(wǎng)站設(shè)計咨詢線上運營推廣
  • 網(wǎng)頁游戲排行榜前十名wangyiseo培訓(xùn)班 有用嗎
  • 天河網(wǎng)站建設(shè)制作百度客戶端電腦版下載
  • 怎么做一個論壇網(wǎng)站關(guān)鍵詞排名網(wǎng)絡(luò)推廣
  • 安卓app開發(fā)框架??趕eo計費
  • 怎么做輪胎網(wǎng)站google官方入口
  • qq刷贊網(wǎng)站怎么做的谷歌瀏覽器網(wǎng)頁版入口
  • 靜態(tài)雙語企業(yè)網(wǎng)站后臺源碼手機(jī)網(wǎng)站建設(shè)