wangwei 7 năm trước cách đây
mục cha
commit
d7ff3dd56f

+ 21 - 0
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/api/ExamApi.java

@@ -9,6 +9,7 @@ import java.util.stream.Stream;
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.PageRequest;
@@ -16,6 +17,7 @@ import org.springframework.data.domain.Sort;
 import org.springframework.data.domain.Sort.Direction;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
+import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.ModelAttribute;
@@ -27,6 +29,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import com.google.common.collect.Lists;
+
 import cn.com.qmth.examcloud.common.support.ControllerSupport;
 import cn.com.qmth.examcloud.common.uac.entity.AccessUser;
 import cn.com.qmth.examcloud.common.util.ErrorMsg;
@@ -63,6 +67,9 @@ public class ExamApi extends ControllerSupport {
 	@Autowired
 	CourseGroupRepo courseGroupRepo;
 
+	@Autowired
+	private JdbcTemplate jdbcTemplate;
+
 	@ApiOperation(value = "查询所有考试批次", notes = "分页带查询")
 	@GetMapping("/exam/all/{curPage}/{pageSize}")
 	public ResponseEntity getAllExam(HttpServletRequest request, @ModelAttribute Exam examCriteria,
@@ -220,6 +227,20 @@ public class ExamApi extends ControllerSupport {
 
 		List<CourseGroup> groupList = courseGroupRepo.findByExamId(examId);
 
+		for (CourseGroup courseGroup : groupList) {
+			List<Long> courseIdList = Lists.newArrayList();
+			courseGroup.setCourseIdList(courseIdList);
+
+			List<Map<String, Object>> queryList = jdbcTemplate.queryForList(
+					"select t.course_id from ecs_exam_course_group_course t where t.group_id=?", courseGroup.getId());
+			if (CollectionUtils.isNotEmpty(queryList)) {
+				for (Map<String, Object> map : queryList) {
+					Long courseId = Long.valueOf(map.get("COURSE_ID").toString());
+					courseIdList.add(courseId);
+				}
+			}
+		}
+
 		return new ResponseEntity<List<CourseGroup>>(groupList, HttpStatus.OK);
 	}
 }

+ 13 - 0
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/entity/CourseGroup.java

@@ -2,11 +2,13 @@ package cn.com.qmth.examcloud.service.examwork.entity;
 
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
 import javax.persistence.Id;
 import javax.persistence.Table;
+import javax.persistence.Transient;
 
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -32,6 +34,9 @@ public class CourseGroup implements Serializable {
 
 	private String description;
 
+	@Transient
+	private List<Long> courseIdList;
+
 	/**
 	 * 考试批次开始时间
 	 */
@@ -76,6 +81,14 @@ public class CourseGroup implements Serializable {
 		this.description = description;
 	}
 
+	public List<Long> getCourseIdList() {
+		return courseIdList;
+	}
+
+	public void setCourseIdList(List<Long> courseIdList) {
+		this.courseIdList = courseIdList;
+	}
+
 	public Date getBeginTime() {
 		return beginTime;
 	}