zouxuan 4 лет назад
Родитель
Сommit
e5ee9ad810

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/SysExamSongAccompanimentDao.java

@@ -6,6 +6,7 @@ import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 public interface SysExamSongAccompanimentDao extends BaseDAO<Integer, SysExamSongAccompaniment> {
 
@@ -34,4 +35,13 @@ public interface SysExamSongAccompanimentDao extends BaseDAO<Integer, SysExamSon
      * @param delExamSongAccompanimentIds
      */
     void batchDel(@Param("delExamSongAccompanimentIds") List<Integer> delExamSongAccompanimentIds);
+
+    /**
+     * 用于学生端,教师端分页查询伴奏列表
+     * @param params
+     * @return
+     */
+    List<SysExamSongAccompaniment> queryAccPage(Map<String, Object> params);
+
+    int findAccCount(Map<String, Object> params);
 }

+ 33 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/SysExamSongAccompaniment.java

@@ -26,6 +26,15 @@ public class SysExamSongAccompaniment {
 	private String xmlUrl;
 
 	/**  */
+	private String examSongName;
+
+	/**  */
+	private String type;
+
+	/**  */
+	private String url;
+
+	/**  */
 	private int delFlag;
 
 	private Integer speed;
@@ -36,6 +45,30 @@ public class SysExamSongAccompaniment {
 	/**  */
 	private java.util.Date updateTime;
 
+	public String getUrl() {
+		return url;
+	}
+
+	public void setUrl(String url) {
+		this.url = url;
+	}
+
+	public String getExamSongName() {
+		return examSongName;
+	}
+
+	public void setExamSongName(String examSongName) {
+		this.examSongName = examSongName;
+	}
+
+	public String getType() {
+		return type;
+	}
+
+	public void setType(String type) {
+		this.type = type;
+	}
+
 	public String getSubjectName() {
 		return subjectName;
 	}

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysExamSongAccompanimentService.java

@@ -2,9 +2,17 @@ package com.ym.mec.biz.service;
 
 
 import com.ym.mec.biz.dal.entity.SysExamSongAccompaniment;
+import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 
+import java.util.List;
+
 public interface SysExamSongAccompanimentService extends BaseService<Integer, SysExamSongAccompaniment> {
 
     void updateAcc(SysExamSongAccompaniment sysExamSongAccompaniment);
+
+    List<SysExamSongAccompaniment> queryAll(SysExamSongQueryInfo queryInfo);
+
+    PageInfo<SysExamSongAccompaniment> queryAccPage(SysExamSongQueryInfo queryInfo);
 }

+ 1 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysExamSongService.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.dto.ExamSongDto;
 import com.ym.mec.biz.dal.entity.SysExamSong;
+import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
 import com.ym.mec.common.service.BaseService;
 
 public interface SysExamSongService extends BaseService<Integer, SysExamSong> {

+ 32 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysExamSongAccompanimentServiceImpl.java

@@ -3,16 +3,21 @@ package com.ym.mec.biz.service.impl;
 
 import com.ym.mec.biz.dal.dao.SysExamSongAccompanimentDao;
 import com.ym.mec.biz.dal.entity.SysExamSongAccompaniment;
+import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
 import com.ym.mec.biz.service.SysExamSongAccompanimentService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.exception.BizException;
+import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import com.ym.mec.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 @Service
@@ -41,4 +46,31 @@ public class SysExamSongAccompanimentServiceImpl extends BaseServiceImpl<Integer
 		}
 		sysExamSongAccompanimentDao.update(sysExamSongAccompaniment);
 	}
+
+	@Override
+	public List<SysExamSongAccompaniment> queryAll(SysExamSongQueryInfo queryInfo) {
+		Map<String, Object> params = new HashMap<>();
+		MapUtil.populateMap(params, queryInfo);
+		return sysExamSongAccompanimentDao.queryPage(params);
+	}
+
+	@Override
+	public PageInfo<SysExamSongAccompaniment> queryAccPage(SysExamSongQueryInfo queryInfo) {
+		PageInfo<SysExamSongAccompaniment> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+
+		List<SysExamSongAccompaniment> dataList = null;
+		int count = sysExamSongAccompanimentDao.findAccCount(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = sysExamSongAccompanimentDao.queryAccPage(params);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
 }

+ 15 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysExamSongServiceImpl.java

@@ -75,16 +75,23 @@ public class SysExamSongServiceImpl extends BaseServiceImpl<Integer, SysExamSong
 			if(subjectIdList.size() > 0){
 				List<Integer> idList = sysExamSongAccompaniment.stream().map(e -> e.getId()).collect(Collectors.toList());
 				List<Integer> subjectIds = sysExamSongAccompanimentDao.findSubjectByExamId(sysExamSong.getId(),idList);
-				if(subjectIds != null && subjectIds.size() > 0){
-					int subjectSize = subjectIds.size() + subjectIdList.size();
-					subjectIdList.addAll(subjectIds);
-					int size = new HashSet<>(subjectIdList).size();
-					if(size < subjectSize){
-						throw new BizException("操作失败:请勿提交重复的伴奏声部");
-					}
+				int subjectSize = subjectIds.size() + subjectIdList.size();
+				subjectIdList.addAll(subjectIds);
+				int size = new HashSet<>(subjectIdList).size();
+				if(size < subjectSize){
+					throw new BizException("操作失败:请勿提交重复的伴奏声部");
 				}
 			}
-			sysExamSongAccompanimentDao.batchUpdate(sysExamSongAccompaniment);
+			//获取需要修改的伴奏
+			List<SysExamSongAccompaniment> updateCollect = sysExamSongAccompaniment.stream().filter(e -> e.getId() != null).collect(Collectors.toList());
+			if(updateCollect.size() > 0){
+				sysExamSongAccompanimentDao.batchUpdate(updateCollect);
+			}
+			//获取需要新增的伴奏
+			List<SysExamSongAccompaniment> addCollect = sysExamSongAccompaniment.stream().filter(e -> e.getId() == null).collect(Collectors.toList());
+			if(addCollect.size() > 0){
+				sysExamSongAccompanimentDao.batchInsert(addCollect,sysExamSong.getId());
+			}
 		}
 	}
 }

