This commit is contained in:
2026-08-13 16:53:39 +08:00
parent 5210ad34f3
commit ed48da0a78
27 changed files with 392 additions and 313 deletions
@@ -1,8 +1,10 @@
package com.yunhai.bschclassmanage.aspect;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.utils.OtherUtil;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.auth.BoaUserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
@@ -15,6 +17,11 @@ import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
@Aspect
@Component
@Order(1)
@@ -22,9 +29,19 @@ public class ControllerUserContextAspect {
private static final Logger log = LoggerFactory.getLogger(ControllerUserContextAspect.class);
private static final ObjectMapper MAPPER = new ObjectMapper();
/**
* 外部认证框架(yunhai platform)把解析好的 BoaUser 放进 request attribute 的候选 key。
* 如果实际 key 不在此列表中,请在配置/网关侧确认后补充,或改用 Header 解析。
*/
private static final List<String> BOA_USER_ATTR_KEYS = Arrays.asList(
"boaUser", "boauser", "currentUser", "user", "authUser", "loginUser"
);
@Around("execution(* com.yunhai.bschclassmanage.controller..*.*(..))")
public Object setUserContext(ProceedingJoinPoint joinPoint) throws Throwable {
// 1. 从方法参数中提取 BoaUser 和 UserSysRole
// 1. 优先从方法参数中提取 BoaUser 和 UserSysRole(兼容旧写法)
Object[] args = joinPoint.getArgs();
BoaUser boaUser = null;
UserSysRole userSysRole = null;
@@ -37,7 +54,26 @@ public class ControllerUserContextAspect {
}
}
// 2. 填充 UserContext
// 2. 参数缺失时,优先从框架静态持有者 BoaUserContext 取身份(等价于原 BoaUser 参数解析器),
// 再回退到请求属性 / currentrole,确保去掉方法参数后仍能正确填充 UserContext。
if (boaUser == null) {
try {
boaUser = BoaUserContext.get();
} catch (Throwable ignore) {
boaUser = null;
}
}
HttpServletRequest request = getCurrentHttpRequest();
if (request != null) {
if (boaUser == null) {
boaUser = resolveBoaUserFromRequest(request);
}
if (userSysRole == null) {
userSysRole = resolveUserSysRoleFromRequest(request);
}
}
// 3. 填充 UserContext
populateUserContext(boaUser, userSysRole);
try {
@@ -48,6 +84,42 @@ public class ControllerUserContextAspect {
}
}
/**
* 从 currentrole(URL 编码,Header 或 Query 参数)解析 UserSysRole。
*/
private UserSysRole resolveUserSysRoleFromRequest(HttpServletRequest request) {
String raw = request.getHeader("currentrole");
boolean fromQuery = false;
if (raw == null) {
raw = request.getParameter("currentrole");
fromQuery = true;
}
if (raw == null) {
return null;
}
try {
String decoded = fromQuery ? raw : URLDecoder.decode(raw, StandardCharsets.UTF_8.name());
return MAPPER.readValue(decoded, UserSysRole.class);
} catch (Exception e) {
log.warn("解析 currentrole 失败: {}", e.getMessage());
return null;
}
}
/**
* 从 request attribute(外部框架注入的 BoaUser)回退解析。
* 如需要时也可改为从某个固定 Header 解析,请按实际接入方式调整。
*/
private BoaUser resolveBoaUserFromRequest(HttpServletRequest request) {
for (String key : BOA_USER_ATTR_KEYS) {
Object attr = request.getAttribute(key);
if (attr instanceof BoaUser) {
return (BoaUser) attr;
}
}
return null;
}
private HttpServletRequest getCurrentHttpRequest() {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
return attributes != null ? attributes.getRequest() : null;
@@ -69,6 +141,8 @@ public class ControllerUserContextAspect {
log.debug("UserContext set roleId={}, schId={}", userSysRole.getRoleId(), userSysRole.getSchId());
}
UserContext.setType(boaUser != null ? boaUser.getType() : null);
String clientIp = OtherUtil.getClientIp();
UserContext.setIp(clientIp);
log.debug("Client IP set: {}", clientIp);
@@ -1,17 +1,19 @@
package com.yunhai.bschclassmanage.config;
import com.yunhai.bschclassmanage.controller.Handler.UserSysRoleArgumentResolver;
import com.yunhai.bschclassmanage.interceptor.UserContextInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import java.util.List;
@Configuration
public class DWebMvcConfig implements WebMvcConfigurer {
@Autowired
private UserContextInterceptor userContextInterceptor;
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(new UserSysRoleArgumentResolver()); // 无参构造
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(userContextInterceptor).addPathPatterns("/**");
}
}
@@ -1,43 +0,0 @@
package com.yunhai.bschclassmanage.controller.Handler;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.core.MethodParameter; // ✅ 正确包
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
@RestControllerAdvice
public class UserSysRoleArgumentResolver implements HandlerMethodArgumentResolver {
@Override
public boolean supportsParameter(MethodParameter parameter) {
return parameter.getParameterType().equals(UserSysRole.class);
}
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
// 优先从 Header 中获取 currentrole(生产环境由网关/门户注入)
String raw = webRequest.getHeader("currentrole");
boolean fromQuery = false;
if (raw == null) {
// 回退:支持以 URL 查询参数 currentrole 传入(便于调试/测试)
raw = webRequest.getParameter("currentrole");
fromQuery = true;
}
if (raw == null) {
return null; // 或抛异常
}
// Header 中的值通常是 URL 编码的,需要解码;URL 查询参数已被容器自动解码,无需再解
String decoded = fromQuery ? raw : URLDecoder.decode(raw, StandardCharsets.UTF_8.name());
// 反序列化 JSON → UserSysRole
ObjectMapper mapper = new ObjectMapper();
return mapper.readValue(decoded, UserSysRole.class);
}
}
@@ -3,6 +3,8 @@ package com.yunhai.bschclassmanage.controller.Handler;
import com.yunhai.platform.utils.exception.ErrorCode;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -30,4 +32,31 @@ public class ValidationExceptionHandler {
return new ResponseEntity(response, HttpStatus.BAD_REQUEST);
}
/**
* @RequestBody 反序列化失败(JSON 格式错 / 字段类型不符 / 未知字段被拒)。
* 不捕获会被平台兜底成 code:6 / 内部服务错误,这里把真实原因透出来。
*/
@ExceptionHandler(HttpMessageNotReadableException.class)
public ResponseEntity<Map<String, Object>> handleNotReadable(HttpMessageNotReadableException ex) {
Map<String, Object> response = new LinkedHashMap<>();
response.put("code", ErrorCode.ERROR.getCode());
response.put("msg", "请求体(JSON)解析失败: " + (ex.getRootCause() != null ? ex.getRootCause().getMessage() : ex.getMessage()));
response.put("data", null);
response.put("timeNow", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
return new ResponseEntity(response, HttpStatus.BAD_REQUEST);
}
/**
* Content-Type 不是 application/json(如 text/plain、form 表单、缺省),@RequestBody 无法选择转换器。
*/
@ExceptionHandler(HttpMediaTypeNotSupportedException.class)
public ResponseEntity<Map<String, Object>> handleMediaType(HttpMediaTypeNotSupportedException ex) {
Map<String, Object> response = new LinkedHashMap<>();
response.put("code", ErrorCode.ERROR.getCode());
response.put("msg", "请求 Content-Type 不被支持: " + ex.getMessage());
response.put("data", null);
response.put("timeNow", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
return new ResponseEntity(response, HttpStatus.BAD_REQUEST);
}
}
@@ -1,9 +1,9 @@
package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.controller.BaseController;
import com.yunhai.bschclassmanage.entity.OperationLogRecord;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.PageVO;
import com.yunhai.bschclassmanage.service.ILogService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -19,17 +19,15 @@ public class LogController extends BaseController {
private ILogService logService; // 使用接口
@GetMapping("systemSearch")
public PageVO<OperationLogRecord> systemSearch(UserSysRole curRole,
@RequestParam(required = false) String keyword,
public PageVO<OperationLogRecord> systemSearch(@RequestParam(required = false) String keyword,
Pageable pageable) {
return logService.search(curRole.getSchId(),keyword,true,pageable);
return logService.search(UserContext.getSchId(),keyword,true,pageable);
}
@GetMapping("search")
public PageVO<OperationLogRecord> search(UserSysRole curRole,
@RequestParam(required = false) String keyword,
public PageVO<OperationLogRecord> search(@RequestParam(required = false) String keyword,
Pageable pageable) {
return logService.search(curRole.getSchId(),keyword,false,pageable);
return logService.search(UserContext.getSchId(),keyword,false,pageable);
}
}
@@ -1,11 +1,10 @@
package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.platform.openapi.client.YschBaseOpenApi;
import com.yunhai.platform.utils.model.BoaModule;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,13 +23,13 @@ public class LoginUserController {
@GetMapping("GetUserMod")
public List<BoaModule> getUserMod(BoaUser authUserWithDept, UserSysRole curRole) {
return YschBaseOpenApi.getUserModule(authUserWithDept.getId(),curRole.getSchId());
public List<BoaModule> getUserMod() {
return YschBaseOpenApi.getUserModule(UserContext.getUserId(),UserContext.getSchId());
}
@GetMapping("GetUserInfo")
public BoaUser getUserInfo(BoaUser authUserWithDept) {
return authUserWithDept;
public UserContext.UserInfo getUserInfo() {
return UserContext.getCurrentUser();
}
@@ -9,7 +9,6 @@ import com.yunhai.bschclassmanage.entity.SchClass;
import com.yunhai.bschclassmanage.model.excel.ImportRuleExcelColumn;
import com.yunhai.bschclassmanage.model.excel.SchClassExcelColumn;
import com.yunhai.bschclassmanage.model.excel.SchHeightClassExcelColumn;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.BaseSchClassVO;
import com.yunhai.bschclassmanage.model.vo.HigherSchClassVO;
import com.yunhai.bschclassmanage.model.vo.PageVO;
@@ -17,7 +16,6 @@ import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
import com.yunhai.bschclassmanage.service.*;
import com.yunhai.bschclassmanage.utils.EasyPoiUtils;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
@@ -61,64 +59,62 @@ public class SchClassController {
@GetMapping("searcBaseSchClass")
public List<BaseSchClassVO> searcBaseSchClass(UserSysRole curRole,
@RequestParam(required = false) Integer schsystemId,
public List<BaseSchClassVO> searcBaseSchClass(@RequestParam(required = false) Integer schsystemId,
@RequestParam(required = false) Integer gradeId) {
return schClassService.searcBaseSchClass(curRole.getSchId(),schsystemId,gradeId,null);
return schClassService.searcBaseSchClass(UserContext.getSchId(),schsystemId,gradeId,null);
}
@PostMapping("addBaseSchClass")
public void addBaseSchClass(BoaUser authUserWithDept, UserSysRole curRole, Integer gradeId, Integer number) {
schClassService.addBaseSchClass(UserContext.getCurrentUserInfo(),gradeId,number);
public void addBaseSchClass(Integer gradeId, Integer number) {
schClassService.addBaseSchClass(UserContext.getCurrentUser(),gradeId,number);
}
@PostMapping("editClassName")
public void editClassName(BoaUser authUserWithDept, UserSysRole curRole,Integer id,String cname) {
schClassService.editClassName(UserContext.getCurrentUserInfo(),id,cname);
public void editClassName(Integer id,String cname) {
schClassService.editClassName(UserContext.getCurrentUser(),id,cname);
}
@PostMapping("editClassFirstTeacher")
public void editClassfirstTeacher(BoaUser authUserWithDept, UserSysRole curRole,Integer id,Integer firstTeacherId) {
schClassService.editClassFirstTeacher(UserContext.getCurrentUserInfo(),id,firstTeacherId);
public void editClassfirstTeacher(Integer id,Integer firstTeacherId) {
schClassService.editClassFirstTeacher(UserContext.getCurrentUser(),id,firstTeacherId);
}
@PostMapping("editClassSecondTeacher")
public void editClassSecondTeacher(BoaUser authUserWithDept, UserSysRole curRole,Integer id,Integer secondTeacherId) {
schClassService.editClassSecondTeacher(UserContext.getCurrentUserInfo(),id,secondTeacherId);
public void editClassSecondTeacher(Integer id,Integer secondTeacherId) {
schClassService.editClassSecondTeacher(UserContext.getCurrentUser(),id,secondTeacherId);
}
@PostMapping("editClassCampus")
public void editClassCampus(BoaUser authUserWithDept, UserSysRole curRole,Integer id,Integer campusId) {
schClassService.editClassCampus(UserContext.getCurrentUserInfo(),id,campusId);
public void editClassCampus(Integer id,Integer campusId) {
schClassService.editClassCampus(UserContext.getCurrentUser(),id,campusId);
}
@GetMapping("searcHigherSchClass")
public PageVO<HigherSchClassVO> searcHigherSchClass(UserSysRole curRole,
@RequestParam(required = false) Integer year,
public PageVO<HigherSchClassVO> searcHigherSchClass(@RequestParam(required = false) Integer year,
@RequestParam(required = false) Integer campusId,
@RequestParam(required = false) Integer divisionId,
@RequestParam(required = false) Integer majorsId,
Pageable pageable) {
return schClassService.searcHigherSchClass(curRole.getSchId(),year,campusId,divisionId,majorsId,pageable);
return schClassService.searcHigherSchClass(UserContext.getSchId(),year,campusId,divisionId,majorsId,pageable);
}
@PostMapping("saveHigherSchClass")
public void addHigherSchClass(BoaUser authUserWithDept, UserSysRole curRole,@RequestBody SchClass model) {
schClassService.saveHigherSchClass(UserContext.getCurrentUserInfo(),model);
public void addHigherSchClass(@RequestBody SchClass model) {
schClassService.saveHigherSchClass(UserContext.getCurrentUser(),model);
}
@PostMapping("delete/{id}")
public void deleteSchClass(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable Integer id) {
schClassService.deleteSchClass(UserContext.getCurrentUserInfo(),id,curRole.getSchId());
public void deleteSchClass(@PathVariable Integer id) {
schClassService.deleteSchClass(UserContext.getCurrentUser(),id,UserContext.getSchId());
}
@GetMapping("select")
public List<SelectIntVO> getClassSelect(UserSysRole curRole, @RequestParam Integer gradeId) {
return schClassService.getClassSelect(curRole.getSchId(),gradeId);
public List<SelectIntVO> getClassSelect(@RequestParam Integer gradeId) {
return schClassService.getClassSelect(UserContext.getSchId(),gradeId);
}
@GetMapping("selectBySchIdAndGradeId")
@@ -187,8 +183,8 @@ public class SchClassController {
}
@PostMapping("importClasses")
public void importClasses(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
schClassService.importClasses(UserContext.getCurrentUserInfo(),file);
public void importClasses(@RequestPart("file") MultipartFile file) {
schClassService.importClasses(UserContext.getCurrentUser(),file);
}
@@ -206,7 +202,7 @@ public class SchClassController {
column.setClazzCName("");
column.setCampus("示例:南校区");
column.setDivistion("示例:信息工程");
column.setDivistion("示例:软件开发");
column.setMajors("示例:软件开发");
column.setBzr("示例:张三");
classList.add(column);
}
@@ -267,8 +263,8 @@ public class SchClassController {
}
@PostMapping("importHeightClasses")
public void importHeightClasses(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
schClassService.importHeightClasses(UserContext.getCurrentUserInfo(),file);
public void importHeightClasses(@RequestPart("file") MultipartFile file) {
schClassService.importHeightClasses(UserContext.getCurrentUser(),file);
}
@GetMapping("backupAllSnapshot")
@@ -11,12 +11,10 @@ import com.yunhai.bschclassmanage.model.dto.SchCustomGroupDTO;
import com.yunhai.bschclassmanage.model.dto.SetLeaderDTO;
import com.yunhai.bschclassmanage.model.excel.CustomGroupExcelColumn;
import com.yunhai.bschclassmanage.model.excel.ImportRuleExcelColumn;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.SchCustomGroupVO;
import com.yunhai.bschclassmanage.service.*;
import com.yunhai.bschclassmanage.utils.EasyPoiUtils;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -52,28 +50,28 @@ public class SchCustomGroupController {
private ISchTeacherService schTeacherService;
@GetMapping("getSchCustomGroup")
public List<SchCustomGroupVO> getSchCustomGroup(UserSysRole curRole, @RequestParam Integer type) {
return schCustomGroupService.getSchCustomGroup(curRole.getSchId(),type);
public List<SchCustomGroupVO> getSchCustomGroup(@RequestParam Integer type) {
return schCustomGroupService.getSchCustomGroup(UserContext.getSchId(),type);
}
@PostMapping("saveSchCustomGroup")
public void saveSchCustomGroup(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchCustomGroupDTO dto) {
schCustomGroupService.saveSchCustomGroup(UserContext.getCurrentUserInfo(),dto);
public void saveSchCustomGroup(@Valid @RequestBody SchCustomGroupDTO dto) {
schCustomGroupService.saveSchCustomGroup(UserContext.getCurrentUser(),dto);
}
@PostMapping("saveMembers")
public void saveMembers(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody AddMemberDTO dto) {
schCustomGroupService.saveMembers(UserContext.getCurrentUserInfo(),dto);
public void saveMembers(@Valid @RequestBody AddMemberDTO dto) {
schCustomGroupService.saveMembers(UserContext.getCurrentUser(),dto);
}
@PostMapping("setLeaders")
public void setLeaders(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody SetLeaderDTO dto) {
schCustomGroupService.setLeaders(UserContext.getCurrentUserInfo(),dto);
public void setLeaders(@Valid @RequestBody SetLeaderDTO dto) {
schCustomGroupService.setLeaders(UserContext.getCurrentUser(),dto);
}
@PostMapping("deleteSchCustomGroup")
public void deleteSchCustomGroup(UserSysRole curRole,@RequestParam Integer groupId) {
schCustomGroupService.deleteSchCustomGroup(UserContext.getCurrentUserInfo(),groupId);
public void deleteSchCustomGroup(@RequestParam Integer groupId) {
schCustomGroupService.deleteSchCustomGroup(UserContext.getCurrentUser(),groupId);
}
@@ -155,7 +153,7 @@ public class SchCustomGroupController {
@PostMapping("importCustomGroup")
public void importCustomGroup(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
schCustomGroupService.importCustomGroup(UserContext.getCurrentUserInfo(),file);
public void importCustomGroup(@RequestPart("file") MultipartFile file) {
schCustomGroupService.importCustomGroup(UserContext.getCurrentUser(),file);
}
}
@@ -3,11 +3,9 @@ package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchDicCampus;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
import com.yunhai.bschclassmanage.service.ISchDicCampusService;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -24,27 +22,27 @@ public class SchDicCampusController {
private ISchDicCampusService schDicCampusService; // 使用接口
@GetMapping("list")
public List<SchDicCampus> getSchDicCampusCacheList(UserSysRole curRole) {
return schDicCampusService.getSchDicCampusCacheList(curRole.getSchId());
public List<SchDicCampus> getSchDicCampusCacheList() {
return schDicCampusService.getSchDicCampusCacheList(UserContext.getSchId());
}
@PostMapping("save")
public void saveSchCampus(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchDicCampus model) {
schDicCampusService.saveSchCampus(UserContext.getCurrentUserInfo(),model);
public void saveSchCampus(@Valid @RequestBody SchDicCampus model) {
schDicCampusService.saveSchCampus(UserContext.getCurrentUser(),model);
}
@PostMapping("sort")
public void sortSchCampus(BoaUser authUserWithDept, UserSysRole curRole, @RequestBody List<Integer> ids) {
schDicCampusService.sortSchCampus(UserContext.getCurrentUserInfo(),ids);
public void sortSchCampus(@RequestBody List<Integer> ids) {
schDicCampusService.sortSchCampus(UserContext.getCurrentUser(),ids);
}
@PostMapping("delete/{id}")
public void delete(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable Integer id) {
schDicCampusService.delete(UserContext.getCurrentUserInfo(),id);
public void delete(@PathVariable Integer id) {
schDicCampusService.delete(UserContext.getCurrentUser(),id);
}
@GetMapping("select")
public List<SelectIntVO> select(UserSysRole curRole) {
return schDicCampusService.select(curRole.getSchId());
public List<SelectIntVO> select() {
return schDicCampusService.select(UserContext.getSchId());
}
}
@@ -5,13 +5,11 @@ import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.controller.BaseController;
import com.yunhai.bschclassmanage.enums.CourseType;
import com.yunhai.bschclassmanage.model.dto.SchDicCourseDTO;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.PageVO;
import com.yunhai.bschclassmanage.model.vo.SchDicCourseVO;
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
import com.yunhai.bschclassmanage.service.ISchDicCourseService;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
@@ -29,24 +27,23 @@ public class SchDicCourseController extends BaseController {
private ISchDicCourseService schDicCourseService; // 使用接口
@GetMapping("search")
public PageVO<SchDicCourseVO> search(UserSysRole curRole,
@RequestParam(required = false) Integer type,
public PageVO<SchDicCourseVO> search(@RequestParam(required = false) Integer type,
@RequestParam(required = false) String keyword,
@RequestParam(required = false) Integer divisionId,
@RequestParam(required = false) Integer majorsId,
Pageable pageable) {
return schDicCourseService.search(curRole.getSchId(),type,keyword,divisionId,majorsId,pageable);
return schDicCourseService.search(UserContext.getSchId(),type,keyword,divisionId,majorsId,pageable);
}
@PostMapping("save")
public void saveSchMajors(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchDicCourseDTO dto) {
schDicCourseService.saveSchCourse(UserContext.getCurrentUserInfo(),dto);
public void saveSchMajors(@Valid @RequestBody SchDicCourseDTO dto) {
schDicCourseService.saveSchCourse(UserContext.getCurrentUser(),dto);
}
@PostMapping("delete/{id}")
public void delete(BoaUser authUserWithDept, UserSysRole curRole, @PathVariable Integer id) {
schDicCourseService.delete(UserContext.getCurrentUserInfo(),id);
public void delete(@PathVariable Integer id) {
schDicCourseService.delete(UserContext.getCurrentUser(),id);
}
@@ -3,11 +3,9 @@ package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchDicDivision;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
import com.yunhai.bschclassmanage.service.ISchDicDivisionService;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -24,27 +22,27 @@ public class SchDicDivisionController {
private ISchDicDivisionService schDicDivisionService; // 使用接口
@GetMapping("list")
public List<SchDicDivision> getSchDicDivisionCacheList(UserSysRole curRole) {
return schDicDivisionService.getSchDicDivisionCacheList(curRole.getSchId());
public List<SchDicDivision> getSchDicDivisionCacheList() {
return schDicDivisionService.getSchDicDivisionCacheList(UserContext.getSchId());
}
@PostMapping("save")
public void saveSchDivision(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchDicDivision model) {
schDicDivisionService.saveSchDivision(UserContext.getCurrentUserInfo(),model);
public void saveSchDivision(@Valid @RequestBody SchDicDivision model) {
schDicDivisionService.saveSchDivision(UserContext.getCurrentUser(),model);
}
@PostMapping("sort")
public void sortSchDivision(BoaUser authUserWithDept, UserSysRole curRole,@RequestBody List<Integer> ids) {
schDicDivisionService.sortSchDivision(UserContext.getCurrentUserInfo(),ids);
public void sortSchDivision(@RequestBody List<Integer> ids) {
schDicDivisionService.sortSchDivision(UserContext.getCurrentUser(),ids);
}
@PostMapping("delete/{id}")
public void delete(BoaUser authUserWithDept, UserSysRole curRole, @PathVariable Integer id) {
schDicDivisionService.delete(UserContext.getCurrentUserInfo(),id);
public void delete(@PathVariable Integer id) {
schDicDivisionService.delete(UserContext.getCurrentUser(),id);
}
@GetMapping("select")
public List<SelectIntVO> select(UserSysRole curRole) {
return schDicDivisionService.select(curRole.getSchId());
public List<SelectIntVO> select() {
return schDicDivisionService.select(UserContext.getSchId());
}
}
@@ -3,11 +3,9 @@ package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchDicMajors;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
import com.yunhai.bschclassmanage.service.ISchDicMajorsService;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -24,29 +22,28 @@ public class SchDicMajorsController {
private ISchDicMajorsService schDicMajorsService; // 使用接口
@GetMapping("list")
public List<SchDicMajors> getSchDicMajorsList(UserSysRole curRole,
@RequestParam(required = false)String keyword) {
return schDicMajorsService.getSchDicMajorsList(curRole.getSchId(),keyword);
public List<SchDicMajors> getSchDicMajorsList(@RequestParam(required = false)String keyword) {
return schDicMajorsService.getSchDicMajorsList(UserContext.getSchId(),keyword);
}
@PostMapping("save")
public void saveSchMajors(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchDicMajors model) {
schDicMajorsService.saveSchMajors(UserContext.getCurrentUserInfo(),model);
public void saveSchMajors(@Valid @RequestBody SchDicMajors model) {
schDicMajorsService.saveSchMajors(UserContext.getCurrentUser(),model);
}
@PostMapping("sort")
public void sortSchMajors(BoaUser authUserWithDept, UserSysRole curRole, @RequestBody List<Integer> ids) {
schDicMajorsService.sortSchMajors(UserContext.getCurrentUserInfo(),ids);
public void sortSchMajors(@RequestBody List<Integer> ids) {
schDicMajorsService.sortSchMajors(UserContext.getCurrentUser(),ids);
}
@PostMapping("delete/{id}")
public void delete(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable Integer id) {
schDicMajorsService.delete(UserContext.getCurrentUserInfo(),id);
public void delete(@PathVariable Integer id) {
schDicMajorsService.delete(UserContext.getCurrentUser(),id);
}
@GetMapping("select")
public List<SelectIntVO> select(UserSysRole curRole) {
return schDicMajorsService.select(curRole.getSchId());
public List<SelectIntVO> select() {
return schDicMajorsService.select(UserContext.getSchId());
}
}
@@ -1,8 +1,8 @@
package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
import com.yunhai.bschclassmanage.service.IBaseSchsystemGradeService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -20,23 +20,23 @@ public class SchGradeController {
private IBaseSchsystemGradeService baseSchsystemGradeService; // 使用接口
@GetMapping("select")
public List<SelectIntVO> getGradeSelect(UserSysRole curRole) {
return baseSchsystemGradeService.getGradeSelect(curRole.getSchId(),null,null);
public List<SelectIntVO> getGradeSelect() {
return baseSchsystemGradeService.getGradeSelect(UserContext.getSchId(),null,null);
}
@GetMapping("selectBySchsystemId")
public List<SelectIntVO> getGradeSelect(UserSysRole curRole,@RequestParam Integer schsystemId) {
return baseSchsystemGradeService.getGradeSelect(curRole.getSchId(),schsystemId,null);
public List<SelectIntVO> getGradeSelectBySchsystemId(@RequestParam Integer schsystemId) {
return baseSchsystemGradeService.getGradeSelect(UserContext.getSchId(),schsystemId,null);
}
@GetMapping("selectBySchId")
public List<SelectIntVO> getGradeSelect(@RequestParam Integer schId) {
public List<SelectIntVO> getGradeSelectBySchId(@RequestParam Integer schId) {
return baseSchsystemGradeService.getGradeSelect(schId,null,null);
}
@GetMapping("selectByMajorsId")
public List<SelectIntVO> getGradeByMajorsId(UserSysRole curRole,@RequestParam Integer majorsId) {
return baseSchsystemGradeService.getGradeByMajorsId(curRole.getSchId(),majorsId);
public List<SelectIntVO> getGradeByMajorsId(@RequestParam Integer majorsId) {
return baseSchsystemGradeService.getGradeByMajorsId(UserContext.getSchId(),majorsId);
}
@@ -11,7 +11,6 @@ import com.yunhai.bschclassmanage.model.dto.StuAbnormalStatusDTO;
import com.yunhai.bschclassmanage.model.dto.StuTransferClassDTO;
import com.yunhai.bschclassmanage.model.excel.ImportRuleExcelColumn;
import com.yunhai.bschclassmanage.model.excel.StudentExcelColumn;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.PageVO;
import com.yunhai.bschclassmanage.model.vo.SchStudentVO;
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
@@ -21,7 +20,6 @@ import com.yunhai.bschclassmanage.service.ISchClassService;
import com.yunhai.bschclassmanage.service.ISchStudentService;
import com.yunhai.bschclassmanage.utils.EasyPoiUtils;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
@@ -55,59 +53,54 @@ public class SchStudentController extends BaseController {
private IComSchTreeService comSchTreeService; // 使用接口
@GetMapping("baseSchSearch")
public PageVO<SchStudentVO> searchBaseSchStudentVO(UserSysRole curRole,
@RequestParam(required = false) Integer schsystemId,
public PageVO<SchStudentVO> searchBaseSchStudentVO(@RequestParam(required = false) Integer schsystemId,
@RequestParam(required = false) Integer gradeId,
@RequestParam(required = false) Integer classId,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return schStudentService.searchBaseSchStudentVO(curRole.getSchId(),schsystemId,gradeId,classId,keyword,true,pageable);
return schStudentService.searchBaseSchStudentVO(UserContext.getSchId(),schsystemId,gradeId,classId,keyword,true,pageable);
}
@GetMapping("higherSchSearch")
public PageVO<SchStudentVO> searchHigherSchStudentVO(UserSysRole curRole,
@RequestParam(required = false) Integer year,
public PageVO<SchStudentVO> searchHigherSchStudentVO(@RequestParam(required = false) Integer year,
@RequestParam(required = false) Integer classId,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return schStudentService.searchHigherSchStudentVO(curRole.getSchId(),year,classId,keyword,true,pageable);
return schStudentService.searchHigherSchStudentVO(UserContext.getSchId(),year,classId,keyword,true,pageable);
}
@GetMapping("baseSchAbnormalSearch")
public PageVO<SchStudentVO> baseSchAbnormalSearch(UserSysRole curRole,
@RequestParam(required = false) Integer schsystemId,
public PageVO<SchStudentVO> baseSchAbnormalSearch(@RequestParam(required = false) Integer schsystemId,
@RequestParam(required = false) Integer gradeId,
@RequestParam(required = false) Integer classId,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return schStudentService.searchBaseSchStudentVO(curRole.getSchId(),schsystemId,gradeId,classId,keyword,false,pageable);
return schStudentService.searchBaseSchStudentVO(UserContext.getSchId(),schsystemId,gradeId,classId,keyword,false,pageable);
}
@GetMapping("higherSchAbnormalSearch")
public PageVO<SchStudentVO> higherSchAbnormalSearch(UserSysRole curRole,
@RequestParam(required = false) Integer year,
public PageVO<SchStudentVO> higherSchAbnormalSearch(@RequestParam(required = false) Integer year,
@RequestParam(required = false) Integer classId,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return schStudentService.searchHigherSchStudentVO(curRole.getSchId(),year,classId,keyword,false,pageable);
return schStudentService.searchHigherSchStudentVO(UserContext.getSchId(),year,classId,keyword,false,pageable);
}
@GetMapping("searchSchClassStudent")
public List<SchStudentVO> searchSchClassStudentVO(UserSysRole curRole,
@RequestParam Integer gradeId,
public List<SchStudentVO> searchSchClassStudentVO(@RequestParam Integer gradeId,
@RequestParam Integer classId) {
return schStudentService.searchSchClassStudentVO(curRole.getSchId(),gradeId,classId,true);
return schStudentService.searchSchClassStudentVO(UserContext.getSchId(),gradeId,classId,true);
}
@PostMapping("save")
public void saveStudent(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody SchStudentVO model) {
schStudentService.saveStudent(UserContext.getCurrentUserInfo(),model);
public void saveStudent(@Valid @RequestBody SchStudentVO model) {
schStudentService.saveStudent(UserContext.getCurrentUser(),model);
}
@PostMapping("delete/{ids}")
public void deleteStudent(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable String ids) {
schStudentService.deleteStudent(UserContext.getCurrentUserInfo(),ids);
public void deleteStudent(@PathVariable String ids) {
schStudentService.deleteStudent(UserContext.getCurrentUser(),ids);
}
@GetMapping("abnormal")
@@ -117,23 +110,23 @@ public class SchStudentController extends BaseController {
@PostMapping("transferClass")
public void transferClass(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody StuTransferClassDTO model) {
schStudentService.transferClass(UserContext.getCurrentUserInfo(),model);
public void transferClass(@Valid @RequestBody StuTransferClassDTO model) {
schStudentService.transferClass(UserContext.getCurrentUser(),model);
}
@PostMapping("setAbnormalStatus")
public void setAbnormalStatus(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody StuAbnormalStatusDTO model) {
schStudentService.setAbnormalStatus(UserContext.getCurrentUserInfo(),model);
public void setAbnormalStatus(@Valid @RequestBody StuAbnormalStatusDTO model) {
schStudentService.setAbnormalStatus(UserContext.getCurrentUser(),model);
}
@PostMapping("setTransferOut/{ids}")
public void setTransferOut(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable String ids){
schStudentService.setTransferOut(UserContext.getCurrentUserInfo(),ids);
public void setTransferOut(@PathVariable String ids){
schStudentService.setTransferOut(UserContext.getCurrentUser(),ids);
}
@PostMapping("setTransferIn")
public void setTransferIn(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody StuTransferClassDTO model) {
schStudentService.setTransferIn(UserContext.getCurrentUserInfo(),model);
public void setTransferIn(@Valid @RequestBody StuTransferClassDTO model) {
schStudentService.setTransferIn(UserContext.getCurrentUser(),model);
}
@GetMapping("transferOutSchSelect")
@@ -219,15 +212,15 @@ public class SchStudentController extends BaseController {
}
@PostMapping("importStudents")
public void importStudents(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
schStudentService.importStudents(UserContext.getCurrentUserInfo(),file);
public void importStudents(@RequestPart("file") MultipartFile file) {
schStudentService.importStudents(UserContext.getCurrentUser(),file);
}
@PostMapping("importStudentClassNo")
public void importStudentClassNo(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file,
public void importStudentClassNo(@RequestPart("file") MultipartFile file,
@RequestParam(required = false) Integer schsystemId,
@RequestParam(required = false) Integer gradeId,
@RequestParam(required = false) Integer classId) {
schStudentService.importStudentClassNo(UserContext.getCurrentUserInfo(),file,schsystemId,gradeId,classId);
schStudentService.importStudentClassNo(UserContext.getCurrentUser(),file,schsystemId,gradeId,classId);
}
}
@@ -3,7 +3,6 @@ package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchDicSubject;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.SelectStrVO;
import com.yunhai.bschclassmanage.service.ISchDicSubjectService;
import com.yunhai.bschclassmanage.utils.UserContext;
@@ -23,29 +22,28 @@ public class SchSubjectController {
private ISchDicSubjectService schDicSubjectService; // 使用接口
@GetMapping("list")
public List<SchDicSubject> getSchSubList(UserSysRole curRole, Integer schSystemId) {
return schDicSubjectService.getSchSubList(curRole.getSchId(),schSystemId);
public List<SchDicSubject> getSchSubList(Integer schSystemId) {
return schDicSubjectService.getSchSubList(UserContext.getSchId(),schSystemId);
}
@PostMapping("save")
public void saveSchSub(BoaUser authUserWithDept,UserSysRole curRole,@Valid @RequestBody SchDicSubject model) {
schDicSubjectService.saveSchSub(UserContext.getCurrentUserInfo(),model);
public void saveSchSub(@Valid @RequestBody SchDicSubject model) {
schDicSubjectService.saveSchSub(UserContext.getCurrentUser(),model);
}
@PostMapping("sort")
public void schSubSort(BoaUser authUserWithDept, UserSysRole curRole, Integer schSystemId, @RequestBody List<String> subIds) {
schDicSubjectService.schSubSort(UserContext.getCurrentUserInfo(),subIds,schSystemId);
public void schSubSort(Integer schSystemId, @RequestBody List<String> subIds) {
schDicSubjectService.schSubSort(UserContext.getCurrentUser(),subIds,schSystemId);
}
@PostMapping("delete/{id}")
public void delSchSub(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable Integer id) {
UserContext.UserInfo user=UserContext.getCurrentUserInfo();
schDicSubjectService.delSchSub(user,id);
public void delSchSub(@PathVariable Integer id) {
schDicSubjectService.delSchSub(UserContext.getCurrentUser(),id);
}
@GetMapping("select")
public List<SelectStrVO> select(UserSysRole curRole,@RequestParam(required = false) Integer schSystemId) {
return schDicSubjectService.select(curRole.getSchId(),schSystemId);
public List<SelectStrVO> select(@RequestParam(required = false) Integer schSystemId) {
return schDicSubjectService.select(UserContext.getSchId(),schSystemId);
}
}
@@ -4,11 +4,9 @@ package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.controller.BaseController;
import com.yunhai.bschclassmanage.entity.SchClassTeach;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.*;
import com.yunhai.bschclassmanage.service.*;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
@@ -42,35 +40,34 @@ public class SchTeachController extends BaseController {
private ISchTeacherService schTeacherService; //使用接口
@GetMapping("search")
public SchTeachMapVO getSchTeachMapVO(UserSysRole curRole,
@RequestParam(required = true) Integer schsystemId,
public SchTeachMapVO getSchTeachMapVO(@RequestParam(required = true) Integer schsystemId,
@RequestParam(required = false) Integer gradeId) {
return schClassTeachService.getSchTeachMapVO(curRole.getSchId(),schsystemId,gradeId);
return schClassTeachService.getSchTeachMapVO(UserContext.getSchId(),schsystemId,gradeId);
}
@GetMapping("getSchClassTeach")
public List<SchTeachMapIdVO> getSchClassTeachMapVO(UserSysRole curRole, @RequestParam Integer gradeId,@RequestParam Integer classId) {
return schClassTeachService.getSchClassTeachMapVO(curRole.getSchId(),gradeId,classId);
public List<SchTeachMapIdVO> getSchClassTeachMapVO(@RequestParam Integer gradeId,@RequestParam Integer classId) {
return schClassTeachService.getSchClassTeachMapVO(UserContext.getSchId(),gradeId,classId);
}
@PostMapping("save")
public void saveTeach(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody SchClassTeach model) {
schClassTeachService.saveTeach(UserContext.getCurrentUserInfo(),model);
public void saveTeach(@Valid @RequestBody SchClassTeach model) {
schClassTeachService.saveTeach(UserContext.getCurrentUser(),model);
}
@PostMapping("delete/{id}")
public void delTeachById(BoaUser authUserWithDept, UserSysRole curRole, @PathVariable Integer id) {
schClassTeachService.delTeachById(UserContext.getCurrentUserInfo(),id);
public void delTeachById(@PathVariable Integer id) {
schClassTeachService.delTeachById(UserContext.getCurrentUser(),id);
}
@PostMapping("delClassTeach")
public void delClassTeach(BoaUser authUserWithDept, UserSysRole curRole,@RequestParam Integer classId) {
schClassTeachService.delClassTeach(UserContext.getCurrentUserInfo(),classId);
public void delClassTeach(@RequestParam Integer classId) {
schClassTeachService.delClassTeach(UserContext.getCurrentUser(),classId);
}
@PostMapping("delBatch")
public void delBatch(BoaUser authUserWithDept, UserSysRole curRole,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) {
schClassTeachService.delBatch(UserContext.getCurrentUserInfo(),schsystemId,gradeId);
public void delBatch(@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) {
schClassTeachService.delBatch(UserContext.getCurrentUser(),schsystemId,gradeId);
}
@@ -174,8 +171,8 @@ public class SchTeachController extends BaseController {
}
@PostMapping("importTeach")
public void importTeach(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) {
schClassTeachService.importTeach(UserContext.getCurrentUserInfo(),file,schsystemId,gradeId);
public void importTeach(@RequestPart("file") MultipartFile file,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) {
schClassTeachService.importTeach(UserContext.getCurrentUser(),file,schsystemId,gradeId);
}
}
@@ -9,7 +9,6 @@ import com.yunhai.bschclassmanage.model.dto.SchTeacherDTO;
import com.yunhai.bschclassmanage.model.dto.TeaTransferGroupDTO;
import com.yunhai.bschclassmanage.model.dto.TeaTransferInGroupDTO;
import com.yunhai.bschclassmanage.model.excel.TeacherExcelColumn;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.PageVO;
import com.yunhai.bschclassmanage.model.vo.SchTeacherTOutVO;
import com.yunhai.bschclassmanage.model.vo.SchTeacherVO;
@@ -18,7 +17,6 @@ import com.yunhai.bschclassmanage.service.IComSchTreeService;
import com.yunhai.bschclassmanage.service.ISchTeacherService;
import com.yunhai.bschclassmanage.utils.EasyPoiUtils;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
@@ -43,11 +41,10 @@ public class SchTeacherController extends BaseController {
private IComSchTreeService comSchTreeService; // 使用接口
@GetMapping("search")
public PageVO<SchTeacherVO> searchSchTeacher(UserSysRole curRole,
@RequestParam(required = false) Integer groupId,
public PageVO<SchTeacherVO> searchSchTeacher(@RequestParam(required = false) Integer groupId,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return schTeacherService.searchSchTeacher(curRole.getSchId(),groupId,keyword,pageable);
return schTeacherService.searchSchTeacher(UserContext.getSchId(),groupId,keyword,pageable);
}
@GetMapping("searchTransferOut")
@@ -59,29 +56,29 @@ public class SchTeacherController extends BaseController {
}
@PostMapping("save")
public void saveTeacher(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchTeacherDTO model) {
schTeacherService.saveTeacher(UserContext.getCurrentUserInfo(),model);
public void saveTeacher(@Valid @RequestBody SchTeacherDTO model) {
schTeacherService.saveTeacher(UserContext.getCurrentUser(),model);
}
@PostMapping("delete/{ids}")
public void deleteTeacher(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable String ids ) {
schTeacherService.deleteTeacher(UserContext.getCurrentUserInfo(),ids);
public void deleteTeacher(@PathVariable String ids ) {
schTeacherService.deleteTeacher(UserContext.getCurrentUser(),ids);
}
@PostMapping("moveGroup")
public void moveGroup(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody TeaTransferGroupDTO model) {
schTeacherService.moveGroup(UserContext.getCurrentUserInfo(),model);
public void moveGroup(@Valid @RequestBody TeaTransferGroupDTO model) {
schTeacherService.moveGroup(UserContext.getCurrentUser(),model);
}
@PostMapping("setStatus")
public void setTeacherStatus(BoaUser authUserWithDept, UserSysRole curRole, String ids,Integer status){
schTeacherService.setTeacherStatus(UserContext.getCurrentUserInfo(),ids,status);
public void setTeacherStatus(String ids,Integer status){
schTeacherService.setTeacherStatus(UserContext.getCurrentUser(),ids,status);
}
@GetMapping("groupSelect") // 当前用户
public List<SelectIntVO> toTeacherGroupSelect(UserSysRole curRole) {
return schTeacherService.toTeacherGroupSelect(curRole.getSchId());
public List<SelectIntVO> toTeacherGroupSelect() {
return schTeacherService.toTeacherGroupSelect(UserContext.getSchId());
}
@GetMapping("groupSelectBySchId")
@@ -90,8 +87,8 @@ public class SchTeacherController extends BaseController {
}
@GetMapping("select")
public List<SelectIntVO> toIdAndNameSelect(UserSysRole curRole,@RequestParam(required = false) Integer groupId) {
return schTeacherService.toIdAndNameSelect(groupId,curRole.getSchId());
public List<SelectIntVO> toIdAndNameSelect(@RequestParam(required = false) Integer groupId) {
return schTeacherService.toIdAndNameSelect(groupId,UserContext.getSchId());
}
@GetMapping("transferOutSchSelect")
@@ -101,22 +98,22 @@ public class SchTeacherController extends BaseController {
@PostMapping("setTransferOut/{ids}")
public void setTransferOut(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable String ids){
schTeacherService.setTransferOut(UserContext.getCurrentUserInfo(),ids);
public void setTransferOut(@PathVariable String ids){
schTeacherService.setTransferOut(UserContext.getCurrentUser(),ids);
}
@PostMapping("setTransferIn")
public void setTransferIn(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody TeaTransferInGroupDTO model) {
schTeacherService.setTransferIn(UserContext.getCurrentUserInfo(),model);
public void setTransferIn(@Valid @RequestBody TeaTransferInGroupDTO model) {
schTeacherService.setTransferIn(UserContext.getCurrentUser(),model);
}
@GetMapping("downloadTemplate")
public void downloadTemplate(UserSysRole curRole,HttpServletResponse response) {
public void downloadTemplate(HttpServletResponse response) {
List<TeacherExcelColumn> list=new ArrayList<>();
String fileName="教师导入模板";
String titleName ="教师信息导入" ;
ExportParams exportParams = new ExportParams(titleName, "");
List<SelectIntVO> teaGroupNameList = comSchTreeService.getTeaGroupNameList(curRole.getSchId(),null);
List<SelectIntVO> teaGroupNameList = comSchTreeService.getTeaGroupNameList(UserContext.getSchId(),null);
for (SelectIntVO group:teaGroupNameList)
{
TeacherExcelColumn column=new TeacherExcelColumn();
@@ -134,8 +131,8 @@ public class SchTeacherController extends BaseController {
}
@PostMapping("importTeachers")
public void importTeachers(BoaUser authUserWithDept, UserSysRole curRole,@RequestPart("file") MultipartFile file) {
schTeacherService.importTeachers(UserContext.getCurrentUserInfo(),file);
public void importTeachers(@RequestPart("file") MultipartFile file) {
schTeacherService.importTeachers(UserContext.getCurrentUser(),file);
}
@@ -1,9 +1,9 @@
package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.model.tool.BaseTree;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.SchSystemTreeVO;
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
import com.yunhai.bschclassmanage.service.IComSchTreeService;
@@ -29,9 +29,9 @@ public class SchTreeController {
}
@GetMapping("getTeacherTree")
public BaseTree getTeacherTree(UserSysRole curRole)
public BaseTree getTeacherTree()
{
return comSchTreeService.getTeacherTree(curRole.getSchId());
return comSchTreeService.getTeacherTree(UserContext.getSchId());
}
@@ -42,41 +42,41 @@ public class SchTreeController {
}
@GetMapping("getGradeTree")
public SchSystemTreeVO getGradeTree(UserSysRole curRole)
public SchSystemTreeVO getGradeTree()
{
return comSchTreeService.getGradeTree(curRole.getSchId());
return comSchTreeService.getGradeTree(UserContext.getSchId());
}
@GetMapping("getClassTree")
public SchSystemTreeVO getClassTree(UserSysRole curRole)
public SchSystemTreeVO getClassTree()
{
return comSchTreeService.getClassTree(curRole.getSchId());
return comSchTreeService.getClassTree(UserContext.getSchId());
}
@GetMapping("getClassHistoryTree")
public SchSystemTreeVO getClassHistoryTree(UserSysRole curRole)
public SchSystemTreeVO getClassHistoryTree()
{
return comSchTreeService.getClassHistoryTree(curRole.getSchId());
return comSchTreeService.getClassHistoryTree(UserContext.getSchId());
}
@GetMapping("getHigherSchGradeTree")
public SchSystemTreeVO getHigherSchGradeTree(UserSysRole curRole)
public SchSystemTreeVO getHigherSchGradeTree()
{
return comSchTreeService.getHigherSchGradeTree(curRole.getSchId());
return comSchTreeService.getHigherSchGradeTree(UserContext.getSchId());
}
@GetMapping("getHigherSchClassTree")
public SchSystemTreeVO getHigherSchClassTree(UserSysRole curRole)
public SchSystemTreeVO getHigherSchClassTree()
{
return comSchTreeService.getHigherSchClassTree(curRole.getSchId());
return comSchTreeService.getHigherSchClassTree(UserContext.getSchId());
}
@GetMapping("getTeaTree")
public BaseTree getTeaTree(UserSysRole curRole)
public BaseTree getTeaTree()
{
return comSchTreeService.getTeaTree(curRole.getSchId());
return comSchTreeService.getTeaTree(UserContext.getSchId());
}
@@ -6,7 +6,6 @@ import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchBinSchsystem;
import com.yunhai.bschclassmanage.enums.UserRole;
import com.yunhai.bschclassmanage.enums.UserType;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.AcademicStageSchsystemVO;
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
import com.yunhai.bschclassmanage.service.IComSchTreeService;
@@ -14,7 +13,6 @@ import com.yunhai.bschclassmanage.service.ISchBinSchsystemService;
import com.yunhai.bschclassmanage.utils.LogContextHolder;
import com.yunhai.bschclassmanage.utils.OtherUtil;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -37,11 +35,10 @@ public class SchsystemController {
* @return 学段分组后的学制列表
*/
@GetMapping("list")
public List<AcademicStageSchsystemVO> getAcademicStageSchsystemList(BoaUser authUserWithDept, UserSysRole curRole,
@RequestParam(required = false) Integer schId) {
public List<AcademicStageSchsystemVO> getAcademicStageSchsystemList(@RequestParam(required = false) Integer schId) {
int roleId = curRole.getRoleId();
boolean isSuperAdmin = UserType.SUPER_ADMINISTRATOR.getId().equals(authUserWithDept.getType());
int roleId = UserContext.getRoleId();
boolean isSuperAdmin = UserType.SUPER_ADMINISTRATOR.getId().equals(UserContext.getType());
boolean isAreaAdmin = UserRole.AREAADMIN.getValue().equals(roleId);
if (!isSuperAdmin && !isAreaAdmin) {
@@ -52,7 +49,7 @@ public class SchsystemController {
Integer targetSchId;
if (isAreaAdmin) {
// 区域管理员:强制使用自己所属的学校,忽略前端传入的schId
targetSchId = curRole.getSchId();
targetSchId = UserContext.getSchId();
if (targetSchId == null || targetSchId <= 0) {
throw new NullPointerException("当前学校管理员未关联有效的学校");
}
@@ -68,8 +65,8 @@ public class SchsystemController {
}
@GetMapping("getType")
public Integer getSchType(UserSysRole curRole) {
return schBinSchsystemService.getSchType(curRole.getSchId());
public Integer getSchType() {
return schBinSchsystemService.getSchType(UserContext.getSchId());
}
/**
@@ -78,14 +75,13 @@ public class SchsystemController {
*/
@PostMapping("save")
@OperationLog(module = "绑定学制")
public void saveSchBinSchsystem(BoaUser authUserWithDept, UserSysRole curRole,
@RequestParam(required = false) Integer schId,
public void saveSchBinSchsystem(@RequestParam(required = false) Integer schId,
@RequestParam("schsystemIds") String schsystemIdsStr) {
UserContext.UserInfo user= UserContext.getCurrentUserInfo();
UserContext.UserInfo user= UserContext.getCurrentUser();
// 2. 角色权限校验
int roleId = user.getRoleId();
boolean isSuperAdmin = UserType.SUPER_ADMINISTRATOR.getId().equals(authUserWithDept.getType());
boolean isSuperAdmin = UserType.SUPER_ADMINISTRATOR.getId().equals(UserContext.getType());
boolean isAreaAdmin = UserRole.AREAADMIN.getValue().equals(roleId);
if (!isSuperAdmin && !isAreaAdmin) {
@@ -96,7 +92,7 @@ public class SchsystemController {
Integer targetSchId;
if (isAreaAdmin) {
// 区域管理员:强制使用自己所属的学校,忽略前端传入的schId
targetSchId = curRole.getSchId();
targetSchId = UserContext.getSchId();
if (targetSchId == null || targetSchId <= 0) {
throw new NullPointerException("当前学校管理员未关联有效的学校");
}
@@ -126,8 +122,8 @@ public class SchsystemController {
}
@GetMapping("select")
public List<SelectIntVO> selectSchBinSchsystem(UserSysRole curRole) {
return schBinSchsystemService.selectSchBinSchsystem(curRole.getSchId());
public List<SelectIntVO> selectSchBinSchsystem() {
return schBinSchsystemService.selectSchBinSchsystem(UserContext.getSchId());
}
@@ -4,11 +4,9 @@ package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.BaseYearTerm;
import com.yunhai.bschclassmanage.model.dto.BaseYearTermDTO;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.bschclassmanage.model.vo.BaseYearTermVO;
import com.yunhai.bschclassmanage.service.IBaseYearTermService;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -32,23 +30,21 @@ public class SystemYearTermController {
}
@PostMapping("add")
public void createYearTerm(BoaUser authUserWithDept, UserSysRole curRole,
@Valid @RequestBody BaseYearTermDTO dto) {
public void createYearTerm(@Valid @RequestBody BaseYearTermDTO dto) {
BaseYearTerm entity = new BaseYearTerm();
entity.setCreateDate(new Date());
entity.setCreateUserId(authUserWithDept.getId());
entity.setCreateUserId(UserContext.getUserId());
BeanUtils.copyProperties(dto, entity);
baseYearTermService.createNowYearTerm(UserContext.getCurrentUserInfo(),entity);
baseYearTermService.createNowYearTerm(UserContext.getCurrentUser(),entity);
}
@PostMapping("edit")
public void updateYearTerm(BoaUser authUserWithDept, UserSysRole curRole,
@Valid @RequestBody BaseYearTermDTO dto) {
public void updateYearTerm(@Valid @RequestBody BaseYearTermDTO dto) {
BaseYearTerm entity = new BaseYearTerm();
entity.setUpdateDate(new Date());
entity.setUpdateUserId(authUserWithDept.getId());
entity.setUpdateUserId(UserContext.getUserId());
BeanUtils.copyProperties(dto, entity);
baseYearTermService.updateYearTerm(UserContext.getCurrentUserInfo(),entity);
baseYearTermService.updateYearTerm(UserContext.getCurrentUser(),entity);
}
}
@@ -1,11 +1,10 @@
package com.yunhai.bschclassmanage.controller.api;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.model.tool.UserSysRole;
import com.yunhai.platform.openapi.client.YschBaseOpenApi;
import com.yunhai.platform.utils.model.BoaModule;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -23,13 +22,13 @@ public class UserController {
@GetMapping("getUserMod")
public List<BoaModule> getUserMod(BoaUser authUserWithDept, UserSysRole curRole) {
return YschBaseOpenApi.getUserModule(authUserWithDept.getId(),curRole.getSchId());
public List<BoaModule> getUserMod() {
return YschBaseOpenApi.getUserModule(UserContext.getUserId(),UserContext.getSchId());
}
@GetMapping("getUserInfo")
public BoaUser getUserInfo(BoaUser authUserWithDept) {
return authUserWithDept;
public UserContext.UserInfo getUserInfo() {
return UserContext.getCurrentUser();
}
@@ -12,7 +12,7 @@ import javax.validation.constraints.*;
/**
* 学校-字典-学科表
*/
@JsonIgnoreProperties({EntityFieldNames.schId , EntityFieldNames.createDate, EntityFieldNames.updateDate, EntityFieldNames.createUserId, EntityFieldNames.updateUserId })
@JsonIgnoreProperties(value = {EntityFieldNames.schId , EntityFieldNames.createDate, EntityFieldNames.updateDate, EntityFieldNames.createUserId, EntityFieldNames.updateUserId })
@AllArgsConstructor
@NoArgsConstructor
@Data
@@ -0,0 +1,40 @@
package com.yunhai.bschclassmanage.interceptor;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Component
public class UserContextInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) {
// 这里改成你项目实际的取当前用户逻辑
// 例如从 token / session 解析出 BoaUser
BoaUser currentUser = resolveUser(request);
if (currentUser != null) {
UserContext.setUserId(currentUser.getId());
UserContext.setUserName(currentUser.getName());
UserContext.setType(currentUser.getType());
}
return true;
}
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception ex) {
// 必须清理,避免线程复用串号
UserContext.clear();
}
private BoaUser resolveUser(HttpServletRequest request) {
// TODO: 按你现有的解析器逻辑实现(token 解码 / session 取值等)
return null;
}
}
@@ -171,11 +171,16 @@ public class SchTeacherInfoService {
}
}
// 校验班主任/副班主任
List<Integer> teacherIds = teachers.stream().map(SchTeacher::getId).collect(Collectors.toList());
long classCount = schClassRepository.countByFirstTeacherIdInOrSecondTeacherIdInAndSchId(teacherIds, schId);
if (classCount > 0) {
throw new DException("选中的教师中有 " + classCount + " 个班级的班主任/副班主任,请先更换");
// 校验班主任/副班主任(SchClass.firstTeacherId/secondTeacherId 存的是 teaId)
List<Integer> teacherTeaIds = teachers.stream()
.map(SchTeacher::getTeaId)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!teacherTeaIds.isEmpty()) {
long classCount = schClassRepository.countByFirstTeacherIdInOrSecondTeacherIdInAndSchId(teacherTeaIds, schId);
if (classCount > 0) {
throw new DException("选中的教师中有 " + classCount + " 个班级的班主任/副班主任,请先更换");
}
}
// 删除关联组关系(先异步日志,再删除)
@@ -84,11 +84,16 @@ public class SchTeacherRelationService {
}
}
// 3. 校验班主任/副班主任
List<Integer> teacherIds = teachers.stream().map(SchTeacher::getId).collect(Collectors.toList());
long classCount = schClassRepository.countByFirstTeacherIdInOrSecondTeacherIdInAndSchId(teacherIds, schId);
if (classCount > 0) {
throw new DException("选中的教师中有 " + classCount + " 个班级的班主任/副班主任,请先更换");
// 3. 校验班主任/副班主任(SchClass.firstTeacherId/secondTeacherId 存的是 teaId)
List<Integer> teacherTeaIds = teachers.stream()
.map(SchTeacher::getTeaId)
.filter(Objects::nonNull)
.collect(Collectors.toList());
if (!teacherTeaIds.isEmpty()) {
long classCount = schClassRepository.countByFirstTeacherIdInOrSecondTeacherIdInAndSchId(teacherTeaIds, schId);
if (classCount > 0) {
throw new DException("选中的教师中有 " + classCount + " 个班级的班主任/副班主任,请先更换");
}
}
// 4. 更新状态为转出
@@ -339,7 +339,7 @@ public class OtherUtil {
// }
public static String getHeader(String headerName) {
String value = getHeader(headerName);
String value = getRequest().getHeader(headerName);
if(StringUtils.hasText(value))
return value;
else
@@ -8,8 +8,8 @@ public class UserContext {
private static final ThreadLocal<Integer> ROLE_ID = new ThreadLocal<>();
private static final ThreadLocal<Integer> SCH_ID = new ThreadLocal<>();
private static final ThreadLocal<String> IP = new ThreadLocal<>();
private static final ThreadLocal<Integer> TYPE = new ThreadLocal<>();
// 原有 setter/getter 示例(请确保都有)
public static void setUserId(Integer userId) {
USER_ID.set(userId);
}
@@ -38,7 +38,6 @@ public class UserContext {
return SCH_ID.get();
}
// ⬇️ 新增 IP 的 setter/getter
public static void setIp(String ip) {
IP.set(ip);
}
@@ -46,6 +45,13 @@ public class UserContext {
return IP.get();
}
public static void setType(Integer type) {
TYPE.set(type);
}
public static Integer getType() {
return TYPE.get();
}
@Value
public static class UserInfo {
Integer userId;
@@ -53,15 +59,17 @@ public class UserContext {
Integer roleId;
Integer schId;
String ip;
Integer type;
}
public static UserInfo getCurrentUserInfo() {
public static UserInfo getCurrentUser() {
return new UserInfo(
USER_ID.get(),
USER_NAME.get(),
ROLE_ID.get(),
SCH_ID.get(),
IP.get()
IP.get(),
TYPE.get()
);
}
@@ -72,10 +80,11 @@ public class UserContext {
ROLE_ID.set(info.getRoleId());
SCH_ID.set(info.getSchId());
IP.set(info.getIp());
TYPE.set(info.getType());
}
public static Runnable wrap(Runnable task) {
UserInfo info = getCurrentUserInfo();
UserInfo info = getCurrentUser();
return () -> {
try {
setUserInfo(info);
@@ -92,5 +101,6 @@ public class UserContext {
ROLE_ID.remove();
SCH_ID.remove();
IP.remove();
TYPE.remove();
}
}
}