mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-10 19:36:50 +08:00
feat: 课程列表相关接口
完善了“查看置顶课程列表”、“设置置顶”、“置顶排序”、“导出课程列表”api层、service层逻辑
This commit is contained in:
@@ -17,6 +17,7 @@ import com.xboe.module.course.service.*;
|
||||
import com.xboe.module.course.vo.CoursePageVo;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.parameters.P;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -110,16 +111,53 @@ public class CourseManageApi extends ApiBaseController{
|
||||
*/
|
||||
@PostMapping("/page")
|
||||
public JsonResponse<PageList<CoursePageVo>> managePage(@RequestBody CoursePageQueryDTO coursePageQueryDTO) {
|
||||
// 处理入参逻辑
|
||||
if (coursePageQueryDTO.getLearningTimeStart() == null || coursePageQueryDTO.getLearningTimeEnd() == null) {
|
||||
return badRequest("请指定正确的培训时间选择范围");
|
||||
}
|
||||
// 管理端查询时不需要传入当前用户信息
|
||||
return success(coursePageService.pageQuery(null, coursePageQueryDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前用户是否在管理端显示置顶相关功能
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/show-settop")
|
||||
public JsonResponse<Boolean> showSetTop() {
|
||||
CurrentUser currentUser = getCurrent();
|
||||
return success(coursePageService.showSetTop(currentUser));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新-管理端 置顶课程列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/topList")
|
||||
public JsonResponse<List<CoursePageVo>> topList() {
|
||||
return success(coursePageService.topList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新-管理端 置顶课程列表排序修改
|
||||
* 对整个置顶列表进行重排序
|
||||
* @param changedList
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/top-sortchange")
|
||||
public JsonResponse<List<CoursePageVo>> topListSortChange(@RequestBody List<CoursePageVo> changedList) {
|
||||
ServiceResponse<List<CoursePageVo>> serviceResponse = coursePageService.topListSortChange(changedList);
|
||||
if (serviceResponse.isSuccess()) {
|
||||
return error(serviceResponse.getMessage());
|
||||
}
|
||||
return success(serviceResponse.getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新-管理端 课程列表导出
|
||||
* @param coursePageQueryDTO
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping("/export")
|
||||
public void manageExport() {}
|
||||
public void manageExport(CoursePageQueryDTO coursePageQueryDTO, HttpServletResponse response) {
|
||||
coursePageService.exportCourseList(coursePageQueryDTO, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 管理列表的查询
|
||||
@@ -873,6 +911,7 @@ public class CourseManageApi extends ApiBaseController{
|
||||
*/
|
||||
@PostMapping("/top")
|
||||
public JsonResponse<Boolean> setTop(String ids,String title, Boolean top){
|
||||
// lzx:这个ids实际上只有一个id。。。
|
||||
if(StringUtils.isBlank(ids)){
|
||||
return badRequest("参数错误");
|
||||
}
|
||||
@@ -881,8 +920,14 @@ public class CourseManageApi extends ApiBaseController{
|
||||
}
|
||||
|
||||
try {
|
||||
courseService.setTop(ids, top,getCurrent().getAccountId(), title,"");
|
||||
return success(true);
|
||||
// courseService.setTop(ids, top,getCurrent().getAccountId(), title,"");
|
||||
// return success(true);
|
||||
// 调整置顶逻辑
|
||||
ServiceResponse<Boolean> serviceResponse = coursePageService.top(ids, top);
|
||||
if (!serviceResponse.isSuccess()) {
|
||||
return error(serviceResponse.getMessage());
|
||||
}
|
||||
return success(serviceResponse.getData());
|
||||
} catch (Exception e) {
|
||||
log.error("课程设置置顶错误",e);
|
||||
return error("设置置顶失败",e.getMessage(),false);
|
||||
|
||||
@@ -20,6 +20,13 @@ public interface ICoursePageService {
|
||||
*/
|
||||
PageList<CoursePageVo> pageQuery(CurrentUser currentUser, CoursePageQueryDTO coursePageQueryDTO);
|
||||
|
||||
/**
|
||||
* 当前用户是否展示置顶相关功能
|
||||
* @param currentUser
|
||||
* @return
|
||||
*/
|
||||
boolean showSetTop(CurrentUser currentUser);
|
||||
|
||||
/**
|
||||
* 置顶列表
|
||||
* @return
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.QueryBuilder;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
import com.xboe.data.dto.UserOrgIds;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.module.course.dao.CourseDao;
|
||||
@@ -14,6 +15,7 @@ import com.xboe.module.course.dto.CoursePageQueryDTO;
|
||||
import com.xboe.module.course.dto.ServiceResponse;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseTeacher;
|
||||
import com.xboe.module.course.service.ICourseFullTextSearch;
|
||||
import com.xboe.module.course.service.ICoursePageService;
|
||||
import com.xboe.module.course.vo.CoursePageVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -23,6 +25,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -40,6 +43,12 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
||||
@Autowired
|
||||
private IOutSideDataService outSideDataService;
|
||||
|
||||
@Autowired(required = false)
|
||||
private ICourseFullTextSearch fullTextSearch;
|
||||
|
||||
@Resource
|
||||
private PublishCourseUtil publishUtil;
|
||||
|
||||
@Override
|
||||
public PageList<CoursePageVo> pageQuery(CurrentUser currentUser, CoursePageQueryDTO coursePageQueryDTO) {
|
||||
/*
|
||||
@@ -115,6 +124,14 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showSetTop(CurrentUser currentUser) {
|
||||
UserOrgIds userOrgIds = outSideDataService.getOrgIds();
|
||||
|
||||
return userOrgIds.getPermissions().containsKey(UserOrgIds.IsSystemAdminKey)
|
||||
&& userOrgIds.getPermissions().get(UserOrgIds.IsSystemAdminKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CoursePageVo> topList() {
|
||||
// 构建查询条件
|
||||
@@ -153,8 +170,9 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
||||
return ServiceResponse.failure("最多只能置顶10个课程");
|
||||
}
|
||||
// 2.3 设置置顶
|
||||
course.setIsTop(true);
|
||||
courseDao.update(course);
|
||||
courseDao.updateMultiFieldById(courseId,
|
||||
UpdateBuilder.create("isTop", top),
|
||||
UpdateBuilder.create("topTime", LocalDateTime.now()));
|
||||
} else {
|
||||
// 3. 取消置顶
|
||||
// 3.1 课程是否已置顶
|
||||
@@ -164,7 +182,17 @@ public class CoursePageServiceImpl implements ICoursePageService {
|
||||
// 3.2 取消置顶
|
||||
course.setIsTop(false);
|
||||
course.setSortWeight(9999);
|
||||
courseDao.update(course);
|
||||
courseDao.updateMultiFieldById(courseId,
|
||||
UpdateBuilder.create("isTop", top),
|
||||
UpdateBuilder.create("topTime", null),
|
||||
UpdateBuilder.create("sortWeight", 9999));
|
||||
}
|
||||
// ES同步
|
||||
if (this.fullTextSearch != null) {
|
||||
Object fullId = courseDao.findField("fullTextId", FieldFilters.eq("id", courseId));
|
||||
if (fullId != null) {
|
||||
publishUtil.updateFieldByDocId((String) fullId, "isTop", top ? 1 : 0);
|
||||
}
|
||||
}
|
||||
return ServiceResponse.success(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user