+ 52 - 6
mec-biz/src/main/resources/config/mybatis/SysExamSongAccompanimentMapper.xml

@@ -13,6 +13,9 @@
 		<result column="subject_name_" property="subjectName" />
 		<result column="mp3_url_" property="mp3Url" />
 		<result column="xml_url_" property="xmlUrl" />
+		<result column="name_" property="examSongName" />
+		<result column="type_" property="type" />
+		<result column="url_" property="url" />
 		<result column="del_flag_" property="delFlag" />
 		<result column="speed_" property="speed" />
 		<result column="create_time_" property="createTime" />
@@ -77,19 +80,19 @@
 		<foreach collection="sysExamSongAccompaniment" item="item" separator=";">
 			UPDATE sys_exam_song_accompaniment
 			<set>
-			<if test="speed != null">
+			<if test="item.speed != null">
 				speed_ = #{item.speed},
 			</if>
-			<if test="subjectId != null">
+			<if test="item.subjectId != null">
 				subject_id_ = #{item.subjectId},
 			</if>
-			<if test="xmlUrl != null">
+			<if test="item.xmlUrl != null">
 				xml_url_ = #{item.xmlUrl},
 			</if>
-			<if test="examSongId != null">
+			<if test="item.examSongId != null">
 				exam_song_id_ = #{item.examSongId},
 			</if>
-			<if test="mp3Url != null">
+			<if test="item.mp3Url != null">
 				mp3_url_ = #{item.mp3Url},
 			</if>
 			update_time_ = NOW()
@@ -98,7 +101,7 @@
 	</update>
     <update id="batchDel">
 		UPDATE sys_exam_song_accompaniment SET del_flag_ = 1,update_time_ = NOW() WHERE id_ IN
-		<foreach collection="sysExamSongAccompaniment" item="item" open="(" close=")" separator=",">
+		<foreach collection="delExamSongAccompanimentIds" item="item" open="(" close=")" separator=",">
 			#{item}
 		</foreach>
 
@@ -142,4 +145,47 @@
 			</if>
 		</where>
 	</select>
