Bläddra i källkod

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	edu-user/edu-user-server/src/main/resources/config/mybatis/ExamSubjectSongMapper.xml
周箭河 5 år sedan
förälder
incheckning
47edb61408

+ 10 - 2
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/ExamSubjectSongController.java

@@ -5,6 +5,7 @@ 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;
+import com.keao.edu.user.dto.ExamSubjectSongDto;
 import com.keao.edu.user.entity.ExamSong;
 import com.keao.edu.user.entity.ExamSubjectSong;
 import com.keao.edu.user.page.ExamSubjectSongQueryInfo;
@@ -32,8 +33,8 @@ public class ExamSubjectSongController extends BaseController {
 
     @ApiOperation("分页查询")
     @GetMapping(value = "/list")
-    public HttpResponseResult<PageInfo<ExamSubjectSong>> getList(ExamSubjectSongQueryInfo queryInfo) {
-        return succeed(examSubjectSongService.queryPage(queryInfo));
+    public HttpResponseResult<PageInfo<ExamSubjectSongDto>> getList(ExamSubjectSongQueryInfo queryInfo) {
+        return succeed(examSubjectSongService.queryExamSubjectSongs(queryInfo));
     }
 
     @ApiOperation("添加考试内容")
@@ -43,6 +44,13 @@ public class ExamSubjectSongController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation("更新考试内容")
+    @PostMapping(value = "/update")
+    public HttpResponseResult update(ExamSubjectSong examSubjectSong) {
+        examSubjectSongService.update(examSubjectSong);
+        return succeed();
+    }
+
     @ApiOperation(value = "删除考试内容")
     @PostMapping(value = "del")
     public HttpResponseResult del(Long id) {

+ 10 - 3
edu-user/edu-user-server/src/main/java/com/keao/edu/user/controller/TenantInfoController.java

@@ -1,6 +1,8 @@
 package com.keao.edu.user.controller;
 
 
+import com.keao.edu.auth.api.client.SysUserFeignService;
+import com.keao.edu.auth.api.entity.SysUser;
 import com.keao.edu.common.controller.BaseController;
 import com.keao.edu.common.entity.HttpResponseResult;
 import com.keao.edu.common.page.PageInfo;
@@ -23,6 +25,8 @@ public class TenantInfoController extends BaseController {
 
 	@Autowired
 	private TenantInfoService tenantInfoService;
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
 	
 	@ApiOperation("机构服务分页查询")
 	@GetMapping(value = "/list")
@@ -47,10 +51,13 @@ public class TenantInfoController extends BaseController {
 	@ApiOperation("更新机构")
 	@PostMapping(value = "/update")
 	public HttpResponseResult update(TenantInfo tenantInfo) {
-		String tenantId = TenantContextHolder.getTenantId().toString();
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if(!sysUser.getIsSuperAdmin()){
+			String tenantId = TenantContextHolder.getTenantId().toString();
+			tenantInfo.setId(Integer.parseInt(tenantId));
+			tenantInfoService.update(tenantInfo);
+		}
 		tenantInfo.setUpdateTime(new Date());
-		tenantInfo.setId(Integer.parseInt(tenantId));
-		tenantInfoService.update(tenantInfo);
 		return succeed();
 	}
 

+ 10 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dao/ExamSongDao.java

@@ -8,6 +8,7 @@ import org.springframework.security.core.parameters.P;
 
 import java.util.List;
 import java.util.Map;
+import java.util.Map;
 
 public interface ExamSongDao extends BaseDAO<Integer, ExamSong> {
 
@@ -54,4 +55,13 @@ public interface ExamSongDao extends BaseDAO<Integer, ExamSong> {
      */
     List<ExamSong> querySongPage(Map<String, Object> params);
 
+    /**
+     * @describe 获取指定的曲目
+     * @author Joburgess
+     * @date 2020.07.03
+     * @param ids:
+     * @return java.util.List<com.keao.edu.user.entity.ExamSong>
+     */
+    List<ExamSong> getWithIds(@Param("ids") List<Integer> ids);
+
 }

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

@@ -1,11 +1,13 @@
 package com.keao.edu.user.dao;
 
 import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.user.dto.ExamSubjectSongDto;
 import com.keao.edu.user.entity.ExamSong;
 import com.keao.edu.user.entity.ExamSubjectSong;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface ExamSubjectSongDao extends BaseDAO<Long, ExamSubjectSong> {
 
@@ -38,4 +40,7 @@ public interface ExamSubjectSongDao extends BaseDAO<Long, ExamSubjectSong> {
      */
     List<ExamSubjectSong> getExamSubjectLevels(@Param("examinationBasicId") Integer examinationBasicId, @Param("examSubjectId") Long examSubjectId);
 
+    List<ExamSubjectSongDto> queryExamSubjectSongs(Map<String, Object> params);
+    int countExamSubjectSongs(Map<String, Object> params);
+
 }

+ 33 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/dto/ExamSubjectSongDto.java

@@ -0,0 +1,33 @@
+package com.keao.edu.user.dto;
+
+import com.keao.edu.user.entity.ExamSubjectSong;
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Author Joburgess
+ * @Date 2020.07.03
+ */
+public class ExamSubjectSongDto extends ExamSubjectSong {
+
+    @ApiModelProperty(value = "练习曲名称")
+    private String practiceSongNames;
+
+    @ApiModelProperty(value = "演奏曲名称")
+    private String performSongNames;
+
+    public String getPracticeSongNames() {
+        return practiceSongNames;
+    }
+
+    public void setPracticeSongNames(String practiceSongNames) {
+        this.practiceSongNames = practiceSongNames;
+    }
+
+    public String getPerformSongNames() {
+        return performSongNames;
+    }
+
+    public void setPerformSongNames(String performSongNames) {
+        this.performSongNames = performSongNames;
+    }
+}

+ 7 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamSubjectSongService.java

@@ -1,10 +1,15 @@
 package com.keao.edu.user.service;
 
+import com.keao.edu.common.page.PageInfo;
 import com.keao.edu.common.service.BaseService;
+import com.keao.edu.user.dao.ExamSubjectSongDao;
+import com.keao.edu.user.dto.ExamSubjectSongDto;
 import com.keao.edu.user.entity.ExamSong;
 import com.keao.edu.user.entity.ExamSubjectSong;
+import com.keao.edu.user.page.ExamSubjectSongQueryInfo;
 
 import java.util.List;
+import java.util.Map;
 
 public interface ExamSubjectSongService extends BaseService<Long, ExamSubjectSong> {
 
@@ -17,6 +22,8 @@ public interface ExamSubjectSongService extends BaseService<Long, ExamSubjectSon
      */
     void addExamSubjects(List<ExamSubjectSong> examSubjectSongs);
 
+    PageInfo<ExamSubjectSongDto> queryExamSubjectSongs(ExamSubjectSongQueryInfo queryInfo);
+
 
     /**
      * 获取考试对应科目对应级别的曲目

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

@@ -37,10 +37,10 @@ public class ExamSongServiceImpl extends BaseServiceImpl<Integer, ExamSong> impl
 	    if(Objects.isNull(examSong.getType())){
 	        throw new BizException("请选择曲库类别");
         }
-        List<ExamSong> existsExamSongs = examSongDao.getWithLevelAndType(examSong.getTenantId(), examSong.getLevelList(), examSong.getType());
-	    if(!CollectionUtils.isEmpty(existsExamSongs)){
-	        throw new BizException("{}级别的{}已存在",examSong.getLevelList(), examSong.getType().getMsg());
-        }
+//      List<ExamSong> existsExamSongs = examSongDao.getWithLevelAndType(examSong.getTenantId(), examSong.getLevelList(), examSong.getType());
+//	    if(!CollectionUtils.isEmpty(existsExamSongs)){
+//	        throw new BizException("{}级别的{}已存在",examSong.getLevelList(), examSong.getType().getMsg());
+//        }
         return super.insert(examSong);
     }
 

+ 67 - 1
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamSubjectSongServiceImpl.java

@@ -10,12 +10,17 @@ import com.keao.edu.user.dao.ExamSongDao;
 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.dto.ExamSubjectSongDto;
 import com.keao.edu.user.entity.ExamSong;
 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.page.ExamSubjectSongQueryInfo;
 import com.keao.edu.user.service.ExamSubjectSongService;
+import com.keao.edu.util.collection.MapUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
@@ -103,7 +108,68 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
 		}
 	}
 
-    @Override
+	@Override
+	public PageInfo<ExamSubjectSongDto> queryExamSubjectSongs(ExamSubjectSongQueryInfo queryInfo) {
+		PageInfo<ExamSubjectSongDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<ExamSubjectSongDto> dataList = new ArrayList<>();
+		int count = examSubjectSongDao.countExamSubjectSongs(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = examSubjectSongDao.queryExamSubjectSongs(params);
+			List<Integer> examSongIds=new ArrayList<>();
+			if(!CollectionUtils.isEmpty(dataList)){
+				for (ExamSubjectSongDto examSubjectSongDto : dataList) {
+					if(StringUtils.isNotBlank(examSubjectSongDto.getPracticeSongIdList())){
+						for (String s : examSubjectSongDto.getPracticeSongIdList().split(",")) {
+							if(!examSongIds.contains(Integer.valueOf(s))){
+								examSongIds.add(Integer.valueOf(s));
+							}
+						}
+					}
+					if(StringUtils.isNotBlank(examSubjectSongDto.getPerformSongIdList())){
+						for (String s : examSubjectSongDto.getPerformSongIdList().split(",")) {
+							if(!examSongIds.contains(Integer.valueOf(s))){
+								examSongIds.add(Integer.valueOf(s));
+							}
+						}
+					}
+				}
+				List<ExamSong> examSongs = new ArrayList<>();
+				if(!CollectionUtils.isEmpty(examSongIds)){
+					examSongs = examSongDao.getWithIds(examSongIds);
+				}
+				Map<Integer, ExamSong> idExamSongMap = examSongs.stream().collect(Collectors.toMap(ExamSong::getId, e -> e));
+				for (ExamSubjectSongDto examSubjectSongDto : dataList) {
+					if(StringUtils.isNotBlank(examSubjectSongDto.getPracticeSongIdList())){
+						List<String> songNames=new ArrayList<>();
+						for (String s : examSubjectSongDto.getPracticeSongIdList().split(",")) {
+							if(idExamSongMap.containsKey(Integer.valueOf(s))){
+								songNames.add(idExamSongMap.get(Integer.valueOf(s)).getSongName());
+							}
+						}
+						examSubjectSongDto.setPracticeSongNames(StringUtils.join(songNames, ","));
+					}
+					if(StringUtils.isNotBlank(examSubjectSongDto.getPerformSongIdList())){
+						List<String> songNames=new ArrayList<>();
+						for (String s : examSubjectSongDto.getPerformSongIdList().split(",")) {
+							if(examSongIds.contains(Integer.valueOf(s))){
+								songNames.add(idExamSongMap.get(Integer.valueOf(s)).getSongName());
+							}
+						}
+						examSubjectSongDto.setPerformSongNames(StringUtils.join(songNames, ","));
+					}
+				}
+			}
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
+
+	@Override
     public List<ExamSong> getExamSubjectSong(Integer examinationBasicId,Long examSubjectId, Integer level) {
 		List<ExamSong> examSongs = new ArrayList<>();
 		ExamSubjectSong examSubjectSong = examSubjectSongDao.getExamSubjectSong(examinationBasicId,examSubjectId, level);

+ 7 - 0
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamSongMapper.xml

@@ -119,4 +119,11 @@
 	<select id="querySongPage" resultMap="ExamSong">
 
 	</select>
+
+	<select id="getWithIds" resultMap="ExamSong">
+		SELECT * FROM exam_song WHERE id_ IN
+		<foreach collection="ids" item="id" separator="," open="(" close=")">
+			#{id}
+		</foreach>
+	</select>
 </mapper>

+ 31 - 4
edu-user/edu-user-server/src/main/resources/config/mybatis/ExamSubjectSongMapper.xml

@@ -21,6 +21,11 @@
 		<result column="tenant_id_" property="tenantId" />
 		<association property="subject" columnPrefix="sub_" resultMap="com.keao.edu.user.dao.SubjectDao.Subject" />
 	</resultMap>
+
+	<resultMap id="ExamSubjectSongDto" type="com.keao.edu.user.dto.ExamSubjectSongDto" extends="ExamSubjectSong">
+		<result property="practiceSongNames" column="practice_song_names_"/>
+		<result property="performSongNames" column="perform_song_names_"/>
+	</resultMap>
 	
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="ExamSubjectSong" >
@@ -112,10 +117,11 @@
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="ExamSubjectSong" parameterType="map">
 		SELECT
-		ess.*,
-		s.id_ sub_id_, s.name_ sub_name_
+			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_
+			LEFT JOIN subject s ON ess.exam_subject_id_=s.id_
 		<include refid="queryCondition"/>
 		ORDER BY ess.id_
 		<include refid="global.limit"/>
@@ -127,12 +133,33 @@
 		LEFT JOIN subject s ON ess.exam_subject_id_=s.id_
 		<include refid="queryCondition"/>
 	</select>
+
+	<select id="queryExamSubjectSongs" resultMap="ExamSubjectSongDto" parameterType="map">
+		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 ess.id_
+		<include refid="global.limit"/>
+	</select>
+
+	<select id="countExamSubjectSongs" resultType="int">
+		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>
-    <select id="getExamSubjectSong" resultMap="ExamSubjectSong">
+
+    <select id="getExamSubjectSong" resultType="com.keao.edu.user.entity.ExamSubjectSong">
 		SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examinationBasicId} AND exam_subject_id_ = #{examSubjectId} AND level_ = #{level}
 	</select>
+
 	<select id="getExamSubjectLevels" resultMap="ExamSubjectSong">
 		SELECT * FROM exam_subject_song WHERE examination_basic_id_=#{examinationBasicId} AND exam_subject_id_ = #{examSubjectId} ORDER BY level_ ASC
 	</select>

+ 14 - 3
edu-user/edu-user-server/src/main/resources/config/mybatis/TenantInfoMapper.xml

@@ -70,14 +70,25 @@
 	<delete id="delete" >
 		DELETE FROM tenant_info WHERE id_ = #{id} 
 	</delete>
-	
-	<!-- 分页查询 -->
+
+	<sql id="queryPageCondition">
+		<where>
+			<if test="search!=null">
+				AND (id_=#{search} OR name_	LIKE CONCAT(#{search}, '%'))
+			</if>
+		</where>
+	</sql>
+
 	<select id="queryPage" resultMap="TenantInfo" parameterType="map">
-		SELECT * FROM tenant_info ORDER BY update_time_ DESC <include refid="global.limit"/>
+		SELECT * FROM tenant_info
+		<include refid="queryPageCondition"/>
+		ORDER BY update_time_ DESC
+		<include refid="global.limit"/>
 	</select>
 	
 	<!-- 查询当前表的总记录数 -->
 	<select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM tenant_info
+		<include refid="queryPageCondition"/>
 	</select>
 </mapper>