yzx 11 місяців тому
батько
коміт
3a24a804e2
19 змінених файлів з 288 додано та 39 видалено
  1. 3 0
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentscollegemanage/AidingStudentsCollegeManageController.java
  2. 2 3
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/AidingStudentsImportListController.java
  3. 3 1
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/dataobject/aidingstudentspersonmanage/AidingStudentsPersonManageDO.java
  4. 29 17
      yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentspersonmanage/AidingStudentsPersonManageServiceImpl.java
  5. 7 0
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java
  6. 6 0
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/dto/DeptRespDTO.java
  7. 9 0
      yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/PermissionApi.java
  8. 12 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java
  9. 11 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/PermissionApiImpl.java
  10. 2 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java
  11. 24 7
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java
  12. 6 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/UserController.java
  13. 6 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/dept/DeptDO.java
  14. 0 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java
  15. 18 3
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java
  16. 15 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java
  17. 125 4
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java
  18. 7 1
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java
  19. 3 0
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/user/AdminUserServiceImpl.java

+ 3 - 0
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentscollegemanage/AidingStudentsCollegeManageController.java

@@ -42,6 +42,7 @@ public class AidingStudentsCollegeManageController {
     @Operation(summary = "创建家庭困难认定项目学院管理")
     @PreAuthorize("@ss.hasPermission('as:aiding-students-college-manage:create')")
     public CommonResult<Long> createAidingStudentsCollegeManage(@Valid @RequestBody AidingStudentsCollegeManageSaveReqVO createReqVO) {
+        //注意学校id和学院id的区别
         return success(aidingStudentsCollegeManageService.createAidingStudentsCollegeManage(createReqVO));
     }
 
@@ -67,6 +68,8 @@ public class AidingStudentsCollegeManageController {
     @Parameter(name = "id", description = "编号", required = true, example = "1024")
     @PreAuthorize("@ss.hasPermission('as:aiding-students-college-manage:get')")
     public CommonResult<AidingStudentsCollegeManageRespVO> getAidingStudentsCollegeManage(@RequestParam("id") Long id) {
+        //通过collegeId 和 manageId 获取,减少学院项目id的使用。
+
         AidingStudentsCollegeManageDO aidingStudentsCollegeManage = aidingStudentsCollegeManageService.getAidingStudentsCollegeManage(id);
         return success(BeanUtils.toBean(aidingStudentsCollegeManage, AidingStudentsCollegeManageRespVO.class));
     }

+ 2 - 3
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/controller/admin/aidingstudentsimportlist/AidingStudentsImportListController.java

@@ -85,9 +85,10 @@ public class AidingStudentsImportListController {
     @Parameters({
             @Parameter(name = "aidingStudentsManageId", description = "助学学校项目id", example = "5")
     })
+
     @PreAuthorize("@ss.hasPermission('as:aiding-students-import-list:import')")
     public CommonResult<AidingStudentsImportExcelRespVO> importExcel(@RequestParam(value = "aidingStudentsManageId", required = true) Long aidingStudentsManageId,
-    @RequestParam(value = "redisUUID") String redisUUID)throws Exception {
+    @RequestParam(value = "redisUUID") String redisUUID) throws Exception {
         return success(aidingStudentsImportListService.aidingStudentsImportExcelList( aidingStudentsManageId,redisUUID));
     }
 
@@ -101,8 +102,6 @@ public class AidingStudentsImportListController {
         return success(redisUUID);
     }
 
-
-
     @PostMapping("/reimport-excel")
     @Operation(summary = "重复导入家庭情况困难认定excel")
     @Parameters({

+ 3 - 1
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/dal/dataobject/aidingstudentspersonmanage/AidingStudentsPersonManageDO.java

@@ -25,6 +25,8 @@ public class AidingStudentsPersonManageDO extends BaseDO {
     // 序号
     @TableId(value = "id", type = IdType.AUTO)
     private Integer id;
+
+
     //姓名
     private String nickname;
     // 困难类型
@@ -36,7 +38,7 @@ public class AidingStudentsPersonManageDO extends BaseDO {
     // 排序
     private Integer sort;
     // 学院id
-    private Integer collegeId;
+    private Long collegeId;
     // 项目ID
     private Integer manageId;
     // 班级 :计算机类2023-1班

+ 29 - 17
yudao-module-as/yudao-module-as-biz/src/main/java/cn/iocoder/yudao/module/as/service/aidingstudentspersonmanage/AidingStudentsPersonManageServiceImpl.java

@@ -10,6 +10,10 @@ import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentspersonmanage.Aidi
 import cn.iocoder.yudao.module.as.dal.dataobject.aidingstudentspersonmanage.AidingStudentsPersonManageDO;
 import cn.iocoder.yudao.module.as.dal.mysql.aidingstudentspersonmanage.AidingStudentPersonManageEvaluationResultMapper;
 import cn.iocoder.yudao.module.as.dal.mysql.aidingstudentspersonmanage.AidingStudentsPersonManageMapper;
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
+import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
 import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
@@ -28,6 +32,7 @@ import javax.annotation.Resource;
 import java.util.*;
 
 import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 
 /**
  * @autor WoVoM
@@ -46,6 +51,11 @@ public class AidingStudentsPersonManageServiceImpl extends ServiceImpl<AidingStu
 
     @Autowired
     private AdminUserMapper admiUSerMapper;
+    @Resource
+    private DeptApi deptApi;
+
+    @Resource
+    private AdminUserApi adminUserApi;
 
     @Autowired
     private DeptMapper deptMapper;
@@ -64,6 +74,7 @@ public class AidingStudentsPersonManageServiceImpl extends ServiceImpl<AidingStu
                     .eq("id", loginUser.getId()));
             Map map = aidingStudentsPersonManageMapper.getByStudentId(one.getStudentId());
             log.info("map = {}" , map);
+
             // 部门名称
             result.setClassName((String) map.get("SZBJMC"));
             // 学号
@@ -74,6 +85,7 @@ public class AidingStudentsPersonManageServiceImpl extends ServiceImpl<AidingStu
             result.setIdCard((String) map.get("SFZJH"));
             // 户籍
             result.setRegisteredResidence((String) map.get("JG"));
+
             return result;
         } catch (Exception exception) {
             exception.printStackTrace();
@@ -88,15 +100,15 @@ public class AidingStudentsPersonManageServiceImpl extends ServiceImpl<AidingStu
      */
     @Override
     public void uploadAidingStudentsManage(AidingStudentsPersonManageUploadVO uploadVO) {
+
         AidingStudentsPersonManageDO aDo = BeanUtils.toBean(uploadVO, AidingStudentsPersonManageDO.class);
-        LoginUser loginUser = getLoginUser();
-        // 获取当前登录的用户表
-        AdminUserDO one = admiUSerMapper.selectOne(new QueryWrapper<AdminUserDO>()
-                .eq("id", loginUser.getId()));
-        Map map = aidingStudentsPersonManageMapper.getByStudentId(one.getStudentId());
-        log.info("map = {}" , map);
-        aDo.setNickname(String.valueOf(map.get("XM")));
+
+        AdminUserRespDTO user =  adminUserApi.getUser(getLoginUserId());
+        Long collegeId = deptApi.getCollegeId(user.getDeptId());
+        aDo.setCollegeId(collegeId);
+        aDo.setNickname(user.getNickname());
         aDo.setStatus(0);
+
         aidingStudentsPersonManageMapper.insert(aDo);
     }
 
@@ -105,11 +117,9 @@ public class AidingStudentsPersonManageServiceImpl extends ServiceImpl<AidingStu
      */
     @Override
     public AidingStudentsPersonManageUploadVO checkAidingStudentsManage() {
-        LoginUser loginUser = getLoginUser();
-        // 获取当前登录的用户表
-        AdminUserDO one = admiUSerMapper.selectOne(new QueryWrapper<AdminUserDO>()
-                .eq("id", loginUser.getId()));
-        String studentId = one.getStudentId();
+
+        AdminUserRespDTO user =  adminUserApi.getUser(getLoginUserId());
+        String studentId = user.getStudentId();
         AidingStudentsPersonManageDO me = this.getById(studentId);
         AidingStudentsPersonManageUploadVO result = BeanUtils
                 .toBean(me, AidingStudentsPersonManageUploadVO.class);
@@ -122,11 +132,8 @@ public class AidingStudentsPersonManageServiceImpl extends ServiceImpl<AidingStu
      */
     @Override
     public void editAidingStudentsManage(AidingStudentsPersonManageUploadVO uploadVO) {
-        AidingStudentsPersonManageDO aDo = new AidingStudentsPersonManageDO();
-         aDo = BeanUtils.toBean(uploadVO, AidingStudentsPersonManageDO.class);
-         log.info("aDo 信息如下{}" , aDo);
-         aDo.setRejectNotes("");
-         aidingStudentsPersonManageMapper.updateById(aDo);
+        AidingStudentsPersonManageDO aDo = BeanUtils.toBean(uploadVO, AidingStudentsPersonManageDO.class);
+        aidingStudentsPersonManageMapper.updateById(aDo);
     }
 
     /**
@@ -137,8 +144,12 @@ public class AidingStudentsPersonManageServiceImpl extends ServiceImpl<AidingStu
     @Override
     public PageResult<AidingStudentPersonManageCollegeRespVO> getAidingStudentsPersonManageCollegePage(
             AidingStudentPersonManagerCollegePageReqVO pageReqVO) {
+
         AidingStudentPersonManageCollegeRespVO vo = new AidingStudentPersonManageCollegeRespVO();
+
         List<AidingStudentPersonManageClassVO> list = new ArrayList<>();
+
+        //
         List<AidingStudentsPersonManageDO> allList = aidingStudentsPersonManageMapper
                 .selectList(new QueryWrapper<AidingStudentsPersonManageDO>()
                         .eq("college_id", pageReqVO.getCollegeId())
@@ -146,6 +157,7 @@ public class AidingStudentsPersonManageServiceImpl extends ServiceImpl<AidingStu
                         .like(StringUtils.isNotBlank(pageReqVO.getMajor()), "class_name", pageReqVO.getMajor())
                         .like(StringUtils.isNotBlank(pageReqVO.getGrade()), "class_name", pageReqVO.getGrade())
                         .like(StringUtils.isNotBlank(pageReqVO.getClName()), "class_name", pageReqVO.getClName()));
+
         int wait = 0, edit = 0, pass = 0;
         for (int i = 0; i < allList.size(); i++) {
             AidingStudentsPersonManageDO aDo = allList.get(i);

+ 7 - 0
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApi.java

@@ -67,6 +67,13 @@ public interface DeptApi {
      */
     Long getCollegeId(Long id);
 
+
+    /**
+     * 获取学院数量
+     * @return Long
+     */
+    Long getCollegeNum();
+
     /**
      *  获得子集部门
      *

+ 6 - 0
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/dept/dto/DeptRespDTO.java

@@ -34,4 +34,10 @@ public class DeptRespDTO {
      */
     private Integer status;
 
+    /**
+     * 部门状态
+     *
+     * 枚举 {@link CommonStatusEnum}
+     */
+    private String bs;
 }

+ 9 - 0
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/permission/PermissionApi.java

@@ -1,10 +1,15 @@
 package cn.iocoder.yudao.module.system.api.permission;
 
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.module.system.api.permission.dto.DeptDataPermissionRespDTO;
+import org.springframework.validation.annotation.Validated;
 
 import java.util.Collection;
+import java.util.List;
 import java.util.Set;
 
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
 /**
  * 权限 API 接口
  *
@@ -46,4 +51,8 @@ public interface PermissionApi {
      */
     DeptDataPermissionRespDTO getDeptDataPermission(Long userId);
 
+    void assignUserRole(Long userId, Set<Long> roleIds);
+
+    Set<Long> getUserRoleIdListByUserId(Long userId);
+
 }

+ 12 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/dept/DeptApiImpl.java

@@ -1,6 +1,7 @@
 package cn.iocoder.yudao.module.system.api.dept;
 
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.service.dept.DeptService;
@@ -29,6 +30,7 @@ public class DeptApiImpl implements DeptApi {
     }
 
     @Override
+    @DataPermission(enable = false)
     public List<DeptRespDTO> getDeptList(Collection<Long> ids) {
         List<DeptDO> depts = deptService.getDeptList(ids);
         return BeanUtils.toBean(depts, DeptRespDTO.class);
@@ -40,18 +42,27 @@ public class DeptApiImpl implements DeptApi {
     }
 
     @Override
+    @DataPermission(enable = false)
     public List<DeptRespDTO> getChildDeptList(Long id) {
         List<DeptDO> childDeptList = deptService.getChildDeptList(id);
         return BeanUtils.toBean(childDeptList, DeptRespDTO.class);
     }
 
     @Override
+    @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
     public Long getCollegeId(Long id) {
         Long collegeId = deptService.getCollegeId(id);
         return collegeId;
     }
+    @Override
+    @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
+    public Long getCollegeNum() {
+        Long collegeId = deptService.getCollegeNum();
+        return collegeId;
+    }
 
-
+    @Override
+    @DataPermission(enable = false)
     public List<DeptRespDTO> getChildDeptListByParent(Long id){
         List<DeptDO> deptList = deptService.getChildDeptListByParent(id);
         return BeanUtils.toBean(deptList, DeptRespDTO.class);

+ 11 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/permission/PermissionApiImpl.java

@@ -6,6 +6,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.Collection;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -39,4 +40,14 @@ public class PermissionApiImpl implements PermissionApi {
         return permissionService.getDeptDataPermission(userId);
     }
 
+    @Override
+    public void assignUserRole(Long userId, Set<Long> roleIds) {
+        permissionService.assignUserRole(userId,roleIds);
+    }
+
+    @Override
+    public Set<Long> getUserRoleIdListByUserId(Long userId) {
+        return permissionService.getUserRoleIdListByUserId(userId);
+    }
+
 }

+ 2 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/user/AdminUserApiImpl.java

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.api.user;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjUtil;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
@@ -66,6 +67,7 @@ public class AdminUserApiImpl implements AdminUserApi {
     }
 
     @Override
+    @DataPermission(enable = false)
     public List<AdminUserRespDTO> getUserList(Collection<Long> ids) {
         List<AdminUserDO> users = userService.getUserList(ids);
         return BeanUtils.toBean(users, AdminUserRespDTO.class);

+ 24 - 7
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/dept/DeptController.java

@@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.system.controller.admin.dept;
 import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.system.api.dept.DeptApi;
+import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptRespVO;
 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
@@ -15,12 +17,14 @@ import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
-
+import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import java.util.ArrayList;
 import java.util.List;
 
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 
 @Tag(name = "管理后台 - 部门")
 @RestController
@@ -28,9 +32,16 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 @Validated
 public class DeptController {
 
+    @Resource
+    private AdminUserApi adminUserApi;
+    @Resource
+    private DeptApi deptApi;
     @Resource
     private DeptService deptService;
 
+    @Resource
+    private PermissionApi permissionApi;
+
     @PostMapping("create")
     @Operation(summary = "创建部门")
     @PreAuthorize("@ss.hasPermission('system:dept:create')")
@@ -67,15 +78,17 @@ public class DeptController {
     @GetMapping(value = {"/list-all-simple", "/simple-list"})
     @Operation(summary = "获取部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
     public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptList() {
-        List<DeptDO> list = deptService.getDeptList(
-                new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
+        List<DeptDO> list;
+        list = deptService.getDeptList(new DeptListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
         return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
     }
 
     @GetMapping(value = {"/list-all-simple-dept", "/simple-list-dept"})
     @Operation(summary = "获取子部门精简信息列表", description = "只包含被开启的部门,主要用于前端的下拉选项")
     public CommonResult<List<DeptSimpleRespVO>> getSimpleDeptListByDept(@RequestParam("id") Long id) {
-        List<DeptDO> list = deptService.getDeptListByDept(id);
+        Long deptId = adminUserApi.getUser(getLoginUserId()).getDeptId();
+        Long collegeId =  deptApi.getCollegeId(deptId);
+        List<DeptDO> list = deptService.getDeptListByDept(collegeId);
         return success(BeanUtils.toBean(list, DeptSimpleRespVO.class));
     }
 
@@ -88,7 +101,11 @@ public class DeptController {
         return success(BeanUtils.toBean(dept, DeptRespVO.class));
     }
 
-
-
-
+    @GetMapping("/test")
+    @Operation(summary = "我试试")
+    @PreAuthorize("@ss.hasPermission('system:dept:query')")
+    public void updateSchoolDept() {
+        List<DeptDO> dept = deptService.updateSchoolDept();
+        System.out.println(dept);
+    }
 }

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

@@ -7,6 +7,8 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.framework.common.pojo.PageParam;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
+import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
 import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.*;
 import cn.iocoder.yudao.module.system.convert.user.UserConvert;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
@@ -34,6 +36,7 @@ import java.util.Map;
 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
 
 @Tag(name = "管理后台 - 用户")
 @RestController
@@ -45,6 +48,8 @@ public class UserController {
     private AdminUserService userService;
     @Resource
     private DeptService deptService;
+    @Resource
+    private PermissionApi permissionApi;
 
     @PostMapping("/create")
     @Operation(summary = "新增用户")
@@ -91,6 +96,7 @@ public class UserController {
     @Operation(summary = "获得用户分页列表")
     @PreAuthorize("@ss.hasPermission('system:user:list')")
     public CommonResult<PageResult<UserRespVO>> getUserPage(@Valid UserPageReqVO pageReqVO) {
+
         // 获得用户分页列表
         PageResult<AdminUserDO> pageResult = userService.getUserPage(pageReqVO);
         if (CollUtil.isEmpty(pageResult.getList())) {

+ 6 - 0
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/dept/DeptDO.java

@@ -67,4 +67,10 @@ public class DeptDO extends TenantBaseDO {
      */
     private Integer status;
 
+    /**
+     * 部门状态
+     *
+     * 枚举 {@link CommonStatusEnum}
+     */
+    private String type;
 }

+ 0 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/user/AdminUserDO.java

@@ -33,7 +33,6 @@ public class AdminUserDO extends TenantBaseDO {
      */
     @TableId
     private Long id;
-
     /**
      * 学号
      */

+ 18 - 3
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/dept/DeptMapper.java

@@ -17,7 +17,12 @@ public interface DeptMapper extends BaseMapperX<DeptDO> {
                 .likeIfPresent(DeptDO::getName, reqVO.getName())
                 .eqIfPresent(DeptDO::getStatus, reqVO.getStatus()));
     }
-
+    default List<DeptDO> selectList(Long collegeId,DeptListReqVO reqVO) {
+        return selectList(new LambdaQueryWrapperX<DeptDO>()
+                .likeIfPresent(DeptDO::getName, reqVO.getName())
+                .eqIfPresent(DeptDO::getStatus, reqVO.getStatus())
+        );
+    }
     default DeptDO selectByParentIdAndName(Long parentId, String name) {
         return selectOne(DeptDO::getParentId, parentId, DeptDO::getName, name);
     }
@@ -30,10 +35,20 @@ public interface DeptMapper extends BaseMapperX<DeptDO> {
         return selectList(DeptDO::getParentId, parentIds);
     }
 
-    default List<DeptDO> selectListByParentId(Long id) {
-        return selectList(DeptDO::getParentId, id);
+    default List<DeptDO> selectListByParentIdAndCollege(Long id) {
+        return selectList(
+                new LambdaQueryWrapperX<DeptDO>()
+                        .eqIfPresent(DeptDO::getParentId, id)
+                        .eqIfPresent(DeptDO::getType,"college")
+              );
     }
+    default List<DeptDO> selectListByParentId(Long id) {
+        return selectList(
+                new LambdaQueryWrapperX<DeptDO>()
+                        .eqIfPresent(DeptDO::getParentId, id)
 
+        );
+    }
     default List<DeptDO> selectListByParentIds(List<Long> ids) {
         return selectList(DeptDO::getParentId, ids);
     }

+ 15 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptService.java

@@ -63,6 +63,14 @@ public interface DeptService {
      */
     List<DeptDO> getDeptList(DeptListReqVO reqVO);
 
+    /**
+     * 辅导员获取筛选学院部门列表
+     *
+     * @param reqVO 筛选条件请求 VO
+     * @return 部门列表
+     */
+    List<DeptDO> getDeptListByCollege(Long collegeId,DeptListReqVO reqVO);
+
     /**
      * 筛选部门列表
      * @param id 部门id
@@ -97,6 +105,12 @@ public interface DeptService {
      * @return 子部门列表
      */
     Long getCollegeId(Long id);
+    /**
+     * 获取学院数量
+     * @return Long
+     */
+    Long getCollegeNum();
+
 
     /**
      * 通过固定id查找学院id
@@ -133,5 +147,5 @@ public interface DeptService {
      */
     void validateDeptList(Collection<Long> ids);
 
-//    List<DeptDO> updateSchoolDept();
+    List<DeptDO> updateSchoolDept();
 }

+ 125 - 4
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/dept/DeptServiceImpl.java

@@ -6,12 +6,18 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
-
+import cn.iocoder.yudao.module.eve.api.data.classes.ClassesApi;
+import cn.iocoder.yudao.module.eve.api.data.classes.dto.ClassesDTO;
+import cn.iocoder.yudao.module.eve.api.data.classes.dto.ClassesDTOO;
+import cn.iocoder.yudao.module.eve.api.data.professional.ProfessionalApi;
+import cn.iocoder.yudao.module.eve.api.data.professional.dto.ProfessionalDTO;
+import cn.iocoder.yudao.module.eve.api.data.schooldept.SchoolDeptApi;
+import cn.iocoder.yudao.module.eve.api.data.schooldept.dto.SchoolDeptDTO;
 import cn.iocoder.yudao.module.system.api.dept.DeptApi;
 import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptListReqVO;
 import cn.iocoder.yudao.module.system.controller.admin.dept.vo.dept.DeptSaveReqVO;
-
+import cn.iocoder.yudao.module.system.convert.dept.SysDeptConvert;
 import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
 import cn.iocoder.yudao.module.system.dal.mysql.dept.DeptMapper;
 import cn.iocoder.yudao.module.system.dal.redis.RedisKeyConstants;
@@ -44,7 +50,12 @@ public class DeptServiceImpl implements DeptService {
     @Resource
     private DeptMapper deptMapper;
 
-
+    @Resource
+    private ClassesApi classesApi;
+    @Resource
+    private ProfessionalApi professionalApi;
+    @Resource
+    private SchoolDeptApi schoolDeptApi;
 
     @Override
     @CacheEvict(cacheNames = RedisKeyConstants.DEPT_CHILDREN_ID_LIST,
@@ -164,6 +175,7 @@ public class DeptServiceImpl implements DeptService {
     }
 
     @Override
+    @DataPermission(enable = false)
     public List<DeptDO> getDeptList(Collection<Long> ids) {
         if (CollUtil.isEmpty(ids)) {
             return Collections.emptyList();
@@ -177,8 +189,15 @@ public class DeptServiceImpl implements DeptService {
         list.sort(Comparator.comparing(DeptDO::getSort));
         return list;
     }
+    @Override
+    public List<DeptDO> getDeptListByCollege(Long collegeId,DeptListReqVO reqVO) {
+        List<DeptDO> list = deptMapper.selectList(reqVO);
+        list.sort(Comparator.comparing(DeptDO::getSort));
+        return list;
+    }
 
     @Override
+    @DataPermission(enable = false)
     public List<DeptDO> getDeptListByDept(Long id) {
         List<DeptDO> list = getChildDeptList(id);
         list.sort(Comparator.comparing(DeptDO::getSort));
@@ -186,6 +205,7 @@ public class DeptServiceImpl implements DeptService {
     }
 
     @Override
+
     public List<DeptDO> getChildDeptList(Long id) {
         List<DeptDO> children = new LinkedList<>();
         // 遍历每一层
@@ -204,8 +224,15 @@ public class DeptServiceImpl implements DeptService {
         return children;
     }
 
+    @Override
+    @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
+    public Long getCollegeNum() {
+        List<DeptDO> collegeList = getCollegeListByGlutID(0L);
+        return (long)collegeList.size();
+    }
 
     @Override
+    @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
     public Long getCollegeId(Long id) {
         List<DeptDO> collegeList = getCollegeListByGlutID(id);
         if(collegeList.isEmpty()){
@@ -215,6 +242,10 @@ public class DeptServiceImpl implements DeptService {
 
         return findCollegeId(id,collegeIdSet);
     }
+
+
+
+    @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
     public Long findCollegeId(Long id,Set<Long> collegeIdSet) {
         if(collegeIdSet.contains(id)){
             return id;
@@ -228,11 +259,13 @@ public class DeptServiceImpl implements DeptService {
         }
     }
     @Override
+    @DataPermission(enable = false) // 禁用数据权限,避免建立不正确的缓存
     public List<DeptDO> getCollegeListByGlutID(Long id) {
-        return deptMapper.selectListByParentId(0L);
+        return deptMapper.selectListByParentIdAndCollege(0L);
     }
 
     @Override
+    @DataPermission(enable = false)
     public List<DeptDO> getChildDeptListByParent(Long id) {
         return deptMapper.selectListByParentId(id);
     }
@@ -268,6 +301,94 @@ public class DeptServiceImpl implements DeptService {
         });
     }
 
+    @Override
+    public List<DeptDO> updateSchoolDept() {
+        List<SchoolDeptDTO> schoolDeptList = schoolDeptApi.getList();
+        List<ClassesDTO> classesList = classesApi.getList();
+        List<ClassesDTOO> classesList2 = BeanUtils.toBean(classesList, ClassesDTOO.class);
+        List<ProfessionalDTO> professionalList = professionalApi.getList();
+        List<DeptDO> list = new ArrayList<>();
+        //学校单位作为一级
+        list = SysDeptConvert.INSTANCE.schoolDeptToSysDeptList(schoolDeptList);
+
+        deptMapper.insertBatch(list);
+        List<String> bsList = list.stream().map(DeptDO::getBs).collect(Collectors.toList());
+        List<DeptDO> deptList = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>().in(DeptDO::getBs, bsList));
+        Map<String, Long> deptMap = deptList.stream().collect(Collectors.toMap(DeptDO::getBs, DeptDO::getId));
+        //专业二级
+        list = SysDeptConvert.INSTANCE.professionalToDeptList(professionalList);
+        list.stream().filter(profession -> profession.getParentBs() != null).forEach(profession -> profession.setParentId(deptMap.get(profession.getParentBs())));
 
+        deptMapper.insertBatch(list);
+        List<String> bsList2 = list.stream().map(DeptDO::getBs).collect(Collectors.toList());
+        List<DeptDO> deptList2 = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>().in(DeptDO::getBs, bsList2));
+        Map<String, Long> deptMap2 = deptList2.stream().collect(Collectors.toMap(DeptDO::getUniqueBs, DeptDO::getId));
+        //年级三级
+        list = SysDeptConvert.INSTANCE.classesNjToToDeptList(classesList2);
+        list = list.stream()
+                .filter(profession -> profession.getParentBs() != null)
+                // 新增过滤条件,剔除2020级以前的班级
+                .filter(profession -> {
+                    String bs = profession.getBs();
+                    if (bs.matches("\\d{4}级")) { // 确保bs是以四位数字加"级"的形式开始
+                        int classYear = Integer.parseInt(bs.substring(0, 4));
+                        return classYear >= 2020;
+                    }
+                    return false; // 如果格式不匹配,默认保留该元素,或根据需求调整
+                })
+                .peek(profession -> {
+                    String uniqueBs = profession.getUniqueBs();
+                    String bs = profession.getBs();
+                    int newLength = uniqueBs.length() - bs.length();
+                    String parentUniqueBs = uniqueBs.substring(0, newLength);
+                    Long parentId = deptMap2.get(parentUniqueBs);
+                    if (parentId != null) {
+                        profession.setParentId(parentId);
+                    }
+                })
+                .filter(profession -> profession.getParentId() != 0L) // 过滤掉parentId为0的元素
+                .collect(Collectors.toList());
+
+        Set<String> seenUniqueBs = new HashSet<>();
+
+        list = list.stream()
+                .filter(profession -> profession.getParentBs() != null)
+                .filter(profession -> seenUniqueBs.add(profession.getUniqueBs()))
+                .collect(Collectors.toList());
+
+
+        deptMapper.insertBatch(list);
+        List<String> bsList3 = list.stream().map(DeptDO::getBs).collect(Collectors.toList());
+        List<DeptDO> deptList3 = deptMapper.selectList(new LambdaQueryWrapperX<DeptDO>().in(DeptDO::getBs, bsList3));
+        Map<String, Long> deptMap3 = deptList3.stream().collect(Collectors.toMap(DeptDO::getUniqueBs, DeptDO::getId));
+        //班级四级
+        list = SysDeptConvert.INSTANCE.classesToToDeptList(classesList);
+        list = list = list.stream()
+                .filter(profession -> profession.getParentBs() != null)
+                // 新增过滤条件,剔除2020级以前的班级
+                .filter(profession -> {
+                    String bs = profession.getParentBs();
+                    if (bs.matches("\\d{4}级")) { // 确保bs是以四位数字加"级"的形式开始
+                        int classYear = Integer.parseInt(bs.substring(0, 4));
+                        return classYear >= 2020;
+                    }
+                    return false; // 如果格式不匹配,默认保留该元素,或根据需求调整
+                })
+                .peek(profession -> {
+                    String uniqueBs = profession.getUniqueBs();
+                    String bs = profession.getBs();
+                    int newLength = uniqueBs.length() - bs.length();
+                    String parentUniqueBs = uniqueBs.substring(0, newLength);
+                    Long parentId = deptMap3.get(parentUniqueBs);
+                    if (parentId != null) {
+                        profession.setParentId(parentId);
+                    }
+                })
+                .filter(profession -> profession.getParentId() != 0L) // 过滤掉parentId为0的元素
+                .collect(Collectors.toList());
+
+        deptMapper.insertBatch(list);
+        return list;
+    }
 
 }

+ 7 - 1
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/permission/PermissionServiceImpl.java

@@ -309,7 +309,13 @@ public class PermissionServiceImpl implements PermissionService {
             }
             // 情况四,DEPT_DEPT_AND_CHILD
             if (Objects.equals(role.getDataScope(), DataScopeEnum.DEPT_AND_CHILD.getScope())) {
-                CollUtil.addAll(result.getDeptIds(), deptService.getChildDeptIdListFromCache(userDeptId.get()));
+                if(hasAnyRoles(userId,"fudaoyuan")){
+                    Long collegeId = deptService.getCollegeId(userService.getUser(userId).getDeptId());
+                    CollUtil.addAll(result.getDeptIds(),deptService.getChildDeptIdListFromCache(collegeId));
+                    CollUtil.addAll(result.getDeptIds(),collegeId);
+                }else {
+                    CollUtil.addAll(result.getDeptIds(), deptService.getChildDeptIdListFromCache(userDeptId.get()));
+                }
                 // 添加本身部门编号
                 CollUtil.addAll(result.getDeptIds(), userDeptId.get());
                 continue;

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

@@ -9,6 +9,7 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
 import cn.iocoder.yudao.framework.datapermission.core.util.DataPermissionUtils;
 import cn.iocoder.yudao.module.infra.api.file.FileApi;
 import cn.iocoder.yudao.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO;
@@ -257,6 +258,7 @@ public class AdminUserServiceImpl implements AdminUserService {
     }
 
     @Override
+    @DataPermission(enable = false)
     public List<AdminUserDO> getUserListByDeptIds(Collection<Long> deptIds) {
         if (CollUtil.isEmpty(deptIds)) {
             return Collections.emptyList();
@@ -277,6 +279,7 @@ public class AdminUserServiceImpl implements AdminUserService {
     }
 
     @Override
+    @DataPermission(enable = false)
     public List<AdminUserDO> getUserList(Collection<Long> ids) {
         if (CollUtil.isEmpty(ids)) {
             return Collections.emptyList();