3
0

2 Incheckningar 86cbfd8aaa ... d9739e39b9

Upphovsman SHA1 Meddelande Datum
  Crazy d9739e39b9 Merge branch 'master' of http://gogs.gisvg.com/YDM/graduate 4 månader sedan
  Crazy 43f32441fe 1.13,补充 4 månader sedan

+ 20 - 3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java

@@ -243,12 +243,12 @@ public class UserController {
         return success(new PageResult<>(userRespList, pageResult.getTotal()));
     }
 
-    @GetMapping("/pageForTeacher")
-    @Operation(summary = "教师获得学生分页")
+    @GetMapping("/pageForTeacher")//
+    @Operation(summary = "教师获得学生分页看工作间下面的")
     @PreAuthorize("@ss.hasPermission('system:user:teacherGetstudentList')")
     public CommonResult<PageResult<UserRespVO>> getUserPageForTeacher(@Valid UserPageReqVO pageReqVO) {
         // 获得用户分页列表
-        PageResult<AdminUserDO> pageResult = userService.getUserPageForTeacher(pageReqVO);
+        PageResult<AdminUserDO> pageResult = userService.getUserDept(pageReqVO);
         if (CollUtil.isEmpty(pageResult.getList())) {
             return success(new PageResult<>(pageResult.getTotal()));
         }
@@ -262,6 +262,23 @@ public class UserController {
         return success(new PageResult<>(userRespList, pageResult.getTotal()));
     }
 
+    @GetMapping("/getStudentsForTeacher")//
+    @Operation(summary = "教师获得学生分页看自己下面的")
+    @PreAuthorize("@ss.hasPermission('system:user:getStudentsForTeacher')")
+    public CommonResult<PageResult<UserRespVO>> getStudentForTeacher(@Valid UserPageReqVO pageReqVO) {
+        // 获得用户分页列表
+        PageResult<AdminUserDO> pageResult = userService.getUserPageForTeacher(pageReqVO);
+        if (CollUtil.isEmpty(pageResult.getList())) {
+            return success(new PageResult<>(pageResult.getTotal()));
+        }
+        // 拼接部门信息
+        Map<Long, DeptDO> deptMap = deptService.getDeptMap(
+                convertList(pageResult.getList(), AdminUserDO::getDeptId));
+        // 转换用户数据并返回结果
+        List<UserRespVO> userRespList = UserConvert.INSTANCE.convertList(pageResult.getList(), deptMap);
+        return success(new PageResult<>(userRespList, pageResult.getTotal()));
+    }
+
 
     //lsq
     @GetMapping("/DeptUser")

+ 20 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java

@@ -149,6 +149,26 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
             @Param("loginId") Long loginId,
             @Param("type") Integer type
     );
+
+    ///按工作间划分学生
+    List<AdminUserDO> selectPageForDept(
+            @Param("reqVO") UserPageReqVO reqVO,
+            @Param("deptIds") Collection<Long> deptIds,
+            @Param("roleIds") Set<Long> roleIds,
+            @Param("deptId") Long deptId,
+            @Param("offset") Integer offset,
+            @Param("loginId") Long loginId,
+            @Param("type") Integer type
+    );
+    Long  selectPageDeptCount(
+            @Param("reqVO") UserPageReqVO reqVO,
+            @Param("deptIds") Collection<Long> deptIds,
+            @Param("roleIds") Set<Long> roleIds,
+            @Param("deptId") Long deptId,
+            @Param("offset") Integer offset,
+            @Param("loginId") Long loginId,
+            @Param("type") Integer type
+    );
     // 会根据登录 查在校学生
 //    default PageResult<AdminUserDO> selectPage1(UserPageReqVO reqVO, Collection<Long> deptIds,Set<Long>roleIds,Long loginId) {
 //

+ 3 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserService.java

