首页查询优化

This commit is contained in:
谭凯凯 2024-12-26 22:31:31 +08:00 committed by Tankaikai
parent e2554bae0f
commit 5c95fc57ad
1 changed files with 425 additions and 421 deletions

View File

@ -1,5 +1,6 @@
package com.sqx.modules.course.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
@ -149,11 +150,11 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
sort = ObjectUtil.defaultIfNull(sort, 0);
List<Map<String, Object>> records = mapIPage.getRecords();
if (sort != null && sort == 1) {
records = records.stream().sorted(Comparator.comparingLong(item -> (long)ObjectUtil.defaultIfNull(item.get("goodNum"),0L))).collect(Collectors.toList());
records = records.stream().sorted(Comparator.comparingLong(item -> Convert.toLong(item.get("goodNum")))).collect(Collectors.toList());
Collections.reverse(records);
}
if (sort != null && sort == 2) {
records = records.stream().sorted(Comparator.comparingLong(item -> (long)ObjectUtil.defaultIfNull(item.get("weekGoodNum"),0L))).collect(Collectors.toList());
records = records.stream().sorted(Comparator.comparingLong(item -> Convert.toLong(item.get("weekGoodNum")))).collect(Collectors.toList());
Collections.reverse(records);
}
for (Map<String, Object> map : records) {
@ -183,12 +184,13 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
IPage<Map<String, Object>> mapIPage = baseMapper.selectCourseAdmin(pages, classifyId, title, isRecommend, status, bannerId,
sort, startTime, endTime, userId, isPrice, over, wxCourse, dyCourse, wxShow, dyShow);
List<Map<String, Object>> records = mapIPage.getRecords();
sort = ObjectUtil.defaultIfNull(sort, 0);
if (sort != null && sort == 1) {
records = records.stream().sorted(Comparator.comparingLong(item -> (long)ObjectUtil.defaultIfNull(item.get("goodNum"),0L))).collect(Collectors.toList());
records = records.stream().sorted(Comparator.comparingLong(item -> Convert.toLong(item.get("goodNum")))).collect(Collectors.toList());
Collections.reverse(records);
}
if (sort != null && sort == 2) {
records = records.stream().sorted(Comparator.comparingLong(item -> (long)ObjectUtil.defaultIfNull(item.get("weekGoodNum"),0L))).collect(Collectors.toList());
records = records.stream().sorted(Comparator.comparingLong(item -> Convert.toLong(item.get("weekGoodNum")))).collect(Collectors.toList());
Collections.reverse(records);
}
for (Map<String, Object> map : records) {
@ -368,7 +370,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
}
@Override
public Result deleteCourseByIds(String ids) {
for (String id : ids.split(",")) {
@ -721,7 +722,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
}
baseMapper.updateById(course);
}
}if("episode_audit".equals(type)){
}
if ("episode_audit".equals(type)) {
String episode_id = msg.getString("episode_id");
CourseDetails courseDetails = courseDetailsDao.selectOne(new QueryWrapper<CourseDetails>().eq("dy_episode_id", episode_id));
if (courseDetails != null) {
@ -1027,7 +1029,8 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
}
HttpClientUtil.downloadImage(cover_url, filePath);
String img=http + "/file/uploadPath/duanju/"+name+"/" +name+".jpg";;
String img = http + "/file/uploadPath/duanju/" + name + "/" + name + ".jpg";
;
course = new Course();
course.setTitle(name);
@ -1101,14 +1104,16 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
String[] splits = http.split("://");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
// 上传文件路径
String filePath = "/www/wwwroot/" + splits[1] + "/file/uploadPath/duanju/"+course.getTitle()+"/" +name+".jpg";;
String filePath = "/www/wwwroot/" + splits[1] + "/file/uploadPath/duanju/" + course.getTitle() + "/" + name + ".jpg";
;
File file = new File(filePath);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
HttpClientUtil.downloadImage(cover_url, filePath);
String img=http + "/file/uploadPath/duanju/"+course.getTitle()+"/" +name+".jpg";;
String img = http + "/file/uploadPath/duanju/" + course.getTitle() + "/" + name + ".jpg";
;
int goodNum = minGood + rand.nextInt(maxGood - minGood + 1);
courseDetails = new CourseDetails();
@ -1208,7 +1213,6 @@ public class CourseServiceImpl extends ServiceImpl<CourseDao, Course> implements
}
@Override
public Result courseListExcelIn(MultipartFile file) throws IOException {
List<CourseIn> courseList = ExcelUtils.importExcel(file, 2, 1, CourseIn.class);