wuzhen update

This commit is contained in:
wuzhen committed 2025-08-12 21:05:36 +08:00
1 parent b8da4c17bf
commit 8c41101de8
7 files changed
+248 -67

No files matched your search

@@ -56,19 +56,14 @@ public class JcbtWorkStudyApplicationCollegeReviewController extends BaseControl
@GetMapping("/pendingList")
public TableDataInfo<JcbtWorkStudyApplicationVo> pendingList(JcbtWorkStudyApplicationBo bo, PageQuery pageQuery) {
// 获取当前用户的学院ID
String currentUserCollegeId = getCurrentUserCollegeId();
Long currentUserCollegeId = getCurrentUserCollegeIdAsLong();
if (currentUserCollegeId == null) {
log.warn("当前用户没有关联的学院信息,无法查看审核列表");
return TableDataInfo.build();
}
// 设置学院过滤条件 - 只查看本学院学生的申请
try {
bo.setCollegeId(Long.parseLong(currentUserCollegeId));
} catch (NumberFormatException e) {
log.error("学院ID格式错误: {}", currentUserCollegeId);
return TableDataInfo.build();
}
bo.setCollegeId(currentUserCollegeId);
// 只查询已提交状态的申请(待学院审核)
bo.setStatus("SUBMITTED");
@@ -84,19 +79,14 @@ public class JcbtWorkStudyApplicationCollegeReviewController extends BaseControl
@GetMapping("/list")
public TableDataInfo<JcbtWorkStudyApplicationVo> list(JcbtWorkStudyApplicationBo bo, PageQuery pageQuery) {
// 获取当前用户的学院ID
String currentUserCollegeId = getCurrentUserCollegeId();
Long currentUserCollegeId = getCurrentUserCollegeIdAsLong();
if (currentUserCollegeId == null) {
log.warn("当前用户没有关联的学院信息,无法查看申请列表");
return TableDataInfo.build();
}
// 设置学院过滤条件 - 只查看本学院学生的申请
try {
bo.setCollegeId(Long.parseLong(currentUserCollegeId));
} catch (NumberFormatException e) {
log.error("学院ID格式错误: {}", currentUserCollegeId);
return TableDataInfo.build();
}
bo.setCollegeId(currentUserCollegeId);
// 审核模块不显示草稿状态的申请
if (bo.getStatus() == null || bo.getStatus().isEmpty()) {
@@ -121,17 +111,32 @@ public class JcbtWorkStudyApplicationCollegeReviewController extends BaseControl
@SaCheckPermission("jcbt:workStudyApplication:collegeReview")
@GetMapping("/{id}")
public R<JcbtWorkStudyApplicationVo> getInfo(@PathVariable Long id) {
// 获取申请信息
JcbtWorkStudyApplicationVo vo = workStudyApplicationService.queryById(id);
if (vo == null) {
return R.fail("申请不存在");
}
// 权限检查:只能查看本学院学生的申请
String currentUserCollegeId = getCurrentUserCollegeId();
if (currentUserCollegeId == null || !currentUserCollegeId.equals(vo.getCollegeId())) {
return R.fail("无权查看此申请");
Long currentUserCollegeId = getCurrentUserCollegeIdAsLong();
// 添加详细日志用于调试
log.info("权限检查 - 申请ID: {}, 申请学院ID: {}({}), 当前用户学院ID: {}({})",
id, vo.getCollegeId(), vo.getCollegeId() != null ? vo.getCollegeId().getClass().getSimpleName() : "null",
currentUserCollegeId, currentUserCollegeId != null ? currentUserCollegeId.getClass().getSimpleName() : "null");
if (currentUserCollegeId == null) {
log.warn("权限检查失败 - 当前用户没有关联的学院信息,用户ID: {}, 部门ID: {}, 部门名称: {}",
LoginHelper.getUserId(), LoginHelper.getDeptId(), LoginHelper.getDeptName());
return R.fail("无权查看此申请:用户未关联学院信息");
}
if (!currentUserCollegeId.equals(vo.getCollegeId())) {
log.warn("权限检查失败 - 学院不匹配,申请学院ID: {}, 用户学院ID: {}", vo.getCollegeId(), currentUserCollegeId);
return R.fail("无权查看此申请:只能查看本学院学生的申请");
}
log.info("权限检查通过 - 申请ID: {}", id);
return R.ok(vo);
}
@@ -151,7 +156,7 @@ public class JcbtWorkStudyApplicationCollegeReviewController extends BaseControl
return R.fail("申请不存在");
}
String currentUserCollegeId = getCurrentUserCollegeId();
Long currentUserCollegeId = getCurrentUserCollegeIdAsLong();
if (currentUserCollegeId == null || !currentUserCollegeId.equals(application.getCollegeId())) {
return R.fail("无权审核此申请");
}
@@ -172,7 +177,7 @@ public class JcbtWorkStudyApplicationCollegeReviewController extends BaseControl
@Parameter(description = "审核意见") @RequestParam String reviewComment) {
// 权限检查:批量审核前检查所有申请是否属于当前用户学院
String currentUserCollegeId = getCurrentUserCollegeId();
Long currentUserCollegeId = getCurrentUserCollegeIdAsLong();
if (currentUserCollegeId == null) {
return R.fail("当前用户没有关联的学院信息");
}
@@ -196,19 +201,14 @@ public class JcbtWorkStudyApplicationCollegeReviewController extends BaseControl
@SaCheckPermission("jcbt:workStudyApplication:collegeReview")
@GetMapping("/statistics")
public R<Map<String, Object>> getStatistics() {
String currentUserCollegeId = getCurrentUserCollegeId();
Long currentUserCollegeId = getCurrentUserCollegeIdAsLong();
if (currentUserCollegeId == null) {
return R.fail("当前用户没有关联的学院信息");
}
// 构建查询条件
JcbtWorkStudyApplicationBo bo = new JcbtWorkStudyApplicationBo();
try {
bo.setCollegeId(Long.parseLong(currentUserCollegeId));
} catch (NumberFormatException e) {
log.error("学院ID格式错误: {}", currentUserCollegeId);
return R.fail("学院ID格式错误");
}
bo.setCollegeId(currentUserCollegeId);
// 获取各状态申请数量
Map<String, Object> statistics = new HashMap<>();
@@ -267,10 +267,58 @@ public class JcbtWorkStudyApplicationCollegeReviewController extends BaseControl
return R.ok(options);
}
// ========== 辅助方法 ==========
// ========== 工具方法 ==========
/**
* 获取当前用户所属学院ID
* 调试权限信息 - 查看当前用户的学院关联情况
*/
@Operation(summary = "调试权限信息")
@SaCheckPermission("jcbt:workStudyApplication:collegeReview")
@GetMapping("/debug/permission")
public R<Map<String, Object>> debugPermission() {
Map<String, Object> result = new HashMap<>();
try {
Long userId = LoginHelper.getUserId();
result.put("userId", userId);
result.put("username", LoginHelper.getUsername());
result.put("deptId", LoginHelper.getDeptId());
result.put("deptName", LoginHelper.getDeptName());
try {
result.put("deptCategory", LoginHelper.getDeptCategory());
} catch (Exception e) {
result.put("deptCategory", "获取失败: " + e.getMessage());
}
// 检查学生信息
try {
XgStudentMsgVo studentInfo = xgStudentMsgService.queryByUserId(userId);
if (studentInfo != null) {
result.put("isStudent", true);
result.put("studentCollegeId", studentInfo.getCollegeId());
result.put("studentCollegeName", studentInfo.getCollegeName());
} else {
result.put("isStudent", false);
}
} catch (Exception e) {
result.put("studentInfoError", e.getMessage());
}
// 获取最终的学院ID
String collegeId = getCurrentUserCollegeId();
result.put("finalCollegeId", collegeId);
result.put("hasCollegeAccess", collegeId != null);
} catch (Exception e) {
result.put("error", e.getMessage());
}
return R.ok(result);
}
/**
* 获取当前用户的学院ID
* 通过查询学生信息或用户部门信息获取
*/
private String getCurrentUserCollegeId() {
@@ -331,4 +379,20 @@ public class JcbtWorkStudyApplicationCollegeReviewController extends BaseControl
return null;
}
}
/**
* 获取当前用户的学院ID,返回Long类型
*/
private Long getCurrentUserCollegeIdAsLong() {
String collegeIdStr = getCurrentUserCollegeId();
if (collegeIdStr == null) {
return null;
}
try {
return Long.parseLong(collegeIdStr);
} catch (NumberFormatException e) {
log.error("学院ID格式错误: {}", collegeIdStr, e);
return null;
}
}
}
@@ -15,6 +15,12 @@
<result property="grade" column="grade"/>
<result property="className" column="class_name"/>
<result property="phone" column="phone"/>
<result property="contactPhone" column="contact_phone"/>
<result property="idCard" column="id_card"/>
<result property="familyFinancialStatus" column="family_financial_status"/>
<result property="plannedWorkHours" column="planned_work_hours"/>
<result property="positionType" column="position_type"/>
<result property="workLocation" column="work_location"/>
<result property="email" column="email"/>
<result property="applicationReason" column="application_reason"/>
<result property="status" column="status"/>
@@ -52,6 +58,12 @@
grade,
class_name,
phone,
contact_phone,
id_card,
family_financial_status,
planned_work_hours,
position_type,
work_location,
email,
application_reason,
status,