|
|
|
@ -12,10 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
/** |
|
|
|
* API端产品信息 |
|
|
|
@ -33,41 +30,61 @@ public class GoodsController extends BaseController { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/addShoppingCar") |
|
|
|
public JSONObject addShoppingCar(HttpServletRequest request){ |
|
|
|
log.info("addshopping car request"); |
|
|
|
log.info(request.toString()); |
|
|
|
public JSONObject addShoppingCar(@RequestBody String reqStr){ |
|
|
|
// {"appkey":"0acdbb709ee95707","goods_isli":"undefined",
|
|
|
|
// "timestamp":"1667194530","use_years":"1","user_isli":"899998-000000001642-1"}
|
|
|
|
log.info("addShoppingCar:"+reqStr); |
|
|
|
JSONObject request =JSONObject.parseObject(reqStr); |
|
|
|
if(StringUtils.isEmpty(reqStr)){ |
|
|
|
jsonObject.put("code","error"); |
|
|
|
jsonObject.put("msg","请求数据不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
long start=System.currentTimeMillis(); |
|
|
|
String userIsli = request.getParameter("user_isli").trim(); |
|
|
|
if(StringUtils.isEmpty(userIsli)){ |
|
|
|
String userIsli = request.getString("user_isli"); |
|
|
|
if(StringUtils.isEmpty(userIsli) || "undefined".equals(userIsli)){ |
|
|
|
jsonObject.put("code","error"); |
|
|
|
jsonObject.put("msg","user_isli不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
String goodsIsli = request.getString("goods_isli"); |
|
|
|
if(StringUtils.isEmpty(goodsIsli)|| "undefined".equals(goodsIsli)){ |
|
|
|
jsonObject.put("code","error"); |
|
|
|
jsonObject.put("msg","goods_isli不能为空"); |
|
|
|
} |
|
|
|
String userYears= request.getString("use_years"); |
|
|
|
Integer uyears = 1; |
|
|
|
if(StringUtils.isNotEmpty(userYears)){ |
|
|
|
uyears=Integer.valueOf(userYears); |
|
|
|
}else{ |
|
|
|
jsonObject.put("code","error"); |
|
|
|
jsonObject.put("msg","userIsli is empty"); |
|
|
|
jsonObject.put("msg","use_years不能为空"); |
|
|
|
} |
|
|
|
|
|
|
|
String goodsIsli = request.getParameter("goods_isli").trim(); |
|
|
|
String userYears= request.getParameter("use_years").trim(); |
|
|
|
Integer uyears = StringUtils.isEmpty(userYears)?1:Integer.valueOf(userYears); |
|
|
|
// do add
|
|
|
|
Map<String,Object> retmap =goodsService.addShopCar(userIsli,goodsIsli,uyears); |
|
|
|
if(retmap!=null){ |
|
|
|
// get msg
|
|
|
|
jsonObject.put("code",retmap.get("code")); |
|
|
|
jsonObject.put("msg",retmap.get("msg")); |
|
|
|
} |
|
|
|
long end = System.currentTimeMillis(); |
|
|
|
long howUse=(end-start)/1000l; |
|
|
|
|
|
|
|
// get msg
|
|
|
|
jsonObject.put("code",retmap.get("code")); |
|
|
|
jsonObject.put("msg",retmap.get("msg")); |
|
|
|
// jsonObject.put("data",retmap);
|
|
|
|
jsonObject.put("useTime",howUse); |
|
|
|
return jsonObject; |
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping("/getShoppingCar") |
|
|
|
public JSONObject getShoppingCar(HttpServletRequest request){ |
|
|
|
public JSONObject getShoppingCar(@RequestBody String reqstr){ |
|
|
|
log.info("getShoppingCar"+reqstr); |
|
|
|
long start = System.currentTimeMillis(); |
|
|
|
String userIsli =request.getParameter("user_isli"); |
|
|
|
String goodsIsli = request.getParameter("goods_isli"); |
|
|
|
String useYears = request.getParameter("use_years"); |
|
|
|
String appkey = request.getParameter("appkey"); |
|
|
|
String timestamp = request.getParameter("timestamp"); |
|
|
|
JSONObject request = JSONObject.parseObject(reqstr); |
|
|
|
String userIsli =request.getString("user_isli"); |
|
|
|
|
|
|
|
if(StringUtils.isEmpty(userIsli) || "undefined".equals(userIsli)){ |
|
|
|
jsonObject.put("code","error"); |
|
|
|
jsonObject.put("msg","user_isli不能为空"); |
|
|
|
} |
|
|
|
//
|
|
|
|
List retlist =goodsService.getShoppingCar(userIsli); |
|
|
|
long end = System.currentTimeMillis(); |
|
|
|
|