Commit 9860d6c4e7cc17d44cd2fc11cd4efe50414c3f54

Authored by alexyang
1 parent 1bc16ae4

修改商品库接口

mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/product/ListCategoryReq.java 0 → 100644
  1 +package com.diligrp.mobsite.getway.domain.protocol.product;
  2 +
  3 +import com.diligrp.mobsite.getway.domain.protocol.BaseReq;
  4 +
  5 +/**
  6 + * Created by yanggang on 2017/1/17.
  7 + */
  8 +public class ListCategoryReq extends BaseReq {
  9 +
  10 + private int parentId;
  11 + private int shopId;
  12 +
  13 + public int getParentId() {
  14 + return parentId;
  15 + }
  16 +
  17 + public void setParentId(int parentId) {
  18 + this.parentId = parentId;
  19 + }
  20 +
  21 + public int getShopId() {
  22 + return shopId;
  23 + }
  24 +
  25 + public void setShopId(int shopId) {
  26 + this.shopId = shopId;
  27 + }
  28 +}
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/product/ListCategoryResp.java 0 → 100644
  1 +package com.diligrp.mobsite.getway.domain.protocol.product;
  2 +
  3 +import com.diligrp.mobsite.getway.domain.protocol.BaseResp;
  4 +import com.diligrp.mobsite.getway.domain.protocol.Category;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * Created by yanggang on 2017/1/17.
  10 + */
  11 +public class ListCategoryResp extends BaseResp {
  12 +
  13 + private List<Category> categories;
  14 +
  15 + public List<Category> getCategories() {
  16 + return categories;
  17 + }
  18 +
  19 + public void setCategories(List<Category> categories) {
  20 + this.categories = categories;
  21 + }
  22 +}
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/product/SearchProductReq.java 0 → 100644
  1 +package com.diligrp.mobsite.getway.domain.protocol.product;
  2 +
  3 +import com.diligrp.mobsite.getway.domain.protocol.BaseReq;
  4 +
  5 +/**
  6 + * Created by yanggang on 2017/1/17.
  7 + */
  8 +public class SearchProductReq extends BaseReq {
  9 +
  10 + private Integer page;
  11 + private Integer pageSize;
  12 + private Integer cateId;
  13 + private Integer status;
  14 + private String name;
  15 +
  16 + public Integer getPage() {
  17 + return page;
  18 + }
  19 +
  20 + public void setPage(Integer page) {
  21 + this.page = page;
  22 + }
  23 +
  24 + public Integer getPageSize() {
  25 + return pageSize;
  26 + }
  27 +
  28 + public void setPageSize(Integer pageSize) {
  29 + this.pageSize = pageSize;
  30 + }
  31 +
  32 + public Integer getCateId() {
  33 + return cateId;
  34 + }
  35 +
  36 + public void setCateId(Integer cateId) {
  37 + this.cateId = cateId;
  38 + }
  39 +
  40 + public Integer getStatus() {
  41 + return status;
  42 + }
  43 +
  44 + public void setStatus(Integer status) {
  45 + this.status = status;
  46 + }
  47 +
  48 + public String getName() {
  49 + return name;
  50 + }
  51 +
  52 + public void setName(String name) {
  53 + this.name = name;
  54 + }
  55 +}
