|
@@ -38,16 +38,13 @@ import cn.com.qmth.examcloud.commons.base.util.excel.ExcelError;
|
|
|
import cn.com.qmth.examcloud.commons.web.security.bean.User;
|
|
|
import cn.com.qmth.examcloud.commons.web.support.ControllerSupport;
|
|
|
import cn.com.qmth.examcloud.core.basic.api.CourseCloudService;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.bean.CourseBean;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.request.SaveCourseReq;
|
|
|
-import cn.com.qmth.examcloud.core.basic.api.response.SaveCourseResp;
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.controller.bean.CourseDomain;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.CourseRepo;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.CourseEntity;
|
|
|
import cn.com.qmth.examcloud.core.basic.dao.entity.CourseSpeciatlyRelationEntity;
|
|
|
-import cn.com.qmth.examcloud.core.basic.service.bean.CourseAssembler;
|
|
|
-import cn.com.qmth.examcloud.core.basic.service.bean.CourseDto;
|
|
|
-import cn.com.qmth.examcloud.core.basic.service.impl.CourseServiceImpl;
|
|
|
-import cn.com.qmth.examcloud.core.basic.service.impl.ExportService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.dao.enums.CourseLevel;
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.CourseService;
|
|
|
+import cn.com.qmth.examcloud.core.basic.service.bean.CourseInfo;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
|
|
/**
|
|
@@ -62,10 +59,7 @@ public class CourseController extends ControllerSupport {
|
|
|
CourseRepo courseRepo;
|
|
|
|
|
|
@Autowired
|
|
|
- CourseServiceImpl courseService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- CourseAssembler courseAssembler;
|
|
|
+ CourseService courseService;
|
|
|
|
|
|
@Autowired
|
|
|
CourseCloudService courseCloudService;
|
|
@@ -85,8 +79,8 @@ public class CourseController extends ControllerSupport {
|
|
|
*/
|
|
|
@ApiOperation(value = "分页查询课程")
|
|
|
@GetMapping("coursePage/{curPage}/{pageSize}")
|
|
|
- public Page<CourseEntity> getCoursePage(@PathVariable Integer curPage, @PathVariable Integer pageSize,
|
|
|
- @RequestParam(required = false) String name,
|
|
|
+ public Page<CourseEntity> getCoursePage(@PathVariable Integer curPage,
|
|
|
+ @PathVariable Integer pageSize, @RequestParam(required = false) String name,
|
|
|
@RequestParam(required = false) String code,
|
|
|
@RequestParam(required = false) String level,
|
|
|
@RequestParam(required = false) Boolean enable,
|
|
@@ -106,15 +100,17 @@ public class CourseController extends ControllerSupport {
|
|
|
predicates.add(cb.like(root.get("code"), toSqlSearchPattern(code)));
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(level)) {
|
|
|
- predicates.add(cb.equal(root.get("level"), toSqlSearchPattern(level)));
|
|
|
+ predicates.add(cb.equal(root.get("level"), CourseLevel.valueOf(level)));
|
|
|
}
|
|
|
if (null != enable) {
|
|
|
predicates.add(cb.equal(root.get("enable"), enable));
|
|
|
}
|
|
|
|
|
|
if (null != specialtyId) {
|
|
|
- Subquery<CourseSpeciatlyRelationEntity> subquery = query.subquery(CourseSpeciatlyRelationEntity.class);
|
|
|
- Root<CourseSpeciatlyRelationEntity> subRoot = subquery.from(CourseSpeciatlyRelationEntity.class);
|
|
|
+ Subquery<CourseSpeciatlyRelationEntity> subquery = query
|
|
|
+ .subquery(CourseSpeciatlyRelationEntity.class);
|
|
|
+ Root<CourseSpeciatlyRelationEntity> subRoot = subquery
|
|
|
+ .from(CourseSpeciatlyRelationEntity.class);
|
|
|
subquery.select(subRoot);
|
|
|
Predicate p1 = cb.equal(subRoot.get("specialtyId"), specialtyId);
|
|
|
Predicate p2 = cb.equal(subRoot.get("courseId"), root.get("id"));
|
|
@@ -179,8 +175,10 @@ public class CourseController extends ControllerSupport {
|
|
|
}
|
|
|
|
|
|
if (null != specialtyId) {
|
|
|
- Subquery<CourseSpeciatlyRelationEntity> subquery = query.subquery(CourseSpeciatlyRelationEntity.class);
|
|
|
- Root<CourseSpeciatlyRelationEntity> subRoot = subquery.from(CourseSpeciatlyRelationEntity.class);
|
|
|
+ Subquery<CourseSpeciatlyRelationEntity> subquery = query
|
|
|
+ .subquery(CourseSpeciatlyRelationEntity.class);
|
|
|
+ Root<CourseSpeciatlyRelationEntity> subRoot = subquery
|
|
|
+ .from(CourseSpeciatlyRelationEntity.class);
|
|
|
subquery.select(subRoot);
|
|
|
Predicate p1 = cb.equal(subRoot.get("specialtyId"), specialtyId);
|
|
|
Predicate p2 = cb.equal(subRoot.get("courseId"), root.get("id"));
|
|
@@ -240,51 +238,63 @@ public class CourseController extends ControllerSupport {
|
|
|
* 修正
|
|
|
*
|
|
|
* @author WANGWEI
|
|
|
- * @param course
|
|
|
+ * @param domain
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "新增课程", notes = "新增")
|
|
|
@PostMapping
|
|
|
- public Long addCourse(@RequestBody CourseEntity course) {
|
|
|
- trim(course);
|
|
|
+ public Long addCourse(@RequestBody CourseDomain domain) {
|
|
|
+ trim(domain, true);
|
|
|
+
|
|
|
User accessUser = getAccessUser();
|
|
|
+ Long rootOrgId = accessUser.getRootOrgId();
|
|
|
+
|
|
|
+ String code = domain.getCode();
|
|
|
+ if (StringUtils.isBlank(code)) {
|
|
|
+ throw new StatusException("B-620001", "code is blank");
|
|
|
+ }
|
|
|
+ CourseEntity course = courseRepo.findByRootOrgIdAndCode(rootOrgId, code);
|
|
|
+ if (null != course) {
|
|
|
+ throw new StatusException("B-620002", "课程编码已被占用");
|
|
|
+ }
|
|
|
|
|
|
- SaveCourseReq saveCourseReq = new SaveCourseReq();
|
|
|
- saveCourseReq.setCourseCode(course.getCode());
|
|
|
- saveCourseReq.setCourseName(course.getName());
|
|
|
- saveCourseReq.setCourseLevel(course.getLevel().getName());
|
|
|
- saveCourseReq.setRootOrgId(accessUser.getRootOrgId());
|
|
|
+ CourseInfo info = new CourseInfo();
|
|
|
+ info.setRootOrgId(rootOrgId);
|
|
|
+ info.setCode(domain.getCode());
|
|
|
+ info.setEnable(domain.getEnable());
|
|
|
+ info.setId(domain.getId());
|
|
|
+ info.setLevel(domain.getLevel());
|
|
|
+ info.setName(domain.getName());
|
|
|
|
|
|
- SaveCourseResp saveCourseResp = courseCloudService.saveCourse(saveCourseReq);
|
|
|
- CourseBean courseBean = saveCourseResp.getCourseBean();
|
|
|
- return courseBean.getId();
|
|
|
+ CourseEntity saved = courseService.saveCourse(info);
|
|
|
+ return saved.getId();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修正
|
|
|
*
|
|
|
* @author WANGWEI
|
|
|
- * @param course
|
|
|
- * @param request
|
|
|
+ * @param domain
|
|
|
* @return
|
|
|
*/
|
|
|
@ApiOperation(value = "更新课程", notes = "更新")
|
|
|
@PutMapping
|
|
|
- public Long updateCourse(@RequestBody CourseEntity course, HttpServletRequest request) {
|
|
|
+ public Long updateCourse(@RequestBody CourseDomain domain) {
|
|
|
+ trim(domain, true);
|
|
|
+
|
|
|
User accessUser = getAccessUser();
|
|
|
+ Long rootOrgId = accessUser.getRootOrgId();
|
|
|
|
|
|
- SaveCourseReq saveCourseReq = new SaveCourseReq();
|
|
|
- saveCourseReq.setCourseCode(course.getCode());
|
|
|
- saveCourseReq.setCourseName(course.getName());
|
|
|
- saveCourseReq.setCourseLevel(course.getLevel().getName());
|
|
|
- saveCourseReq.setRootOrgId(accessUser.getRootOrgId());
|
|
|
- if (null != course.getEnable()) {
|
|
|
- saveCourseReq.setEnable(course.getEnable());
|
|
|
- }
|
|
|
+ CourseInfo info = new CourseInfo();
|
|
|
+ info.setRootOrgId(rootOrgId);
|
|
|
+ info.setCode(domain.getCode());
|
|
|
+ info.setEnable(domain.getEnable());
|
|
|
+ info.setId(domain.getId());
|
|
|
+ info.setLevel(domain.getLevel());
|
|
|
+ info.setName(domain.getName());
|
|
|
|
|
|
- SaveCourseResp saveCourseResp = courseCloudService.saveCourse(saveCourseReq);
|
|
|
- CourseBean courseBean = saveCourseResp.getCourseBean();
|
|
|
- return courseBean.getId();
|
|
|
+ CourseEntity saved = courseService.saveCourse(info);
|
|
|
+ return saved.getId();
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "删除课程", notes = "删除")
|
|
@@ -317,12 +327,8 @@ public class CourseController extends ControllerSupport {
|
|
|
|
|
|
@ApiOperation(value = "导出课程", notes = "导出")
|
|
|
@GetMapping("export")
|
|
|
- public void exportCourse(@ModelAttribute CourseEntity orgCriteria, HttpServletResponse response) {
|
|
|
- List<CourseDto> list = new ArrayList<CourseDto>();
|
|
|
- courseService.findAll(orgCriteria).forEach(c -> {
|
|
|
- list.add(courseAssembler.toDTO(c));
|
|
|
- });
|
|
|
- ExportService.exportEXCEL("课程列表", CourseDto.class, list, response);
|
|
|
+ public void exportCourse(@ModelAttribute CourseEntity orgCriteria,
|
|
|
+ HttpServletResponse response) {
|
|
|
}
|
|
|
|
|
|
/**
|