Joburgess 5 years ago
parent
commit
eedd381958

+ 14 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamAgencyRelationController.java

@@ -31,4 +31,18 @@ public class ExamAgencyRelationController extends BaseController {
         return succeed(examAgencyRelationService.queryPage(queryInfo));
     }
 
+    @ApiOperation("更新考级项目与代理商关联信息")
+    @GetMapping(value = "/updateExamAgencyRelation")
+    public HttpResponseResult updateExamAgencyRelation(ExamAgencyRelation examAgencyRelation){
+        examAgencyRelationService.updateExamAgencyRelation(examAgencyRelation);
+        return succeed();
+    }
+
+    @ApiOperation("发送考级报名链接")
+    @GetMapping(value = "/sendUrl")
+    public HttpResponseResult sendUrl(Integer examId, String agencyIds){
+        examAgencyRelationService.sendUrl(examId, agencyIds);
+        return succeed();
+    }
+
 }

+ 18 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamSubjectSongController.java

@@ -9,10 +9,14 @@ 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 java.util.List;
+
 /**
  * @Author Joburgess
  * @Date 2020.06.18
@@ -31,4 +35,18 @@ public class ExamSubjectSongController extends BaseController {
         return succeed(examSubjectSongService.queryPage(queryInfo));
     }
 
+    @ApiOperation("添加考试内容")
+    @PostMapping(value = "/addExamSubjects")
+    public HttpResponseResult addExamSubjects(List<ExamSubjectSong> examSubjectSongs){
+        examSubjectSongService.addExamSubjects(examSubjectSongs);
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除考试内容")
+    @PostMapping(value = "del")
+    public HttpResponseResult del(Long id) {
+        examSubjectSongService.delete(id);
+        return succeed();
+    }
+
 }

+ 14 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExaminationBasicController.java

@@ -10,6 +10,7 @@ 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.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -31,4 +32,17 @@ public class ExaminationBasicController extends BaseController {
         return succeed(examinationBasicService.queryPage(queryInfo));
     }
 
+    @ApiOperation("创建考级项目")
+    @GetMapping(value = "/addExaminationBasic")
+    public HttpResponseResult<ExaminationBasic> addExaminationBasic(ExaminationBasic examinationBasic){
+        return succeed(examinationBasicService.addExaminationBasic(examinationBasic));
+    }
+
+    @ApiOperation("关闭考级项目")
+    @PostMapping(value = "/closeExam")
+    public HttpResponseResult closeExam(Integer examId, String reason){
+        examinationBasicService.closeExam(examId, reason);
+        return succeed();
+    }
+
 }

+ 22 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamSubjectDao.java

@@ -0,0 +1,22 @@
+package com.keao.edu.user.dao;
+
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.user.entity.ExamSubject;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface ExamSubjectDao extends BaseDAO<Long, ExamSubject> {
+
+    int batchInsert(@Param("examSubjects")List<ExamSubject> examSubjects);
+
+    /**
+     * @describe 获取考级项目关联的声部
+     * @author Joburgess
+     * @date 2020.06.19
+     * @param examId: 考级项目编号
+     * @return java.util.List<com.keao.edu.user.entity.ExamSubject>
+     */
+    List<ExamSubject> getWithTenant(@Param("examId") Integer examId);
+	
+}

+ 78 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamSubject.java

@@ -0,0 +1,78 @@
+package com.keao.edu.user.entity;
+
+import io.swagger.annotations.ApiModelProperty;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+
+/**
+ * 对应数据库表(exam_subject):
+ */
+public class ExamSubject {
+
+	private Long id;
+	
+	@ApiModelProperty(value = "考级项目编号")
+	private Integer examinationBasicId;
+	
+	@ApiModelProperty(value = "声部编号")
+	private Integer subjectId;
+
+	private java.util.Date createTime;
+
+	private java.util.Date updateTime;
+
+	private String tenantId;
+	
+	public void setId(Long id){
+		this.id = id;
+	}
+	
+	public Long getId(){
+		return this.id;
+	}
+			
+	public void setExaminationBasicId(Integer examinationBasicId){
+		this.examinationBasicId = examinationBasicId;
+	}
+	
+	public Integer getExaminationBasicId(){
+		return this.examinationBasicId;
+	}
+			
+	public void setSubjectId(Integer subjectId){
+		this.subjectId = subjectId;
+	}
+	
+	public Integer getSubjectId(){
+		return this.subjectId;
+	}
+			
+	public void setCreateTime(java.util.Date createTime){
+		this.createTime = createTime;
+	}
+	
+	public java.util.Date getCreateTime(){
+		return this.createTime;
+	}
+			
+	public void setUpdateTime(java.util.Date updateTime){
+		this.updateTime = updateTime;
+	}
+	
+	public java.util.Date getUpdateTime(){
+		return this.updateTime;
+	}
+			
+	public void setTenantId(String tenantId){
+		this.tenantId = tenantId;
+	}
+	
+	public String getTenantId(){
+		return this.tenantId;
+	}
+			
+	@Override
+	public String toString() {
+		return ToStringBuilder.reflectionToString(this);
+	}
+
+}

