Explorar o código

Merge branch 'feature/1019-tenant' into develop-new

yuanliang hai 1 ano
pai
achega
204cba39ee

+ 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 = "查询机构群成员")

+ 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 = "查询机构群成员")