Browse Source

添加返回学生关系

DESKTOP-USV654P\pc 1 year ago
parent
commit
9abb41d18a

+ 28 - 0
src/main/java/com/xjrsoft/module/organization/controller/UserController.java

@@ -14,6 +14,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.yulichang.toolkit.MPJWrappers;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.constant.GlobalConstant;
 import com.xjrsoft.common.enums.EnabledMark;
 import com.xjrsoft.common.enums.RoleEnum;
@@ -30,6 +31,12 @@ import com.xjrsoft.module.organization.entity.*;
 import com.xjrsoft.module.organization.service.*;
 import com.xjrsoft.module.organization.vo.*;
 import com.xjrsoft.module.oss.factory.OssFactory;
+import com.xjrsoft.module.student.entity.BaseClass;
+import com.xjrsoft.module.student.entity.BaseStudent;
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
+import com.xjrsoft.module.student.entity.BaseStudentUser;
+import com.xjrsoft.module.student.service.IBaseClassService;
+import com.xjrsoft.module.student.vo.BaseStudentClassVo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -78,6 +85,7 @@ public class UserController {
     private final SmsCtcc smsCtcc;
 
     private final IUserStudentService userStudentService;
+    private final IBaseClassService baseClassService;
 
 
     @GetMapping(value = "/list")
@@ -192,6 +200,10 @@ public class UserController {
                         .eq(UserPostRelation::getUserId, user.getId().toString()))
                 .stream().map(UserPostRelation::getPostId).collect(Collectors.toList());
 
+        List<Long> studentIds = userStudentService.list(Wrappers.lambdaQuery(UserStudent.class)
+                        .eq(UserStudent::getUserId, user.getId().toString()))
+                .stream().map(UserStudent::getStudentId).collect(Collectors.toList());
+
         UserInfoVo vo = BeanUtil.toBean(user, UserInfoVo.class);
         if (roleIds.size() > 0) {
 
@@ -220,6 +232,22 @@ public class UserController {
 
         }
 
+        if (studentIds.size() > 0) {
+            MPJLambdaWrapper<BaseClass> queryWrapper = new MPJLambdaWrapper<>();
+            queryWrapper
+                    .disableSubLogicDel()
+                    .rightJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getClassId, BaseStudent::getId)
+                    .innerJoin(BaseStudentUser.class, BaseStudentUser::getId, BaseStudentSchoolRoll::getUserId)
+                    .in(BaseStudentSchoolRoll::getUserId, studentIds)
+                    .selectAs(BaseClass::getName, UserStudentVo::getClassName)
+                    .selectAs(BaseStudentUser::getName, UserStudentVo::getStudentName)
+                    .selectAs(BaseStudentUser::getId, UserStudentVo::getStudentId)
+                    .selectAs(BaseStudentUser::getAvatar, UserStudentVo::getAvatar);
+
+            List<BaseClass> list = baseClassService.list(queryWrapper);
+            List<UserStudentVo> userStudentVoList = BeanUtil.copyToList(list, UserStudentVo.class);
+            vo.setStudents(userStudentVoList);
+        }
 
         return R.ok(vo);
     }

+ 5 - 0
src/main/java/com/xjrsoft/module/organization/vo/UserInfoVo.java

@@ -91,4 +91,9 @@ public class UserInfoVo {
      * 所有部门信息
      */
     private List<UserPostVo> posts;
+
+    /**
+     * 家长绑定的学生
+     */
+    private List<UserStudentVo> students;
 }

+ 1 - 0
src/main/java/com/xjrsoft/module/organization/vo/UserStudentVo.java

@@ -7,4 +7,5 @@ import lombok.Data;
 public class UserStudentVo extends UserStudentUpdateDto {
     private String studentName;
     private String className;
+    private String avatar;
 }

+ 7 - 0
src/main/java/com/xjrsoft/module/student/service/IBaseClassService.java

@@ -0,0 +1,7 @@
+package com.xjrsoft.module.student.service;
+
+import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.student.entity.BaseClass;
+
+public interface IBaseClassService  extends MPJBaseService<BaseClass> {
+}

+ 13 - 0
src/main/java/com/xjrsoft/module/student/service/impl/BaseClassServiceImpl.java

@@ -0,0 +1,13 @@
+package com.xjrsoft.module.student.service.impl;
+
+import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.xjrsoft.module.student.entity.BaseClass;
+import com.xjrsoft.module.student.mapper.BaseClassMapper;
+import com.xjrsoft.module.student.service.IBaseClassService;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+
+@Service
+@AllArgsConstructor
+public class BaseClassServiceImpl  extends MPJBaseServiceImpl<BaseClassMapper, BaseClass> implements IBaseClassService {
+}

+ 2 - 2
src/main/resources/application.yml

@@ -125,8 +125,8 @@ mybatis-plus:
     cache-enabled: false
     call-setters-on-nulls: true
     jdbc-type-for-null: 'null'
-    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
-
+#    log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 
 camunda:
   bpm: