|
@@ -4,6 +4,10 @@ import java.util.*;
|
|
|
import java.util.Map.Entry;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
+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;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -11,11 +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.dao.ImGroupDao;
|
|
|
-import com.ym.mec.biz.dal.dao.ImGroupMemberDao;
|
|
|
-import com.ym.mec.biz.dal.dao.TeacherDao;
|
|
|
-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;
|
|
@@ -35,9 +34,30 @@ public class ImGroupMemberServiceImpl extends BaseServiceImpl<Long, ImGroupMembe
|
|
|
private ImGroupDao imGroupDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private ImGroupService imGroupService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private TeacherDao teacherDao;
|
|
|
|
|
|
@Autowired
|
|
|
+ private ClassGroupDao classGroupDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private MusicGroupDao musicGroupDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PracticeGroupDao practiceGroupDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private VipGroupDao vipGroupDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupTeacherMapperDao classGroupTeacherMapperDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupStudentMapperDao classGroupStudentMapperDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private ImFeignService imFeignService;
|
|
|
|
|
|
@Autowired
|
|
@@ -48,12 +68,55 @@ public class ImGroupMemberServiceImpl extends BaseServiceImpl<Long, ImGroupMembe
|
|
|
return imGroupMemberDao;
|
|
|
}
|
|
|
|
|
|
+ public void joinGroup(Long imGroupId, Integer userId, String roleType, boolean isAdmin,Map<Integer,String> userRoleMap){
|
|
|
+ ClassGroup classGroup = classGroupDao.get(imGroupId.intValue());
|
|
|
+ String tags = classGroup.getName();
|
|
|
+ //相关用户加入群组
|
|
|
+ //获取班级关联的老师列表
|
|
|
+ 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(), tags, tags, tags, null, classGroup.getGroupType().getCode());
|
|
|
+ if(userId != null){
|
|
|
+ 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) {
|
|
|
- throw new BizException("加入群组失败:群组[{}]不存在", imGroupId);
|
|
|
+ joinGroup(imGroupId,userId,roleType,isAdmin,new HashMap<>());
|
|
|
+ return true;
|
|
|
}
|
|
|
//检查用户是否已存在
|
|
|
List<ImGroupMember> imGroupMemberList = imGroupMemberDao.queryByImGroupIdAndUserId(imGroupId.toString(), userId.toString());
|
|
@@ -97,7 +160,7 @@ public class ImGroupMemberServiceImpl extends BaseServiceImpl<Long, ImGroupMembe
|
|
|
public boolean join(Long imGroupId, Map<Integer, String> userRoleMap) {
|
|
|
ImGroup imGroup = imGroupDao.getLocked(imGroupId);
|
|
|
if (imGroup == null) {
|
|
|
- throw new BizException("加入群组失败:群组[{}]不存在", imGroupId);
|
|
|
+ joinGroup(imGroupId,null,null,false,userRoleMap);
|
|
|
}
|
|
|
//检查用户是否已存在
|
|
|
List<Integer> existUserIdList = imGroupMemberDao.queryByImGroupIdAndUserId(imGroupId.toString(), userRoleMap.keySet().stream().filter(Objects::nonNull).map(Objects::toString)
|