From 616c3102afa7fa4d7f99745b3d5fc43c8d5d049f Mon Sep 17 00:00:00 2001 From: wuzhen <52326163@qq.com> Date: Wed, 13 Aug 2025 08:23:34 +0800 Subject: [PATCH] wuzhen update --- .../domain/bo/JcbtWorkStudyApplicationBo.java | 10 ++++ .../JcbtWorkStudyApplicationServiceImpl.java | 51 ++++++++++++++++--- web/src/store/modules/permission.ts | 11 +++- .../depreview/components/AllApplications.vue | 2 +- 4 files changed, 65 insertions(+), 9 deletions(-) diff --git a/backend/ruoyi-modules/ruoyi-jcbt/src/main/java/org/dromara/jcbt/domain/bo/JcbtWorkStudyApplicationBo.java b/backend/ruoyi-modules/ruoyi-jcbt/src/main/java/org/dromara/jcbt/domain/bo/JcbtWorkStudyApplicationBo.java index 857c6aa6..750b1e0c 100644 --- a/backend/ruoyi-modules/ruoyi-jcbt/src/main/java/org/dromara/jcbt/domain/bo/JcbtWorkStudyApplicationBo.java +++ b/backend/ruoyi-modules/ruoyi-jcbt/src/main/java/org/dromara/jcbt/domain/bo/JcbtWorkStudyApplicationBo.java @@ -212,4 +212,14 @@ public class JcbtWorkStudyApplicationBo extends BaseEntity { */ private List statusList; + /** + * 创建时间开始(用于时间范围查询) + */ + private String createTimeStart; + + /** + * 创建时间结束(用于时间范围查询) + */ + private String createTimeEnd; + } diff --git a/backend/ruoyi-modules/ruoyi-jcbt/src/main/java/org/dromara/jcbt/service/impl/JcbtWorkStudyApplicationServiceImpl.java b/backend/ruoyi-modules/ruoyi-jcbt/src/main/java/org/dromara/jcbt/service/impl/JcbtWorkStudyApplicationServiceImpl.java index 35f644c3..b19c6069 100644 --- a/backend/ruoyi-modules/ruoyi-jcbt/src/main/java/org/dromara/jcbt/service/impl/JcbtWorkStudyApplicationServiceImpl.java +++ b/backend/ruoyi-modules/ruoyi-jcbt/src/main/java/org/dromara/jcbt/service/impl/JcbtWorkStudyApplicationServiceImpl.java @@ -23,6 +23,8 @@ import org.dromara.jcbt.enums.WorkStudyApplicationStatusEnum; import org.dromara.jcbt.mapper.JcbtWorkStudyApplicationMapper; import org.dromara.jcbt.mapper.JcbtWorkStudyPositionMapper; import org.dromara.jcbt.service.IJcbtWorkStudyApplicationService; +import org.dromara.xg.service.IXgStudentMsgService; +import org.dromara.xg.domain.vo.XgStudentMsgVo; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -42,6 +44,7 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic private final JcbtWorkStudyApplicationMapper baseMapper; private final JcbtWorkStudyPositionMapper positionMapper; + private final IXgStudentMsgService xgStudentMsgService; /** * 查询勤工俭学申请信息 @@ -161,10 +164,46 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic if (add.getStudentId() == null) { add.setStudentId(LoginHelper.getUserId()); } - // 设置学院ID(如果BO中没有设置的话,设置为默认值0,表示待确定) - if (add.getCollegeId() == null) { - add.setCollegeId(0L); + + // 智能设置学院ID:优先使用BO中的值,否则根据学生信息自动获取 + if (add.getCollegeId() == null || add.getCollegeId().equals(0L)) { + // 根据学生ID从学生信息表中获取学院ID + Long studentId = add.getStudentId(); + if (studentId != null) { + try { + // 调用学生信息服务获取学院ID + XgStudentMsgVo studentInfo = xgStudentMsgService.queryByUserId(studentId); + if (studentInfo != null && StringUtils.isNotBlank(studentInfo.getCollegeId())) { + // 将字符串类型的collegeId转换为Long类型 + try { + Long collegeId = Long.parseLong(studentInfo.getCollegeId()); + add.setCollegeId(collegeId); + log.info("成功获取学生学院信息,studentId={}, collegeId={}, collegeName={}", + studentId, collegeId, studentInfo.getCollegeName()); + + // 同时确保学院名称的一致性 + if (StringUtils.isBlank(add.getCollegeName()) && StringUtils.isNotBlank(studentInfo.getCollegeName())) { + add.setCollegeName(studentInfo.getCollegeName()); + } + } catch (NumberFormatException e) { + log.warn("学院ID格式转换失败,studentId={}, collegeId={}", studentId, studentInfo.getCollegeId(), e); + add.setCollegeId(0L); + } + } else { + // 如果仍然获取不到,记录日志并设置为待确定状态 + log.warn("无法获取学生ID={}的学院信息,设置为待确定状态", studentId); + add.setCollegeId(0L); + } + } catch (Exception e) { + log.error("获取学生学院信息失败,studentId={}", studentId, e); + add.setCollegeId(0L); + } + } else { + log.warn("学生ID为空,无法获取学院信息"); + add.setCollegeId(0L); + } } + // 设置年级(如果BO中没有设置的话,设置为默认值) if (add.getGrade() == null || add.getGrade().trim().isEmpty()) { add.setGrade("未设置"); @@ -173,7 +212,7 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic if (add.getMajorName() == null || add.getMajorName().trim().isEmpty()) { add.setMajorName("待确定"); } - // 设置申请状态为已提交 + // 设置申请状态为已提交 add.setStatus(WorkStudyApplicationStatusEnum.SUBMITTED.getCode()); add.setApplicationDate(new Date()); // 设置岗位名称 @@ -225,7 +264,7 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic if (application == null) { throw new ServiceException("申请不存在"); } - + // 检查当前登录用户权限 Long currentUserId = LoginHelper.getUserId(); if (!currentUserId.equals(application.getCreateBy())) { @@ -236,7 +275,7 @@ public class JcbtWorkStudyApplicationServiceImpl implements IJcbtWorkStudyApplic if (!WorkStudyApplicationStatusEnum.SUBMITTED.getCode().equals(application.getStatus())) { throw new ServiceException("申请状态异常"); } - + return true; } diff --git a/web/src/store/modules/permission.ts b/web/src/store/modules/permission.ts index 1169cc88..d20d89c4 100644 --- a/web/src/store/modules/permission.ts +++ b/web/src/store/modules/permission.ts @@ -9,6 +9,13 @@ import ParentView from '@/components/ParentView/index.vue'; import InnerLink from '@/layout/components/InnerLink/index.vue'; import { ref } from 'vue'; import { createCustomNameComponent } from '@/utils/createCustomNameComponent'; +import { ElNotification } from 'element-plus'; + +// 扩展RouteRecordRaw类型以支持权限 +interface ExtendedRouteRecordRaw extends RouteRecordRaw { + permissions?: string[]; + roles?: string[]; +} // 匹配views里面所有的.vue文件 const modules = import.meta.glob('./../../views/**/*.vue'); @@ -127,8 +134,8 @@ export const usePermissionStore = defineStore('permission', () => { }); // 动态路由遍历,验证是否具备权限 -export const filterDynamicRoutes = (routes: RouteRecordRaw[]) => { - const res: RouteRecordRaw[] = []; +export const filterDynamicRoutes = (routes: ExtendedRouteRecordRaw[]) => { + const res: ExtendedRouteRecordRaw[] = []; routes.forEach((route) => { if (route.permissions) { if (auth.hasPermiOr(route.permissions)) { diff --git a/web/src/views/jcbt/workstudy/depreview/components/AllApplications.vue b/web/src/views/jcbt/workstudy/depreview/components/AllApplications.vue index 44b18b1b..49494d82 100644 --- a/web/src/views/jcbt/workstudy/depreview/components/AllApplications.vue +++ b/web/src/views/jcbt/workstudy/depreview/components/AllApplications.vue @@ -181,7 +181,7 @@ const getList = async () => { const response = await listCollegeApplications(params); console.log('API响应:', response); - + // 处理不同的响应格式 if (response.data) { // 如果是标准的TableDataInfo格式