mobsite-getway-domain/src/main/java/com/diligrp/mobsite/getway/domain/protocol/product/SearchProductResp.java 0 → 100644
  1 +package com.diligrp.mobsite.getway.domain.protocol.product;
  2 +
  3 +import com.diligrp.mobsite.getway.domain.protocol.BaseResp;
  4 +import com.diligrp.mobsite.getway.domain.protocol.Goods;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * Created by yanggang on 2017/1/17.
  10 + */
  11 +public class SearchProductResp extends BaseResp {
  12 +
  13 + private List<Goods> productList;
  14 +
  15 + public List<Goods> getProductList() {
  16 + return productList;
  17 + }
  18 +
  19 + public void setProductList(List<Goods> productList) {
  20 + this.productList = productList;
  21 + }
  22 +}
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/GoodsRPC.java
@@ -15,8 +15,6 @@ import com.diligrp.titan.sdk.domain.Category; @@ -15,8 +15,6 @@ import com.diligrp.titan.sdk.domain.Category;
15 import com.diligrp.titan.sdk.domain.Product; 15 import com.diligrp.titan.sdk.domain.Product;
16 import com.diligrp.titan.sdk.input.CategoryInput; 16 import com.diligrp.titan.sdk.input.CategoryInput;
17 import com.diligrp.titan.sdk.input.PopProductView; 17 import com.diligrp.titan.sdk.input.PopProductView;
18 -import com.diligrp.titan.sdk.input.ProductSearchInput;  
19 -import com.diligrp.titan.sdk.output.PageOutput;  
20 18
21 import java.util.HashMap; 19 import java.util.HashMap;
22 import java.util.List; 20 import java.util.List;
@@ -43,7 +41,7 @@ public interface GoodsRPC { @@ -43,7 +41,7 @@ public interface GoodsRPC {
43 * @Title: getGoodsById 41 * @Title: getGoodsById
44 * @Description: 根据id获取商品详情 42 * @Description: 根据id获取商品详情
45 */ 43 */
46 - public Product getGoodsById(Long id, String[] defindResult); 44 + Product getGoodsById(Long id, String[] defindResult);
47 45
48 /** 46 /**
49 * @param categoryId 47 * @param categoryId
@@ -53,7 +51,7 @@ public interface GoodsRPC { @@ -53,7 +51,7 @@ public interface GoodsRPC {
53 * @createTime 2014年8月19日 下午2:55:50 51 * @createTime 2014年8月19日 下午2:55:50
54 * @author zhangshirui 52 * @author zhangshirui
55 */ 53 */
56 - public HashMap<String, List<Attribute>> getConditionByCid(Integer categoryId); 54 + HashMap<String, List<Attribute>> getConditionByCid(Integer categoryId);
57 55
58 /** 56 /**
59 * 更具商品id获取商品 57 * 更具商品id获取商品
@@ -127,4 +125,8 @@ public interface GoodsRPC { @@ -127,4 +125,8 @@ public interface GoodsRPC {
127 Object addGoods(PopProductView req, Long userId); 125 Object addGoods(PopProductView req, Long userId);
128 126
129 PageOutput<List<Product>> getProductRecommend(ProductSearchInput input , Long userId); 127 PageOutput<List<Product>> getProductRecommend(ProductSearchInput input , Long userId);
  128 +
  129 + List<Category> listCategory(int parentId,int shopId);
  130 +
  131 + List<Product> searchProduct(ProductSearchInput input);
130 } 132 }
mobsite-getway-rpc/src/main/java/com/diligrp/mobsite/getway/rpc/impl/GoodsRPCImpl.java
1 -/**  
2 - * @Title: GoodsRPCImpl.java 1 +/**
  2 + * @Title: GoodsRPCImpl.java
3 * @Package:com.diligrp.mobsite.getway.rpc.impl 3 * @Package:com.diligrp.mobsite.getway.rpc.impl
4 - * @Copyright:地利集团  
5 - * @Description:  
6 - * @author:zhangshirui  
7 - * @date: 2014年8月14日 上午11:21:21  
8 - * @version: V1.0  
9 - */ 4 + * @Copyright:地利集团
  5 + * @Description:
  6 + * @author:zhangshirui
  7 + * @date: 2014年8月14日 上午11:21:21
  8 + * @version: V1.0
  9 + */
10 package com.diligrp.mobsite.getway.rpc.impl; 10 package com.diligrp.mobsite.getway.rpc.impl;
11 11
12 import com.diligrp.mobsite.getway.domain.common.ErrorMessage; 12 import com.diligrp.mobsite.getway.domain.common.ErrorMessage;
@@ -36,53 +36,53 @@ import java.util.HashMap; @@ -36,53 +36,53 @@ import java.util.HashMap;
36 import java.util.List; 36 import java.util.List;
37 import java.util.Map; 37 import java.util.Map;
38 38
39 -/**  
40 - * @ClassName: GoodsRPCImpl 39 +/**
  40 + * @author zhangshirui
  41 + * @ClassName: GoodsRPCImpl
41 * @Description: 商品信息接口 42 * @Description: 商品信息接口
42 - * @author zhangshirui  
43 - * @date 2014年8月14日 上午11:21:21 43 + * @date 2014年8月14日 上午11:21:21
44 */ 44 */
45 @Service("goodsRPC") 45 @Service("goodsRPC")
46 public class GoodsRPCImpl implements GoodsRPC { 46 public class GoodsRPCImpl implements GoodsRPC {
47 47
48 - @Resource  
49 - private TitanClient titanClient;  
50 - @Resource  
51 - private RedisUtil redisUtil;  
52 -  
53 - private static final Logger logger = LoggerFactory.getLogger(GoodsRPCImpl.class);  
54 -  
55 - @Override  
56 - public Product getGoodsById(Long id, String[] defindResult) {  
57 -  
58 - List<Long> idList = new ArrayList<Long>();  
59 - idList.add(id); 48 + @Resource
  49 + private TitanClient titanClient;
  50 + @Resource
  51 + private RedisUtil redisUtil;
  52 +
  53 + private static final Logger logger = LoggerFactory.getLogger(GoodsRPCImpl.class);
  54 +
  55 + @Override
  56 + public Product getGoodsById(Long id, String[] defindResult) {
  57 +
  58 + List<Long> idList = new ArrayList<Long>();
  59 + idList.add(id);
60 List<Product> productList = getProductByIds(idList, defindResult); 60 List<Product> productList = getProductByIds(idList, defindResult);
61 Product product = null; 61 Product product = null;
62 - if(!Validator.isEmpty(productList)){  
63 - product = productList.get(0);  
64 - }  
65 - return product;  
66 - }  
67 -  
68 - @Override  
69 - public HashMap<String,List<Attribute>> getConditionByCid(Integer categoryId) {  
70 - BaseOutput<HashMap<String, List<Attribute>>> attributeBo = null;  
71 - try {  
72 - attributeBo = titanClient.getCategoryService().listAttributes(categoryId); 62 + if (!Validator.isEmpty(productList)) {
  63 + product = productList.get(0);
  64 + }
  65 + return product;
  66 + }
  67 +
  68 + @Override
  69 + public HashMap<String, List<Attribute>> getConditionByCid(Integer categoryId) {
  70 + BaseOutput<HashMap<String, List<Attribute>>> attributeBo = null;
  71 + try {
  72 + attributeBo = titanClient.getCategoryService().listAttributes(categoryId);
73 } catch (Exception e) { 73 } catch (Exception e) {
74 - logger.error("titanClient接口挂掉:根据分类id查询商品筛选条件",e); 74 + logger.error("titanClient接口挂掉:根据分类id查询商品筛选条件", e);
75 throw new ServiceException(); 75 throw new ServiceException();
76 } 76 }
77 - if(attributeBo.getCode() != ResultCode.SUCCESS){  
78 - logger.error(String.format("商品筛选条件失败.[categoryId=%s,code=%s, message=%s]",  
79 - categoryId, attributeBo.getCode(), attributeBo.getResult()));  
80 - throw new ServiceException();  
81 - }  
82 - if(logger.isInfoEnabled()){ 77 + if (attributeBo.getCode() != ResultCode.SUCCESS) {
  78 + logger.error(String.format("商品筛选条件失败.[categoryId=%s,code=%s, message=%s]",
  79 + categoryId, attributeBo.getCode(), attributeBo.getResult()));
  80 + throw new ServiceException();
  81 + }
  82 + if (logger.isInfoEnabled()) {
83 logger.info(String.format("商品筛选条件.[size=%s]", attributeBo.getData().size())); 83 logger.info(String.format("商品筛选条件.[size=%s]", attributeBo.getData().size()));
84 } 84 }
85 - return attributeBo.getData(); 85 + return attributeBo.getData();
86 } 86 }
87 87
88 88
@@ -90,91 +90,90 @@ public class GoodsRPCImpl implements GoodsRPC { @@ -90,91 +90,90 @@ public class GoodsRPCImpl implements GoodsRPC {
90 public List<Product> getProductByIds(List<Long> productId, String[] defindResult) { 90 public List<Product> getProductByIds(List<Long> productId, String[] defindResult) {
91 BaseOutput<List<Product>> output = null; 91 BaseOutput<List<Product>> output = null;
92 try { 92 try {
93 - // output = titanClient.getProductService().getProductInfo(productId, defindResult); 93 + // output = titanClient.getProductService().getProductInfo(productId, defindResult);
94 } catch (Exception e) { 94 } catch (Exception e) {
95 - logger.error("titanClient接口挂掉:搜索商品详情",e); 95 + logger.error("titanClient接口挂掉:搜索商品详情", e);
96 throw new RuntimeException(ErrorMessage.NETWORK_ERROR); 96 throw new RuntimeException(ErrorMessage.NETWORK_ERROR);
97 } 97 }
98 - if(output.getCode() != ResultCode.SUCCESS){  
99 - logger.error(String.format("搜索商品详情失败.[productId=%s,code=%s, message=%s]",  
100 - productId.toString(),output.getCode(), output.getResult())); 98 + if (output.getCode() != ResultCode.SUCCESS) {
  99 + logger.error(String.format("搜索商品详情失败.[productId=%s,code=%s, message=%s]",
  100 + productId.toString(), output.getCode(), output.getResult()));
101 throw new ServiceException(ErrorMessage.PRODUCT_STATE_DOWNORDEL); 101 throw new ServiceException(ErrorMessage.PRODUCT_STATE_DOWNORDEL);
102 } 102 }
103 return output.getData(); 103 return output.getData();
104 } 104 }
105 - 105 +
106 @Override 106 @Override
107 - public List<GoodsSuper> getGoodsInfoByIds(List<Long> productIds){  
108 - List<Product> products = getProductByIds(productIds, new String[]{});  
109 - if (Validator.isEmpty(products)) {  
110 - return null;  
111 - }  
112 -  
113 - List<GoodsSuper> goodsInfos = new ArrayList<GoodsSuper>();  
114 - GoodsSuper goodsInfo = null;  
115 - for (Product product : products) {  
116 - //goodsInfo = new GoodsSuper();  
117 - //goodsInfo.setId(product.getPid());  
118 - //goodsInfo.setTitle(product.getName());  
119 - //goodsInfo.setDefaultPic(product.getDefaultPic());  
120 - //goodsInfo.setPrice((long)product.getMinPrice());  
121 - //goodsInfo.setUnit(product.getSaleUnit());  
122 - //goodsInfos.add(goodsInfo);  
123 - }  
124 -  
125 - return goodsInfos; 107 + public List<GoodsSuper> getGoodsInfoByIds(List<Long> productIds) {
  108 + List<Product> products = getProductByIds(productIds, new String[]{});
  109 + if (Validator.isEmpty(products)) {
  110 + return null;
  111 + }
  112 +
  113 + List<GoodsSuper> goodsInfos = new ArrayList<GoodsSuper>();
  114 + GoodsSuper goodsInfo = null;
  115 + for (Product product : products) {
  116 + //goodsInfo = new GoodsSuper();
  117 + //goodsInfo.setId(product.getPid());
  118 + //goodsInfo.setTitle(product.getName());
  119 + //goodsInfo.setDefaultPic(product.getDefaultPic());
  120 + //goodsInfo.setPrice((long)product.getMinPrice());
  121 + //goodsInfo.setUnit(product.getSaleUnit());
  122 + //goodsInfos.add(goodsInfo);
  123 + }
  124 +
  125 + return goodsInfos;
126 } 126 }
127 127
128 128
129 -  
130 @Override 129 @Override
131 - public Map<String, Product> getSkuInfoMap(List<String> skuList){  
132 - BaseOutput<Map<String,Product>> output = null; 130 + public Map<String, Product> getSkuInfoMap(List<String> skuList) {
  131 + BaseOutput<Map<String, Product>> output = null;
133 try { 132 try {
134 output = titanClient.getProductService().getSkuInfoMap(skuList); 133 output = titanClient.getProductService().getSkuInfoMap(skuList);
135 } catch (Exception e) { 134 } catch (Exception e) {
136 throw new RuntimeException(String.format("sku接口失败:获取商品sku信息失败.[code=%s, result=%s]", 135 throw new RuntimeException(String.format("sku接口失败:获取商品sku信息失败.[code=%s, result=%s]",
137 - output.getCode(),output.getResult())); 136 + output.getCode(), output.getResult()));
138 } 137 }
139 - if(output.getCode() != ResultCode.SUCCESS){  
140 - throw new ServiceException(ResultCode.BUSINESS_FAILED,output.getResult()); 138 + if (output.getCode() != ResultCode.SUCCESS) {
  139 + throw new ServiceException(ResultCode.BUSINESS_FAILED, output.getResult());
141 } 140 }
142 if (logger.isInfoEnabled()) { 141 if (logger.isInfoEnabled()) {
143 logger.info(String.format("查询sku信息成功:[skus=%s]", skuList.toString())); 142 logger.info(String.format("查询sku信息成功:[skus=%s]", skuList.toString()));
144 } 143 }
145 return output.getData(); 144 return output.getData();
146 } 145 }
147 - 146 +
148 @Override 147 @Override
149 - public String getProductDesc(Long productId){  
150 - BaseOutput<String> output = null; 148 + public String getProductDesc(Long productId) {
  149 + BaseOutput<String> output = null;
151 try { 150 try {
152 - // output = titanClient.getProductService().getProductDesc(productId); 151 + // output = titanClient.getProductService().getProductDesc(productId);
153 } catch (Exception e) { 152 } catch (Exception e) {
154 - logger.error("商品库接口超时",e); 153 + logger.error("商品库接口超时", e);
155 } 154 }
156 - if(output.getCode() != ResultCode.SUCCESS){  
157 - logger.error("查询商品描述信息失败[productId={},result={}]",productId,output.getResult()); 155 + if (output.getCode() != ResultCode.SUCCESS) {
  156 + logger.error("查询商品描述信息失败[productId={},result={}]", productId, output.getResult());
158 } 157 }
159 logger.info("查询商品描述信息:[productId={}]", productId); 158 logger.info("查询商品描述信息:[productId={}]", productId);
160 return output.getData(); 159 return output.getData();
161 } 160 }
162 - 161 +
163 @Override 162 @Override
164 - public Category getCategoryById(Long cid){  
165 - String redisKey = redisUtil.makeKey(RedisKey.PRODUCT_CATEGORY, String.valueOf(cid));  
166 - Category category = redisUtil.getObject(redisKey, Category.class);  
167 - if (!Validator.isNull(category)) {  
168 - return category;  
169 - } 163 + public Category getCategoryById(Long cid) {
  164 + String redisKey = redisUtil.makeKey(RedisKey.PRODUCT_CATEGORY, String.valueOf(cid));
  165 + Category category = redisUtil.getObject(redisKey, Category.class);
  166 + if (!Validator.isNull(category)) {
  167 + return category;
  168 + }
170 try { 169 try {
171 - BaseOutput<Category> output = titanClient.getCategoryService().getCategoryInfo(cid.intValue());  
172 - if(output.getCode() != ResultCode.SUCCESS){  
173 - logger.error("查询分类信息失败[cid={},result={}]",cid,output.getResult());  
174 - }  
175 - category = output.getData(); 170 + BaseOutput<Category> output = titanClient.getCategoryService().getCategoryInfo(cid.intValue());
  171 + if (output.getCode() != ResultCode.SUCCESS) {
  172 + logger.error("查询分类信息失败[cid={},result={}]", cid, output.getResult());
  173 + }
  174 + category = output.getData();
176 } catch (Exception e) { 175 } catch (Exception e) {
177 - logger.error("商品库接口超时",e); 176 + logger.error("商品库接口超时", e);
178 } 177 }
179 logger.info("查询分类信息:[cid={}]", cid); 178 logger.info("查询分类信息:[cid={}]", cid);
180 redisUtil.setObjectByExpire(redisKey, category, RedisKey.PRODUCT_EXPIRE_TIME); 179 redisUtil.setObjectByExpire(redisKey, category, RedisKey.PRODUCT_EXPIRE_TIME);
@@ -186,32 +185,32 @@ public class GoodsRPCImpl implements GoodsRPC { @@ -186,32 +185,32 @@ public class GoodsRPCImpl implements GoodsRPC {
186 List<Category> categories = null; 185 List<Category> categories = null;
187 BaseOutput<List<Category>> output = null; 186 BaseOutput<List<Category>> output = null;
188 try { 187 try {
189 - // BaseOutput<List<Category>> output = titanClient.getCategoryService().listCrumbs(cid.intValue());  
190 - if(output.getCode() != ResultCode.SUCCESS){  
191 - logger.error("查询类目面包屑失败[cid={},result={}]",cid,output.getResult()); 188 + // BaseOutput<List<Category>> output = titanClient.getCategoryService().listCrumbs(cid.intValue());
  189 + if (output.getCode() != ResultCode.SUCCESS) {
  190 + logger.error("查询类目面包屑失败[cid={},result={}]", cid, output.getResult());
192 } 191 }
193 categories = output.getData(); 192 categories = output.getData();
194 } catch (Exception e) { 193 } catch (Exception e) {
195 - logger.error("商品库接口超时",e); 194 + logger.error("商品库接口超时", e);
196 } 195 }
197 logger.info("查询类目面包屑:[cid={}]", cid); 196 logger.info("查询类目面包屑:[cid={}]", cid);
198 return categories; 197 return categories;
199 } 198 }
200 199
201 @Override 200 @Override
202 - public Object addProductCategory(CategoryInput input,Long userId) { 201 + public Object addProductCategory(CategoryInput input, Long userId) {
203 BaseOutput<Object> output = null; 202 BaseOutput<Object> output = null;
204 try { 203 try {
205 output = titanClient.getCategoryService().insertCategory(input); 204 output = titanClient.getCategoryService().insertCategory(input);
206 } catch (Exception e) { 205 } catch (Exception e) {
207 - logger.error("调用添加分类接口失败:[userId={},code={},result={}]",new Object[]{userId,output.getCode(),output.getResult()}); 206 + logger.error("调用添加分类接口失败:[userId={},code={},result={}]", new Object[]{userId, output.getCode(), output.getResult()});
208 throw new ServiceException(); 207 throw new ServiceException();
209 208
210 } 209 }
211 - if (output.getCode()!=200) { 210 + if (output.getCode() != 200) {
212 logger.error("调用添加分类接口失败[userId={},code={},result={}]", 211 logger.error("调用添加分类接口失败[userId={},code={},result={}]",
213 - new Object[]{ userId,output.getCode(),output.getResult()});  
214 - throw new ServiceException(ResultCode.BUSINESS_FAILED,output.getResult()); 212 + new Object[]{userId, output.getCode(), output.getResult()});
  213 + throw new ServiceException(ResultCode.BUSINESS_FAILED, output.getResult());
215 } 214 }
216 return output.getData(); 215 return output.getData();
217 } 216 }
@@ -222,32 +221,32 @@ public class GoodsRPCImpl implements GoodsRPC { @@ -222,32 +221,32 @@ public class GoodsRPCImpl implements GoodsRPC {
222 try { 221 try {
223 output = titanClient.getCategoryService().updateCategory(input); 222 output = titanClient.getCategoryService().updateCategory(input);
224 } catch (Exception e) { 223 } catch (Exception e) {
225 - logger.error("调用修改分类接口失败:[userId={},code={},result={}]",new Object[]{userId,output.getCode(),output.getResult()}); 224 + logger.error("调用修改分类接口失败:[userId={},code={},result={}]", new Object[]{userId, output.getCode(), output.getResult()});
226 throw new ServiceException(); 225 throw new ServiceException();
227 226
228 } 227 }
229 - if (output.getCode()!=200) { 228 + if (output.getCode() != 200) {
230 logger.error("调用修改分类接口失败[userId={},code={},result={}]", 229 logger.error("调用修改分类接口失败[userId={},code={},result={}]",
231 - new Object[]{ userId,output.getCode(),output.getResult()});  
232 - throw new ServiceException(ResultCode.BUSINESS_FAILED,output.getResult()); 230 + new Object[]{userId, output.getCode(), output.getResult()});
  231 + throw new ServiceException(ResultCode.BUSINESS_FAILED, output.getResult());
233 } 232 }
234 return output.getData(); 233 return output.getData();
235 } 234 }
236 235
237 @Override 236 @Override
238 public List<Category> searchProductCategory(String input, Long userId) { 237 public List<Category> searchProductCategory(String input, Long userId) {
239 - BaseOutput<List<Category>> output = null; 238 + BaseOutput<List<Category>> output = null;
240 try { 239 try {
241 output = titanClient.getCategoryService().searchCategoryInfo(input); 240 output = titanClient.getCategoryService().searchCategoryInfo(input);
242 } catch (Exception e) { 241 } catch (Exception e) {
243 - logger.error("搜索分类接口失败:[userId={},code={},result={}]",new Object[]{userId,output.getCode(),output.getResult()}); 242 + logger.error("搜索分类接口失败:[userId={},code={},result={}]", new Object[]{userId, output.getCode(), output.getResult()});
244 throw new ServiceException(); 243 throw new ServiceException();
245 244
246 } 245 }
247 - if (output.getCode()!=200) { 246 + if (output.getCode() != 200) {
248 logger.error("搜索分类接口失败[userId={},code={},result={}]", 247 logger.error("搜索分类接口失败[userId={},code={},result={}]",
249 - new Object[]{ userId,output.getCode(),output.getResult()});  
250 - throw new ServiceException(ResultCode.BUSINESS_FAILED,output.getResult()); 248 + new Object[]{userId, output.getCode(), output.getResult()});
  249 + throw new ServiceException(ResultCode.BUSINESS_FAILED, output.getResult());
251 } 250 }
252 return output.getData(); 251 return output.getData();
253 } 252 }
@@ -256,16 +255,16 @@ public class GoodsRPCImpl implements GoodsRPC { @@ -256,16 +255,16 @@ public class GoodsRPCImpl implements GoodsRPC {
256 public Object addGoods(PopProductView input, Long userId) { 255 public Object addGoods(PopProductView input, Long userId) {
257 BaseOutput<Object> output = null; 256 BaseOutput<Object> output = null;
258 try { 257 try {
259 - output = titanClient.getProductService().insertPopProduct(input,userId+""); 258 + output = titanClient.getProductService().insertPopProduct(input, userId + "");
260 } catch (Exception e) { 259 } catch (Exception e) {
261 - logger.error("添加商品失败:[userId={},code={},result={}]",new Object[]{userId,output.getCode(),output.getResult()}); 260 + logger.error("添加商品失败:[userId={},code={},result={}]", new Object[]{userId, output.getCode(), output.getResult()});
262 throw new ServiceException(); 261 throw new ServiceException();
263 262
264 } 263 }
265 - if (output.getCode()!=200) { 264 + if (output.getCode() != 200) {
266 logger.error("添加商品失败[userId={},code={},result={}]", 265 logger.error("添加商品失败[userId={},code={},result={}]",
267 - new Object[]{ userId,output.getCode(),output.getResult()});  
268 - throw new ServiceException(ResultCode.BUSINESS_FAILED,output.getResult()); 266 + new Object[]{userId, output.getCode(), output.getResult()});
  267 + throw new ServiceException(ResultCode.BUSINESS_FAILED, output.getResult());
269 } 268 }
270 return output.getData(); 269 return output.getData();
271 } 270 }
@@ -285,4 +284,33 @@ public class GoodsRPCImpl implements GoodsRPC { @@ -285,4 +284,33 @@ public class GoodsRPCImpl implements GoodsRPC {
285 } 284 }
286 return output; 285 return output;
287 } 286 }
  287 + @Override
  288 + public List<Category> listCategory(int parentId, int shopId) {
  289 + try {
  290 + BaseOutput<List<Category>> output = titanClient.getCategoryService().listChildren(parentId, shopId);
  291 + if (output.getCode() != 200) {
  292 + throw new ServiceException(ResultCode.BUSINESS_FAILED, output.getResult());
  293 + }
  294 + return output.getData();
  295 + } catch (Exception e) {
  296 + logger.error("获取商品分类失败:[parentId={},shopId={}]", new Object[]{parentId, shopId});
  297 + throw new ServiceException();
  298 + }
  299 + }
  300 +
  301 + @Override
  302 + public List<Product> searchProduct(ProductSearchInput input) {
  303 + try {
  304 + PageOutput<List<Product>> output = titanClient.getProductService().searchListPopProducts(input);
  305 + if (output.getCode() != 200) {
  306 + throw new ServiceException(ResultCode.BUSINESS_FAILED, output.getResult());
  307 + }
  308 + return output.getData();
  309 + } catch (Exception e) {
  310 + logger.error("搜搜商品失败", e);
  311 + throw new ServiceException();
  312 + }
  313 + }
  314 +
  315 +
288 } 316 }
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/seller/SellerGoodsService.java
@@ -29,7 +29,7 @@ public interface SellerGoodsService { @@ -29,7 +29,7 @@ public interface SellerGoodsService {
29 * @return 29 * @return
30 * @createTime 2014年8月18日 下午4:11:27 30 * @createTime 2014年8月18日 下午4:11:27
31 */ 31 */
32 - public GetProductsResp searchProductsByStatus(GetProductsReq req); 32 + GetProductsResp searchProductsByStatus(GetProductsReq req);
33 33
34 /** 34 /**
35 *根据商品id查询商品详情 35 *根据商品id查询商品详情
@@ -37,7 +37,7 @@ public interface SellerGoodsService { @@ -37,7 +37,7 @@ public interface SellerGoodsService {
37 * @return 37 * @return
38 * @createTime 2014年8月18日 下午4:11:27 38 * @createTime 2014年8月18日 下午4:11:27
39 */ 39 */
40 - public GetSellerProductDetailResp getSellerProductDetail(GetProductDetailReq req); 40 + GetSellerProductDetailResp getSellerProductDetail(GetProductDetailReq req);
41 41
42 /** 42 /**
43 *更新商品区间价格 43 *更新商品区间价格
@@ -45,7 +45,7 @@ public interface SellerGoodsService { @@ -45,7 +45,7 @@ public interface SellerGoodsService {
45 * @return 45 * @return
46 * @createTime 2014年8月18日 下午4:11:27 46 * @createTime 2014年8月18日 下午4:11:27
47 */ 47 */
48 - public SellerProductCommonResp updateSellerProductRangePrice(UpdateRangePriceReq rangePriceReq); 48 + SellerProductCommonResp updateSellerProductRangePrice(UpdateRangePriceReq rangePriceReq);
49 49
50 /** 50 /**
51 *更新商品sku价格 51 *更新商品sku价格
@@ -53,7 +53,7 @@ public interface SellerGoodsService { @@ -53,7 +53,7 @@ public interface SellerGoodsService {
53 * @return 53 * @return
54 * @createTime 2014年8月18日 下午4:11:27 54 * @createTime 2014年8月18日 下午4:11:27
55 */ 55 */
56 - public SellerProductCommonResp updateSellerProductSkuPrice(UpdateSkuPriceReq skuPriceReq); 56 + SellerProductCommonResp updateSellerProductSkuPrice(UpdateSkuPriceReq skuPriceReq);
57 57
58 /** 58 /**
59 *更新商品库存 59 *更新商品库存
@@ -61,7 +61,7 @@ public interface SellerGoodsService { @@ -61,7 +61,7 @@ public interface SellerGoodsService {
61 * @return 61 * @return
62 * @createTime 2014年8月18日 下午4:11:27 62 * @createTime 2014年8月18日 下午4:11:27
63 */ 63 */
64 - public SellerProductCommonResp updateSellerProductStock(UpdateSellerProductStockReq stockReq); 64 + SellerProductCommonResp updateSellerProductStock(UpdateSellerProductStockReq stockReq);
65 65
66 /** 66 /**
67 *批量更新商品状态 67 *批量更新商品状态
@@ -69,7 +69,7 @@ public interface SellerGoodsService { @@ -69,7 +69,7 @@ public interface SellerGoodsService {
69 * @return 69 * @return
70 * @createTime 2014年8月18日 下午4:11:27 70 * @createTime 2014年8月18日 下午4:11:27
71 */ 71 */
72 - public SellerProductCommonResp batchUpdateSellerProductStatus(BatchUpdateProductStatusReq batchReq); 72 + SellerProductCommonResp batchUpdateSellerProductStatus(BatchUpdateProductStatusReq batchReq);
73 73
74 /** 74 /**
75 *批量删除商品 75 *批量删除商品
@@ -77,7 +77,7 @@ public interface SellerGoodsService { @@ -77,7 +77,7 @@ public interface SellerGoodsService {
77 * @return 77 * @return
78 * @createTime 2014年8月18日 下午4:11:27 78 * @createTime 2014年8月18日 下午4:11:27
79 */ 79 */
80 - public SellerProductCommonResp batchDeleteProduct(List<Long> pids, Long sellerId); 80 + SellerProductCommonResp batchDeleteProduct(List<Long> pids, Long sellerId);
81 81
82 /** 82 /**
83 *卖家发布商品 83 *卖家发布商品
@@ -85,7 +85,7 @@ public interface SellerGoodsService { @@ -85,7 +85,7 @@ public interface SellerGoodsService {
85 * @return 85 * @return
86 * @createTime 2014年8月18日 下午4:11:27 86 * @createTime 2014年8月18日 下午4:11:27
87 */ 87 */
88 - public SellerProductCommonResp insertPopProduct(SellerPublishProductReq req); 88 + SellerProductCommonResp insertPopProduct(SellerPublishProductReq req);
89 89
90 90
91 /** 91 /**
@@ -94,7 +94,7 @@ public interface SellerGoodsService { @@ -94,7 +94,7 @@ public interface SellerGoodsService {
94 * @return 94 * @return
95 * @createTime 2014年8月18日 下午4:11:27 95 * @createTime 2014年8月18日 下午4:11:27
96 */ 96 */
97 - public SellerProductCommonResp updatePopProduct(SellerUpdateProductReq req); 97 + SellerProductCommonResp updatePopProduct(SellerUpdateProductReq req);
98 98
99 /** 99 /**
100 *根据分类id获取商品属性 100 *根据分类id获取商品属性
@@ -102,7 +102,7 @@ public interface SellerGoodsService { @@ -102,7 +102,7 @@ public interface SellerGoodsService {
102 * @return 102 * @return
103 * @createTime 2014年8月18日 下午4:11:27 103 * @createTime 2014年8月18日 下午4:11:27
104 */ 104 */
105 - public GetProductAttrResp listAttributes(Integer cid); 105 + GetProductAttrResp listAttributes(Integer cid);
106 106
107 /** 107 /**
108 *设置商品描述信息 108 *设置商品描述信息
@@ -124,7 +124,7 @@ public interface SellerGoodsService { @@ -124,7 +124,7 @@ public interface SellerGoodsService {
124 * @return 124 * @return
125 * @createTime 2014年8月18日 下午4:11:27 125 * @createTime 2014年8月18日 下午4:11:27
126 */ 126 */
127 - public GetProductAttrResp getProductAttrHasSelected(Integer cid, Long pid); 127 + GetProductAttrResp getProductAttrHasSelected(Integer cid, Long pid);
128 128
129 AddProductCategoryResp addProductCategory(AddProductCategoryReq req); 129 AddProductCategoryResp addProductCategory(AddProductCategoryReq req);
130 130
@@ -139,4 +139,10 @@ public interface SellerGoodsService { @@ -139,4 +139,10 @@ public interface SellerGoodsService {
139 GetGoodsResp getGoods(GetGoodsReq req); 139 GetGoodsResp getGoods(GetGoodsReq req);
140 140
141 HandleGoodsResp handleGoods(HandleGoodsReq req); 141 HandleGoodsResp handleGoods(HandleGoodsReq req);
  142 +
  143 + ListCategoryResp listCategory(ListCategoryReq req);
  144 +
  145 + SearchProductResp searchProduct(SearchProductReq req);
  146 +
  147 +
142 } 148 }
mobsite-getway-service/src/main/java/com/diligrp/mobsite/getway/service/seller/impl/SellerGoodsServiceImpl.java
1 package com.diligrp.mobsite.getway.service.seller.impl; 1 package com.diligrp.mobsite.getway.service.seller.impl;
2 2
  3 +import com.alibaba.fastjson.JSONArray;
3 import com.diligrp.mobsite.getway.domain.protocol.Attribute; 4 import com.diligrp.mobsite.getway.domain.protocol.Attribute;
  5 +import com.diligrp.mobsite.getway.domain.protocol.Goods;
4 import com.diligrp.mobsite.getway.domain.protocol.GoodsSuper; 6 import com.diligrp.mobsite.getway.domain.protocol.GoodsSuper;
5 import com.diligrp.mobsite.getway.domain.protocol.SKUInfo; 7 import com.diligrp.mobsite.getway.domain.protocol.SKUInfo;
6 import com.diligrp.mobsite.getway.domain.protocol.product.*; 8 import com.diligrp.mobsite.getway.domain.protocol.product.*;
@@ -11,9 +13,11 @@ import com.diligrp.mobsite.getway.rpc.GoodsRPC; @@ -11,9 +13,11 @@ import com.diligrp.mobsite.getway.rpc.GoodsRPC;
11 import com.diligrp.mobsite.getway.rpc.UserRPC; 13 import com.diligrp.mobsite.getway.rpc.UserRPC;
12 import com.diligrp.mobsite.getway.service.seller.SellerGoodsService; 14 import com.diligrp.mobsite.getway.service.seller.SellerGoodsService;
13 import com.diligrp.titan.sdk.domain.Category; 15 import com.diligrp.titan.sdk.domain.Category;
  16 +import com.diligrp.titan.sdk.domain.Product;
14 import com.diligrp.titan.sdk.domain.Sku; 17 import com.diligrp.titan.sdk.domain.Sku;
15 import com.diligrp.titan.sdk.input.CategoryInput; 18 import com.diligrp.titan.sdk.input.CategoryInput;
16 import com.diligrp.titan.sdk.input.PopProductView; 19 import com.diligrp.titan.sdk.input.PopProductView;
  20 +import com.diligrp.titan.sdk.input.ProductSearchInput;
17 import com.diligrp.website.util.security.Validator; 21 import com.diligrp.website.util.security.Validator;
18 import com.yqyw.filter.client.KeyWordsClient; 22 import com.yqyw.filter.client.KeyWordsClient;
19 import org.apache.log4j.Logger; 23 import org.apache.log4j.Logger;
@@ -25,10 +29,9 @@ import java.util.ArrayList; @@ -25,10 +29,9 @@ import java.util.ArrayList;
25 import java.util.List; 29 import java.util.List;
26 30
27 /** 31 /**
28 - *  
29 - * @ClassName: GoodsServiceImpl  
30 - * @Description: 商品服务层  
31 * @author duanyugen 32 * @author duanyugen
  33 + * @ClassName: GoodsServiceImpl
  34 + * @Description: 商品服务层
32 * @date 2014年8月14日 上午10:34:22 35 * @date 2014年8月14日 上午10:34:22
33 */ 36 */
34 @Service("sellerGoodsService") 37 @Service("sellerGoodsService")
@@ -42,10 +45,10 @@ public class SellerGoodsServiceImpl implements SellerGoodsService { @@ -42,10 +45,10 @@ public class SellerGoodsServiceImpl implements SellerGoodsService {
42 @Resource 45 @Resource
43 private GoodsRPC goodsRPC; 46 private GoodsRPC goodsRPC;
44 47
45 - @Resource  
46 - private KeyWordsClient keyWordsClient; 48 + @Resource
  49 + private KeyWordsClient keyWordsClient;
47 50
48 - private static Logger log = Logger.getLogger(SellerGoodsServiceImpl.class); 51 + private static Logger log = Logger.getLogger(SellerGoodsServiceImpl.class);
49 52
50 53
51 @Override 54 @Override
@@ -120,7 +123,7 @@ public class SellerGoodsServiceImpl implements SellerGoodsService { @@ -120,7 +123,7 @@ public class SellerGoodsServiceImpl implements SellerGoodsService {
120 input.setName(req.getCategory().getName()); 123 input.setName(req.getCategory().getName());
121 input.setShopId(req.getShopId()); 124 input.setShopId(req.getShopId());
122 input.setParent(req.getCategory().getParentId().intValue()); 125 input.setParent(req.getCategory().getParentId().intValue());
123 - goodsRPC.addProductCategory(input,req.getUserId()); 126 + goodsRPC.addProductCategory(input, req.getUserId());
124 return resp; 127 return resp;
125 } 128 }
126 129
@@ -132,28 +135,28 @@ public class SellerGoodsServiceImpl implements SellerGoodsService { @@ -132,28 +135,28 @@ public class SellerGoodsServiceImpl implements SellerGoodsService {
132 input.setName(req.getCategory().getName()); 135 input.setName(req.getCategory().getName());
133 input.setShopId(req.getShopId()); 136 input.setShopId(req.getShopId());
134 input.setParent(req.getCategory().getParentId().intValue()); 137 input.setParent(req.getCategory().getParentId().intValue());
135 - goodsRPC.updateProductCategory(input,req.getUserId()); 138 + goodsRPC.updateProductCategory(input, req.getUserId());
136 return resp; 139 return resp;
137 } 140 }
138 141
139 @Override 142 @Override
140 public SearchProductCategoryResp searchProductCategory(SearchProductCategoryReq req) { 143 public SearchProductCategoryResp searchProductCategory(SearchProductCategoryReq req) {
141 SearchProductCategoryResp resp = new SearchProductCategoryResp(); 144 SearchProductCategoryResp resp = new SearchProductCategoryResp();
142 - List<Category> categories = goodsRPC.searchProductCategory(req.getKeyword(),req.getUserId()); 145 + List<Category> categories = goodsRPC.searchProductCategory(req.getKeyword(), req.getUserId());
143 resp.setCategories(buildCategories(categories)); 146 resp.setCategories(buildCategories(categories));
144 return resp; 147 return resp;
145 } 148 }
146 149
147 private List<com.diligrp.mobsite.getway.domain.protocol.Category> buildCategories(List<Category> categories) { 150 private List<com.diligrp.mobsite.getway.domain.protocol.Category> buildCategories(List<Category> categories) {
148 - List<com.diligrp.mobsite.getway.domain.protocol.Category> categoryInfos = null;  
149 - if (!Validator.isEmpty(categories)){ 151 + List<com.diligrp.mobsite.getway.domain.protocol.Category> categoryInfos = null;
  152 + if (!Validator.isEmpty(categories)) {
150 categoryInfos = new ArrayList<>(); 153 categoryInfos = new ArrayList<>();
151 - for(Category category:categories){ 154 + for (Category category : categories) {
152 com.diligrp.mobsite.getway.domain.protocol.Category categoryInfo = new com.diligrp.mobsite.getway.domain.protocol.Category(); 155 com.diligrp.mobsite.getway.domain.protocol.Category categoryInfo = new com.diligrp.mobsite.getway.domain.protocol.Category();
153 - categoryInfo.setId((long)category.getCid()); 156 + categoryInfo.setId((long) category.getCid());
154 categoryInfo.setName(category.getCname()); 157 categoryInfo.setName(category.getCname());
155 categoryInfo.setImgUrl(category.getIcon()); 158 categoryInfo.setImgUrl(category.getIcon());
156 - categoryInfo.setParentId((long)category.getPcid()); 159 + categoryInfo.setParentId((long) category.getPcid());
157 categoryInfos.add(categoryInfo); 160 categoryInfos.add(categoryInfo);
158 } 161 }
159 } 162 }
@@ -164,8 +167,8 @@ public class SellerGoodsServiceImpl implements SellerGoodsService { @@ -164,8 +167,8 @@ public class SellerGoodsServiceImpl implements SellerGoodsService {
164 public AddGoodsResp addGoods(AddGoodsReq req) { 167 public AddGoodsResp addGoods(AddGoodsReq req) {
165 AddGoodsResp resp = new AddGoodsResp(); 168 AddGoodsResp resp = new AddGoodsResp();
166 PopProductView input = new PopProductView(); 169 PopProductView input = new PopProductView();
167 - buildAddGoodsInput(req,input);  
168 - goodsRPC.addGoods(input ,req.getUserId()); 170 + buildAddGoodsInput(req, input);
  171 + goodsRPC.addGoods(input, req.getUserId());
169 return resp; 172 return resp;
170 } 173 }
171 174
@@ -174,8 +177,8 @@ public class SellerGoodsServiceImpl implements SellerGoodsService { @@ -174,8 +177,8 @@ public class SellerGoodsServiceImpl implements SellerGoodsService {
174 input.setName(goods.getName()); 177 input.setName(goods.getName());
175 input.setIndexTop(goods.getIndexTop()); 178 input.setIndexTop(goods.getIndexTop());
176 input.setPid(goods.getPid()); 179 input.setPid(goods.getPid());
177 - input.setSellerId(req.getUserId()+"");  
178 - input.setVendorId(req.getShopId()+""); 180 + input.setSellerId(req.getUserId() + "");
  181 + input.setVendorId(req.getShopId() + "");
179 input.setCid(goods.getCid()); 182 input.setCid(goods.getCid());
180 input.setCname(goods.getCname()); 183 input.setCname(goods.getCname());
181 input.setDefaultPic(goods.getDefaultPic()); 184 input.setDefaultPic(goods.getDefaultPic());
@@ -187,16 +190,34 @@ public class SellerGoodsServiceImpl implements SellerGoodsService { @@ -187,16 +190,34 @@ public class SellerGoodsServiceImpl implements SellerGoodsService {
187 190
188 } 191 }
189 192
  193 + private List<Goods> buildGoods(List<Product> productList) {
  194 + List<Goods> result = new ArrayList<>();
  195 + for (Product product : productList) {
  196 + Goods goods = new Goods();
  197 + goods.setName(product.getName());
  198 + goods.setCid(product.getCid());
  199 + goods.setDefaultPic(product.getDefaultPic());
  200 + goods.setDesc(product.getDesc());
  201 + goods.setPictures(product.getPictures());
  202 + goods.setProductType(product.getProductType());
  203 + String jsonString = JSONArray.toJSONString(product.getSaleAtt());
  204 + goods.setSaleAtt(JSONArray.parseArray(jsonString, Attribute.class));
  205 +
  206 + goods.setState(product.getStatus().longValue());
  207 + goods.setSkus(JSONArray.parseArray(JSONArray.toJSONString(product.getSkus()), SKUInfo.class));
  208 + result.add(goods);
  209 + }
  210 + return result;
  211 + }
  212 +
190 private List<Sku> bulidSkus(List<SKUInfo> skusInfo) { 213 private List<Sku> bulidSkus(List<SKUInfo> skusInfo) {
191 List<Sku> skus = null; 214 List<Sku> skus = null;
192 - if (!Validator.isEmpty(skusInfo)){ 215 + if (!Validator.isEmpty(skusInfo)) {
193 skus = new ArrayList<>(); 216 skus = new ArrayList<>();
194 - for (SKUInfo info : skusInfo){ 217 + for (SKUInfo info : skusInfo) {
195 Sku sku = new Sku(); 218 Sku sku = new Sku();
196 219
197 220
198 -  
199 -  
200 skus.add(sku); 221 skus.add(sku);
201 } 222 }
202 } 223 }
@@ -207,7 +228,7 @@ public class SellerGoodsServiceImpl implements SellerGoodsService { @@ -207,7 +228,7 @@ public class SellerGoodsServiceImpl implements SellerGoodsService {
207 228
208 private List<com.diligrp.titan.sdk.domain.Attribute> buildSaleAttr(List<Attribute> saleAtt) { 229 private List<com.diligrp.titan.sdk.domain.Attribute> buildSaleAttr(List<Attribute> saleAtt) {
209 230
210 - List<com.diligrp.titan.sdk.domain.Attribute> attrs = null; 231 + List<com.diligrp.titan.sdk.domain.Attribute> attrs = null;
211 232
212 return attrs; 233 return attrs;
213 234
@@ -227,4 +248,26 @@ public class SellerGoodsServiceImpl implements SellerGoodsService { @@ -227,4 +248,26 @@ public class SellerGoodsServiceImpl implements SellerGoodsService {
227 public HandleGoodsResp handleGoods(HandleGoodsReq req) { 248 public HandleGoodsResp handleGoods(HandleGoodsReq req) {
228 return null; 249 return null;
229 } 250 }
  251 +
  252 + @Override
  253 + public ListCategoryResp listCategory(ListCategoryReq req) {
  254 + return null;
  255 + }
  256 +
  257 + @Override
  258 + public SearchProductResp searchProduct(SearchProductReq req) {
  259 + ProductSearchInput input = new ProductSearchInput();
  260 + SearchProductResp resp = new SearchProductResp();
  261 + input.setPage(req.getPage());
  262 + input.setPageSize(req.getPageSize());
  263 + input.setCateId(req.getCateId());
  264 + input.setStatus(req.getStatus());
  265 + input.setName(req.getName());
  266 +
  267 + List<Product> productList = goodsRPC.searchProduct(input);
  268 +
  269 + resp.setProductList(buildGoods(productList));
  270 + return resp;
  271 +
  272 + }
230 } 273 }
mobsite-getway-web/src/main/java/com/diligrp/mobsite/getway/web/api/seller/product/SellerGoodsController.java
@@ -20,8 +20,9 @@ import javax.annotation.Resource; @@ -20,8 +20,9 @@ import javax.annotation.Resource;
20 * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br /> 20 * <B>Copyright</B> Copyright (c) 2014 www.diligrp.com All rights reserved. <br />
21 * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br /> 21 * 本软件源代码版权归地利集团,未经许可不得任意复制与传播.<br />
22 * <B>Company</B> 地利集团 22 * <B>Company</B> 地利集团
23 - * @createTime 2014年8月30日 下午2:13:16 23 + *
24 * @author duanyugen 24 * @author duanyugen
  25 + * @createTime 2014年8月30日 下午2:13:16
25 */ 26 */
26 @Controller 27 @Controller
27 @RequestMapping("/mobsiteApp/seller/goods") 28 @RequestMapping("/mobsiteApp/seller/goods")
@@ -29,18 +30,63 @@ import javax.annotation.Resource; @@ -29,18 +30,63 @@ import javax.annotation.Resource;
29 public class SellerGoodsController extends BaseApiController { 30 public class SellerGoodsController extends BaseApiController {
30 31
31 @Resource 32 @Resource
32 - private SellerGoodsService sellerGoodsService; 33 + private SellerGoodsService sellerGoodsService;
33 34
34 - private static Logger log = Logger.getLogger(SellerGoodsController.class); 35 + private static Logger log = Logger.getLogger(SellerGoodsController.class);
35 36
36 //商品操作 37 //商品操作
37 - private static final Integer HANDLEGOODS_OPERATE_ON=1;//上架  
38 - private static final Integer HANDLEGOODS_OPERATE_DOWN=2;//下架  
39 - private static final Integer HANDLEGOODS_OPERATE_SALES=3;//设置促销  
40 - private static final Integer HANDLEGOODS_OPERATE_TOP=4;//首页推荐  
41 - private static final Integer HANDLEGOODS_OPERATE_DEL=5;//删除 38 + private static final Integer HANDLEGOODS_OPERATE_ON = 1;//上架
  39 + private static final Integer HANDLEGOODS_OPERATE_DOWN = 2;//下架
  40 + private static final Integer HANDLEGOODS_OPERATE_SALES = 3;//设置促销
  41 + private static final Integer HANDLEGOODS_OPERATE_TOP = 4;//首页推荐
  42 + private static final Integer HANDLEGOODS_OPERATE_DEL = 5;//删除
  43 +
  44 + /**
  45 + * 商品搜搜
  46 + * @param req
  47 + */
  48 + @ApiOperation(value = "搜搜商品", httpMethod = "POST", response = SearchProductResp.class)
  49 + @RequestMapping(value = "/searchProduct", method = RequestMethod.POST)
  50 + @ResponseBody
  51 + public void searchProduct(SearchProductReq req) {
42 52
  53 + try {
  54 + SearchProductResp resp = sellerGoodsService.searchProduct(req);
  55 + sendSuccessResp(resp);
  56 + } catch (ServiceException e) {
  57 + log.error(String.format("Code=%s,ErrorMessage=%s",
  58 + e.getCode(), e.getMessage()), e);
  59 + sendError(e.getCode(), e.getMessage());
  60 + } catch (Exception e) {
  61 + log.error(String.format("ErrorMessage=%s",
  62 + e.getMessage()), e);
  63 + sendError(e.getMessage());
  64 + }
  65 +
  66 + }
43 67
  68 + /**
  69 + * 获取商品分类
  70 + *
  71 + * @param listCategoryReq
  72 + */
  73 + @ApiOperation(value = "获取商品分类", httpMethod = "POST", response = ListCategoryResp.class)
  74 + @RequestMapping(value = "/listCategory", method = RequestMethod.POST)
  75 + @ResponseBody
  76 + public void listCategory(@RequestBody ListCategoryReq listCategoryReq) {
  77 + try {
  78 + ListCategoryResp resp = sellerGoodsService.listCategory(listCategoryReq);
  79 + sendSuccessResp(resp);
  80 + } catch (ServiceException e) {
  81 + log.error(String.format("Code=%s,ErrorMessage=%s",
  82 + e.getCode(), e.getMessage()), e);
  83 + sendError(e.getCode(), e.getMessage());
  84 + } catch (Exception e) {
  85 + log.error(String.format("ErrorMessage=%s",
  86 + e.getMessage()), e);
  87 + sendError(e.getMessage());
  88 + }
  89 + }
44 90
45 /** 91 /**
46 * 添加商品分类 92 * 添加商品分类
@@ -51,8 +97,8 @@ public class SellerGoodsController extends BaseApiController { @@ -51,8 +97,8 @@ public class SellerGoodsController extends BaseApiController {
51 * @createTime Aug 18, 2014 4:02:38 PM 97 * @createTime Aug 18, 2014 4:02:38 PM
52 * @author weili 98 * @author weili
53 */ 99 */
54 - @ApiOperation(value = "添加商品分类", httpMethod = "POST",response = AddProductCategoryResp.class)  
55 - @RequestMapping(value = "/addProductCategory",method = RequestMethod.POST) 100 + @ApiOperation(value = "添加商品分类", httpMethod = "POST", response = AddProductCategoryResp.class)
  101 + @RequestMapping(value = "/addProductCategory", method = RequestMethod.POST)
56 @ResponseBody 102 @ResponseBody
57 public void addProductCategory(@RequestBody AddProductCategoryReq temp) { 103 public void addProductCategory(@RequestBody AddProductCategoryReq temp) {
58 AddProductCategoryReq req = getRequest(AddProductCategoryReq.class); 104 AddProductCategoryReq req = getRequest(AddProductCategoryReq.class);
@@ -79,8 +125,8 @@ public class SellerGoodsController extends BaseApiController { @@ -79,8 +125,8 @@ public class SellerGoodsController extends BaseApiController {
79 * @createTime Aug 18, 2014 4:02:38 PM 125 * @createTime Aug 18, 2014 4:02:38 PM
80 * @author weili 126 * @author weili
81 */ 127 */
82 - @ApiOperation(value = "修改商品分类", httpMethod = "POST",response = UpdateProductCategoryResp.class)  
83 - @RequestMapping(value = "/updateProductCategory",method = RequestMethod.POST) 128 + @ApiOperation(value = "修改商品分类", httpMethod = "POST", response = UpdateProductCategoryResp.class)
  129 + @RequestMapping(value = "/updateProductCategory", method = RequestMethod.POST)
84 @ResponseBody 130 @ResponseBody
85 public void updateProductCategory(@RequestBody UpdateProductCategoryReq temp) { 131 public void updateProductCategory(@RequestBody UpdateProductCategoryReq temp) {
86 UpdateProductCategoryReq req = getRequest(UpdateProductCategoryReq.class); 132 UpdateProductCategoryReq req = getRequest(UpdateProductCategoryReq.class);
@@ -107,8 +153,8 @@ public class SellerGoodsController extends BaseApiController { @@ -107,8 +153,8 @@ public class SellerGoodsController extends BaseApiController {
107 * @createTime Aug 18, 2014 4:02:38 PM 153 * @createTime Aug 18, 2014 4:02:38 PM
108 * @author weili 154 * @author weili
109 */ 155 */
110 - @ApiOperation(value = "搜索商品分类", httpMethod = "POST",response = SearchProductCategoryResp.class)  
111 - @RequestMapping(value = "/searchProductCategory",method = RequestMethod.POST) 156 + @ApiOperation(value = "搜索商品分类", httpMethod = "POST", response = SearchProductCategoryResp.class)
  157 + @RequestMapping(value = "/searchProductCategory", method = RequestMethod.POST)
112 @ResponseBody 158 @ResponseBody
113 public void searchProductCategory(@RequestBody SearchProductCategoryReq temp) { 159 public void searchProductCategory(@RequestBody SearchProductCategoryReq temp) {
114 SearchProductCategoryReq req = getRequest(SearchProductCategoryReq.class); 160 SearchProductCategoryReq req = getRequest(SearchProductCategoryReq.class);
@@ -127,8 +173,6 @@ public class SellerGoodsController extends BaseApiController { @@ -127,8 +173,6 @@ public class SellerGoodsController extends BaseApiController {
127 } 173 }
128 174
129 175
130 -  
131 -  
132 /** 176 /**
133 * 添加新商品 177 * 添加新商品
134 * <p> 178 * <p>
@@ -138,8 +182,8 @@ public class SellerGoodsController extends BaseApiController { @@ -138,8 +182,8 @@ public class SellerGoodsController extends BaseApiController {
138 * @createTime Aug 18, 2014 4:02:38 PM 182 * @createTime Aug 18, 2014 4:02:38 PM
139 * @author weili 183 * @author weili
140 */ 184 */
141 - @ApiOperation(value = "添加新商品", httpMethod = "POST",response = AddGoodsResp.class)  
142 - @RequestMapping(value = "/addGoods",method = RequestMethod.POST) 185 + @ApiOperation(value = "添加新商品", httpMethod = "POST", response = AddGoodsResp.class)
  186 + @RequestMapping(value = "/addGoods", method = RequestMethod.POST)
143 @ResponseBody 187 @ResponseBody
144 public void addGoods(@RequestBody AddGoodsReq temp) { 188 public void addGoods(@RequestBody AddGoodsReq temp) {
145 AddGoodsReq req = getRequest(AddGoodsReq.class); 189 AddGoodsReq req = getRequest(AddGoodsReq.class);
@@ -166,8 +210,8 @@ public class SellerGoodsController extends BaseApiController { @@ -166,8 +210,8 @@ public class SellerGoodsController extends BaseApiController {
166 * @createTime Aug 18, 2014 4:02:38 PM 210 * @createTime Aug 18, 2014 4:02:38 PM
167 * @author weili 211 * @author weili
168 */ 212 */
169 - @ApiOperation(value = "修改商品", httpMethod = "POST",response = UpdateGoodsResp.class)  
170 - @RequestMapping(value = "/updateGoods",method = RequestMethod.POST) 213 + @ApiOperation(value = "修改商品", httpMethod = "POST", response = UpdateGoodsResp.class)
  214 + @RequestMapping(value = "/updateGoods", method = RequestMethod.POST)
171 @ResponseBody 215 @ResponseBody
172 public void updateGoods(@RequestBody UpdateGoodsReq temp) { 216 public void updateGoods(@RequestBody UpdateGoodsReq temp) {
173 UpdateGoodsReq req = getRequest(UpdateGoodsReq.class); 217 UpdateGoodsReq req = getRequest(UpdateGoodsReq.class);
@@ -195,8 +239,8 @@ public class SellerGoodsController extends BaseApiController { @@ -195,8 +239,8 @@ public class SellerGoodsController extends BaseApiController {
195 * @createTime Aug 18, 2014 4:02:38 PM 239 * @createTime Aug 18, 2014 4:02:38 PM
196 * @author weili 240 * @author weili
197 */ 241 */
198 - @ApiOperation(value = "卖家获取商品列表", httpMethod = "POST",response = GetGoodsResp.class)  
199 - @RequestMapping(value = "/getGoods",method = RequestMethod.POST) 242 + @ApiOperation(value = "卖家获取商品列表", httpMethod = "POST", response = GetGoodsResp.class)
  243 + @RequestMapping(value = "/getGoods", method = RequestMethod.POST)
200 @ResponseBody 244 @ResponseBody
201 public void getGoods(@RequestBody GetGoodsReq temp) { 245 public void getGoods(@RequestBody GetGoodsReq temp) {
202 GetGoodsReq req = getRequest(GetGoodsReq.class); 246 GetGoodsReq req = getRequest(GetGoodsReq.class);
@@ -224,8 +268,8 @@ public class SellerGoodsController extends BaseApiController { @@ -224,8 +268,8 @@ public class SellerGoodsController extends BaseApiController {
224 * @createTime Aug 18, 2014 4:02:38 PM 268 * @createTime Aug 18, 2014 4:02:38 PM
225 * @author weili 269 * @author weili
226 */ 270 */
227 - @ApiOperation(value = "卖家操作商品:1上架 2 下架 3设置促销 4设置首页推荐 5删除", httpMethod = "POST",response = HandleGoodsResp.class)  
228 - @RequestMapping(value = "/handleGoods",method = RequestMethod.POST) 271 + @ApiOperation(value = "卖家操作商品:1上架 2 下架 3设置促销 4设置首页推荐 5删除", httpMethod = "POST", response = HandleGoodsResp.class)
  272 + @RequestMapping(value = "/handleGoods", method = RequestMethod.POST)
229 @ResponseBody 273 @ResponseBody
230 public void handleGoods(@RequestBody HandleGoodsReq temp) { 274 public void handleGoods(@RequestBody HandleGoodsReq temp) {
231 HandleGoodsReq req = getRequest(HandleGoodsReq.class); 275 HandleGoodsReq req = getRequest(HandleGoodsReq.class);
@@ -244,5 +288,4 @@ public class SellerGoodsController extends BaseApiController { @@ -244,5 +288,4 @@ public class SellerGoodsController extends BaseApiController {
244 } 288 }
245 289
246 290
247 -  
248 } 291 }
@@ -41,16 +41,6 @@ @@ -41,16 +41,6 @@
41 41
42 <dependencies> 42 <dependencies>
43 43
44 - <dependency>  
45 - <groupId>jdk.tools</groupId>  
46 - <artifactId>jdk.tools</artifactId>  
47 - <version>1.7</version>  
48 - <scope>system</scope>  
49 - <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>  
50 - </dependency>  
51 -  
52 -  
53 -  
54 <!-- spring --> 44 <!-- spring -->
55 <dependency> 45 <dependency>
56 <groupId>org.springframework</groupId> 46 <groupId>org.springframework</groupId>