发表于: 2018-01-02 23:03:38
1 487
今天完成的事情:
一.增加了资料与课程,课时,教材的关系接口
增加了学习星购买的接口
@RequestMapping(value = "/a/u/paper/status", method = RequestMethod.GET)
public String getData(HttpServletRequest request, ModelMap model,Integer dataBelongType,Long belongId) throws Exception {
// 验参
boolean isIllegal=CheckTheParameters.valueIsIllegal(dataBelongType,CheckTheParameters.typeOfCheck.DATA_BELONG);
List<Long> orderedId=new ArrayList <>();
List<Long> dataIdsOfLessonOrBook=new ArrayList <>();
List<Long> dataIdsOfPeriod=new ArrayList <>();
List<Long> unorderedIds=new ArrayList <>();
List<Long> ordereds=new ArrayList <>();
BigDecimal datasPrice=new BigDecimal(0);
try {
if (isIllegal){
model.addAttribute("code",-3);
}else {
log.info("=====获取用户ID=====");
String token = CookieUtil.getCookie(request, "token");
String[] mToken = DesUtil.getStrM(token).split(",");
Long uid = Long.parseLong(mToken[0]);
if (dataBelongType==1||dataBelongType==2){
// 取出课程或教材包含的课时的资料
Map<String,Object> params=DynamicSQL.getDataByIdAndType(belongId,dataBelongType,null);
dataIdsOfLessonOrBook=dataService.getIdsByDynamicCondition(Data.class,params,0,Integer.MAX_VALUE);
// 取出已购买的资料
for (Long dataId:dataIdsOfLessonOrBook
) {
Map<String,Object> orderParams=DynamicSQL.getOrdered(4,dataId,uid);
orderedId=userOrderService.getIdsByDynamicCondition(UserOrder.class,orderParams,0,Integer.MAX_VALUE);
if (orderedId.size()==0){
unorderedIds.add(dataId);
datasPrice=datasPrice.add(dataService.getObjectById(dataId).getPrice());
}else {
ordereds.add(orderedId.get(0));
}
}
model.addAttribute("dataId",unorderedIds);
model.addAttribute("datasPrice",datasPrice);
if (dataIdsOfLessonOrBook.size()==0){
model.addAttribute("status",1);
}else if (ordereds.size()==0){
model.addAttribute("status",2);
}else if (ordereds.size()!=0){
model.addAttribute("status",3);
}
}else if (dataBelongType==3){
Map<String,Object> dataParams=DynamicSQL.getDataByIdAndType(null,null,belongId);
dataIdsOfPeriod=dataService.getIdsByDynamicCondition(Data.class,dataParams,0,Integer.MAX_VALUE);
for (Long dataId:dataIdsOfPeriod
) {
Map<String,Object> orderParams=DynamicSQL.getOrdered(4,dataId,uid);
ordereds=userOrderService.getIdsByDynamicCondition(UserOrder.class,orderParams,0,Integer.MAX_VALUE);
}
if (dataIdsOfPeriod.size()==0){
model.addAttribute("status",1);
}else if(ordereds.size()==0){
datasPrice=dataService.getObjectById(dataIdsOfPeriod.get(0)).getPrice();
model.addAttribute("status",2);
model.addAttribute("dataId",dataIdsOfPeriod.get(0));
model.addAttribute("datasPrice",datasPrice);
}else if (ordereds.size()!=0){
model.addAttribute("status",3);
model.addAttribute("dataId",dataIdsOfPeriod.get(0));
}
}
model.addAttribute("code",0);
}
}catch (Exception e){
e.printStackTrace();
model.addAttribute("code",-1);
}
return "/jsps/course-jsp/lesson/json/dataStatus";
}
明天计划完成的事情:
每天计划完成人民币购买的接口
遇到的问题:
代码问题还是不少
收获:
快速定位问题
评论