+	<select id="queryAccPage" resultMap="SysExamSongAccompaniment">
+		SELECT sesa.*,ses.name_,ses.type_,ses.url_ FROM sys_exam_song_accompaniment sesa
+		LEFT JOIN sys_exam_song ses ON ses.id_ = sesa.exam_song_id_
+		<include refid="queryPageSql"/>
+		<include refid="global.limit"/>
+	</select>
+	<select id="findAccCount" resultType="java.lang.Integer">
+		SELECT COUNT(DISTINCT sesa.id_) FROM sys_exam_song_accompaniment sesa
+		LEFT JOIN sys_exam_song ses ON ses.id_ = sesa.exam_song_id_
+		<include refid="queryPageSql"/>
+	</select>
+	<sql id="queryPageSql">
+		<where>
+			sesa.del_flag_ = 0
+			<if test="search != null and search != ''">
+				AND (sesa.id_ = #{search} OR ses.name_ LIKE CONCAT('%',#{search},'%'))
+			</if>
+			<if test="subjectId != null">
+				AND sesa.subject_id_ = #{subjectId}
+			</if>
+			<if test="type != null and type == 'COMMON'">
+				AND ses.type_ = #{type}
+			</if>
+			<if test="type != null and type == 'ALL'">
+				<if test="createUserId != null">
+					AND (ses.type_ = 'COMMON' OR (ses.create_user_id_ = #{createUserId} AND ses.type_ = 'PERSON'))
+				</if>
+			</if>
+			<if test="type != null and type == 'PERSON'">
+				<if test="createUserId != null">
+					AND ses.type_ = #{type} AND ses.create_user_id_ = #{createUserId}
+				</if>
+				<if test="createUserId == null">
+					AND ses.type_ = #{type}
+				</if>
+			</if>
+			<if test="type == null or type == ''">
+				<if test="createUserId != null">
+					AND ses.create_user_id_ = #{createUserId}
+				</if>
+			</if>
+		</where>
+	</sql>
 </mapper>

+ 43 - 0
mec-student/src/main/java/com/ym/mec/student/controller/SysExamSongAccompanimentController.java

@@ -0,0 +1,43 @@
+package com.ym.mec.student.controller;
+
+import com.ym.mec.biz.dal.entity.SysExamSongAccompaniment;
+import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
+import com.ym.mec.biz.service.SysExamSongAccompanimentService;
+import com.ym.mec.common.controller.BaseController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+@RequestMapping("sysExamSongAccompaniment")
+@Api(tags = "曲库伴奏服务")
+@RestController
+public class SysExamSongAccompanimentController extends BaseController {
+
+    @Autowired
+    private SysExamSongAccompanimentService sysExamSongAccompanimentService;
+
+    @ApiOperation(value = "修改")
+    @PostMapping("/update")
+    public Object update(@RequestBody SysExamSongAccompaniment sysExamSongAccompaniment) {
+        sysExamSongAccompanimentService.updateAcc(sysExamSongAccompaniment);
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除")
+    @PostMapping("/del/{id}")
+    public Object del(@ApiParam(value = "收费类型编号", required = true) @PathVariable("id") Integer id) {
+        sysExamSongAccompanimentService.delete(id);
+        return succeed();
+    }
+
+    @ApiOperation(value = "分页查询")
+    @GetMapping("/queryPage")
+    public Object queryPage(SysExamSongQueryInfo queryInfo) {
+        queryInfo.setType("COMMON");
+        return succeed(sysExamSongAccompanimentService.queryAccPage(queryInfo));
+    }
+
+}

+ 57 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/SysExamSongAccompanimentController.java

@@ -0,0 +1,57 @@
+package com.ym.mec.teacher.controller;
+
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.entity.SysExamSongAccompaniment;
+import com.ym.mec.biz.dal.page.SysExamSongQueryInfo;
+import com.ym.mec.biz.service.SysExamSongAccompanimentService;
+import com.ym.mec.common.controller.BaseController;
+import com.ym.mec.common.exception.BizException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+@RequestMapping("sysExamSongAccompaniment")
+@Api(tags = "曲库伴奏服务")
+@RestController
+public class SysExamSongAccompanimentController extends BaseController {
+
+    @Autowired
+    private SysExamSongAccompanimentService sysExamSongAccompanimentService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
+    @ApiOperation(value = "修改")
+    @PostMapping("/update")
+    public Object update(@RequestBody SysExamSongAccompaniment sysExamSongAccompaniment) {
+        sysExamSongAccompanimentService.updateAcc(sysExamSongAccompaniment);
+        return succeed();
+    }
+
+    @ApiOperation(value = "删除")
+    @PostMapping("/del/{id}")
+    public Object del(@ApiParam(value = "收费类型编号", required = true) @PathVariable("id") Integer id) {
+        sysExamSongAccompanimentService.delete(id);
+        return succeed();
+    }
+
+    @ApiOperation(value = "分页查询")
+    @GetMapping("/queryPage")
+    public Object queryPage(SysExamSongQueryInfo queryInfo) {
+        String type = queryInfo.getType();
+        if(StringUtils.isEmpty(type)){
+            queryInfo.setType("ALL");
+        }
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if(sysUser == null){
+            throw new BizException("请登录");
+        }
+        queryInfo.setCreateUserId(sysUser.getId());
+        return succeed(sysExamSongAccompanimentService.queryAccPage(queryInfo));
+    }
+
+}

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/SysExamSongAccompanimentController.java

@@ -39,7 +39,7 @@ public class SysExamSongAccompanimentController extends BaseController {
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('sysExamSongAccompaniment/queryPage')")
     public Object queryPage(SysExamSongQueryInfo queryInfo) {
-        return succeed(sysExamSongAccompanimentService.queryPage(queryInfo));
+        return succeed(sysExamSongAccompanimentService.queryAll(queryInfo));
     }
 
 }