发表于: 2018-01-22 22:52:54
2 535
今天完成的事情:
对之前完成的接口调试测通, ,用户课程记录 , 单个删除,批量删除, 课程搜索,课时搜索,
今天主要讲课时搜索写完,写了部分热门推荐.
@RequestMapping(value = "/a/u/lessonPeriod/search", method = RequestMethod.GET)
public String searchCourse(HttpServletRequest request, HttpServletResponse response, ModelMap model, Long subject, Long grade, String name, Integer page, Integer size) throws Exception {
if (IsNullUtil.isNullOrEmpty(subject)) {
model.addAttribute("code", "-1000");
return "common/fail";
}
if (IsNullUtil.isNullOrEmpty(grade)) {
model.addAttribute("code", "-1000");
return "common/fail";
}
if (null == page) {
page = 1;
}
if (null == size) {
size = 5;
}
// 当页开始数目
Integer firstNmuber = (page - 1) * size;
if (firstNmuber < 0) {
firstNmuber = 0;
}
Integer total = null;
List<HashMap<String, Object>> realSearchLessonPeriod = new ArrayList<>();
HashMap<String, Object> searchLessonPeriod = new HashMap<>();
try {
// 根据搜索条件获取课程ids,获取课程下面课时ids,
List<Long> searchCourseIds=courseService.getCourseIdsBySearch(grade,subject,name,0,Integer.MAX_VALUE);
List<Long> lessonPeriodIds=lessonPeriodService.getLessonPeriodIdsByCourseIds(searchCourseIds,firstNmuber,size);
List<LessonPeriod> lessonPeriodList = lessonPeriodService.getObjectsByIds(lessonPeriodIds);
// 根据课时ids获取对应的任务数
Map<String, Object> param = DynamicUtil.countTaskTotalByCourse(lessonPeriodIds);
List<Long> taskCountids = lessonPeriodService.getIdsByDynamicCondition(Task.class, param, 0, Integer.MAX_VALUE);
if (IsNullUtil.isListNullOrEmpty(lessonPeriodList)){
model.addAttribute("code","-3210");
return "common/fail";
}
for (LessonPeriod lessonPeriod: lessonPeriodList){
Long lessonPeriodId = lessonPeriod.getId();
String lessonPeriodName = lessonPeriod.getName();
// 0不收费 1收费,
Integer lockStatus = null;
if (lessonPeriod.getStatus() == 1){
Map<String, Object> param1 = DynamicUtil.getLockByLessonPeriodId(lessonPeriodId);
List<Long> lessonPeriodLockId = lessonPeriodService.getIdsByDynamicCondition(Task.class, param, 0, Integer.MAX_VALUE);
// 如果id为空说明没有解锁 0为解锁
if (CollectionUtils.isEmpty(lessonPeriodIds)){
lockStatus = 0;
}else{
lockStatus = 1;
}
}
for (Long taskCountid:taskCountids) {
searchLessonPeriod.put("taskCountids",taskCountids);
}
searchLessonPeriod.put("lessonPeriodId",lessonPeriodId);
searchLessonPeriod.put("lockStatus",lockStatus);
searchLessonPeriod.put("lessonPeriodName",lessonPeriodName);
realSearchLessonPeriod.add(searchLessonPeriod);
}
model.addAttribute("code",0);
model.addAttribute("total", total);
model.addAttribute("size", size);
model.addAttribute("realSearchLessonPeriod", realSearchLessonPeriod);
}catch (Throwable t) {
log.error(t.getMessage());
log.error("get course error,id is ");
model.addAttribute("code", -1);
}
return "lessonPeriod/json/lessonPeriodSearch";
}
明天计划的事情:
完成热门推荐接口,
尝试写一个排序工具类
完成收藏接口.
遇到的困难:
IDEA报错出参入参不符合,并且出错的地方与报错地方不一致, 通过mvn clean install -e -x 查看报错解决
收获:
get新技能,打印日志,
任务进度:接口编写
任务开始时间:2017-12-12
预计demo时间:2017-02-09
是否有延期风险:暂无
禅道地址:http://task.ptteng.com/zentao/task-view-17095.html
评论