首页查询优化
This commit is contained in:
@@ -88,7 +88,7 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
||||
|
||||
private void setCache(String key, String value) {
|
||||
key = getIndexKey(key);
|
||||
redisUtils.set(key, value, 600);
|
||||
redisUtils.set(key, value, 60 * 60 * 3);
|
||||
}
|
||||
|
||||
private String getCache(String key) {
|
||||
@@ -174,26 +174,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
||||
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||
List<Map<String, Object>> records = mapIPage.getRecords();
|
||||
for (Map<String, Object> map : records) {
|
||||
Object courseDetailsId = map.get("courseDetailsId");
|
||||
Object courseId = map.get("courseId");
|
||||
if (courseDetailsId != null) {
|
||||
CourseDetails courseDetails = courseDetailsDao.selectById(Long.parseLong(String.valueOf(courseDetailsId)));
|
||||
if (courseDetails != null) {
|
||||
map.put("courseDetailsName", courseDetails.getCourseDetailsName());
|
||||
map.put("dyEpisodeId", courseDetails.getDyEpisodeId());
|
||||
map.put("wxCourseDetailsId", courseDetails.getWxCourseDetailsId());
|
||||
}
|
||||
} else {
|
||||
//默认取第一集
|
||||
CourseDetails courseDetails = courseDetailsDao.selectOne(new QueryWrapper<CourseDetails>().eq("course_id", courseId)
|
||||
.orderByAsc("sort").last(" limit 1"));
|
||||
if (courseDetails != null) {
|
||||
map.put("courseDetailsId", courseDetails.getCourseDetailsId());
|
||||
map.put("courseDetailsName", courseDetails.getCourseDetailsName());
|
||||
map.put("dyEpisodeId", courseDetails.getDyEpisodeId());
|
||||
map.put("wxCourseDetailsId", courseDetails.getWxCourseDetailsId());
|
||||
}
|
||||
}
|
||||
map.put("courseDetailsId", null);
|
||||
map.put("courseDetailsName", "");
|
||||
map.put("dyEpisodeId", "");
|
||||
map.put("wxCourseDetailsId", "");
|
||||
}
|
||||
setCache(cacheKey, JSONUtil.toJsonStr(new PageUtils(mapIPage)));
|
||||
return Result.success().put("data", new PageUtils(mapIPage));
|
||||
@@ -202,16 +186,10 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
|
||||
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
|
||||
List<Map<String, Object>> records = mapIPage.getRecords();
|
||||
for (Map<String, Object> map : records) {
|
||||
Object courseId = map.get("courseId");
|
||||
//默认取第一集
|
||||
CourseDetails courseDetails = courseDetailsDao.selectOne(new QueryWrapper<CourseDetails>().eq("course_id", courseId)
|
||||
.orderByAsc("sort").last(" limit 1"));
|
||||
if (courseDetails != null) {
|
||||
map.put("courseDetailsId", courseDetails.getCourseDetailsId());
|
||||
map.put("courseDetailsName", courseDetails.getCourseDetailsName());
|
||||
map.put("dyEpisodeId", courseDetails.getDyEpisodeId());
|
||||
map.put("wxCourseDetailsId", courseDetails.getWxCourseDetailsId());
|
||||
}
|
||||
map.put("courseDetailsId", null);
|
||||
map.put("courseDetailsName", "");
|
||||
map.put("dyEpisodeId", "");
|
||||
map.put("wxCourseDetailsId", "");
|
||||
}
|
||||
setCache(cacheKey, JSONUtil.toJsonStr(new PageUtils(mapIPage)));
|
||||
return Result.success().put("data", new PageUtils(mapIPage));
|
||||
|
||||
Reference in New Issue
Block a user