+ 12 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExaminationBasic.java

@@ -46,12 +46,23 @@ public class ExaminationBasic {
 	@ApiModelProperty(value = "背景图")
 	private String posterBackgroundImg;
 
+	@ApiModelProperty(value = "备注")
+	private String memo;
+
 	private java.util.Date createTime;
 
 	private java.util.Date updateTime;
 
 	private String tenantId;
-	
+
+	public String getMemo() {
+		return memo;
+	}
+
+	public void setMemo(String memo) {
+		this.memo = memo;
+	}
+
 	public void setId(Integer id){
 		this.id = id;
 	}

+ 9 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamSubjectService.java

@@ -0,0 +1,9 @@
+package com.keao.edu.user.service;
+
+
+import com.keao.edu.common.service.BaseService;
+import com.keao.edu.user.entity.ExamSubject;
+
+public interface ExamSubjectService extends BaseService<Long, ExamSubject> {
+
+}

+ 22 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamSubjectServiceImpl.java

@@ -0,0 +1,22 @@
+package com.keao.edu.user.service.impl;
+
+import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.service.impl.BaseServiceImpl;
+import com.keao.edu.user.dao.ExamSubjectDao;
+import com.keao.edu.user.entity.ExamSubject;
+import com.keao.edu.user.service.ExamSubjectService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class ExamSubjectServiceImpl extends BaseServiceImpl<Long, ExamSubject> implements ExamSubjectService {
+	
+	@Autowired
+	private ExamSubjectDao examSubjectDao;
+
+	@Override
+	public BaseDAO<Long, ExamSubject> getDAO() {
+		return examSubjectDao;
+	}
+	
+}

+ 25 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamSubjectSongServiceImpl.java

@@ -5,21 +5,27 @@ 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.user.dao.ExamSubjectDao;
 import com.keao.edu.user.dao.ExamSubjectSongDao;
+import com.keao.edu.user.entity.ExamSubject;
 import com.keao.edu.user.entity.ExamSubjectSong;
 import com.keao.edu.user.service.ExamSubjectSongService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Isolation;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjectSong> implements ExamSubjectSongService {
 	
 	@Autowired
 	private ExamSubjectSongDao examSubjectSongDao;
+	@Autowired
+	private ExamSubjectDao examSubjectDao;
 
 	@Override
 	public BaseDAO<Long, ExamSubjectSong> getDAO() {
@@ -27,10 +33,17 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
 	}
 
 	@Override
+	@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
 	public void addExamSubjects(List<ExamSubjectSong> examSubjectSongs) {
 		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());
+		}
+		List<ExamSubject> newExamSubjects = new ArrayList<>();
 		for (ExamSubjectSong examSubjectSong : examSubjectSongs) {
 			if(Objects.isNull(examSubjectSong.getExaminationBasicId())){
 				throw new BizException("请指定考级项目");
@@ -44,7 +57,17 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
 			if(Objects.isNull(examSubjectSong.getRegistrationFee())){
 				throw new BizException("请指定报名费用");
 			}
+			if(existSubjectIds.contains(examSubjectSong.getExamSubjectId())){
+				continue;
+			}
+			ExamSubject newExamSubject=new ExamSubject();
+			newExamSubject.setExaminationBasicId(examSubjectSong.getExaminationBasicId());
+			newExamSubject.setTenantId(examSubjectSong.getTenantId());
+			newExamSubject.setSubjectId(examSubjectSong.getExamSubjectId().intValue());
+			newExamSubjects.add(newExamSubject);
+			existSubjectIds.add(newExamSubject.getSubjectId());
 		}
 		examSubjectSongDao.batchInsert(examSubjectSongs);
+		examSubjectDao.batchInsert(newExamSubjects);
 	}
 }

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

@@ -86,6 +86,7 @@ public class ExaminationBasicServiceImpl extends BaseServiceImpl<Long, Examinati
 		if(StringUtils.isBlank(reason)){
 			reason="后台手动关闭";
 		}
+		examinationBasic.setMemo(reason);
 		examinationBasic.setStatus(ExamStatusEnum.CLOSE);
 		examinationBasicDao.update(examinationBasic);
 	}

+ 79 - 0
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamSubjectMapper.xml

