教研室账号校验改为用角色校验

This commit is contained in:
2026-09-18 19:31:53 +08:00
parent 5a3d202599
commit 7096873e2c
3 changed files with 16 additions and 2 deletions
@@ -17,4 +17,13 @@ public interface JYSDLBMapper extends BaseMapper<JYSDLB> {
+ "WHERE LOWER(TRIM(a.\"账号\")) = LOWER(TRIM(#{username})) "
+ "OR LOWER(TRIM(a.\"统一账号\")) = LOWER(TRIM(#{username}))")
String selectResearchOfficeIdByAccount(@Param("username") String username);
/**
* 按登录用户所属部门(SYS_USER.DEPT_ID = 教研室表.部门编号)解析教研室。
* 用于持有教研室角色的系统账号(旧账号体系的教研室登录表未绑定时兜底)。
*/
@Select("SELECT TRIM(b.\"教研室代号\") FROM \"教研室表\" b "
+ "JOIN SYS_USER u ON u.DEPT_ID = b.\"部门编号\" "
+ "WHERE LOWER(TRIM(u.USER_NAME)) = LOWER(TRIM(#{username})) AND ROWNUM = 1")
String selectResearchOfficeIdByUserDept(@Param("username") String username);
}
@@ -257,7 +257,7 @@ public class TeachingMaterialServiceImpl implements TeachingMaterialService {
public void downloadTemplate(HttpServletResponse response) {
try {
// 从resources/template目录读取模板文件
ClassPathResource resource = new ClassPathResource("template/教材管理.xls");
ClassPathResource resource = new ClassPathResource("file/教材管理.xls");
InputStream is = resource.getInputStream();
// 设置响应头
@@ -103,7 +103,12 @@ public class JwglRoleHelper {
if (StringUtils.isEmpty(username) || jysdlbMapper == null) {
return null;
}
return jysdlbMapper.selectResearchOfficeIdByAccount(username);
String officeId = jysdlbMapper.selectResearchOfficeIdByAccount(username);
// 教研室角色账号按所属部门解析教研室;普通教员不得走此通道
if (StringUtils.isEmpty(officeId) && hasRoleKey(ROLE_RESEARCH_OFFICE)) {
officeId = jysdlbMapper.selectResearchOfficeIdByUserDept(username);
}
return officeId;
} catch (Exception ignored) {
return null;
}