Explorar o código

Merge remote-tracking branch 'origin/master'

Joburgess %!s(int64=5) %!d(string=hai) anos
pai
achega
0c091f66ba

+ 5 - 0
cms/src/main/java/com/ym/mec/cms/dal/dao/SysNewsInformationDao.java

@@ -1,6 +1,7 @@
 package com.ym.mec.cms.dal.dao;
 
 import java.util.List;
+import java.util.Map;
 
 import com.ym.mec.cms.dal.entity.SysNewsInformation;
 import com.ym.mec.common.dal.BaseDAO;
@@ -20,4 +21,8 @@ public interface SysNewsInformationDao extends BaseDAO<Long, SysNewsInformation>
 	 * @return
 	 */
 	int deleteWithLogical(Long id);
+	
+	List<SysNewsInformation> queryHomePage(Map<String, Object> params);
+	
+	int queryHomeCount(Map<String, Object> params);
 }

+ 28 - 7
cms/src/main/java/com/ym/mec/cms/service/impl/SysNewsInformationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.cms.service.impl;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -7,6 +8,7 @@ import java.util.Map;
 import com.ym.mec.cms.controller.queryinfo.NewsInformationQueryInfo;
 import com.ym.mec.cms.dal.entity.NewsStatusEnum;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.page.QueryInfo;
 
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -52,28 +54,47 @@ public class SysNewsInformationServiceImpl extends BaseServiceImpl<Long, SysNews
 		MapUtil.populateMap(params, queryInfo);
 
 		queryInfo.setType(3);
-		int count = sysNewsInformationDao.queryCount(params);
+		int count = sysNewsInformationDao.queryHomeCount(params);
 		if(count == 0){
 			queryInfo.setMemo(null);
 		}
-		homeList.put("banner",queryPage(queryInfo));
+		homeList.put("banner",queryHomePage(queryInfo));
 		
 		queryInfo.setMemo(memo);
 		queryInfo.setType(6);
-		count = sysNewsInformationDao.queryCount(params);
+		count = sysNewsInformationDao.queryHomeCount(params);
 		if(count == 0){
 			queryInfo.setMemo(null);
 		}
-		homeList.put("app",queryPage(queryInfo));
+		homeList.put("app",queryHomePage(queryInfo));
 		
 		queryInfo.setMemo(null);
 		queryInfo.setType(1);
-		homeList.put("active",queryPage(queryInfo));
+		homeList.put("active",queryHomePage(queryInfo));
 		queryInfo.setType(2);
-		homeList.put("hot",queryPage(queryInfo));
+		homeList.put("hot",queryHomePage(queryInfo));
 		queryInfo.setType(5);
-		homeList.put("flash",queryPage(queryInfo));
+		homeList.put("flash",queryHomePage(queryInfo));
 		return homeList;
 	}
+	
+	private PageInfo<SysNewsInformation> queryHomePage(QueryInfo queryInfo) {
+		PageInfo<SysNewsInformation> pageInfo = new PageInfo<SysNewsInformation>(queryInfo.getPage(), queryInfo.getRows());
+		Map<String, Object> params = new HashMap<String, Object>();
+		MapUtil.populateMap(params, queryInfo);
+		
+		List<SysNewsInformation> dataList = null;
+		int count = sysNewsInformationDao.queryHomeCount(params);
+		if (count > 0) {
+			pageInfo.setTotal(count);
+			params.put("offset", pageInfo.getOffset());
+			dataList = sysNewsInformationDao.queryHomePage(params);
+		}
+		if (count == 0) {
+			dataList = new ArrayList<SysNewsInformation>();
+		}
+		pageInfo.setRows(dataList);
+		return pageInfo;
+	}
 
 }

+ 56 - 9
cms/src/main/resources/config/mybatis/SysNewsInformationMapper.xml

@@ -37,14 +37,6 @@
 			<if test="search != null">
 				and title_ like '%' #{search} '%'
 			</if>
-			<choose>
-		        <when test="memo != null and memo != ''">
-		            and memo_ = #{memo}
-		        </when>
-		        <otherwise>
-		            and memo_ is null
-		        </otherwise>
-		    </choose>
 		</where>
 	</sql>
 	
