Преглед изворни кода

Merge branch 'master' of http://git.dayaedu.com/yonge/edu-saas

zouxuan пре 5 година
родитељ
комит
e6baafcda5

+ 3 - 5
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamAgencyRelationController.java

@@ -9,9 +9,7 @@ import com.keao.edu.user.service.ExamAgencyRelationService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * @Author Joburgess
@@ -32,8 +30,8 @@ public class ExamAgencyRelationController extends BaseController {
     }
 
     @ApiOperation("更新考级项目与代理商关联信息")
-    @GetMapping(value = "/updateExamAgencyRelation")
-    public HttpResponseResult updateExamAgencyRelation(ExamAgencyRelation examAgencyRelation){
+    @PostMapping(value = "/updateExamAgencyRelation")
+    public HttpResponseResult updateExamAgencyRelation(@RequestBody ExamAgencyRelation examAgencyRelation){
         examAgencyRelationService.updateExamAgencyRelation(examAgencyRelation);
         return succeed();
     }

+ 4 - 6
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamSubjectSongController.java

@@ -1,5 +1,7 @@
 package com.keao.edu.user.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
@@ -9,11 +11,7 @@ import com.keao.edu.user.service.ExamSubjectSongService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -37,7 +35,7 @@ public class ExamSubjectSongController extends BaseController {
 
     @ApiOperation("添加考试内容")
     @PostMapping(value = "/addExamSubjects")
-    public HttpResponseResult addExamSubjects(List<ExamSubjectSong> examSubjectSongs){
+    public HttpResponseResult addExamSubjects(@RequestBody List<ExamSubjectSong> examSubjectSongs){
         examSubjectSongService.addExamSubjects(examSubjectSongs);
         return succeed();
     }

+ 3 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExaminationBasicController.java

@@ -1,5 +1,7 @@
 package com.keao.edu.user.controller;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
@@ -30,7 +32,7 @@ public class ExaminationBasicController extends BaseController {
     }
 
     @ApiOperation("创建考级项目")
-    @GetMapping(value = "/addExaminationBasic")
+    @PostMapping(value = "/addExaminationBasic")
     public HttpResponseResult<ExaminationBasic> addExaminationBasic(@RequestBody ExaminationBasic examinationBasic){
         return succeed(examinationBasicService.addExaminationBasic(examinationBasic));
     }
@@ -41,5 +43,4 @@ public class ExaminationBasicController extends BaseController {
         examinationBasicService.closeExam(examId, reason);
         return succeed();
     }
-
 }

+ 1 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamAgencyRelationDao.java

@@ -17,7 +17,7 @@ public interface ExamAgencyRelationDao extends BaseDAO<Long, ExamAgencyRelation>
      * @param examAgencyRelations:
      * @return int
      */
-    int batchInsert(List<ExamAgencyRelation> examAgencyRelations);
+    int batchInsert(@Param("examAgencyRelations") List<ExamAgencyRelation> examAgencyRelations);
 
     /**
      * @describe 批量更新代理商的链接发送状态

+ 9 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamSubjectSongDao.java

@@ -9,5 +9,14 @@ import java.util.List;
 public interface ExamSubjectSongDao extends BaseDAO<Long, ExamSubjectSong> {
 
     int batchInsert(@Param("examSubjectSongs") List<ExamSubjectSong> examSubjectSongs);
+
+    /**
+     * @describe 获取考级项目下的专业设置
+     * @author Joburgess
+     * @date 2020.06.22
+     * @param examId:
+     * @return java.util.List<com.keao.edu.user.entity.ExamSubjectSong>
+     */
+    List<ExamSubjectSong> findByExam(@Param("examId") Integer examId);
 	
 }

+ 11 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamSubjectSong.java

@@ -40,7 +40,17 @@ public class ExamSubjectSong {
 	private java.util.Date updateTime;
 
 	private String tenantId;
-	
+
+	private Subject subject;
+
+	public Subject getSubject() {
+		return subject;
+	}
+
+	public void setSubject(Subject subject) {
+		this.subject = subject;
+	}
+
 	public void setId(Long id){
 		this.id = id;
 	}

+ 0 - 12
edu-user/edu-user-server/src/main/java/com/keao/edu/user/page/ExamSubjectSongQueryInfo.java

@@ -9,24 +9,12 @@ import io.swagger.annotations.ApiModelProperty;
  */
 public class ExamSubjectSongQueryInfo extends QueryInfo {
 
-    @ApiModelProperty(value = "机构编号")
-    private String tenantId;
-
     @ApiModelProperty(value = "考试项目编号")
     private Integer examId;
 
     @ApiModelProperty(value = "级别")
     private Integer level;
 
-    @Override
-    public String getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(String tenantId) {
-        this.tenantId = tenantId;
-    }
-
     public Integer getExamId() {
         return examId;
     }

+ 4 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamAgencyRelationServiceImpl.java

@@ -1,8 +1,11 @@
 package com.keao.edu.user.service.impl;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.serializer.SerializerFeature;
 import com.keao.edu.common.dal.BaseDAO;
 import com.keao.edu.common.exception.BizException;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
+import com.keao.edu.common.tenant.TenantContextHolder;
 import com.keao.edu.user.dao.ExamAgencyRelationDao;
 import com.keao.edu.user.dao.ExaminationBasicDao;
 import com.keao.edu.user.entity.ExamAgencyRelation;
@@ -42,6 +45,7 @@ public class ExamAgencyRelationServiceImpl extends BaseServiceImpl<Long, ExamAge
 		if(Objects.isNull(examAgencyRelation.getAgencyId())){
 			throw new BizException("请指定代理商");
 		}
+		examAgencyRelation.setTenantId(TenantContextHolder.getTenantId().toString());
 		Set<Integer> agencyIds = examAgencyRelationDao.getAgencyIdsWithExam(examAgencyRelation.getExaminationBasicId());
 		if(agencyIds.contains(examAgencyRelation.getAgencyId())){
 			examAgencyRelationDao.update(examAgencyRelation);

+ 35 - 8
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamSubjectSongServiceImpl.java

@@ -5,10 +5,14 @@ import com.keao.edu.common.exception.BizException;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
+import com.keao.edu.common.tenant.TenantContextHolder;
 import com.keao.edu.user.dao.ExamSubjectDao;
 import com.keao.edu.user.dao.ExamSubjectSongDao;
+import com.keao.edu.user.dao.ExaminationBasicDao;
 import com.keao.edu.user.entity.ExamSubject;
 import com.keao.edu.user.entity.ExamSubjectSong;
+import com.keao.edu.user.entity.ExaminationBasic;
+import com.keao.edu.user.enums.ExamStatusEnum;
 import com.keao.edu.user.service.ExamSubjectSongService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -21,7 +25,9 @@ import java.util.stream.Collectors;
 
 @Service
 public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjectSong> implements ExamSubjectSongService {
-	
+
+	@Autowired
+	private ExaminationBasicDao examinationBasicDao;
 	@Autowired
 	private ExamSubjectSongDao examSubjectSongDao;
 	@Autowired
@@ -38,11 +44,22 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
 		if(CollectionUtils.isEmpty(examSubjectSongs)){
 			return;
 		}
-		List<ExamSubject> examSubjects = examSubjectDao.getWithTenant(examSubjectSongs.get(0).getExaminationBasicId());
-		Set<Integer> existSubjectIds = new HashSet<>();
-		if(!CollectionUtils.isEmpty(examSubjects)){
-			existSubjectIds=examSubjects.stream().map(ExamSubject::getSubjectId).collect(Collectors.toSet());
+		ExaminationBasic examinationBasic = examinationBasicDao.get(examSubjectSongs.get(0).getExaminationBasicId().longValue());
+		if(Objects.isNull(examinationBasic)){
+			throw new BizException("考级项目不存在");
+		}
+		if(!ExamStatusEnum.SETTING.equals(examinationBasic.getStatus())){
+			throw new BizException("此状态考级项目不支持添加考级内容");
+		}
+
+		List<ExamSubjectSong> existExamSubjectSongs=examSubjectSongDao.findByExam(examSubjectSongs.get(0).getExaminationBasicId());
+		Map<Long, List<Integer>> subjectLevelMap = new HashMap<>();
+		Set<Long> existSubjectIds = new HashSet<>();
+		if(!CollectionUtils.isEmpty(existExamSubjectSongs)){
+			subjectLevelMap = existExamSubjectSongs.stream().collect(Collectors.groupingBy(ExamSubjectSong::getExamSubjectId, Collectors.mapping(ExamSubjectSong::getLevel, Collectors.toList())));
+			existSubjectIds = existExamSubjectSongs.stream().map(ExamSubjectSong::getExamSubjectId).collect(Collectors.toSet());
 		}
+
 		List<ExamSubject> newExamSubjects = new ArrayList<>();
 		for (ExamSubjectSong examSubjectSong : examSubjectSongs) {
 			if(Objects.isNull(examSubjectSong.getExaminationBasicId())){
@@ -54,20 +71,30 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
 			if(Objects.isNull(examSubjectSong.getLevel())){
 				throw new BizException("请指定报考等级");
 			}
+			List<Integer> levels = subjectLevelMap.get(examSubjectSong.getExamSubjectId());
+			if(!CollectionUtils.isEmpty(levels)&&levels.contains(examSubjectSong.getLevel())){
+				throw new BizException("考级内容等级重复");
+			}
 			if(Objects.isNull(examSubjectSong.getRegistrationFee())){
 				throw new BizException("请指定报名费用");
 			}
-			if(existSubjectIds.contains(examSubjectSong.getExamSubjectId())){
+			if(existSubjectIds.contains(examSubjectSong.getExamSubjectId().longValue())){
 				continue;
 			}
+
+			examSubjectSong.setTenantId(TenantContextHolder.getTenantId().toString());
+
 			ExamSubject newExamSubject=new ExamSubject();
 			newExamSubject.setExaminationBasicId(examSubjectSong.getExaminationBasicId());
 			newExamSubject.setTenantId(examSubjectSong.getTenantId());
 			newExamSubject.setSubjectId(examSubjectSong.getExamSubjectId().intValue());
+			newExamSubject.setTenantId(TenantContextHolder.getTenantId().toString());
 			newExamSubjects.add(newExamSubject);
-			existSubjectIds.add(newExamSubject.getSubjectId());
+			existSubjectIds.add(newExamSubject.getSubjectId().longValue());
 		}
 		examSubjectSongDao.batchInsert(examSubjectSongs);
-		examSubjectDao.batchInsert(newExamSubjects);
+		if(!CollectionUtils.isEmpty(newExamSubjects)){
+			examSubjectDao.batchInsert(newExamSubjects);
+		}
 	}
 }

+ 2 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExaminationBasicServiceImpl.java

@@ -5,6 +5,7 @@ import com.keao.edu.common.exception.BizException;
 import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.page.QueryInfo;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
+import com.keao.edu.common.tenant.TenantContextHolder;
 import com.keao.edu.user.dao.AgencyDao;
 import com.keao.edu.user.dao.ExamAgencyRelationDao;
 import com.keao.edu.user.dao.ExaminationBasicDao;
@@ -49,6 +50,7 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
 			throw new BizException("请指定考试开始与结束时间");
 		}
 		examinationBasic.setStatus(ExamStatusEnum.SETTING);
+		examinationBasic.setTenantId(TenantContextHolder.getTenantId().toString());
 		examinationBasicDao.insert(examinationBasic);
 		return examinationBasic;
 	}

+ 11 - 8
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamAgencyRelationMapper.xml

@@ -98,10 +98,7 @@
 
 	<sql id="queryCondition">
 		<where>
-			ear.tenant_id_#{tenantId}
-			<if test="examId!=null">
-				AND ear.examination_basic_id_=#{examId}
-			</if>
+			ear.tenant_id_=#{tenantId}
 			<if test="settlementType!=null">
 				AND ear.settlement_type_=#{settlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler}
 			</if>
@@ -116,16 +113,22 @@
 		SELECT
 			ear.*,
 			a.name_ agency_name_
-		FROM exam_agency_relation ear
-		LEFT JOIN agency a ON ear.agency_id_=a.id_
+		FROM agency a
+		LEFT JOIN exam_agency_relation ear ON ear.agency_id_=a.id_
+		<if test="examId!=null">
+			AND ear.examination_basic_id_=#{examId}
+		</if>
 		<include refid="queryCondition"/>
 		ORDER BY id_ <include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM exam_agency_relation ear
-		LEFT JOIN agency a ON ear.agency_id_=a.id_
+		SELECT COUNT(*) FROM agency a
+		LEFT JOIN exam_agency_relation ear ON ear.agency_id_=a.id_
+		<if test="examId!=null">
+			AND ear.examination_basic_id_=#{examId}
+		</if>
 		<include refid="queryCondition"/>
 	</select>
 	<select id="getWithExam" resultMap="ExamAgencyRelation">

+ 10 - 3
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamSubjectSongMapper.xml

@@ -19,6 +19,7 @@
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 		<result column="tenant_id_" property="tenantId" />
+		<association property="subject" columnPrefix="sub_" resultMap="com.keao.edu.user.dao.SubjectDao.Subject" />
 	</resultMap>
 	
 	<!-- 根据主键查询一条记录 -->
@@ -110,17 +111,23 @@
 	
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="ExamSubjectSong" parameterType="map">
-		SELECT * FROM exam_subject_song ess
+		SELECT
+		ess.*,
+		s.id_ sub_id_, s.name_ sub_name_
+		FROM exam_subject_song ess
 		LEFT JOIN subject s ON ess.exam_subject_id_=s.id_
 		<include refid="queryCondition"/>
-		ORDER BY id_
+		ORDER BY ess.id_
 		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM exam_subject_song
+		SELECT COUNT(*) FROM exam_subject_song ess
 		LEFT JOIN subject s ON ess.exam_subject_id_=s.id_
 		<include refid="queryCondition"/>
 	</select>
+	<select id="findByExam" resultMap="ExamSubjectSong">
+		SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examId}
+	</select>
 </mapper>

+ 26 - 26
edu-user/edu-user-server/src/main/resources/config/mybatis/ExaminationBasicMapper.xml

@@ -45,43 +45,43 @@
 		UPDATE examination_basic
 		<set>
 			<if test="name != null">
-				AND name_ = #{name},
+				name_ = #{name},
 			</if>
 			<if test="examMode != null">
-				AND exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
+				exam_mode_ = #{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
 			</if>
 			<if test="examLocationIdList != null">
-				AND exam_location_id_list_ = #{examLocationIdList},
+				exam_location_id_list_ = #{examLocationIdList},
 			</if>
 			<if test="status != null">
-				AND status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
+				status_ = #{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
 			</if>
 			<if test="enrollStartTime != null">
-				AND enroll_start_time_ = #{enrollStartTime},
+				enroll_start_time_ = #{enrollStartTime},
 			</if>
 			<if test="enrollEndTime != null">
-				AND enroll_end_time_ = #{enrollEndTime},
+				enroll_end_time_ = #{enrollEndTime},
 			</if>
 			<if test="expectExamStartTime != null">
-				AND expect_exam_start_time_ = #{expectExamStartTime},
+				expect_exam_start_time_ = #{expectExamStartTime},
 			</if>
 			<if test="expectExamEndTime != null">
-				AND expect_exam_end_time_ = #{expectExamEndTime},
+				expect_exam_end_time_ = #{expectExamEndTime},
 			</if>
 			<if test="posterTitle != null">
-				AND poster_title_ = #{posterTitle},
+				poster_title_ = #{posterTitle},
 			</if>
 			<if test="posterProfile != null">
-				AND poster_profile_ = #{posterProfile},
+				poster_profile_ = #{posterProfile},
 			</if>
 			<if test="posterBackgroundImg != null">
-				AND poster_profile_ = #{posterBackgroundImg},
+				poster_profile_ = #{posterBackgroundImg},
 			</if>
 			<if test="tenantId != null">
-				AND tenant_id_ = #{tenantId},
+				tenant_id_ = #{tenantId},
 			</if>
 			<if test="memo!=null">
-				AND memo_=#{memo},
+				memo_=#{memo},
 			</if>
 			update_time_ = NOW()
 		</set> WHERE id_ = #{id}
@@ -92,43 +92,43 @@
 			UPDATE examination_basic
 			<set>
 				<if test="name != null">
-					AND name_ = #{exam.name},
+					name_ = #{exam.name},
 				</if>
 				<if test="examMode != null">
-					AND exam_mode_ = #{exam.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
+					exam_mode_ = #{exam.examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
 				</if>
 				<if test="examLocationIdList != null">
-					AND exam_location_id_list_ = #{exam.examLocationIdList},
+					exam_location_id_list_ = #{exam.examLocationIdList},
 				</if>
 				<if test="status != null">
-					AND status_ = #{exam.status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
+					status_ = #{exam.status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
 				</if>
 				<if test="enrollStartTime != null">
-					AND enroll_start_time_ = #{exam.enrollStartTime},
+					enroll_start_time_ = #{exam.enrollStartTime},
 				</if>
 				<if test="enrollEndTime != null">
-					AND enroll_end_time_ = #{exam.enrollEndTime},
+					enroll_end_time_ = #{exam.enrollEndTime},
 				</if>
 				<if test="expectExamStartTime != null">
-					AND expect_exam_start_time_ = #{exam.expectExamStartTime},
+					expect_exam_start_time_ = #{exam.expectExamStartTime},
 				</if>
 				<if test="expectExamEndTime != null">
-					AND expect_exam_end_time_ = #{exam.expectExamEndTime},
+					expect_exam_end_time_ = #{exam.expectExamEndTime},
 				</if>
 				<if test="posterTitle != null">
-					AND poster_title_ = #{exam.posterTitle},
+					poster_title_ = #{exam.posterTitle},
 				</if>
 				<if test="posterProfile != null">
-					AND poster_profile_ = #{exam.posterProfile},
+					poster_profile_ = #{exam.posterProfile},
 				</if>
 				<if test="posterBackgroundImg != null">
-					AND poster_profile_ = #{exam.posterBackgroundImg},
+					poster_profile_ = #{exam.posterBackgroundImg},
 				</if>
 				<if test="tenantId != null">
-					AND tenant_id_ = #{exam.tenantId},
+					tenant_id_ = #{exam.tenantId},
 				</if>
 				<if test="memo!=null">
-					AND memo_=#{memo},
+					memo_=#{memo},
 				</if>
 				update_time_ = NOW()
 			</set> WHERE id_ = #{exam.id}