Переглянути джерело

1.后端学生列表返回小组名称

yuanliang 1 рік тому
батько
коміт
ff38091937

+ 12 - 0
cooleshow-app/src/main/java/com/yonge/cooleshow/admin/controller/StudentController.java

@@ -109,6 +109,17 @@ public class StudentController extends BaseController {
         IPage<StudentVo> pages = studentService.selectPage(PageUtil.getPage(query), query);
         List<StudentVo> rows = pages.getRecords();
 
+        List<Long> tenantGroupIds = rows.stream().map(Student::getTenantGroupId)
+                .filter(next -> next != null && next != -1L).distinct().collect(Collectors.toList());
+        Map<Long, String> tenantGroupIdNameMap = new HashMap<>();
+        if (!tenantGroupIds.isEmpty()) {
+            Map<Long, String> tenantGroupMap = tenantGroupService.lambdaQuery()
+                    .in(TenantGroup::getId, tenantGroupIds)
+                    .list().stream().collect(Collectors.toMap(TenantGroup::getId, TenantGroup::getName));
+            tenantGroupIdNameMap.putAll(tenantGroupMap);
+        }
+
+
         for (StudentVo vo : rows) {
             if (vo.getDelFlag() == YesOrNoEnum.YES) {
                 vo.setUserStatus(UserStatusEnum.CLOSED);
@@ -119,6 +130,7 @@ public class StudentController extends BaseController {
                     vo.setUserStatus(UserStatusEnum.NORMAL);
                 }
             }
+            vo.setTenantGroupName(tenantGroupIdNameMap.getOrDefault(vo.getTenantGroupId(), ""));
         }
         return succeed(PageUtil.pageInfo(pages));
     }

+ 12 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/StudentController.java

@@ -109,6 +109,17 @@ public class StudentController extends BaseController {
         IPage<StudentVo> pages = studentService.selectPage(PageUtil.getPage(query), query);
         List<StudentVo> rows = pages.getRecords();
 
+        List<Long> tenantGroupIds = rows.stream().map(Student::getTenantGroupId)
+                .filter(next -> next != null && next != -1L).distinct().collect(Collectors.toList());
+        Map<Long, String> tenantGroupIdNameMap = new HashMap<>();
+        if(!tenantGroupIds.isEmpty()){
+            Map<Long, String> tenantGroupMap = tenantGroupService.lambdaQuery()
+                    .in(TenantGroup::getId, tenantGroupIds)
+                    .list().stream().collect(Collectors.toMap(TenantGroup::getId, TenantGroup::getName));
+            tenantGroupIdNameMap.putAll(tenantGroupMap);
+        }
+
+
         for (StudentVo vo : rows) {
             if (vo.getDelFlag() == YesOrNoEnum.YES) {
                 vo.setUserStatus(UserStatusEnum.CLOSED);
@@ -119,6 +130,7 @@ public class StudentController extends BaseController {
                     vo.setUserStatus(UserStatusEnum.NORMAL);
                 }
             }
+            vo.setTenantGroupName(tenantGroupIdNameMap.getOrDefault(vo.getTenantGroupId(), ""));
         }
         return succeed(PageUtil.pageInfo(pages));
     }