@@ -114,7 +106,7 @@
 	<select id="queryPage" resultMap="SysNewsInformation" parameterType="map">
 		SELECT * FROM sys_news_information
 		<include refid="queryCondition" />
-		order by order_ desc,update_time_ desc
+		order by status_ desc,order_ desc,update_time_ desc
 		<include refid="global.limit"/>
 	</select>
 	
@@ -137,4 +129,59 @@
 	<update id="deleteWithLogical">
 		UPDATE sys_news_information SET del_flag_ = 1,update_time_ = NOW() WHERE id_ = #{id}
 	</update>
+	
+	<!-- 分页查询 -->
+	<select id="queryHomePage" resultMap="SysNewsInformation"
+		parameterType="map">
+		SELECT * FROM sys_news_information where del_flag_=0
+		<if test="type != null">
+			and type_ = #{type}
+		</if>
+		<if test="status != null">
+			and status_ = #{status,
+			typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+		</if>
+		<if test="title != null">
+			and title_ like '%' #{title} '%'
+		</if>
+		<if test="search != null">
+			and title_ like '%' #{search} '%'
+		</if>
+		<choose>
+			<when test="memo != null and memo != ''">
+				and memo_ = #{memo}
+			</when>
+			<otherwise>
+				and memo_ is null
+			</otherwise>
+		</choose>
+		order by status_ desc,order_ desc,update_time_ desc
+		<include refid="global.limit" />
+	</select>
+
+	<!-- 查询当前表的总记录数 -->
+	<select id="queryHomeCount" resultType="int">
+		SELECT COUNT(*) FROM sys_news_information where del_flag_=0
+		<if test="type != null">
+			and type_ = #{type}
+		</if>
+		<if test="status != null">
+			and status_ = #{status,
+			typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+		</if>
+		<if test="title != null">
+			and title_ like '%' #{title} '%'
+		</if>
+		<if test="search != null">
+			and title_ like '%' #{search} '%'
+		</if>
+		<choose>
+			<when test="memo != null and memo != ''">
+				and memo_ = #{memo}
+			</when>
+			<otherwise>
+				and memo_ is null
+			</otherwise>
+		</choose>
+	</select>
 </mapper>

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/BatchInsertCoursesDto.java