@@ -147,6 +147,9 @@ public interface AdminUserService {
     List<AdminUserDO> getInnerSupervisor();
 
     List<AdminUserDO> selectAllList(UserPageReqVO reqVO);
+
+    //工作间管理下的学生
+    PageResult<AdminUserDO> getUserDept(UserPageReqVO reqVO);
     /**
      * 通过用户 ID 查询用户
      *

+ 18 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

@@ -438,6 +438,24 @@ public class AdminUserServiceImpl implements AdminUserService {
         return new PageResult<>(result, size);
     }
 
+    ///工作间管理下的工作间下的学生
+    public PageResult<AdminUserDO> getUserDept(UserPageReqVO reqVO){
+        Long loginId = SecurityFrameworkUtils.getLoginUserId();
+        Long deptId = SecurityFrameworkUtils.getLoginUserDeptId();
+        Set<Long> roleIds = permissionService.getUserRoleIdListByUserId(loginId);
+        int offset;
+        if (reqVO.getPageSize() == -1) {
+            offset =-1;  //
+        } else {
+            offset = (reqVO.getPageNo() - 1) * reqVO.getPageSize();
+        }
+
+        List<AdminUserDO> result =userMapper.selectPageForDept(reqVO, getDeptCondition(reqVO.getDeptId()),roleIds,deptId,offset,loginId,1);
+        Long size = userMapper.selectPageDeptCount(reqVO, getDeptCondition(reqVO.getDeptId()),roleIds,deptId,offset,loginId,1);
+
+        return new PageResult<>(result, size);
+    }
+
 
     @Override
     public  List<AdminUserDO> getUserList1(UserPageReqVO reqVO){

+ 209 - 0
yudao-module-system/yudao-module-system-biz/src/main/resources/Mapper/user/AdminUserMapper.xml

@@ -216,6 +216,215 @@
         ) AS subquery;
     </select>
 
+    <select id="selectPageForDept" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
+        SELECT
+        a.*,
+        COALESCE(
+        (SELECT MIN(ua.is_graduate) FROM system_user_achievement ua WHERE ua.user_id = a.id),
+        1
+        ) AS is_graduate,
+        CASE
+        WHEN a.photo_url IS NOT NULL AND TRIM(a.photo_url) != '' THEN 1
+        ELSE 0
+        END AS photoIsExist,
+
+        COALESCE(system_dept.name, "测绘学院") AS deptName,
+        supervisor_user.nickname as supervisor,
+        supervisor_user.mobile as supervisorMobile
+        FROM
+        system_users a
+        LEFT JOIN
+        system_user_achievement ua ON ua.user_id = a.id
+        LEFT JOIN
+        system_users supervisor_user
+        ON supervisor_user.id = a.supervisor_id
+        AND supervisor_user.deleted = 0
+        LEFT JOIN
+        system_dept system_dept ON system_dept.id = a.dept_id
+        WHERE
+        1=1
+        <if test="reqVO.username != null and reqVO.username != ''">
+            AND a.username LIKE CONCAT('%', #{reqVO.username}, '%')
+        </if>
+        <if test="reqVO.email != null and reqVO.email != ''">
+            AND a.email LIKE CONCAT('%', #{reqVO.email}, '%')
+        </if>
+        <if test="reqVO.mobile != null and reqVO.mobile != ''">
+            AND a.mobile LIKE CONCAT('%', #{reqVO.mobile}, '%')
+        </if>
+        <if test="reqVO.userNumber != null and reqVO.userNumber != ''">
+            AND a.user_number LIKE CONCAT('%', #{reqVO.userNumber}, '%')
+        </if>
+        <if test="reqVO.nickname != null and reqVO.nickname != ''">
+            AND a.nickname LIKE CONCAT('%', #{reqVO.nickname}, '%')
+        </if>
+        <if test="reqVO.userType != null">
+            AND a.user_type = #{reqVO.userType}
+        </if>
+
+        <bind name="gradePrefix" value="reqVO.grade != null and reqVO.grade.length() >= 4 ? reqVO.grade.substring(0, 4) : ''"/>
+        <if test="gradePrefix != ''">
+            AND a.grade LIKE CONCAT('%', #{gradePrefix}, '%')
+        </if>
+
+        <if test="reqVO.supervisorId != null">
+            AND a.supervisor_id = #{reqVO.supervisorId}
+        </if>
+
+        <if test="reqVO.major != null">
+            AND a.major = #{reqVO.major}
+        </if>
+
+        <if test="reqVO.masterType != null">
+            AND a.masterType = #{reqVO.masterType}
+        </if>
+
+        <if test="reqVO.status != null">
+            AND a.status = #{reqVO.status}
+        </if>
+        <if test="deptIds != null and !deptIds.isEmpty()">
+            AND a.dept_id IN
+            <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
+                #{deptId}
+            </foreach>
+        </if>
+        <choose>
+            <when test="type == 0">
+                AND a.user_type = 1
+            </when>
+            <when test="type == 1">
+                AND a.user_type = 1
+                AND (
+                ( a.dept_id != 0
+                AND  a.dept_id = #{deptId}
+                AND a.dept_id IS NOT NULL
+                AND a.dept_id != ''
+                )
+                )
+            </when>
+        </choose>
+        <if test="reqVO.isGraduate != null">
+            <if test="reqVO.isGraduate == 1">
+                AND a.id NOT IN (SELECT user_id FROM system_user_achievement WHERE user_id = a.id AND is_graduate = 0)
+            </if>
+            <if test="reqVO.isGraduate == 0">
+                AND a.id IN (SELECT user_id FROM system_user_achievement WHERE user_id = a.id AND is_graduate = #{reqVO.isGraduate})
+                AND ua.is_graduate = 0
+            </if>
+        </if>
+        <if test="reqVO.photoIsExist != null">
+            <if test="reqVO.photoIsExist == 0">
+                AND a.photo_url IS NULL
+            </if>
+            <if test="reqVO.photoIsExist == 1">
+                AND a.photo_url IS NOT NULL AND a.photo_url != ''
+            </if>
+        </if>
+        AND a.deleted = 0
+        GROUP BY
+        a.id
+        ORDER BY
+        a.id DESC
+        <if test="offset != -1">
+            LIMIT #{offset}, #{reqVO.pageSize}
+        </if>
+    </select>
+
+    <select id="selectPageDeptCount" resultType="Long">
+        SELECT COUNT(*) AS total_count
+        FROM (
+        SELECT a.id
+        FROM system_users a
+        LEFT JOIN system_user_achievement ua ON ua.user_id = a.id
+        WHERE 1=1
+        <if test="reqVO.username != null and reqVO.username != ''">
+            AND a.username LIKE CONCAT('%', #{reqVO.username}, '%')
+        </if>
+        <if test="reqVO.email != null and reqVO.email != ''">
+            AND a.email LIKE CONCAT('%', #{reqVO.email}, '%')
+        </if>
+        <if test="reqVO.mobile != null and reqVO.mobile != ''">
+            AND a.mobile LIKE CONCAT('%', #{reqVO.mobile}, '%')
+            AND a.mobile LIKE CONCAT('%', #{reqVO.mobile}, '%')
+            AND a.mobile LIKE CONCAT('%', #{reqVO.mobile}, '%')
+        </if>
+        <if test="reqVO.userNumber != null and reqVO.userNumber != ''">
+            AND a.user_number LIKE CONCAT('%', #{reqVO.userNumber}, '%')
+        </if>
+        <if test="reqVO.nickname != null and reqVO.nickname != ''">
+            AND a.nickname LIKE CONCAT('%', #{reqVO.nickname}, '%')
+        </if>
+        <if test="reqVO.userType != null">
+            AND a.user_type = #{reqVO.userType}
+        </if>
+
+        <bind name="gradePrefix" value="reqVO.grade != null and reqVO.grade.length() >= 4 ? reqVO.grade.substring(0, 4) : ''"/>
+        <if test="gradePrefix != ''">
+            AND a.grade LIKE CONCAT('%', #{gradePrefix}, '%')
+        </if>
+
+        <if test="reqVO.supervisorId != null">
+            AND a.supervisor_id = #{reqVO.supervisorId}
+        </if>
+
+        <if test="reqVO.major != null">
+            AND a.major = #{reqVO.major}
+        </if>
+
+        <if test="reqVO.masterType != null">
+            AND a.masterType = #{reqVO.masterType}
+        </if>
+
+        <if test="reqVO.status != null">
+            AND a.status = #{reqVO.status}
+        </if>
+        <if test="deptIds != null and !deptIds.isEmpty()">
+            AND a.dept_id IN
+            <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
+                #{deptId}
+            </foreach>
+        </if>
+        <choose>
+            <when test="type == 0">
+                AND a.user_type = 1
+            </when>
+            <when test="type == 1">
+                AND a.user_type = 1
+                AND (
+                ( a.dept_id != 0
+                AND  a.dept_id = #{deptId}
+                AND a.dept_id IS NOT NULL
+                AND a.dept_id != ''
+                )
+                )
+            </when>
+        </choose>
+        <if test="reqVO.isGraduate != null">
+            <if test="reqVO.isGraduate == 1">
+                AND a.id NOT IN (SELECT user_id FROM system_user_achievement WHERE user_id = a.id AND is_graduate = 0)
+            </if>
+            <if test="reqVO.isGraduate == 0">
+                AND a.id IN (SELECT user_id FROM system_user_achievement WHERE user_id = a.id AND is_graduate = #{reqVO.isGraduate})
+                AND ua.is_graduate = 0
+            </if>
+        </if>
+        <if test="reqVO.photoIsExist != null">
+            <if test="reqVO.photoIsExist == 0">
+                AND a.photo_url IS NULL
+            </if>
+            <if test="reqVO.photoIsExist == 1">
+                AND a.photo_url IS NOT NULL AND a.photo_url != ''
+            </if>
+        </if>
+        AND a.deleted = 0
+        GROUP BY a.id
+        ) AS subquery;
+    </select>
+
+
+
+
+
     <select id="selectList1" resultType="cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO">
         SELECT
         a.*,