|
@@ -5,8 +5,7 @@ import java.util.Map.Entry;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
-import com.ym.mec.biz.dal.entity.ClassGroup;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
import com.ym.mec.biz.dal.enums.GroupType;
|
|
|
import com.ym.mec.biz.service.ImGroupService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -16,8 +15,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import com.ym.mec.auth.api.client.SysUserFeignService;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.biz.dal.entity.ImGroup;
|
|
|
-import com.ym.mec.biz.dal.entity.ImGroupMember;
|
|
|
import com.ym.mec.biz.service.ImGroupMemberService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
@@ -49,6 +46,18 @@ public class ImGroupMemberServiceImpl extends BaseServiceImpl<Long, ImGroupMembe
|
|
|
private MusicGroupDao musicGroupDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private PracticeGroupDao practiceGroupDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private VipGroupDao vipGroupDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private ImFeignService imFeignService;
|
|
|
|
|
|
@Autowired
|
|
@@ -59,18 +68,54 @@ public class ImGroupMemberServiceImpl extends BaseServiceImpl<Long, ImGroupMembe
|
|
|
return imGroupMemberDao;
|
|
|
}
|
|
|
|
|
|
+ public void joinGroup(Long imGroupId, Integer userId, String roleType, boolean isAdmin){
|
|
|
+ ClassGroup classGroup = classGroupDao.get(imGroupId.intValue());
|
|
|
+ String tags = classGroup.getName();
|
|
|
+ Map<Integer,String> userRoleMap = new HashMap<>();
|
|
|
+ //相关用户加入群组
|
|
|
+ //获取班级关联的老师列表
|
|
|
+ Set<Integer> teacherIds = classGroupTeacherMapperDao.queryTeacherIdsByClassGroupId(imGroupId.intValue(),null,null);
|
|
|
+ //获取班级关联的学员列表
|
|
|
+ Set<Integer> studentIds = classGroupStudentMapperDao.queryStudentIdsByClassGroupId(imGroupId.intValue(),null,null);
|
|
|
+ if(studentIds != null && studentIds.size() > 0){
|
|
|
+ for(Integer studentId : studentIds){
|
|
|
+ userRoleMap.put(studentId, null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(teacherIds != null && teacherIds.size() > 0){
|
|
|
+ for(Integer teacherId : teacherIds){
|
|
|
+ userRoleMap.put(teacherId, "指导老师");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(classGroup.getGroupType() == GroupType.MUSIC){
|
|
|
+ MusicGroup musicGroup = musicGroupDao.get(classGroup.getMusicGroupId());
|
|
|
+ tags = musicGroup.getName();
|
|
|
+ userRoleMap.put(musicGroup.getEducationalTeacherId(), "乐团主管");
|
|
|
+ userRoleMap.put(musicGroup.getTeamTeacherId(), "运营主管");
|
|
|
+ userRoleMap.put(musicGroup.getDirectorUserId(), "乐队指导");
|
|
|
+ }else if(classGroup.getGroupType() == GroupType.PRACTICE){
|
|
|
+ PracticeGroup practiceGroup = practiceGroupDao.get(Long.parseLong(classGroup.getMusicGroupId()));
|
|
|
+ tags = practiceGroup.getName();
|
|
|
+ userRoleMap.put(practiceGroup.getUserId(), "指导老师");
|
|
|
+ userRoleMap.put(practiceGroup.getEducationalTeacherId(), "乐团主管");
|
|
|
+ }else if(classGroup.getGroupType() == GroupType.VIP){
|
|
|
+ VipGroup vipGroup = vipGroupDao.get(Long.parseLong(classGroup.getMusicGroupId()));
|
|
|
+ userRoleMap.put(vipGroup.getUserId(), "指导老师");
|
|
|
+ userRoleMap.put(vipGroup.getEducationalTeacherId(), "乐团主管");
|
|
|
+ tags = vipGroup.getName();
|
|
|
+ }
|
|
|
+ imGroupService.create(imGroupId, null, classGroup.getName(), null, null, tags, null, classGroup.getGroupType().getCode());
|
|
|
+ join(imGroupId,userId,roleType,isAdmin);
|
|
|
+ join(imGroupId,userRoleMap);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean join(Long imGroupId, Integer userId, String roleType, boolean isAdmin) {
|
|
|
ImGroup imGroup = imGroupDao.getLocked(imGroupId);
|
|
|
if (imGroup == null) {
|
|
|
- ClassGroup classGroup = classGroupDao.get(imGroupId.intValue());
|
|
|
- String tags = classGroup.getName();
|
|
|
- if(classGroup.getGroupType() == GroupType.MUSIC){
|
|
|
- MusicGroup musicGroup = musicGroupDao.get(classGroup.getMusicGroupId());
|
|
|
- tags = musicGroup.getName();
|
|
|
- }
|
|
|
- imGroup = imGroupService.create(imGroupId, null, classGroup.getName(), null, null, tags, null, classGroup.getGroupType().getCode());
|
|
|
+ joinGroup(imGroupId,userId,roleType,isAdmin);
|
|
|
+ return true;
|
|
|
}
|
|
|
//检查用户是否已存在
|
|
|
List<ImGroupMember> imGroupMemberList = imGroupMemberDao.queryByImGroupIdAndUserId(imGroupId.toString(), userId.toString());
|