Commit 80514e88 authored by zhangyong's avatar zhangyong

加签名

parent 8cbee67e
......@@ -26,6 +26,7 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
......
package com.egolm.shop.config;
import java.util.EventListener;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.springframework.boot.web.servlet.ServletListenerRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestContextListener;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import com.egolm.shop.config.interceptor.OpenInterceptor;
@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void configurePathMatch(PathMatchConfigurer configurer) {
configurer.setUseSuffixPatternMatch(false).setUseTrailingSlashMatch(false);
@Autowired
private OpenInterceptor openInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
//注册自定义拦截器,添加拦截路径和排除拦截路径
System.out.println("-addInterceptors------");
registry.addInterceptor(openInterceptor).excludePathPatterns("api/path/login");
super.addInterceptors(registry);
}
@Bean
public ServletListenerRegistrationBean<EventListener> getDemoListener(){
ServletListenerRegistrationBean<EventListener> registrationBean = new ServletListenerRegistrationBean<>();
registrationBean.setListener(new RequestContextListener());
return registrationBean;
}
public static HttpServletRequest getRequest() {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
if(servletRequestAttributes != null) {
return servletRequestAttributes.getRequest();
}
return null;
}
public static HttpServletResponse getResponse() {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
if(servletRequestAttributes != null) {
return servletRequestAttributes.getResponse();
}
return null;
}
public static HttpSession getSession() {
HttpServletRequest request = WebMvcConfig.getRequest();
if(request != null) {
return request.getSession();
}
return null;
}
}
package com.egolm.shop.config.interceptor;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import com.egolm.common.GsonUtil;
import com.egolm.common.HttpUtil;
import com.egolm.common.MD5Util;
import com.egolm.common.StringUtil;
import com.egolm.shop.config.XException;
import com.egolm.shop.util.I18NUtils;
import com.egolm.shop.util.ShopContstrant;
@Component
public class OpenInterceptor extends HandlerInterceptorAdapter {
private static final Log logger = LogFactory.getLog(OpenInterceptor.class);
String encoding = "UTF-8";
@Autowired
private RedisTemplate redisTemplate;
/*签名规则:1.按照参数字段名ASCII码排序;2.参数进行url拼接;3.加上签名字符串secret;4.得到字符串后进行SHA1签名;5.将签名得到的字符串加入参数列表中,字段名为sig*/
@Override
public boolean preHandle(HttpServletRequest req, HttpServletResponse resp, Object handler) throws Exception {
String uri = req.getRequestURI();
if((uri.indexOf("swagger") == -1 && uri.indexOf("/v2/api-docs") == -1) ) {
Map<String, String[]> paramMap = req.getParameterMap();
logger.info(GsonUtil.toJson(paramMap));
String sign = req.getParameter("sign");
String timestamp = req.getParameter("timestamp");
String langID = req.getParameter("langID");
String terminal = req.getParameter("terminal");
if(!StringUtil.isNotBlank(sign,timestamp,langID,terminal)) {
throw new XException(I18NUtils.getMessage(langID, "Msg_Paramter_Empty","[sign,timestamp,langID,terminal]")) ;
}
SortedMap<Object,Object> parameters = new TreeMap<Object,Object>();
Set<String> keys = paramMap.keySet() ;
for (String key : keys) {
String value = req.getParameter(key);
parameters.put(key,value);
}
String md5Key = (String)redisTemplate.opsForValue().get(ShopContstrant.CLIENT_MD5KEY);
parameters.put("md5Key", md5Key);
logger.info("request sign >>>>>>"+sign);
String createSign = MD5Util.createSign(encoding, parameters);
logger.info("create sign >>>>>>>"+createSign);
if(createSign.toUpperCase().equals(sign.toUpperCase())) {
return super.preHandle(req, resp, handler);
} else {
throw new XException(I18NUtils.getMessage(langID, "Msg_Sign_failure"));
}
}else {
return super.preHandle(req, resp, handler); //swagger-ui.html 界面不进行验证
}
}
public static void main(String[] args) {
String a= "/A0001/20181023/2018_10_23_17_27_00_58303479.png";
System.out.println(a.length());
}
}
......@@ -37,6 +37,8 @@ public class AddressController {
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "int", required = true, value = "页码", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "int", required = true, value = "每页显示数", defaultValue = "10"),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
})
@RequestMapping(value = "/list",method=RequestMethod.GET)
public String list(HttpServletRequest request) {
......@@ -90,6 +92,8 @@ public class AddressController {
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/saveOrUpdate",method=RequestMethod.POST)
......@@ -143,7 +147,9 @@ public class AddressController {
@ApiImplicitParam(paramType = "query", name = "userNO", dataType = "String", required = true, value = "用户编码", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "addId", dataType = "String", required = true, value = "地址ID", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/delete",method=RequestMethod.GET)
public String delete(HttpServletRequest request) {
......@@ -162,7 +168,9 @@ public class AddressController {
@ApiImplicitParam(paramType = "query", name = "addId", dataType = "String", required = true, value = "地址ID", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "type", dataType = "String", required = true, value = "操作类型 0为取消默认 ,2为设置默认", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/defaultAdd",method=RequestMethod.GET)
public String defaultAdd(HttpServletRequest request) {
......@@ -181,6 +189,8 @@ public class AddressController {
@ApiImplicitParam(paramType = "query", name = "addId", dataType = "String", required = true, value = "地址ID", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/detail",method=RequestMethod.GET)
public String detail(HttpServletRequest request) {
......
......@@ -40,6 +40,9 @@ public class BrandController {
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "int", required = true, value = "页码", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "int", required = true, value = "每页显示数", defaultValue = "10"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/getBanner",method=RequestMethod.GET)
public String getBanner(HttpServletRequest request) {
......@@ -72,8 +75,11 @@ public class BrandController {
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "OrgNO", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "ShopNO", dataType = "String", required = false, value = "店铺编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/getBrandList",method=RequestMethod.GET)
public String getBrandList(HttpServletRequest request, HttpServletResponse response) {
......@@ -122,7 +128,12 @@ public class BrandController {
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "区域编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "compNO", dataType = "String", required = true, value = "组件编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "index", dataType = "String", required = false, value = "第几页", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/getHotSaleBrands",method=RequestMethod.GET)
public String getHotSaleBrands(HttpServletRequest request, HttpServletResponse response) {
......
......@@ -33,7 +33,9 @@ public class CartController {
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name="shopNO", dataType = "String", required = true, value = "店铺编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/cartQuery",method=RequestMethod.GET)
......@@ -49,44 +51,52 @@ public class CartController {
@ApiOperation("加入购物车(JSON格式)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\",\"cartList\": [{\"goodsID\": \"30771\",\"goodsTypeID\": 0,\"saleQty\": \"24\",\"agentContractNO\": \"600327002\",\"promoGroupNO\":\"\",\"promoPaperNO\":\"00001810100007\" }]}"),
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"cartList\": [{\"goodsID\": \"30771\",\"goodsTypeID\": 0,\"saleQty\": \"24\",\"agentContractNO\": \"600327002\",\"promoGroupNO\":\"\",\"promoPaperNO\":\"00001810100007\" }]}"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/appendCart",method=RequestMethod.POST,produces = "application/json")
public String appendCart(HttpServletRequest request, HttpServletResponse response) {
String reqJson = ServletUtil.readReqJson(request);
String reqJson =request.getParameter("data");
JSONObject jsonObj = JSONObject.parseObject(reqJson);
System.out.println("appendCart-------"+reqJson);
return cartService.append(jsonObj);
System.out.println("appendCart-------"+reqJson);
String terminal = request.getParameter("terminal");
return cartService.append(jsonObj,terminal);
}
@ApiOperation("删除购物车(JSON格式)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\",\"idxs\": [1,2,3]}"),
@ApiImplicitParam(paramType = "query",name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\",\"idxs\": [1,2,3]}"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/remove",method=RequestMethod.POST)
public String remove(HttpServletRequest request, HttpServletResponse response) {
String reqJson = ServletUtil.readReqJson(request);
String reqJson = request.getParameter("data");
JSONObject jsonObj = JSONObject.parseObject(reqJson);
System.out.println("remove-------"+reqJson);
return cartService.remove(jsonObj);
String terminal = request.getParameter("terminal");
return cartService.remove(jsonObj,terminal);
}
@ApiOperation("修改数量(JSON格式)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\",\"terminal\": \"wechat\",\"langID\": \"936\", \"idx\": 2,\"saleQty\": \"23\" }"),
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = false, value = "JSON格式", defaultValue = "{\"shopNO\": \"00029975\", \"idx\": 2,\"saleQty\": \"23\" }"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/updateQty",method=RequestMethod.POST)
public String updateQty(HttpServletRequest request, HttpServletResponse response) {
String reqJson = ServletUtil.readReqJson(request);
String reqJson = request.getParameter("data");
JSONObject jsonObj = JSONObject.parseObject(reqJson);
System.out.println("updateQty-------"+reqJson);
return cartService.updateQty(jsonObj);
String terminal = request.getParameter("terminal");
return cartService.updateQty(jsonObj,terminal);
}
}
......@@ -32,6 +32,8 @@ public class CategoryController {
@ApiImplicitParam(paramType = "query", name = "scopeTypeID", dataType = "String", required = true, value = "店铺类型", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/queryCategory",method=RequestMethod.GET)
......
......@@ -27,6 +27,8 @@ public class CommonController {
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "组织机构", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/queryDistrictByOrgNO",method=RequestMethod.GET)
public String detail(HttpServletRequest request) {
......
......@@ -35,6 +35,8 @@ public class CouponController {
@ApiImplicitParam(paramType = "query", name = "userNO", dataType = "String", required = true, value = "用户编码", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/allCoupon",method=RequestMethod.GET)
public String allCoupon(HttpServletRequest request) {
......@@ -71,6 +73,8 @@ public class CouponController {
@ApiImplicitParam(paramType = "query", name = "endDate", dataType = "String", required = false, value = "结束日期", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/myCoupon",method=RequestMethod.GET)
public String myCoupon(HttpServletRequest request) {
......@@ -112,6 +116,8 @@ public class CouponController {
@ApiImplicitParam(paramType = "query", name = "point", dataType = "int", required = false, value = "抵扣金币", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/getCoupon",method=RequestMethod.GET)
public String getCoupon(HttpServletRequest request) {
......
......@@ -41,6 +41,8 @@ public class GoodsController {
@ApiImplicitParam(paramType = "query", name = "compNO", dataType = "String", required = true, value = "组件编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/thinkLike",method=RequestMethod.GET)
public String thinkLike(HttpServletRequest request) {
......@@ -86,6 +88,8 @@ public class GoodsController {
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/getHotSaleGoods",method=RequestMethod.GET)
public String getHotSaleGoods(HttpServletRequest request, HttpServletResponse response) {
......@@ -111,6 +115,8 @@ public class GoodsController {
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/getCategoryGoods",method=RequestMethod.GET)
......@@ -138,6 +144,8 @@ public class GoodsController {
@ApiImplicitParam(paramType = "query", name = "limit", dataType = "String", required = false, value = "每页数量", defaultValue = "20"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/hotSearchKey",method=RequestMethod.GET)
public String hotSearchKey(HttpServletRequest request, HttpServletResponse response) {
......@@ -154,25 +162,29 @@ public class GoodsController {
@ApiOperation("统一搜索(支持品牌,分类,关键字,仓库等)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType = "String", required = true, value = "JSON参数", defaultValue = "{\"topCategoryNO\":\"01\",\"upCategoryNO\":\"\",\"categoryID\":[\"\"],\"brandID\":[\"\"],\"agentID\":\"\",\"warehouseNO\":\"\",\"scopeTypeID\":\"1\",\"districtID\":\"\",\"keyword\":\"*\",\"index\":1,\"limit\":10,\"userNO\":\"00034\",\"orgNO\":\"XIAN\",\"shopNO\":\"167728271\",\"langID\":\"936\",\"terminal\":\"wechat\"}"),
@ApiImplicitParam(paramType = "query", name = "data", dataType = "String", required = true, value = "JSON参数", defaultValue = "{\"topCategoryNO\":\"01\",\"upCategoryNO\":\"\",\"categoryID\":[\"\"],\"brandID\":[\"\"],\"agentID\":\"\",\"warehouseNO\":\"\",\"scopeTypeID\":\"1\",\"districtID\":\"\",\"keyword\":\"*\",\"index\":1,\"limit\":10,\"userNO\":\"00034\",\"orgNO\":\"XIAN\",\"shopNO\":\"167728271\"}"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/searchGoods",method=RequestMethod.POST)
public String searchGoods(HttpServletRequest request, HttpServletResponse response) {
String reqJson = ServletUtil.readReqJson(request);
String reqJson = request.getParameter("data");
System.out.println("searchGoods-------"+reqJson);
Map<String, Object> argsMap = new HashMap<String,Object>();
argsMap = GsonUtil.toMap(reqJson);
String LangID = argsMap.get("langID")+"";
String langID = request.getParameter("langID");
argsMap.put("langID", langID);
try {
if(!argsMap.containsKey("index") || !argsMap.containsKey("limit") || !argsMap.containsKey("userNO") || !argsMap.containsKey("shopNO") || !argsMap.containsKey("orgNO") || !argsMap.containsKey("langID")
|| !argsMap.containsKey("terminal") ) {
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(LangID, "Msg_Parameter_empty")).set("errorMsg", "index,limit,userNO,shopNO,orgNO,langID,terminal " +I18NUtils.getMessage(LangID, "Msg_Must_enter")).toJson();
if(!argsMap.containsKey("index") || !argsMap.containsKey("limit") || !argsMap.containsKey("userNO") || !argsMap.containsKey("shopNO") || !argsMap.containsKey("orgNO") ) {
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_Parameter_empty")).set("errorMsg", "index,limit,userNO,shopNO,orgNO " +I18NUtils.getMessage(langID, "Msg_Must_enter")).toJson();
}
} catch (Exception e) {
e.printStackTrace();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(LangID, "Msg_QueryParam_error")).toJson();
return Rjx.jsonErr().setCode(-100).setMessage(I18NUtils.getMessage(langID, "Msg_QueryParam_error")).toJson();
}
return goodsService.searchGoods(argsMap);
}
......@@ -188,6 +200,8 @@ public class GoodsController {
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/goodsDetail",method=RequestMethod.GET)
......@@ -226,6 +240,8 @@ public class GoodsController {
@ApiImplicitParam(paramType = "query", name = "override", dataType = "String", required = true, value = "收藏状态(1为收藏,0为取消)", defaultValue = "1"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/myFlavor",method=RequestMethod.GET)
......
......@@ -32,6 +32,8 @@ public class PageController {
@ApiOperation("查询(只有一条)")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", name = "LangID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/query",method=RequestMethod.GET)
public String query(HttpServletRequest request) {
......
......@@ -47,6 +47,8 @@ public class SolrGoodsController {
@ApiImplicitParam(paramType = "query", dataType="string", allowMultiple=true, required=true, name="keywords", value="精确搜索条件"),
@ApiImplicitParam(paramType = "query", dataType="string", allowMultiple=true, required=true, name="facetFields", value="单字段分组字段"),
@ApiImplicitParam(paramType = "query", dataType="string", allowMultiple=true, required=true, name="facetPivotFields", value="多字段分组字段"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
public Object query(Long index, Long limit, String queryKey, String[] orders, String[] keywords, String[] facetFields, String[] facetPivotFields) {
Page page = new Page(index, limit, orders);
......@@ -58,6 +60,8 @@ public class SolrGoodsController {
@ApiOperation("搜索引擎按区域编号更新商品索引")
@ApiImplicitParams({
@ApiImplicitParam(paramType = "query", dataType="string", allowMultiple=false, required=true, name="sDistrictID", value="区域编号"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
public Object updateByDistrictID(String sDistrictID) {
service.update(sDistrictID);
......
......@@ -32,6 +32,8 @@ public class SystemCtrlController {
@ApiImplicitParam(paramType = "query", name = "code", dataType = "String", required = true, value = "编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = false, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/getSystemCtrlByCode",method=RequestMethod.GET)
......
......@@ -35,6 +35,8 @@ public class UserController {
@ApiImplicitParam(paramType = "query", name = "orgNO", dataType = "String", required = true, value = "组织机构", defaultValue = "SHBS"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/createGuest",method=RequestMethod.GET)
......@@ -57,6 +59,8 @@ public class UserController {
@ApiImplicitParam(paramType = "query", name = "openID", dataType = "String", required = false, value = "openID(优先级小于账号)", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = false, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/login",method=RequestMethod.POST)
......@@ -81,6 +85,8 @@ public class UserController {
@ApiImplicitParam(paramType = "query", name = "shopNO", dataType = "String", required = false, value = "店铺编号", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/userInfo",method=RequestMethod.GET)
public String userInfo(HttpServletRequest request, HttpServletResponse response) {
......@@ -116,6 +122,8 @@ public class UserController {
@ApiImplicitParam(paramType = "query", name = "smsTmpID", dataType = "String", required = true, value = "短信模板ID", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/modifyPwd",method=RequestMethod.POST)
public String modifyPwd(HttpServletRequest request, HttpServletResponse response) {
......@@ -143,6 +151,8 @@ public class UserController {
@ApiImplicitParam(paramType = "query", name = "content", dataType = "String", required = true, value = "内容,按模板上的参数填值,以,分隔", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "langID", dataType = "String", required = true, value = "语言", defaultValue = "936"),
@ApiImplicitParam(paramType = "query", name = "terminal", dataType = "String", required = true, value = "终端标识", defaultValue = "wechat"),
@ApiImplicitParam(paramType = "query", name = "sign", dataType = "String", required = true, value = "签名", defaultValue = ""),
@ApiImplicitParam(paramType = "query", name = "timestamp", dataType = "String", required = true, value = "时间戳", defaultValue = "")
})
@RequestMapping(value = "/sendSms",method=RequestMethod.GET)
public String sendSms(HttpServletRequest request, HttpServletResponse response) {
......
......@@ -6,11 +6,11 @@ import com.alibaba.fastjson.JSONObject;
public interface CartService {
public String append(JSONObject obj);
public String append(JSONObject obj,String terminal);
public String remove(JSONObject obj);
public String remove(JSONObject obj,String terminal);
public String updateQty (JSONObject obj);
public String updateQty (JSONObject obj,String terminal);
public String query (Map<String,Object> params);
}
......@@ -49,9 +49,8 @@ public class CartServiceImpl implements CartService {
* @return
* @see com.egolm.shop.service.CartService#append(com.alibaba.fastjson.JSONObject)
*/
public String append(JSONObject obj) {
public String append(JSONObject obj,String terminal) {
String shopNO = obj.getString("shopNO");
String terminal = obj.getString("terminal");
JSONArray cartList = obj.getJSONArray("cartList");
Integer nMaxIdx = jdbcTemplate.queryForInt("select max(nIdx) from tCart where sShopNO = '" + shopNO + "'");
......@@ -128,10 +127,9 @@ public class CartServiceImpl implements CartService {
* {"shopNO": "00029975","terminal": "wechat","langID": "936","idxs": [1,2,3]}
*/
@Override
public String remove(JSONObject obj) {
public String remove(JSONObject obj,String terminal) {
String shopNO = obj.getString("shopNO");
JSONArray idxArray = obj.getJSONArray("idxs");
String terminal = obj.getString("terminal");
System.out.println("idxArray----"+idxArray);
List<String> nIdx = new ArrayList<String>();
if(idxArray == null) {
......@@ -161,12 +159,11 @@ public class CartServiceImpl implements CartService {
* @throws
* {"shopNO": "00029975","terminal": "wechat","langID": "936", "idx": 2,"saleQty": "23" }
*/
public String updateQty (JSONObject obj) {
public String updateQty (JSONObject obj,String terminal) {
String shopNO = obj.getString("shopNO");
Integer idx = obj.getInteger("idx");
Double saleQty = obj.getDouble("saleQty");
String terminal = obj.getString("terminal");
String langID = obj.getString("langID");
String langID = obj.getString("langID");
System.out.println(saleQty );
System.out.println(saleQty == 0 );
if(saleQty == 0) {
......@@ -178,7 +175,7 @@ public class CartServiceImpl implements CartService {
removeIdxArray.add(idx);
removeObj.put("idxs", removeIdxArray);
System.out.println(removeObj);
this.remove(removeObj);
this.remove(removeObj,terminal);
} else {
jdbcTemplate.executeUpdate("update tCart set nSaleQty = " + saleQty + " where sShopNO = '" + shopNO + "' and nIdx = " + idx);
}
......
......@@ -11,4 +11,6 @@ public class ShopContstrant {
public static final String SMS_TEMPLATE_CODE = "SmsTemplate"; //模板字典 code tcommon表
public static final String CLIENT_MD5KEY ="Client_Md5Key"; //客户端计算签名的MD5 Key
}
......@@ -48,3 +48,5 @@ Msg_Redemption_failure=The gold coin is insufficient and the redemption failed.
Msg_Coupon_Redemption_success=Coupon redemption success
Msg_Coupon_Redemption_failure=Coupon redemption failure
Msg_Gold_return_failure=Gold coin return failed
Msg_Sign_failure=Signature mismatch
Msg_Paramter_Empty=Parameter {0} can not be empty.
\ No newline at end of file
......@@ -47,4 +47,6 @@ Msg_Deduction_failure=\u64CD\u4F5C\u5F02\u5E38\uFF0C\u6263\u79EF\u5206\u5931\u8D
Msg_Redemption_failure=\u91D1\u5E01\u4E0D\u8DB3,\u5151\u6362\u5931\u8D25.
Msg_Coupon_Redemption_success=\u4F18\u60E0\u5238\u5151\u6362\u6210\u529F
Msg_Coupon_Redemption_failure=\u4F18\u60E0\u5238\u5151\u6362\u5931\u8D25
Msg_Gold_return_failure=\u91D1\u5E01\u8FD4\u8FD8\u5931\u8D25
\ No newline at end of file
Msg_Gold_return_failure=\u91D1\u5E01\u8FD4\u8FD8\u5931\u8D25
Msg_Sign_failure=\u7B7E\u540D\u4E0D\u5339\u914D
Msg_Paramter_Empty=\u53C2\u6570{0}\u4E0D\u80FD\u4E3A\u7A7A
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment