浏览代码

Merge remote-tracking branch 'origin/yonge' into yonge

Joburgess 5 年之前
父节点
当前提交
da1ae9a500

+ 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() {

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

@@ -19,7 +19,7 @@ public interface ClassGroupService extends BaseService<Integer, ClassGroup> {
 	
 	public PageInfo<ClassGroup> queryPage(ClassGroupQueryInfo queryInfo);
 	
-	boolean createClassGroup(ClassGroup classGroup);
+	boolean create(ClassGroup classGroup);
 
     /**
      * 查询老师乐团课课程

+ 52 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -147,9 +147,58 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 	}
 
 	@Override
-	public boolean createClassGroup(ClassGroup classGroup) {
-		return true;
-	}
+    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+	public boolean create(ClassGroup classGroup) {
+		
+		if(classGroup.getType() == null){
+			throw new BizException("班级类型不能为空");
+		}
+		if(classGroup.getGroupType() == null){
+			throw new BizException("课程组类型不能为空");
+		}
+        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>

+ 7 - 0
mec-web/src/main/java/com/ym/mec/web/controller/ClassGroupController.java

@@ -57,6 +57,13 @@ public class ClassGroupController extends BaseController {
         return succeed(classGroupService.queryPage(queryInfo));
     }
 
+    @ApiOperation(value = "创建班级")
+    @PostMapping("/add")
+    @PreAuthorize("@pcs.hasPermissions('classGroup/create')")
+    public Object create(@RequestBody ClassGroup classGroup) throws Exception {
+        return succeed(classGroupService.create(classGroup));
+    }
+
     @ApiOperation(value = "新增单技班班级")
     @PostMapping("/add")
     @PreAuthorize("@pcs.hasPermissions('classGroup/add')")