Просмотр исходного кода

Merge branch 'feature/1019-tenant' into test

yuanliang 1 год назад
Родитель
Сommit
1fecf7fec0

+ 27 - 2
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/TenantGroupController.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.tenant.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.microsvc.toolkit.common.response.paging.PageInfo;
@@ -7,13 +8,16 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.microsvc.toolkit.common.response.template.R;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.ImGroup;
 import com.yonge.cooleshow.biz.dal.entity.TenantGroup;
+import com.yonge.cooleshow.biz.dal.service.ImGroupService;
 import com.yonge.cooleshow.biz.dal.service.TenantGroupService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantGroupWrapper;
 import com.yonge.cooleshow.tenant.vo.TenantGroupVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -26,6 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Validated
@@ -40,11 +45,31 @@ public class TenantGroupController {
     @Resource
     private SysUserFeignService sysUserFeignService;
 
+    @Autowired
+    private ImGroupService imGroupService;
+
     @ApiOperation(value = "详情", notes = "机构小组表-根据详情ID查询单条, 传入id")
     @GetMapping("/detail/{id}")
-    public R<TenantGroup> detail(@PathVariable("id") Long id) {
+    public R<TenantGroupWrapper.TenantGroup> detail(@PathVariable("id") Long id) {
         TenantGroup wrapper = tenantGroupService.detail(id);
-        return R.from(wrapper);
+        if (wrapper == null) {
+            return R.from(new TenantGroupWrapper.TenantGroup());
+        }
+        TenantGroupWrapper.TenantGroup group = TenantGroupWrapper.TenantGroup.from(JSON.toJSONString(wrapper));
+        if (StringUtils.isNotEmpty(wrapper.getImGroupId())) {
+            ImGroup imGroup = imGroupService.getById(wrapper.getImGroupId());
+            if (imGroup != null) {
+                group.setImGroupExist(true);
+            }
+        }
+        List<TenantGroupWrapper.TenantGroupMember> members =
+                tenantGroupService.queryGroupMember(wrapper.getTenantId(), id);
+        List<Long> userIds = members.stream().map(TenantGroupWrapper.TenantGroupMember::getUserId)
+                .collect(Collectors.toList());
+        group.setUserIds(userIds);
+        group.setGroupUserCount(members.size());
+        group.setUserList(members);
+        return R.from(group);
     }
 
     @ApiOperation(value = "查询机构群成员", notes = "查询机构群成员")

+ 1 - 1
cooleshow-app/src/main/java/com/yonge/cooleshow/tenant/controller/open/OpenStudentController.java

@@ -88,7 +88,7 @@ public class OpenStudentController extends BaseController {
         Long tenantGroupId = student.getTenantGroupId();
         TenantGroup tenantGroup = tenantGroupMapper.selectById(tenantGroupId);
         if (tenantGroup == null) {
-            throw new com.microsvc.toolkit.common.webportal.exception.BizException("机构小组不存在");
+            throw new com.microsvc.toolkit.common.webportal.exception.BizException("请选择小组");
         }
         Long studentId = student.getId();
 

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

@@ -686,7 +686,9 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
 
 
         // 手机号码修改
+        boolean updatePhone = false;
         if (!student.getPhone().equals(studentInfo.getPhone())) {
+            updatePhone = true;
             com.yonge.cooleshow.biz.dal.entity.SysUser sysUser = getOrCreateAccount(studentInfo);
             this.lambdaUpdate().set(Student::getSubjectId, studentInfo.getSubjectId())
                     .set(Student::getTenantId, studentInfo.getTenantId())
@@ -722,6 +724,10 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao, Student> impleme
         } catch (Exception e) {
             log.warn("学生注册IM失败:" + e.getMessage());
         }
+        // 手机号修改,退出登录
+        if (updatePhone) {
+            sysUserFeignService.exitByPhone(ClientEnum.STUDENT.getCode(), student.getPhone());
+        }
 
         return true;
     }

+ 20 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/TenantAlbumCategoryServiceImpl.java

@@ -26,6 +26,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 /**
@@ -116,10 +117,17 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
             throw new BizException("专辑分类名称已存在");
         }
 
+        // 校验子分类值是否存在重复
+        List<TenantAlbumCategoryDetail> values = tenantAlbumCategory.getValues();
+        Set<String> names = values.stream().map(TenantAlbumCategoryDetail::getValue).collect(Collectors.toSet());
+        if (names.size() != values.size()) {
+            ETenantAlbumCategoryType categoryType = tenantAlbumCategory.getCategoryType();
+            throw new BizException(ETenantAlbumCategoryType.CATEGORY_TYPE.equals(categoryType) ? "类型不能有重复" : "级别不能有重复");
+        }
+
         TenantAlbumCategory albumCategory = JSON.parseObject(tenantAlbumCategory.jsonString(),
                 TenantAlbumCategory.class);
         this.save(albumCategory);
-        List<TenantAlbumCategoryDetail> values = tenantAlbumCategory.getValues();
         if (!values.isEmpty()) {
             values.forEach(next -> next.setTenantAlbumCategoryId(albumCategory.getId()));
             tenantAlbumCategoryDetailService.saveBatch(values);
@@ -147,12 +155,20 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
             throw new BizException("专辑分类名称已存在");
         }
 
+        // 校验子分类值是否存在重复
+        List<TenantAlbumCategoryDetail> values = tenantAlbumCategory.getValues();
+        Set<String> names = values.stream().map(TenantAlbumCategoryDetail::getValue).collect(Collectors.toSet());
+        if (names.size() != values.size()) {
+            TenantAlbumCategory albumCategory = this.getById(tenantAlbumCategory.getId());
+            ETenantAlbumCategoryType categoryType = albumCategory.getCategoryType();
+            throw new BizException(ETenantAlbumCategoryType.CATEGORY_TYPE.equals(categoryType) ? "类型不能有重复" : "级别不能有重复");
+        }
+
         // 校验是否存在引用删除
         List<TenantAlbumCategoryDetail> detailList = tenantAlbumCategoryDetailService.lambdaQuery()
                 .eq(TenantAlbumCategoryDetail::getTenantAlbumCategoryId, tenantAlbumCategory.getId())
                 .list();
 
-        List<TenantAlbumCategoryDetail> values = tenantAlbumCategory.getValues();
         List<Long> newUpdateIds = values.stream().map(TenantAlbumCategoryDetail::getId).filter(Objects::nonNull)
                 .collect(Collectors.toList());
 
@@ -226,7 +242,8 @@ public class TenantAlbumCategoryServiceImpl extends ServiceImpl<TenantAlbumCateg
         Integer useCount = tenantAlbumMusicMapper.selectCount(queryWrapper);
         // 删除的ID被应用的数量大于0
         if (useCount > 0) {
-            throw new BizException("专辑分类存在" + (ETenantAlbumCategoryType.CATEGORY_TYPE.equals(categoryType) ? "类型" : "级别") + "引用");
+            throw new BizException("专辑分类存在" + (ETenantAlbumCategoryType.CATEGORY_TYPE.equals(categoryType) ? "类型" :
+                    "级别") + "引用");
         }
     }
 }

+ 3 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/TenantGroupWrapper.java

@@ -93,6 +93,9 @@ public class TenantGroupWrapper {
         @ApiModelProperty("群成员列表")
         private List<Long> userIds = new ArrayList<>();
 
+        @ApiModelProperty("群成员列表")
+        private List<TenantGroupMember> userList = new ArrayList<>();
+
         @ApiModelProperty("群成员数量")
         private Integer groupUserCount = 0;
 

+ 27 - 2
cooleshow-user/user-tenant/src/main/java/com/yonge/cooleshow/tenant/controller/TenantGroupController.java

@@ -1,5 +1,6 @@
 package com.yonge.cooleshow.tenant.controller;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.microsvc.toolkit.common.response.paging.PageInfo;
@@ -7,13 +8,16 @@ import com.microsvc.toolkit.common.response.paging.QueryInfo;
 import com.microsvc.toolkit.common.response.template.R;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
+import com.yonge.cooleshow.biz.dal.entity.ImGroup;
 import com.yonge.cooleshow.biz.dal.entity.TenantGroup;
+import com.yonge.cooleshow.biz.dal.service.ImGroupService;
 import com.yonge.cooleshow.biz.dal.service.TenantGroupService;
 import com.yonge.cooleshow.biz.dal.wrapper.TenantGroupWrapper;
 import com.yonge.cooleshow.tenant.vo.TenantGroupVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
@@ -27,6 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Validated
@@ -41,11 +46,31 @@ public class TenantGroupController {
     @Resource
     private SysUserFeignService sysUserFeignService;
 
+    @Autowired
+    private ImGroupService imGroupService;
+
     @ApiOperation(value = "详情", notes = "机构小组表-根据详情ID查询单条, 传入id")
     @GetMapping("/detail/{id}")
-    public R<TenantGroup> detail(@PathVariable("id") Long id) {
+    public R<TenantGroupWrapper.TenantGroup> detail(@PathVariable("id") Long id) {
         TenantGroup wrapper = tenantGroupService.detail(id);
-        return R.from(wrapper);
+        if (wrapper == null) {
+            return R.from(new TenantGroupWrapper.TenantGroup());
+        }
+        TenantGroupWrapper.TenantGroup group = TenantGroupWrapper.TenantGroup.from(JSON.toJSONString(wrapper));
+        if (StringUtils.isNotEmpty(wrapper.getImGroupId())) {
+            ImGroup imGroup = imGroupService.getById(wrapper.getImGroupId());
+            if (imGroup != null) {
+                group.setImGroupExist(true);
+            }
+        }
+        List<TenantGroupWrapper.TenantGroupMember> members =
+                tenantGroupService.queryGroupMember(wrapper.getTenantId(), id);
+        List<Long> userIds = members.stream().map(TenantGroupWrapper.TenantGroupMember::getUserId)
+                .collect(Collectors.toList());
+        group.setUserIds(userIds);
+        group.setGroupUserCount(members.size());
+        group.setUserList(members);
+        return R.from(group);
     }
 
     @ApiOperation(value = "查询机构群成员", notes = "查询机构群成员")

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

@@ -97,7 +97,7 @@ public class OpenStudentController extends BaseController {
         Long tenantGroupId = student.getTenantGroupId();
         TenantGroup tenantGroup = tenantGroupMapper.selectById(tenantGroupId);
         if (tenantGroup == null) {
-            throw new com.microsvc.toolkit.common.webportal.exception.BizException("机构小组不存在");
+            throw new com.microsvc.toolkit.common.webportal.exception.BizException("请选择小组");
         }
         Long studentId = student.getId();