Pārlūkot izejas kodu

Merge branch 'feature/0721-tenant' of http://git.dayaedu.com/yonge/cooleshow into feature/0721-tenant

haonan 1 gadu atpakaļ
vecāks
revīzija
13e5693902

+ 15 - 3
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/TenantUnbindHistoryController.java

@@ -7,9 +7,11 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.microsvc.toolkit.common.response.template.R;
 import com.yonge.cooleshow.biz.dal.entity.Employee;
 import com.yonge.cooleshow.biz.dal.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.TenantInfo;
 import com.yonge.cooleshow.biz.dal.entity.TenantUnbindHistory;
 import com.yonge.cooleshow.biz.dal.service.EmployeeService;
 import com.yonge.cooleshow.biz.dal.service.SysUserService;
+import com.yonge.cooleshow.biz.dal.service.TenantInfoService;
 import com.yonge.cooleshow.biz.dal.service.TenantStaffService;
 import com.yonge.cooleshow.biz.dal.service.TenantUnbindHistoryService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantUnbindHistoryWrapper;
@@ -44,6 +46,9 @@ public class TenantUnbindHistoryController {
     @Autowired
     private SysUserService sysUserService;
 
+    @Autowired
+    private TenantInfoService tenantInfoService;
+
     @ApiOperation(value = "查询分页", notes = "机构解绑历史表- 传入 TenantUnbindHistoryWrapper.TenantUnbindHistoryQuery")
     @PostMapping("/page")
     public R<PageInfo<TenantUnbindHistoryWrapper.TenantUnbindHistory>> page(@RequestBody TenantUnbindHistoryWrapper.TenantUnbindHistoryQuery query) {
@@ -59,13 +64,20 @@ public class TenantUnbindHistoryController {
                         .collect(Collectors.toList());
         Map<Long, SysUser> mapByIds = sysUserService.getMapByIds(userIds);
 
+        List<Long> tenantIds =
+                pages.getRecords().stream().map(TenantUnbindHistory::getTenantId).distinct()
+                        .collect(Collectors.toList());
+        Map<Long, TenantInfo> tenantInfoMap = tenantInfoService.getMapByIds(tenantIds);
         List<TenantUnbindHistoryWrapper.TenantUnbindHistory> histories = records.stream().map(next -> {
             TenantUnbindHistoryWrapper.TenantUnbindHistory tenantUnbindHistory =
                     JSON.parseObject(JSON.toJSONString(next), TenantUnbindHistoryWrapper.TenantUnbindHistory.class);
             SysUser orDefault = mapByIds.getOrDefault(next.getVerifyUserId(), new SysUser());
-            tenantUnbindHistory.setVerifyUserName(StringUtils.isEmpty(orDefault.getRealName()) ?
-                    orDefault.getUsername() :
-                    orDefault.getRealName());
+            tenantUnbindHistory.setVerifyUserName(orDefault.getUsername());
+            if(tenantInfoMap.containsKey(next.getTenantId())){
+                TenantInfo tenantInfo = tenantInfoMap.get(next.getTenantId());
+                tenantUnbindHistory.setTenantUserName(tenantInfo.getUsername());
+                tenantUnbindHistory.setTenantPhone(tenantInfo.getPhone());
+            }
             return tenantUnbindHistory;
 
         }).collect(Collectors.toList());

+ 5 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/StudentServiceImpl.java

@@ -597,6 +597,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
                     .set(Student::getTenantId, studentInfo.getTenantId())
                     .set(Student::getUserId, sysUser.getId())
                     .set(Student::getUpdateTime, new Date())
+                    .set(Student::getAvatar,studentInfo.getAvatar())
                     .eq(Student::getUserId, studentInfo.getId())
                     .update();
         } else {
@@ -605,8 +606,12 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
             newStudent.setSubjectId(studentInfo.getSubjectId());
             newStudent.setUpdateTime(new Date());
             newStudent.setTenantId(studentInfo.getTenantId());
+            newStudent.setAvatar(studentInfo.getAvatar());
             this.getBaseMapper().updateById(newStudent);
         }
+        com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = sysUserMapper.selectById(studentInfo.getId());
+        sysUser.setGender(studentInfo.getGender());
+        sysUserMapper.updateById(sysUser);
         return true;
     }
 

+ 6 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantUnbindHistoryWrapper.java

@@ -75,6 +75,12 @@ public class TenantUnbindHistoryWrapper {
         @ApiModelProperty("机构名称")
         private String tenantName;
 
+        @ApiModelProperty("机构员工")
+        private String tenantUserName;
+
+        @ApiModelProperty("机构员工")
+        private String tenantPhone;
+
         @ApiModelProperty("用户ID")
         private Long userId;
 

+ 1 - 1
cooleshow-user/user-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -107,7 +107,7 @@
         u.del_flag_ as delFlag,
         (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
         (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
-        (case when t.tenant_id_ = -1 then '平台老师' else ti.name_ end) as tenantName
+        (case when t.tenant_id_ = -1 then '平台' else ti.name_ end) as tenantName
         FROM teacher t
         left join sys_user u on t.user_id_ = u.id_
         left join (

+ 28 - 24
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenStudentController.java

@@ -39,6 +39,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 
 @Slf4j
@@ -109,30 +110,33 @@ public class OpenStudentController extends BaseController {
                 if (one.getTenantId().equals(-1L)) {
                     throw new BizException("该手机号已经注册为平台学生");
                 }
-                if (one.getTenantId().equals(tenantId)) {
-                    //已经注册当前机构,请勿重复注册
-                    throw new BizException(5004, tenantInfo.getName());
-                }
+//                if (one.getTenantId().equals(tenantId)) {
+//                    //已经注册当前机构,请勿重复注册
+//                    throw new BizException(5004, tenantInfo.getName());
+//                }
                 // 转到其他机构
-                if ((student.getUpdateTenant() == null ||
-                        !student.getUpdateTenant())) {
-                    throw new BizException(5004, "该手机号已经注册为其他平台学生");
-                }
-                // 退群
-                List<ImGroupMember> groupMembers = imGroupMemberService.lambdaQuery()
-                        .eq(ImGroupMember::getRoleType, ImGroupMemberRoleType.STUDENT)
-                        .eq(ImGroupMember::getIsAdmin, false)
-                        .eq(ImGroupMember::getUserId, one.getUserId())
-                        .list();
-                List<String> groupIdList = groupMembers.stream().map(ImGroupMember::getGroupId)
-                        .distinct().collect(Collectors.toList());
-                groupIdList.forEach(groupId -> {
-                    try {
-                        imGroupService.quit(groupId, one.getUserId(), ClientEnum.STUDENT);
-                    } catch (Exception e) {
-                        log.error("学生注册,切换机构退群失败:{}", e.getMessage());
+                if ((!Objects.equals(student.getTenantId(), one.getTenantId()))) {
+                    if(student.getUpdateTenant() == null || Boolean.FALSE.equals(student.getUpdateTenant())){
+                        TenantInfo oldTenant = tenantInfoService.getById(one.getTenantId());
+                        throw new BizException(5004, oldTenant.getName());
+                    } else {
+                        // 退群
+                        List<ImGroupMember> groupMembers = imGroupMemberService.lambdaQuery()
+                                .eq(ImGroupMember::getRoleType, ImGroupMemberRoleType.STUDENT)
+                                .eq(ImGroupMember::getIsAdmin, false)
+                                .eq(ImGroupMember::getUserId, one.getUserId())
+                                .list();
+                        List<String> groupIdList = groupMembers.stream().map(ImGroupMember::getGroupId)
+                                .distinct().collect(Collectors.toList());
+                        groupIdList.forEach(groupId -> {
+                            try {
+                                imGroupService.quit(groupId, one.getUserId(), ClientEnum.STUDENT);
+                            } catch (Exception e) {
+                                log.error("学生注册,切换机构退群失败:{}", e.getMessage());
+                            }
+                        });
                     }
-                });
+                }
 
                 // 更新头像
                 if (StringUtils.isEmpty(student.getAvatar())) {
@@ -152,9 +156,8 @@ public class OpenStudentController extends BaseController {
             student.setAvatar(avatar);
         }
 
-        StudentWrapper.Student studentInfo = JSON.parseObject(JSON.toJSONString(student), StudentWrapper.Student.class);
+        Student studentInfo = JSON.parseObject(JSON.toJSONString(student), Student.class);
         studentInfo.setTenantId(tenantInfo.getId());
-        studentService.save(studentInfo);
 
         // 加好友
         if (student.getId() == null) {
@@ -165,6 +168,7 @@ public class OpenStudentController extends BaseController {
             teacherList.forEach(next -> imUserFriendService.saveUserFriend(next.getUserId(),
                     new HashSet<>(ImmutableList.of(sysUser.getId()))));
         }
+        studentService.saveOrUpdate(studentInfo);
         return succeed();
     }
 }