@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!--
+这个文件是自动生成的。
+不要修改此文件。所有改动将在下次重新自动生成时丢失。
+-->
+<mapper namespace="com.keao.edu.user.dao.ExamSubjectDao">
+	
+	<resultMap type="com.keao.edu.user.entity.ExamSubject" id="ExamSubject">
+		<result column="id_" property="id" />
+		<result column="examination_basic_id_" property="examinationBasicId" />
+		<result column="subject_id_" property="subjectId" />
+		<result column="create_time_" property="createTime" />
+		<result column="update_time_" property="updateTime" />
+		<result column="tenant_id_" property="tenantId" />
+	</resultMap>
+	
+	<!-- 根据主键查询一条记录 -->
+	<select id="get" resultMap="ExamSubject" >
+		SELECT * FROM exam_subject WHERE id_ = #{id} 
+	</select>
+	
+	<!-- 全查询 -->
+	<select id="findAll" resultMap="ExamSubject">
+		SELECT * FROM exam_subject ORDER BY id_
+	</select>
+	
+	<!-- 向数据库增加一条记录 -->
+	<insert id="insert" parameterType="com.keao.edu.user.entity.ExamSubject" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
+		INSERT INTO exam_subject (id_,examination_basic_id_,subject_id_,create_time_,update_time_,tenant_id_)
+		VALUES(#{id},#{examinationBasicId},#{subjectId},NOW(),NOW(),#{tenantId})
+	</insert>
+
+	<insert id="batchInsert">
+		INSERT INTO exam_subject (examination_basic_id_,subject_id_,create_time_,update_time_,tenant_id_)
+		VALUES
+		<foreach collection="examSubjects" item="examSubject" separator=",">
+			(#{examSubject.examinationBasicId},#{examSubject.subjectId},NOW(),NOW(),#{examSubject.tenantId})
+		</foreach>
+	</insert>
+
+	<!-- 根据主键查询一条记录 -->
+	<update id="update" parameterType="com.keao.edu.user.entity.ExamSubject">
+		UPDATE exam_subject <set>
+			<if test="examinationBasicId != null">
+				examination_basic_id_ = #{examinationBasicId},
+			</if>
+			<if test="subjectId != null">
+				subject_id_ = #{subjectId},
+			</if>
+			<if test="id != null">
+				id_ = #{id},
+			</if>
+			<if test="tenantId != null">
+				tenant_id_ = #{tenantId},
+			</if>
+			update_time_ = NOW()
+		</set> WHERE id_ = #{id}
+	</update>
+	
+	<!-- 根据主键删除一条记录 -->
+	<delete id="delete" >
+		DELETE FROM exam_subject WHERE id_ = #{id} 
+	</delete>
+	
+	<!-- 分页查询 -->
+	<select id="queryPage" resultMap="ExamSubject" parameterType="map">
+		SELECT * FROM exam_subject ORDER BY id_
+		<include refid="global.limit"/>
+	</select>
+	
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryCount" resultType="int">
+		SELECT COUNT(*) FROM exam_subject
+	</select>
+	<select id="getWithTenant" resultMap="ExamSubject">
+		SELECT * FROM exam_subject WHERE examination_basic_id_=#{examId}
+	</select>
+</mapper>

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

@@ -22,6 +22,7 @@
 		<result column="create_time_" property="createTime" />
 		<result column="update_time_" property="updateTime" />
 		<result column="tenant_id_" property="tenantId" />
+		<result column="memo_" property="memo" />
 	</resultMap>
 
 	<!-- 根据主键查询一条记录 -->
@@ -36,8 +37,8 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.keao.edu.user.entity.ExaminationBasic" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO examination_basic (id_,name_,exam_mode_,exam_location_id_list_,status_,enroll_start_time_,enroll_end_time_,expect_exam_start_time_,expect_exam_end_time_,poster_title_,poster_profile_,poster_background_img_,create_time_,update_time_,tenant_id_)
-		VALUES(#{id},#{name},#{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examLocationIdList},#{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{enrollStartTime},#{enrollEndTime},#{expectExamStartTime},#{expectExamEndTime},#{posterTitle},#{posterProfile},#{posterBackgroundImg},NOW(),NOW(),#{tenantId})
+		INSERT INTO examination_basic (id_,name_,exam_mode_,exam_location_id_list_,status_,enroll_start_time_,enroll_end_time_,expect_exam_start_time_,expect_exam_end_time_,poster_title_,poster_profile_,poster_background_img_,create_time_,update_time_,tenant_id_,memo_)
+		VALUES(#{id},#{name},#{examMode,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{examLocationIdList},#{status,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{enrollStartTime},#{enrollEndTime},#{expectExamStartTime},#{expectExamEndTime},#{posterTitle},#{posterProfile},#{posterBackgroundImg},NOW(),NOW(),#{tenantId},#{memo})
 	</insert>
 
 	<update id="update" parameterType="com.keao.edu.user.entity.ExamAgencyRelation">
@@ -79,6 +80,9 @@
 			<if test="tenantId != null">
 				AND tenant_id_ = #{tenantId},
 			</if>
+			<if test="memo!=null">
+				AND memo_=#{memo},
+			</if>
 			update_time_ = NOW()
 		</set> WHERE id_ = #{id}
 	</update>
@@ -123,6 +127,9 @@
 				<if test="tenantId != null">
 					AND tenant_id_ = #{exam.tenantId},
 				</if>
+				<if test="memo!=null">
+					AND memo_=#{memo},
+				</if>
 				update_time_ = NOW()
 			</set> WHERE id_ = #{exam.id}
 		</foreach>