@@ -25,6 +25,8 @@ public class BatchInsertCoursesDto {
 	private Integer schoolId;
 
 	private boolean isJumpHoliday;
+	
+    private List<Long> courseScheduleIdList;
 
 	public String getMusicGroupId() {
 		return musicGroupId;
@@ -97,4 +99,12 @@ public class BatchInsertCoursesDto {
 	public void setIsJumpHoliday(boolean isJumpHoliday) {
 		this.isJumpHoliday = isJumpHoliday;
 	}
+
+	public List<Long> getCourseScheduleIdList() {
+		return courseScheduleIdList;
+	}
+
+	public void setCourseScheduleIdList(List<Long> courseScheduleIdList) {
+		this.courseScheduleIdList = courseScheduleIdList;
+	}
 }

+ 8 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java

@@ -36,7 +36,7 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 * @param courseScheduleIds: 课程计划编号列表
 	 * @return int
 	 */
-	void deleteCourseSchedules(List<Long> courseScheduleIds);
+	void batchDeleteCourseSchedules(List<Long> courseScheduleIds);
 
 	/**
 	 * @describe 删除乐团下所有未上的课时
@@ -85,6 +85,13 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 */
 	boolean batchAddCourseSchedule(Integer classGroupId, int coursesTimes, Date startDate, List<CourseTimeDto> teachingArrangementList,
 			TeachModeEnum teachMode, CourseScheduleType type, Integer schoolId, boolean isJumpHoliday);
+	
+	/**
+	 * 批量调整
+	 * @param batchInsertCoursesDto
+	 * @return
+	 */
+	boolean batchUpdateCourseSchedule(BatchInsertCoursesDto batchInsertCoursesDto);
 
 	/**
 	 * @Author: Joburgess

+ 25 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -168,7 +168,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
     @Override
     @Transactional(rollbackFor = Exception.class)
-	public void deleteCourseSchedules(List<Long> courseScheduleIds) {
+	public void batchDeleteCourseSchedules(List<Long> courseScheduleIds) {
 
 		List<CourseSchedule> courseScheduleList = courseScheduleDao.findByCourseScheduleIds(courseScheduleIds);
 
@@ -211,7 +211,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
         List<Long> courseScheduleIds = musicGroupCourseSchedules.stream()
                 .map(CourseSchedule::getId)
                 .collect(Collectors.toList());
-        deleteCourseSchedules(courseScheduleIds);
+        batchDeleteCourseSchedules(courseScheduleIds);
     }
 
     @Override
@@ -565,6 +565,29 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
     @Override
     @Transactional(rollbackFor = Exception.class)
+	public boolean batchUpdateCourseSchedule(BatchInsertCoursesDto batchInsertCoursesDto) {
+
+		List<CourseSchedule> courseScheduleList = courseScheduleDao.findByCourseScheduleIds(batchInsertCoursesDto.getCourseScheduleIdList());
+		List<Integer> classGroupList = courseScheduleList.stream().distinct().map(CourseSchedule::getClassGroupId).collect(Collectors.toList());
+
+		if (classGroupList == null || classGroupList.size() != 1) {
+			throw new BizException("修改失败,只支持同一个班级的课程批量调整");
+		}
+
+		Integer classGroupId = classGroupList.get(0);
+
+		// 批量上课
+		batchDeleteCourseSchedules(batchInsertCoursesDto.getCourseScheduleIdList());
+
+		// 批量加课
+		batchAddCourseSchedule(classGroupId, batchInsertCoursesDto.getCourseScheduleIdList().size(), batchInsertCoursesDto.getStartDate(),
+				batchInsertCoursesDto.getTeachingArrangementList(), batchInsertCoursesDto.getTeachMode(), batchInsertCoursesDto.getType(),
+				batchInsertCoursesDto.getSchoolId(), batchInsertCoursesDto.getIsJumpHoliday());
+		return true;
+	}
+
+	@Override
+    @Transactional(rollbackFor = Exception.class)
     public void batchAddCourseSchedule(List<CourseSchedule> courseSchedules) {
         if (Objects.isNull(courseSchedules) && courseSchedules.size() <= 0) {
             throw new BizException("参数错误!");

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -470,7 +470,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 					.map(CourseSchedule::getId)
 					.collect(Collectors.toList());
 			//删除对应的课程及相关信息
-			courseScheduleService.deleteCourseSchedules(deleteCourseScheduleIds);
+			courseScheduleService.batchDeleteCourseSchedules(deleteCourseScheduleIds);
 
 		}
 

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

@@ -137,7 +137,7 @@ public class CourseScheduleController extends BaseController {
         }
         long[] ints = Arrays.asList(courseScheduleIds.split(",")).stream().mapToLong(Long::parseLong).toArray();
         Long[] longs = ArrayUtils.toObject(ints);
-        scheduleService.deleteCourseSchedules(Arrays.asList(longs));
+        scheduleService.batchDeleteCourseSchedules(Arrays.asList(longs));
         return succeed();
     }
 
@@ -282,6 +282,14 @@ public class CourseScheduleController extends BaseController {
         return succeed();
     }
 
+    @ApiOperation(value = "课程批量调整")
+    @PostMapping("/batchUpdateCourseSchedule")
+    @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchUpdateCourseSchedule')")
+    public Object batchUpdateCourseSchedule(@RequestBody BatchInsertCoursesDto batchInsertCoursesDto){
+        scheduleService.batchUpdateCourseSchedule(batchInsertCoursesDto);
+        return succeed();
+    }
+
     @ApiOperation(value = "vip课批量新增")
     @PostMapping("/batchAppendVipGroupCourses")
     @PreAuthorize("@pcs.hasPermissions('courseSchedule/batchAppendVipGroupCourses')")