|
@@ -3,6 +3,7 @@ package com.yonge.cooleshow.auth.service.impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.yonge.cooleshow.api.feign.AdminFeignService;
|
|
|
+import com.yonge.cooleshow.api.feign.TeacherFeignService;
|
|
|
import com.yonge.cooleshow.api.feign.dto.UserFriendInfoVO;
|
|
|
import com.yonge.cooleshow.auth.api.dto.QRLoginDto;
|
|
|
import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
|
|
@@ -14,6 +15,7 @@ import com.yonge.cooleshow.auth.api.vo.UserSetVo;
|
|
|
import com.yonge.cooleshow.auth.config.CustomerServiceConfig;
|
|
|
import com.yonge.cooleshow.auth.config.RongCloudConfig;
|
|
|
import com.yonge.cooleshow.auth.dal.dao.SysUserDao;
|
|
|
+import com.yonge.cooleshow.auth.enums.EClientType;
|
|
|
import com.yonge.cooleshow.auth.service.SysConfigService;
|
|
|
import com.yonge.cooleshow.auth.service.SysRoleMenuService;
|
|
|
import com.yonge.cooleshow.auth.service.SysUserRoleService;
|
|
@@ -28,6 +30,7 @@ import com.yonge.toolset.base.exception.BizException;
|
|
|
import com.yonge.toolset.base.util.ThreadPool;
|
|
|
import com.yonge.toolset.mybatis.dal.BaseDAO;
|
|
|
import com.yonge.toolset.mybatis.service.impl.BaseServiceImpl;
|
|
|
+import io.rong.models.response.TokenResult;
|
|
|
import io.rong.models.user.UserModel;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -36,10 +39,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.text.MessageFormat;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
@@ -65,6 +68,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
|
|
|
private AdminFeignService adminFeignService;
|
|
|
@Autowired
|
|
|
private CustomerServiceConfig customerServiceConfig;
|
|
|
+ @Autowired
|
|
|
+ private TeacherFeignService teacherFeignService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, SysUser> getDAO() {
|
|
@@ -347,4 +352,51 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
|
|
|
public void updateLockStatus(Long userId, Integer lockFlag, String sysUserType) {
|
|
|
sysUserDao.updateLockStatus(userId, lockFlag, sysUserType);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户信息
|
|
|
+ *
|
|
|
+ * @param userId 用户ID
|
|
|
+ * @param clientType 客户端类型
|
|
|
+ * @return SysUser
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public SysUser queryUserInfoWithIMToken(Long userId, EClientType clientType) {
|
|
|
+
|
|
|
+ // 查询用户基本信息
|
|
|
+ SysUser sysUser = sysUserDao.get(userId);
|
|
|
+
|
|
|
+ if (EClientType.STUDENT == clientType && Objects.nonNull(sysUser)) {
|
|
|
+
|
|
|
+ // 重新请求生成IM会话TOKEN
|
|
|
+ try {
|
|
|
+
|
|
|
+ HttpResponseResult<Boolean> recv = teacherFeignService.userTeacherIdentityInfo(userId);
|
|
|
+
|
|
|
+ if (Objects.nonNull(recv) && recv.getData()) {
|
|
|
+
|
|
|
+ String name = sysUser.getRealName();
|
|
|
+ if(StringUtils.isEmpty(name)){
|
|
|
+ name = sysUser.getUsername();
|
|
|
+ }
|
|
|
+
|
|
|
+ // IM用户ID
|
|
|
+ String imIdentity = MessageFormat.format("{0}:{1}", String.valueOf(sysUser.getId()), clientType.name());
|
|
|
+
|
|
|
+ TokenResult result = RongCloudConfig.rongCloud.user.register(new UserModel(imIdentity, name, sysUser.getAvatar()));
|
|
|
+ if(result.code.equals(200)){
|
|
|
+
|
|
|
+ sysUser.setImToken(result.getToken());
|
|
|
+ } else {
|
|
|
+ log.warn("queryUserInfoWithIMToken 获取用户token失败:{}", result.errorMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("queryUserInfoWithIMToken 获取用户token失败, userId={}", userId, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return sysUser;
|
|
|
+ }
|
|
|
}
|