Explorar el Código

消息通知改造

zouxuan hace 1 año
padre
commit
d273850eba

+ 37 - 37
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/SysUserServiceImpl.java

@@ -1,6 +1,10 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
+import com.dayaedu.cbs.common.enums.EAppKey;
+import com.dayaedu.cbs.openfeign.client.MessageFeignClientService;
+import com.dayaedu.cbs.openfeign.wrapper.message.CbsMessageWrapper;
 import com.google.common.collect.Lists;
+import com.microsvc.toolkit.common.response.template.R;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.dto.RealnameAuthReq;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
@@ -21,42 +25,34 @@ import com.yonge.toolset.thirdparty.message.MessageSenderPluginContext;
 import com.yonge.toolset.thirdparty.user.realname.RealnameAuthenticationPlugin;
 import com.yonge.toolset.utils.idcard.IdcardInfoExtractor;
 import com.yonge.toolset.utils.idcard.IdcardValidator;
-import jodd.util.StringUtil;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
-import org.springframework.util.StringUtils;
 
 import javax.annotation.Resource;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Optional;
-import java.util.stream.Collectors;
 
 @Service
 public class SysUserServiceImpl implements SysUserService {
 
-    @Autowired
+    @Resource
     private SysUserFeignService sysUserFeignService;
-
-    @Autowired
+    @Resource
     private RealnameAuthenticationPlugin realnameAuthenticationPlugin;
-    @Autowired
+    @Resource
     private SysUserMapper sysUserMapper;
-
     @Resource
     private SysUserContractRecordService sysUserContractRecordService;
-
-    @Autowired
+    @Resource
     private StudentService studentService;
-
-    @Autowired
+    @Resource
     private TeacherService teacherService;
-
-    @Autowired
+    @Resource
     private MessageSenderPluginContext messageSenderPluginContext;
-
+    @Resource
+    private MessageFeignClientService messageFeignClientService;
     @Override
     public SysUserMapper getDao() {
         return sysUserMapper;
@@ -164,27 +160,31 @@ public class SysUserServiceImpl implements SysUserService {
 
     @Override
     public void imDeviceId(UserInfoWrapper.UpdateUser info) {
-
-        switch (info.getClient()) {
-            case STUDENT:
-            case TENANT_STUDENT:
-                Student student = new Student();
-                student.setUserId(info.getUserId().longValue());
-                student.setImDeviceId(info.getImDeviceId());
-                studentService.updateById(student);
-
-                break;
-            case TEACHER:
-                Teacher teacher = new Teacher();
-                teacher.setUserId(info.getUserId().longValue());
-                teacher.setImDeviceId(info.getImDeviceId());
-                teacherService.updateById(teacher);
-                break;
-            default:
-                break;
+        CbsMessageWrapper.UpdateDevice updateDevice = new CbsMessageWrapper.UpdateDevice();
+        updateDevice.setUserId(info.getUserId().longValue());
+        updateDevice.setDeviceIds(Lists.newArrayList(info.getImDeviceId()));
+        updateDevice.setClientType(info.getClient().getCode());
+        updateDevice.setAppKey(EAppKey.KLX);
+        R<Boolean> booleanR = messageFeignClientService.updateDevice(updateDevice);
+        if (booleanR != null && booleanR.feignData()) {
+            switch (info.getClient()) {
+                case STUDENT:
+                case TENANT_STUDENT:
+                    Student student = new Student();
+                    student.setUserId(info.getUserId().longValue());
+                    student.setImDeviceId(info.getImDeviceId());
+                    studentService.updateById(student);
+
+                    break;
+                case TEACHER:
+                    Teacher teacher = new Teacher();
+                    teacher.setUserId(info.getUserId().longValue());
+                    teacher.setImDeviceId(info.getImDeviceId());
+                    teacherService.updateById(teacher);
+                    break;
+                default:
+                    break;
+            }
         }
-
-        messageSenderPluginContext.getMessageSenderPlugin(MessageSenderPluginContext.MessageSender.JIGUANG)
-            .deviceRemoveAlias(info.getUserId().toString(),Lists.newArrayList(info.getImDeviceId()),info.getClient().getCode());
     }
 }