|
@@ -1,38 +1,54 @@
|
|
|
package com.yonge.cooleshow.auth.service.impl;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import com.yonge.cooleshow.api.feign.AdminFeignService;
|
|
|
-import com.yonge.cooleshow.auth.api.dto.*;
|
|
|
+import com.yonge.cooleshow.api.feign.dto.UserFriendInfoVO;
|
|
|
+import com.yonge.cooleshow.auth.api.dto.QRLoginDto;
|
|
|
+import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
|
|
|
+import com.yonge.cooleshow.auth.api.dto.SysUserInfo;
|
|
|
+import com.yonge.cooleshow.auth.api.dto.SysUserQueryInfo;
|
|
|
+import com.yonge.cooleshow.auth.api.dto.UserSetReq;
|
|
|
+import com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
+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.service.SysConfigService;
|
|
|
+import com.yonge.cooleshow.auth.service.SysRoleMenuService;
|
|
|
+import com.yonge.cooleshow.auth.service.SysUserRoleService;
|
|
|
+import com.yonge.cooleshow.auth.service.SysUserService;
|
|
|
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
|
|
|
+import com.yonge.cooleshow.common.entity.ImUserModel;
|
|
|
import com.yonge.cooleshow.common.enums.CacheNameEnum;
|
|
|
import com.yonge.cooleshow.common.enums.SysUserType;
|
|
|
import com.yonge.cooleshow.common.enums.UserFirstTimeTypeEnum;
|
|
|
-import com.yonge.cooleshow.common.enums.UserLockFlag;
|
|
|
+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.user.UserModel;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
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 com.yonge.cooleshow.auth.api.entity.SysUser;
|
|
|
-import com.yonge.cooleshow.auth.api.vo.UserSetVo;
|
|
|
-import com.yonge.cooleshow.auth.dal.dao.SysUserDao;
|
|
|
-import com.yonge.cooleshow.auth.service.SysConfigService;
|
|
|
-import com.yonge.cooleshow.auth.service.SysRoleMenuService;
|
|
|
-import com.yonge.cooleshow.auth.service.SysUserRoleService;
|
|
|
-import com.yonge.cooleshow.auth.service.SysUserService;
|
|
|
-import com.yonge.cooleshow.common.constant.SysConfigConstant;
|
|
|
-import com.yonge.toolset.mybatis.dal.BaseDAO;
|
|
|
-import com.yonge.cooleshow.common.entity.ImUserModel;
|
|
|
-import com.yonge.toolset.base.exception.BizException;
|
|
|
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Random;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
+@RefreshScope
|
|
|
public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implements SysUserService {
|
|
|
|
|
|
@Autowired
|
|
@@ -47,6 +63,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
|
|
|
private RedissonClient redissonClient;
|
|
|
@Resource
|
|
|
private AdminFeignService adminFeignService;
|
|
|
+ @Autowired
|
|
|
+ private CustomerServiceConfig customerServiceConfig;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Long, SysUser> getDAO() {
|
|
@@ -135,16 +153,19 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public SysUserInfo registerUser(String phone, String clientId, String loginUserType) {
|
|
|
+
|
|
|
+ SysUserInfo userInfo = null;
|
|
|
if (StringUtils.equalsIgnoreCase(loginUserType, "TEACHER")) {
|
|
|
- return registerTeacher(phone);
|
|
|
+ userInfo = registerTeacher(phone);
|
|
|
} else if (StringUtils.equalsIgnoreCase(loginUserType, "STUDENT")) {
|
|
|
- return registerStudent(phone);
|
|
|
+ userInfo = registerStudent(phone);
|
|
|
} else if (StringUtils.equalsIgnoreCase(clientId, "TEACHER")) {
|
|
|
- return registerTeacher(phone);
|
|
|
+ userInfo = registerTeacher(phone);
|
|
|
} else if (StringUtils.equalsIgnoreCase(clientId, "STUDENT")) {
|
|
|
- return registerStudent(phone);
|
|
|
+ userInfo = registerStudent(phone);
|
|
|
}
|
|
|
- return null;
|
|
|
+
|
|
|
+ return userInfo;
|
|
|
}
|
|
|
|
|
|
private SysUserInfo registerTeacher(String phone) {
|
|
@@ -160,6 +181,7 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
|
|
|
//用户默认昵称
|
|
|
sysUser.setUsername("游客" + sysUser.getId());
|
|
|
sysUserDao.update(sysUser);
|
|
|
+
|
|
|
return queryUserInfoByPhone(phone);
|
|
|
}
|
|
|
|
|
@@ -176,9 +198,47 @@ public class SysUserServiceImpl extends BaseServiceImpl<Long, SysUser> implement
|
|
|
//用户默认昵称
|
|
|
sysUser.setUsername("游客" + sysUser.getId());
|
|
|
sysUserDao.update(sysUser);
|
|
|
+
|
|
|
return queryUserInfoByPhone(phone);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加系统客服好友消息
|
|
|
+ * @param sysUser SysUser
|
|
|
+ */
|
|
|
+ public void sendSysCustomerServiceFriendMessage(SysUser sysUser) {
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ ThreadPool.getExecutor().submit(() -> {
|
|
|
+
|
|
|
+ String customerService = customerServiceConfig.getCustomerService();
|
|
|
+ if (StringUtils.isNotEmpty(customerService)) {
|
|
|
+
|
|
|
+ List<String> collect = Arrays.stream(customerService.split(",")).collect(Collectors.toList());
|
|
|
+
|
|
|
+ Random rand = new Random();
|
|
|
+ String mobile = collect.get(rand.nextInt(collect.size()));
|
|
|
+
|
|
|
+ // 系统客服好友
|
|
|
+ SysUser friend = sysUserDao.queryByPhone(mobile);
|
|
|
+
|
|
|
+ // 发送添加系统客服好友消息
|
|
|
+ HttpResponseResult<Boolean> result = adminFeignService.customerService(UserFriendInfoVO.builder()
|
|
|
+ .userId(sysUser.getId())
|
|
|
+ .friendIds(Lists.newArrayList(friend.getId()))
|
|
|
+ .build());
|
|
|
+ log.info("sendSysCustomerServiceFriendMessage mobile={}, ret={}", mobile, JSON.toJSONString(result));
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("sendSysCustomerServiceFriendMessage userId={}", sysUser.getId(), e);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void refreshImToken(SysUser sysUser) {
|