Commit c72a788da62442a4e78e666388190d222a1784a2
1 parent
d8621149
新增描述功能(mongodb)
Showing
6 changed files
with
115 additions
and
86 deletions
titan-api/pom.xml
@@ -90,6 +90,34 @@ | @@ -90,6 +90,34 @@ | ||
90 | </build> | 90 | </build> |
91 | 91 | ||
92 | <dependencies> | 92 | <dependencies> |
93 | + <dependency> | ||
94 | + <groupId>org.springframework.data</groupId> | ||
95 | + <artifactId>spring-data-mongodb</artifactId> | ||
96 | + <version>1.4.2.RELEASE</version> | ||
97 | + <exclusions> | ||
98 | + <exclusion> | ||
99 | + <artifactId>spring-tx</artifactId> | ||
100 | + <groupId>org.springframework</groupId> | ||
101 | + </exclusion> | ||
102 | + <exclusion> | ||
103 | + <artifactId>spring-context</artifactId> | ||
104 | + <groupId>org.springframework</groupId> | ||
105 | + </exclusion> | ||
106 | + <exclusion> | ||
107 | + <artifactId>spring-beans</artifactId> | ||
108 | + <groupId>org.springframework</groupId> | ||
109 | + </exclusion> | ||
110 | + <exclusion> | ||
111 | + <artifactId>spring-core</artifactId> | ||
112 | + <groupId>org.springframework</groupId> | ||
113 | + </exclusion> | ||
114 | + <exclusion> | ||
115 | + <artifactId>spring-expression</artifactId> | ||
116 | + <groupId>org.springframework</groupId> | ||
117 | + </exclusion> | ||
118 | + </exclusions> | ||
119 | + </dependency> | ||
120 | + | ||
93 | <!-- spring --> | 121 | <!-- spring --> |
94 | <dependency> | 122 | <dependency> |
95 | <groupId>org.springframework</groupId> | 123 | <groupId>org.springframework</groupId> |
@@ -317,6 +345,11 @@ | @@ -317,6 +345,11 @@ | ||
317 | <!--权限管理的redis配置--> | 345 | <!--权限管理的redis配置--> |
318 | <manage.redis.url>10.28.11.205</manage.redis.url> | 346 | <manage.redis.url>10.28.11.205</manage.redis.url> |
319 | <manage.redis.port>6379</manage.redis.port> | 347 | <manage.redis.port>6379</manage.redis.port> |
348 | + <!-- mongodb --> | ||
349 | + <mongo.host>10.28.11.148</mongo.host> | ||
350 | + <mongo.port>27017</mongo.port> | ||
351 | + <mongo.username></mongo.username> | ||
352 | + <mongo.pwd></mongo.pwd> | ||
320 | </properties> | 353 | </properties> |
321 | </profile> | 354 | </profile> |
322 | </profiles> | 355 | </profiles> |
titan-api/src/main/java/com/diligrp/titan/rest/domain/output/ProductInfoOut.java
@@ -85,6 +85,15 @@ public class ProductInfoOut { | @@ -85,6 +85,15 @@ public class ProductInfoOut { | ||
85 | */ | 85 | */ |
86 | private List<String> pictures; | 86 | private List<String> pictures; |
87 | 87 | ||
88 | + private String desc; | ||
89 | + | ||
90 | + public String getDesc() { | ||
91 | + return desc; | ||
92 | + } | ||
93 | + | ||
94 | + public void setDesc(String desc) { | ||
95 | + this.desc = desc; | ||
96 | + } | ||
88 | 97 | ||
89 | /** | 98 | /** |
90 | * 创建时间 | 99 | * 创建时间 |
titan-api/src/main/java/com/diligrp/titan/ws/product/ProductRestService.java
@@ -22,7 +22,7 @@ public interface ProductRestService { | @@ -22,7 +22,7 @@ public interface ProductRestService { | ||
22 | * @createTime 2014年6月9日 下午2:09:41 | 22 | * @createTime 2014年6月9日 下午2:09:41 |
23 | * @author celine | 23 | * @author celine |
24 | */ | 24 | */ |
25 | - public Long insertPopProduct(PopProductInput input) throws TitanError; | 25 | + Long insertPopProduct(PopProductInput input) throws TitanError; |
26 | 26 | ||
27 | 27 | ||
28 | /** | 28 | /** |
@@ -35,7 +35,7 @@ public interface ProductRestService { | @@ -35,7 +35,7 @@ public interface ProductRestService { | ||
35 | * @createTime 2015年3月30日 下午4:03:14 | 35 | * @createTime 2015年3月30日 下午4:03:14 |
36 | * @author yangwd | 36 | * @author yangwd |
37 | */ | 37 | */ |
38 | - public List<ProductInfoOut> getProductInfo(List<Long> pids, boolean isCludDeleteSku) throws TitanError; | 38 | + List<ProductInfoOut> getProductInfo(List<Long> pids, boolean isCludDeleteSku) throws TitanError; |
39 | 39 | ||
40 | /** | 40 | /** |
41 | * 分页获取所有第三方商品(搜索同步使用) | 41 | * 分页获取所有第三方商品(搜索同步使用) |
@@ -44,9 +44,9 @@ public interface ProductRestService { | @@ -44,9 +44,9 @@ public interface ProductRestService { | ||
44 | * @param pageSize | 44 | * @param pageSize |
45 | * @return | 45 | * @return |
46 | */ | 46 | */ |
47 | - public PageOutput<List<ProductInfoOut>> getAllProductPop(int page, int pageSize); | 47 | + PageOutput<List<ProductInfoOut>> getAllProductPop(int page, int pageSize); |
48 | 48 | ||
49 | - public PageOutput<List<ProductInfoOut>> searchProductPop(int page, int pageSize, ProductInfoInput input); | 49 | + PageOutput<List<ProductInfoOut>> searchProductPop(int page, int pageSize, ProductInfoInput input); |
50 | 50 | ||
51 | /** | 51 | /** |
52 | * 批量获取sku信息 | 52 | * 批量获取sku信息 |
@@ -54,7 +54,7 @@ public interface ProductRestService { | @@ -54,7 +54,7 @@ public interface ProductRestService { | ||
54 | * @param skus 需要查询的sku | 54 | * @param skus 需要查询的sku |
55 | * @return 返回 key为sku 值为相应sku商品 | 55 | * @return 返回 key为sku 值为相应sku商品 |
56 | */ | 56 | */ |
57 | - public Map<String, ProductInfoOut> getSkuInfoMap(List<String> skus); | 57 | + Map<String, ProductInfoOut> getSkuInfoMap(List<String> skus); |
58 | 58 | ||
59 | /** | 59 | /** |
60 | * this method is 删除第三方产品信息 | 60 | * this method is 删除第三方产品信息 |
@@ -64,18 +64,9 @@ public interface ProductRestService { | @@ -64,18 +64,9 @@ public interface ProductRestService { | ||
64 | * @createTime 2014年6月18日 下午2:57:51 | 64 | * @createTime 2014年6月18日 下午2:57:51 |
65 | * @author yangjianjun | 65 | * @author yangjianjun |
66 | */ | 66 | */ |
67 | - public void delProductInfo(List<Long> pids) throws TitanError; | 67 | + void delProductInfo(List<Long> pids) throws TitanError; |
68 | 68 | ||
69 | 69 | ||
70 | - /** | ||
71 | - * 更新买卖对接商品 | ||
72 | - * | ||
73 | - * @param input 买卖对接商品信息 | ||
74 | - * @return | ||
75 | - * @throws TitanError | ||
76 | - * @createTime 2014年6月20日 下午5:13:59 | ||
77 | - */ | ||
78 | - public Map<String, Boolean> updatePopProduct(PopProductInput input) throws TitanError; | ||
79 | 70 | ||
80 | /** | 71 | /** |
81 | * this method is 更新第三方商品库的状态信息 | 72 | * this method is 更新第三方商品库的状态信息 |
@@ -88,7 +79,7 @@ public interface ProductRestService { | @@ -88,7 +79,7 @@ public interface ProductRestService { | ||
88 | * @createTime 2014年6月19日 上午11:18:27 | 79 | * @createTime 2014年6月19日 上午11:18:27 |
89 | * @author yangjianjun | 80 | * @author yangjianjun |
90 | */ | 81 | */ |
91 | - public int updatePopProductStatus(int status, List<Long> pids, long sellerId) throws TitanError; | 82 | + int updatePopProductStatus(int status, List<Long> pids, long sellerId) throws TitanError; |
92 | 83 | ||
93 | /** | 84 | /** |
94 | * this method is 自定义第三方商品的分类 | 85 | * this method is 自定义第三方商品的分类 |
@@ -100,7 +91,7 @@ public interface ProductRestService { | @@ -100,7 +91,7 @@ public interface ProductRestService { | ||
100 | * @createTime 2014年6月19日 下午2:14:32 | 91 | * @createTime 2014年6月19日 下午2:14:32 |
101 | * @author yangjianjun | 92 | * @author yangjianjun |
102 | */ | 93 | */ |
103 | - public int setProductVirtualCid(List<Long> pids, long vcid) throws TitanError; | 94 | + int setProductVirtualCid(List<Long> pids, long vcid) throws TitanError; |
104 | 95 | ||
105 | 96 | ||
106 | /** | 97 | /** |
@@ -110,7 +101,7 @@ public interface ProductRestService { | @@ -110,7 +101,7 @@ public interface ProductRestService { | ||
110 | * @param num 获取数量 | 101 | * @param num 获取数量 |
111 | * @return | 102 | * @return |
112 | */ | 103 | */ |
113 | - public List<ProductInfoOut> listLatestProduct(Long shopId, Integer num); | 104 | + List<ProductInfoOut> listLatestProduct(Long shopId, Integer num); |
114 | 105 | ||
115 | /** | 106 | /** |
116 | * this method is 获取设置的商品搜索排序 | 107 | * this method is 获取设置的商品搜索排序 |
@@ -119,7 +110,7 @@ public interface ProductRestService { | @@ -119,7 +110,7 @@ public interface ProductRestService { | ||
119 | * @createTime 2014年9月7日 下午3:36:14 | 110 | * @createTime 2014年9月7日 下午3:36:14 |
120 | * @author chenzhiwei | 111 | * @author chenzhiwei |
121 | */ | 112 | */ |
122 | - public List<ProductSearchSortOut> getProductSearchSort(Long cid, Integer type); | 113 | + List<ProductSearchSortOut> getProductSearchSort(Long cid, Integer type); |
123 | 114 | ||
124 | /** | 115 | /** |
125 | * this method is 查询上架自定义类目下的商品总数 | 116 | * this method is 查询上架自定义类目下的商品总数 |
@@ -130,7 +121,7 @@ public interface ProductRestService { | @@ -130,7 +121,7 @@ public interface ProductRestService { | ||
130 | * @createTime 2014年6月19日 下午3:59:32 | 121 | * @createTime 2014年6月19日 下午3:59:32 |
131 | * @author yangjianjun | 122 | * @author yangjianjun |
132 | */ | 123 | */ |
133 | - public Long countVirtualCatProducts(long vcid) throws TitanError; | 124 | + Long countVirtualCatProducts(long vcid) throws TitanError; |
134 | 125 | ||
135 | /** | 126 | /** |
136 | * 获取商品描述信息 | 127 | * 获取商品描述信息 |
@@ -141,7 +132,7 @@ public interface ProductRestService { | @@ -141,7 +132,7 @@ public interface ProductRestService { | ||
141 | * @createTime 2015年3月31日 下午5:17:24 | 132 | * @createTime 2015年3月31日 下午5:17:24 |
142 | * @author yangjianjun | 133 | * @author yangjianjun |
143 | */ | 134 | */ |
144 | - public String getProductDesc(Long pid) throws TitanError; | 135 | + String getProductDesc(Long pid) throws TitanError; |
145 | 136 | ||
146 | /** | 137 | /** |
147 | * 设置商品描述信息 | 138 | * 设置商品描述信息 |
@@ -152,7 +143,7 @@ public interface ProductRestService { | @@ -152,7 +143,7 @@ public interface ProductRestService { | ||
152 | * @createTime 2015年3月31日 下午5:17:24 | 143 | * @createTime 2015年3月31日 下午5:17:24 |
153 | * @author yangjianjun | 144 | * @author yangjianjun |
154 | */ | 145 | */ |
155 | - public void setProductDesc(Long pid, String desc) throws TitanError; | 146 | + void setProductDesc(Long pid, String desc) throws TitanError; |
156 | 147 | ||
157 | 148 | ||
158 | /** | 149 | /** |
@@ -165,7 +156,7 @@ public interface ProductRestService { | @@ -165,7 +156,7 @@ public interface ProductRestService { | ||
165 | * @createTime 2015年4月20日 下午8:20:32 | 156 | * @createTime 2015年4月20日 下午8:20:32 |
166 | * @author yjj | 157 | * @author yjj |
167 | */ | 158 | */ |
168 | - public Map<Integer, String> getPopProductCategroyByShopId(Integer shopId, Integer pstatus) throws TitanError; | 159 | + Map<Integer, String> getPopProductCategroyByShopId(Integer shopId, Integer pstatus) throws TitanError; |
169 | 160 | ||
170 | 161 | ||
171 | /** | 162 | /** |
@@ -174,7 +165,7 @@ public interface ProductRestService { | @@ -174,7 +165,7 @@ public interface ProductRestService { | ||
174 | * @param query | 165 | * @param query |
175 | * @return | 166 | * @return |
176 | */ | 167 | */ |
177 | - public int getProductPopCount(ProductPop query); | 168 | + int getProductPopCount(ProductPop query); |
178 | 169 | ||
179 | /** | 170 | /** |
180 | * 根据店铺ID获取商品数量 | 171 | * 根据店铺ID获取商品数量 |
@@ -182,7 +173,7 @@ public interface ProductRestService { | @@ -182,7 +173,7 @@ public interface ProductRestService { | ||
182 | * @param shopId | 173 | * @param shopId |
183 | * @return | 174 | * @return |
184 | */ | 175 | */ |
185 | - public int getCountByShopId(Long shopId); | 176 | + int getCountByShopId(Long shopId); |
186 | 177 | ||
187 | 178 | ||
188 | /** | 179 | /** |
titan-api/src/main/java/com/diligrp/titan/ws/product/impl/ProductRestServiceImpl.java
1 | package com.diligrp.titan.ws.product.impl; | 1 | package com.diligrp.titan.ws.product.impl; |
2 | 2 | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
3 | import com.diligrp.titan.common.ProductStatus; | 4 | import com.diligrp.titan.common.ProductStatus; |
4 | import com.diligrp.titan.common.exception.TitanError; | 5 | import com.diligrp.titan.common.exception.TitanError; |
5 | import com.diligrp.titan.common.log.LogHelper; | 6 | import com.diligrp.titan.common.log.LogHelper; |
@@ -32,6 +33,11 @@ import com.diligrp.titan.ws.product.pop.ProductPopRestService; | @@ -32,6 +33,11 @@ import com.diligrp.titan.ws.product.pop.ProductPopRestService; | ||
32 | import com.diligrp.titan.ws.product.pop.ProductSkuPopRestService; | 33 | import com.diligrp.titan.ws.product.pop.ProductSkuPopRestService; |
33 | import org.apache.commons.collections.CollectionUtils; | 34 | import org.apache.commons.collections.CollectionUtils; |
34 | import org.apache.commons.lang.StringUtils; | 35 | import org.apache.commons.lang.StringUtils; |
36 | +import org.springframework.beans.factory.annotation.Autowired; | ||
37 | +import org.springframework.data.mongodb.core.MongoTemplate; | ||
38 | +import org.springframework.data.mongodb.core.query.Criteria; | ||
39 | +import org.springframework.data.mongodb.core.query.Query; | ||
40 | +import org.springframework.data.mongodb.core.query.Update; | ||
35 | import org.springframework.stereotype.Service; | 41 | import org.springframework.stereotype.Service; |
36 | import org.springframework.transaction.annotation.Transactional; | 42 | import org.springframework.transaction.annotation.Transactional; |
37 | 43 | ||
@@ -72,6 +78,9 @@ public class ProductRestServiceImpl implements ProductRestService { | @@ -72,6 +78,9 @@ public class ProductRestServiceImpl implements ProductRestService { | ||
72 | @Resource | 78 | @Resource |
73 | private AttributeRestService attributeRestService; | 79 | private AttributeRestService attributeRestService; |
74 | 80 | ||
81 | + @Autowired | ||
82 | + private MongoTemplate mongoTemplate; | ||
83 | + | ||
75 | @Override | 84 | @Override |
76 | @Transactional(rollbackFor = TitanError.class) | 85 | @Transactional(rollbackFor = TitanError.class) |
77 | public Long insertPopProduct(PopProductInput productInput) throws TitanError { | 86 | public Long insertPopProduct(PopProductInput productInput) throws TitanError { |
@@ -88,7 +97,15 @@ public class ProductRestServiceImpl implements ProductRestService { | @@ -88,7 +97,15 @@ public class ProductRestServiceImpl implements ProductRestService { | ||
88 | 97 | ||
89 | 98 | ||
90 | // 将商品描述写入hbase | 99 | // 将商品描述写入hbase |
91 | - //productDescDao.putProductDesc(pid, keyWordsRPC.filterKeyWordsInfoByTag(productInput.getDesc(),"*")); | 100 | + try { |
101 | + JSONObject json = new JSONObject(); | ||
102 | + json.put("id", pid); | ||
103 | + json.put("content", productInput.getDesc()); | ||
104 | + mongoTemplate.save(json, "content"); | ||
105 | + | ||
106 | + } catch (Exception e) { | ||
107 | + e.printStackTrace(); | ||
108 | + } | ||
92 | // 生成属性列表 | 109 | // 生成属性列表 |
93 | List<ProductPopAttr> attrs = generateAttrs(productInput, pid); | 110 | List<ProductPopAttr> attrs = generateAttrs(productInput, pid); |
94 | productPopAttrRestService.batchInsert(attrs); | 111 | productPopAttrRestService.batchInsert(attrs); |
@@ -172,7 +189,14 @@ public class ProductRestServiceImpl implements ProductRestService { | @@ -172,7 +189,14 @@ public class ProductRestServiceImpl implements ProductRestService { | ||
172 | Map<String, List<AttributeOut>> attrMap = productPopAttrRestService.findByPid(pid, popProductDb.getCateId()); | 189 | Map<String, List<AttributeOut>> attrMap = productPopAttrRestService.findByPid(pid, popProductDb.getCateId()); |
173 | result.setSaleAtt(attrMap.get("saleAttrs")); | 190 | result.setSaleAtt(attrMap.get("saleAttrs")); |
174 | 191 | ||
175 | - | 192 | + try { |
193 | + Query query = new Query(); | ||
194 | + query.addCriteria(Criteria.where("id").is(pid)); | ||
195 | + JSONObject object = mongoTemplate.findOne(query, JSONObject.class, "content"); | ||
196 | + result.setDesc(object.getString("content")); | ||
197 | + } catch (Exception e) { | ||
198 | + e.printStackTrace(); | ||
199 | + } | ||
176 | //设置sku信息 | 200 | //设置sku信息 |
177 | List<ProductSkuPop> skuList = productSkuPopRestService.findByPid(pid, isCludDeleteSku); | 201 | List<ProductSkuPop> skuList = productSkuPopRestService.findByPid(pid, isCludDeleteSku); |
178 | List<SkuOut> skus = CovertUtils.covertEntrtyList(skuList, SkuOut.class); | 202 | List<SkuOut> skus = CovertUtils.covertEntrtyList(skuList, SkuOut.class); |
@@ -518,64 +542,6 @@ public class ProductRestServiceImpl implements ProductRestService { | @@ -518,64 +542,6 @@ public class ProductRestServiceImpl implements ProductRestService { | ||
518 | productSearchSortRestService.deleteProductSearchSort(pids); | 542 | productSearchSortRestService.deleteProductSearchSort(pids); |
519 | } | 543 | } |
520 | 544 | ||
521 | - @Override | ||
522 | - @Transactional(rollbackFor = TitanError.class) | ||
523 | - public Map<String, Boolean> updatePopProduct(PopProductInput input) throws TitanError { | ||
524 | - Map<String, Boolean> resultMap = new HashMap<String, Boolean>(); | ||
525 | - boolean isWaitProduct = false; //强制下架后,用户重新修改的商品 | ||
526 | - Long pid = input.getPid(); | ||
527 | - if (pid == null) { | ||
528 | - throw new TitanError(0, "商品PID为空,请检查输入参数"); | ||
529 | - } | ||
530 | - ProductPop condtion = new ProductPop(); | ||
531 | - condtion.setPid(pid); | ||
532 | - List<ProductPop> productInDb = productPopRestService.selectEntryList(condtion); | ||
533 | - if (productInDb == null || productInDb.size() != 1) { | ||
534 | - throw new TitanError(0, "商品" + pid + "不存在"); | ||
535 | - } | ||
536 | - try { | ||
537 | - // 插入商品主表product_pop | ||
538 | - ProductPop productPop = generateProduct(input); | ||
539 | - productPop.setPid(pid); | ||
540 | - // 根据商品原来的状体和新的商品信息,更新商品状态 | ||
541 | - int status = productInDb.get(0).getStatus(); | ||
542 | - // 商品在架状态,不允许修改上架时间和上架模式 | ||
543 | - | ||
544 | - | ||
545 | - productPopRestService.updateByKey(productPop); | ||
546 | - | ||
547 | - | ||
548 | - // 生成SKU更新product_pop | ||
549 | - List<ProductSkuPop> skus = generateSku(input, productPop.getPid(), false); | ||
550 | - List<ProductSkuPop> skuInDb = productSkuPopRestService.findByPid(pid); | ||
551 | - updateSku(skus, skuInDb); | ||
552 | - | ||
553 | - // 将商品描述写入hbase | ||
554 | - //productDescDao.putProductDesc(pid, keyWordsRPC.filterKeyWordsInfoByTag(input.getDesc(), "*")); | ||
555 | - | ||
556 | - // 生成属性列表 | ||
557 | - List<ProductPopAttr> attrs = generateAttrs(input, pid); | ||
558 | - productPopAttrRestService.deleteByPid(pid); | ||
559 | - productPopAttrRestService.batchInsert(attrs); | ||
560 | - // 生成图片列表 | ||
561 | - List<ProductImg> imgs = generateImgs(input.getPictures(), pid); | ||
562 | - productImgRestService.updateProductImg(pid, imgs); | ||
563 | - | ||
564 | - // 生成属性值列表 | ||
565 | - List<ProductAttrValue> attrValues = generateAttrValues(input, pid); | ||
566 | - productPopAttrValueRestService.deleteByPid(pid); | ||
567 | - productPopAttrValueRestService.batchInsert(attrValues); | ||
568 | - | ||
569 | - | ||
570 | - resultMap.put("isWaitProduct", isWaitProduct); | ||
571 | - resultMap.put("updateSuccess", true); | ||
572 | - return resultMap; | ||
573 | - } catch (Exception e) { | ||
574 | - LogHelper.error(LogTypeEnum.PRODUCT, e, "更新商品失败!{}", e.getMessage()); | ||
575 | - throw new TitanError(500, "更新商品失败" + e.getMessage()); | ||
576 | - } | ||
577 | - } | ||
578 | - | ||
579 | /** | 545 | /** |
580 | * 对比输入的SKU与数据库中的SKU,进行新增、更新、删除 | 546 | * 对比输入的SKU与数据库中的SKU,进行新增、更新、删除 |
581 | * | 547 | * |
@@ -690,7 +656,7 @@ public class ProductRestServiceImpl implements ProductRestService { | @@ -690,7 +656,7 @@ public class ProductRestServiceImpl implements ProductRestService { | ||
690 | List<Integer> cateId = productPopRestService.getPopProductCategroyByShopId(shopId, pstatus); | 656 | List<Integer> cateId = productPopRestService.getPopProductCategroyByShopId(shopId, pstatus); |
691 | Map<Integer, String> map = null; | 657 | Map<Integer, String> map = null; |
692 | if (!CollectionUtils.isEmpty(cateId)) { | 658 | if (!CollectionUtils.isEmpty(cateId)) { |
693 | - map = new HashMap<Integer, String>(); | 659 | + map = new HashMap<>(); |
694 | for (Integer categroy : cateId) { | 660 | for (Integer categroy : cateId) { |
695 | CategoryOut cateOut = categoryRestService.getCatrgoryInfo(categroy, false); | 661 | CategoryOut cateOut = categoryRestService.getCatrgoryInfo(categroy, false); |
696 | if (cateOut != null) { | 662 | if (cateOut != null) { |
@@ -746,6 +712,7 @@ public class ProductRestServiceImpl implements ProductRestService { | @@ -746,6 +712,7 @@ public class ProductRestServiceImpl implements ProductRestService { | ||
746 | //修改详情 | 712 | //修改详情 |
747 | if (StringUtils.isNotEmpty(input.getDesc())) { | 713 | if (StringUtils.isNotEmpty(input.getDesc())) { |
748 | // 将商品描述写入hbase | 714 | // 将商品描述写入hbase |
715 | + mongoTemplate.updateFirst(new Query(Criteria.where("id").is(input.getPid())), Update.update("content", input.getDesc()), "content"); | ||
749 | } | 716 | } |
750 | 717 | ||
751 | resultMap.put("isWaitProduct", isWaitProduct); | 718 | resultMap.put("isWaitProduct", isWaitProduct); |
titan-api/src/main/resources/mongodb/spring-mongo.xml
0 → 100755
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | + xmlns:mongo="http://www.springframework.org/schema/data/mongo" | ||
4 | + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd" | ||
5 | + default-lazy-init="true"> | ||
6 | + | ||
7 | + <description>RPC配置文件</description> | ||
8 | + | ||
9 | + <mongo:mongo host="${mongo.host}" port="${mongo.port}"> | ||
10 | + <mongo:options connections-per-host="8" | ||
11 | + threads-allowed-to-block-for-connection-multiplier="4" | ||
12 | + connect-timeout="1000" | ||
13 | + max-wait-time="1500" | ||
14 | + auto-connect-retry="true" | ||
15 | + socket-keep-alive="true" | ||
16 | + socket-timeout="1500" | ||
17 | + slave-ok="true" | ||
18 | + write-number="1" | ||
19 | + write-timeout="0" | ||
20 | + write-fsync="true"/> | ||
21 | + </mongo:mongo> | ||
22 | + | ||
23 | + <mongo:db-factory dbname="titan" mongo-ref="mongo" password="${mongo.pwd}" username="${mongo.username}"/> | ||
24 | + | ||
25 | + <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> | ||
26 | + <constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/> | ||
27 | + </bean> | ||
28 | +</beans> | ||
0 | \ No newline at end of file | 29 | \ No newline at end of file |
titan-api/src/main/resources/spring-config.xml
@@ -31,4 +31,5 @@ | @@ -31,4 +31,5 @@ | ||
31 | <import resource="classpath*:spring-config-rpc.xml" /> | 31 | <import resource="classpath*:spring-config-rpc.xml" /> |
32 | <import resource="classpath*:spring-config-redis.xml" /> | 32 | <import resource="classpath*:spring-config-redis.xml" /> |
33 | <import resource="classpath*:spring-redis-manager.xml" /> | 33 | <import resource="classpath*:spring-redis-manager.xml" /> |
34 | + <import resource="mongodb/spring-mongo.xml" /> | ||
34 | </beans> | 35 | </beans> |
35 | \ No newline at end of file | 36 | \ No newline at end of file |