|
@@ -1,9 +1,13 @@
|
|
|
package com.yonge.cooleshow.biz.dal.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Lists;
|
|
|
+import com.microsvc.toolkit.common.response.paging.QueryInfo;
|
|
|
import com.microsvc.toolkit.middleware.im.ImPluginContext;
|
|
|
import com.microsvc.toolkit.middleware.im.message.GroupMemberWrapper;
|
|
|
import com.microsvc.toolkit.middleware.im.message.MessageWrapper;
|
|
@@ -17,6 +21,8 @@ import com.yonge.cooleshow.biz.dal.dao.ImGroupDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dao.ImGroupMemberAuditDao;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.ImGroupResultDto;
|
|
|
import com.yonge.cooleshow.biz.dal.dto.ImGroupSearchDto;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.search.StudentSearch;
|
|
|
+import com.yonge.cooleshow.biz.dal.dto.search.TeacherSearch;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.CourseGroup;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.ImGroup;
|
|
|
import com.yonge.cooleshow.biz.dal.entity.ImGroupMember;
|
|
@@ -27,19 +33,14 @@ import com.yonge.cooleshow.biz.dal.enums.ClientEnum;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.ImGroupMemberRoleType;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.ImGroupType;
|
|
|
import com.yonge.cooleshow.biz.dal.enums.RoleEnum;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.CustomerServiceBatchSendingService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.ImGroupMemberService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.ImGroupService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.ImUserFriendService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.StudentStarService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysConfigService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.SysUserService;
|
|
|
-import com.yonge.cooleshow.biz.dal.service.TeacherService;
|
|
|
+import com.yonge.cooleshow.biz.dal.service.*;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.StudentVo;
|
|
|
+import com.yonge.cooleshow.biz.dal.vo.TeacherVo;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.im.ImGroupWrapper;
|
|
|
import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.util.ThreadPool;
|
|
|
+import com.yonge.toolset.mybatis.support.PageUtil;
|
|
|
import io.rong.RongCloud;
|
|
|
import io.rong.methods.message.history.History;
|
|
|
import io.rong.models.Result;
|
|
@@ -129,6 +130,9 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
@Autowired
|
|
|
private SysConfigService sysConfigService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private StudentService studentService;
|
|
|
+
|
|
|
@Override
|
|
|
public ImGroupDao getDao() {
|
|
|
return this.baseMapper;
|
|
@@ -929,5 +933,76 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
|
|
|
// 自动激活学生IM帐号
|
|
|
registerUser(groupMembers);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void importUser() {
|
|
|
+ int page = 1;
|
|
|
+ int rows = 200;
|
|
|
+ List<String[]> teachers = getTeachers(page, rows);
|
|
|
+ while (!teachers.isEmpty()) {
|
|
|
+ register(teachers);
|
|
|
+ page++;
|
|
|
+ teachers = getTeachers(page, rows);
|
|
|
+ }
|
|
|
+ page = 1;
|
|
|
+
|
|
|
+
|
|
|
+ List<String[]> student = getStudent(page, rows);
|
|
|
+ while (!student.isEmpty()) {
|
|
|
+ register(student);
|
|
|
+ page++;
|
|
|
+ student = getStudent(page, rows);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void register(List<String[]> users) {
|
|
|
+ for (String[] user : users) {
|
|
|
+ try {
|
|
|
+ register(user[0], ClientEnum.valueOf(user[1]), user[2], user[3]);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("注册失败:" + JSON.toJSONString(user) + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String[]> getStudent(int page,int rows) {
|
|
|
+ StudentSearch studentQuery = new StudentSearch();
|
|
|
+ studentQuery.setPage(page);
|
|
|
+ studentQuery.setRows(rows);
|
|
|
+ IPage<StudentVo> studentIPage = studentService.selectPage(PageUtil.getPage(studentQuery), studentQuery);
|
|
|
+ return studentIPage.getRecords().stream().map(next -> {
|
|
|
+ String[] strings = new String[4];
|
|
|
+ strings[0] = next.getUserId().toString();
|
|
|
+ strings[1] = ClientEnum.STUDENT.name();
|
|
|
+ strings[2] = next.getUsername();
|
|
|
+ String avatar = next.getAvatar();
|
|
|
+ strings[3] = avatar;
|
|
|
+ if (StringUtils.isEmpty(avatar)) {
|
|
|
+ strings[3] = "https://gyt.ks3-cn-beijing.ksyuncs.com/ktyq/student_default_avatar.png";
|
|
|
+ }
|
|
|
+ return strings;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String[]> getTeachers(int page, int rows) {
|
|
|
+ TeacherSearch query = new TeacherSearch();
|
|
|
+ query.setPage(page);
|
|
|
+ query.setRows(rows);
|
|
|
+ IPage<TeacherVo> teacherIPage = teacherService.selectPage(PageUtil.getPage(query), query);
|
|
|
+ List<TeacherVo> records = teacherIPage.getRecords();
|
|
|
+ return records.stream().map(next -> {
|
|
|
+ String[] strings = new String[4];
|
|
|
+ strings[0] = next.getUserId().toString();
|
|
|
+ strings[1] = ClientEnum.TEACHER.name();
|
|
|
+ strings[2] = next.getRealName();
|
|
|
+ String avatar = next.getAvatar();
|
|
|
+ strings[3] = avatar;
|
|
|
+ if (StringUtils.isEmpty(avatar)) {
|
|
|
+ strings[3] = "https://gyt.ks3-cn-beijing.ksyuncs.com/ktyq/teacher_default_avatar.png";
|
|
|
+ }
|
|
|
+ return strings;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
}
|
|
|
|