yonge 5 years ago
parent
commit
43641d18de

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/dal/page/ClassGroupQueryInfo.java

@@ -11,16 +11,16 @@ public class ClassGroupQueryInfo extends QueryInfo {
 	@ApiModelProperty(value = "班级编号", required = false)
 	private Integer id;
 
-	@ApiModelProperty(value = "课程组编号", required = true)
+	@ApiModelProperty(value = "课程组编号", required = false)
     private String musicGroupId;
     
-	@ApiModelProperty(value = "班级类型(普通班级、合奏班级、提高课班级、VIP班级、试听课)", required = true)
+	@ApiModelProperty(value = "班级类型(普通班级、合奏班级、提高课班级、VIP班级、试听课)", required = false)
     private ClassGroupTypeEnum type;
     
 	@ApiModelProperty(value = "课程组类型(MUSIC、VIP、DEMO、PRACTICE、COMM、REPAIR)", required = true)
     private GroupType groupType;
     
-    @ApiModelProperty(value = "班级名称", required = true)
+    @ApiModelProperty(value = "班级名称", required = false)
     private String name;
 
 	public Integer getId() {

+ 43 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -148,8 +148,49 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
 	@Override
 	public boolean createClassGroup(ClassGroup classGroup) {
-		return true;
-	}
+        String userIds = classGroup.getUserIds();
+        
+        if(StringUtils.isBlank(userIds)){
+        	userIds = "";
+        }
+
+        Set<String> userIdStrSet = new HashSet<>(Arrays.asList(userIds.split(",")));
+
+        Date date = new Date();
+        classGroup.setCreateTime(date);
+        classGroup.setUpdateTime(date);
+        classGroup.setType(ClassGroupTypeEnum.NORMAL);
+        classGroup.setExpectStudentNum(userIdStrSet.size());
+        classGroup.setStudentNum(userIdStrSet.size());
+        insert(classGroup);
+
+        //2、插入班级学生关联关系
+        List<Integer> userIdList = new ArrayList<>();
+        List<ClassGroupStudentMapper> classGroupStudentList = new ArrayList<>();
+        for (String userId : userIdStrSet) {
+            ClassGroupStudentMapper classGroupStudentMapper = new ClassGroupStudentMapper();
+            classGroupStudentMapper.setMusicGroupId(classGroup.getMusicGroupId());
+            classGroupStudentMapper.setClassGroupId(classGroup.getId());
+            classGroupStudentMapper.setUserId(Integer.parseInt(userId));
+            classGroupStudentMapper.setCreateTime(date);
+            classGroupStudentMapper.setStatus(ClassGroupStudentStatusEnum.NORMAL);
+            classGroupStudentMapper.setGroupType(GroupType.MUSIC);
+            classGroupStudentList.add(classGroupStudentMapper);
+
+            StudentRegistration studentRegistration = new StudentRegistration();
+            studentRegistration.setClassGroupId(classGroup.getId());
+            studentRegistration.setUserId(Integer.parseInt(userId));
+            studentRegistration.setMusicGroupId(classGroup.getMusicGroupId());
+            studentRegistrationDao.updateByUserIdAndMusicGroupId(studentRegistration);
+
+            userIdList.add(Integer.parseInt(userId));
+        }
+        classGroupStudentMapperDao.classGroupStudentsInsert(classGroupStudentList);
+
+        //加入IM群组
+        addImGroup(classGroup, userIdList);
+        return true;
+    }
 
 	@Override
     public List<ClassGroup> findClassGroup4Teacher(Integer teacherId) {

+ 10 - 10
mec-biz/src/main/resources/config/mybatis/ClassGroupMapper.xml

@@ -150,19 +150,19 @@
         SELECT * FROM class_group 
         <where>
         	<if test="id != null">
-				id_ = #{id}
+				and id_ = #{id}
 			</if>
         	<if test="type != null">
-				type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+				and type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
         	<if test="groupType != null">
-				group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+				and group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
         	<if test="musicGroupId != null and musicGroupId != ''">
-				music_group_id_ = #{musicGroupId}
+				and music_group_id_ = #{musicGroupId}
 			</if>
         	<if test="name != null and name != ''">
-				name_ LIKE CONCAT('%',#{name},'%')
+				and name_ LIKE CONCAT('%',#{name},'%')
 			</if>
         </where>
         ORDER BY id_ desc
@@ -174,19 +174,19 @@
         SELECT COUNT(*) FROM class_group
         <where>
         	<if test="id != null">
-				id_ = #{id}
+				and id_ = #{id}
 			</if>
         	<if test="type != null">
-				type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+				and type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
         	<if test="groupType != null">
-				group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+				and group_type_ = #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
 			</if>
         	<if test="musicGroupId != null and musicGroupId != ''">
-				music_group_id_ = #{musicGroupId}
+				and music_group_id_ = #{musicGroupId}
 			</if>
         	<if test="name != null and name != ''">
-				name_ LIKE CONCAT('%',#{name},'%')
+				and name_ LIKE CONCAT('%',#{name},'%')
 			</if>
         </where>
     </select>