This commit is contained in:
2026-08-14 09:04:58 +08:00
parent 863c4f5c13
commit ea13c4ea7c
16 changed files with 74 additions and 69 deletions
@@ -13,6 +13,7 @@ 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.exception.DException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -42,7 +43,7 @@ public class SchsystemController {
boolean isAreaAdmin = UserRole.AREAADMIN.getValue().equals(roleId);
if (!isSuperAdmin && !isAreaAdmin) {
throw new NullPointerException("无权操作,仅超级管理员或学校管理员可设置学制");
throw new DException("无权操作,仅超级管理员或学校管理员可设置学制");
}
// 3. 确定最终操作的学校ID,并校验
@@ -51,11 +52,11 @@ public class SchsystemController {
// 区域管理员:强制使用自己所属的学校,忽略前端传入的schId
targetSchId = UserContext.getSchId();
if (targetSchId == null || targetSchId <= 0) {
throw new NullPointerException("当前学校管理员未关联有效的学校");
throw new DException("当前学校管理员未关联有效的学校");
}
} else { // 超管
if (schId == null || schId <= 0) {
throw new NullPointerException("学校ID不能为空且必须为正整数");
throw new DException("学校ID不能为空且必须为正整数");
}
targetSchId = schId;
}
@@ -85,7 +86,7 @@ public class SchsystemController {
boolean isAreaAdmin = UserRole.AREAADMIN.getValue().equals(roleId);
if (!isSuperAdmin && !isAreaAdmin) {
throw new NullPointerException("无权操作,仅超级管理员或学校管理员可设置学制");
throw new DException("无权操作,仅超级管理员或学校管理员可设置学制");
}
// 3. 确定最终操作的学校ID,并校验
@@ -94,11 +95,11 @@ public class SchsystemController {
// 区域管理员:强制使用自己所属的学校,忽略前端传入的schId
targetSchId = UserContext.getSchId();
if (targetSchId == null || targetSchId <= 0) {
throw new NullPointerException("当前学校管理员未关联有效的学校");
throw new DException("当前学校管理员未关联有效的学校");
}
} else { // 超管
if (schId == null || schId <= 0) {
throw new NullPointerException("学校ID不能为空且必须为正整数");
throw new DException("学校ID不能为空且必须为正整数");
}
targetSchId = schId;
}
@@ -112,7 +113,7 @@ public class SchsystemController {
LogContextHolder.setDescription(String.format("为学校 %d 绑定学制:%s", schName,String.join(",",schsystemNames) ));
if (schsystemIds == null || schsystemIds.length == 0) {
throw new NullPointerException("学制ID列表无效");
throw new DException("学制ID列表无效");
}
SchBinSchsystem entity=new SchBinSchsystem();
OtherUtil.setBaseEntityValue(user, entity);
@@ -740,12 +740,12 @@ public class ComSchTreeService implements IComSchTreeService {
Integer maxSchsystemLeng = schDicMajorsRepository.findMaxSchsystemLengBySchId(schId).orElse(0);
if(maxSchsystemLeng==0){
throw new IllegalArgumentException("请创建高校系部和专业!");
throw new DException("请创建高校系部和专业!");
}
SelectIntVO systemVO=schBinSchsystemService.selectSchBinSchsystem(schId).stream().findFirst()
.orElseThrow(() -> new RuntimeException("学制未选择!"));
.orElseThrow(() -> new DException("学制未选择!"));
// 2. 循环生成年级节点(从当前学年往前推)
List<SchSystemTreeVO> gradeNodes = new ArrayList<>();
@@ -12,6 +12,7 @@ import com.yunhai.bschclassmanage.utils.LogContextHolder;
import com.yunhai.bschclassmanage.utils.RedisConstants;
import com.yunhai.bschclassmanage.utils.RedisUtil;
import com.yunhai.bschclassmanage.utils.UserContext;
import com.yunhai.platform.utils.exception.DException;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.client.utils.DateUtils;
import org.springframework.beans.BeanUtils;
@@ -77,7 +78,7 @@ public class BaseYearTermService implements IBaseYearTermService {
@Transactional(rollbackFor = Exception.class)
public void createNowYearTerm(UserContext.UserInfo user,BaseYearTerm entity){
if(getAllYearTerm().stream().anyMatch(s->s.getYear().equals(entity.getYear())))
throw new IllegalArgumentException("创建学年已存在!");
throw new DException("创建学年已存在!");
redisUtil.del(cacheKey);
baseYearTermRepository.save(entity);
{
@@ -112,11 +113,11 @@ public class BaseYearTermService implements IBaseYearTermService {
@Transactional(rollbackFor = Exception.class)
public void updateYearTerm(UserContext.UserInfo user,BaseYearTerm entity){
if (entity.getId() == null) {
throw new IllegalArgumentException("更新时ID不能为空");
throw new DException("更新时ID不能为空");
}
BaseYearTerm existing = baseYearTermRepository.findById(entity.getId())
.orElseThrow(() -> new IllegalArgumentException("学年记录不存在,ID=" + entity.getId()));
.orElseThrow(() -> new DException("学年记录不存在,ID=" + entity.getId()));
BaseYearTerm oldEntity = new BaseYearTerm();
BeanUtils.copyProperties(existing, oldEntity);
@@ -247,7 +248,7 @@ public class BaseYearTermService implements IBaseYearTermService {
public YearTerm getCurrentYearTerm() {
BaseYearTerm nowTerm = getNowYearTerm();
if (nowTerm == null) {
throw new IllegalStateException("当前学年未设置,请先配置学年学期");
throw new DException("当前学年未设置,请先配置学年学期");
}
int year = nowTerm.getYear();
int term = getCurrentTerm(); // 调用下面定义的 getCurrentTerm 方法
@@ -258,7 +259,7 @@ public class BaseYearTermService implements IBaseYearTermService {
public int getCurrentYear() {
BaseYearTerm nowTerm = getNowYearTerm();
if (nowTerm == null) {
throw new IllegalStateException("当前学年未设置");
throw new DException("当前学年未设置");
}
return nowTerm.getYear();
}
@@ -266,7 +267,7 @@ public class BaseYearTermService implements IBaseYearTermService {
public int getCurrentTerm() {
BaseYearTerm nowTerm = getNowYearTerm();
if (nowTerm == null) {
throw new IllegalStateException("当前学年未设置");
throw new DException("当前学年未设置");
}
Date now = new Date();
Date firstStart = nowTerm.getFirstTermStartDate();
@@ -283,6 +284,6 @@ public class BaseYearTermService implements IBaseYearTermService {
return 2;
}
}
throw new IllegalStateException("当前日期不在任何学期区间内,请检查学年学期配置");
throw new DException("当前日期不在任何学期区间内,请检查学年学期配置");
}
}
@@ -14,6 +14,7 @@ import com.yunhai.bschclassmanage.service.IBaseSchsystemService;
import com.yunhai.bschclassmanage.service.ISchBinSchsystemService;
import com.yunhai.bschclassmanage.utils.RedisConstants;
import com.yunhai.bschclassmanage.utils.RedisUtil;
import com.yunhai.platform.utils.exception.DException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.domain.Specification;
@@ -147,24 +148,24 @@ public class SchBinSchsystemService implements ISchBinSchsystemService {
// 校验:类型必须唯一
if (typeIds.isEmpty()) {
throw new IllegalArgumentException("该学校未绑定任何学制,请先绑定");
throw new DException("该学校未绑定任何学制,请先绑定");
}
if (typeIds.size() > 1) {
throw new IllegalArgumentException("该学校绑定了多种学制类型(" + typeIds + "),数据异常,请检查");
throw new DException("该学校绑定了多种学制类型(" + typeIds + "),数据异常,请检查");
}
// 此时 typeIds 仅有一个元素,直接获取
Integer typeId = typeIds.iterator().next();
if(typeId.equals(SchType.VOCATIONALEDUCATION.getKey())&&schsystemIds.size()>1){
throw new IllegalArgumentException("该学校只能选择单个学制,请重新选择学制!");
throw new DException("该学校只能选择单个学制,请重新选择学制!");
}
// 从枚举中匹配该 typeId
return SchType.list().stream()
.filter(s -> s.getKey().equals(typeId))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException("未找到对应的学制类型,typeId=" + typeId))
.orElseThrow(() -> new DException("未找到对应的学制类型,typeId=" + typeId))
.getKey();
}
@@ -221,10 +221,10 @@ public class SchCustomGroupService implements ISchCustomGroupService {
// 1. 参数校验
if (dto.getGroupName() == null || dto.getGroupName().trim().isEmpty()) {
throw new IllegalArgumentException("组名不能为空");
throw new DException("组名不能为空");
}
if (dto.getGroupType() == null) {
throw new IllegalArgumentException("组类型不能为空");
throw new DException("组类型不能为空");
}
// 2. 重名校验(同学校同类型下组名唯一)
@@ -235,18 +235,18 @@ public class SchCustomGroupService implements ISchCustomGroupService {
nameExists = teacherCustomGroupRepository.existsBySchIdAndGroupTypeAndGroupName(
schId, dto.getGroupType(), dto.getGroupName());
if (nameExists) {
throw new IllegalArgumentException("组名已存在:" + dto.getGroupName());
throw new DException("组名已存在:" + dto.getGroupName());
}
} else {
// 更新:排除自身,检查其他组同名
nameExists = teacherCustomGroupRepository.existsBySchIdAndGroupTypeAndGroupNameAndIdNot(
schId, dto.getGroupType(), dto.getGroupName(), dto.getId());
if (nameExists) {
throw new IllegalArgumentException("组名已存在:" + dto.getGroupName());
throw new DException("组名已存在:" + dto.getGroupName());
}
// 查询旧实体,用于日志对比
oldEntity = teacherCustomGroupRepository.findById(dto.getId())
.orElseThrow(() -> new IllegalArgumentException("组不存在,ID=" + dto.getId()));
.orElseThrow(() -> new DException("组不存在,ID=" + dto.getId()));
}
// 3. 构建新实体并设置基础字段
@@ -364,7 +364,7 @@ public class SchCustomGroupService implements ISchCustomGroupService {
// 1. 参数校验
if (groupId == null || groupId <= 0) {
throw new IllegalArgumentException("组ID无效");
throw new DException("组ID无效");
}
if (teaIds == null) {
// 如果传 null,视为不修改;传空列表表示清空
@@ -373,7 +373,7 @@ public class SchCustomGroupService implements ISchCustomGroupService {
// 2. 检查组是否存在
SchTeacherCustomGroup group = teacherCustomGroupRepository.findById(groupId)
.orElseThrow(() -> new IllegalArgumentException("组不存在,ID=" + groupId));
.orElseThrow(() -> new DException("组不存在,ID=" + groupId));
// 3. 查询当前组长ID(如果有),用于从组员列表中排除
Integer leaderId = groupInTeacherRepository.findByCgGroupIdAndGroupType(groupId, 1)
@@ -433,19 +433,19 @@ public class SchCustomGroupService implements ISchCustomGroupService {
// 1. 参数校验
if (groupId == null || groupId <= 0) {
throw new IllegalArgumentException("组ID无效");
throw new DException("组ID无效");
}
// 2. 检查组是否存在
SchTeacherCustomGroup group = teacherCustomGroupRepository.findById(groupId)
.orElseThrow(() -> new IllegalArgumentException("组不存在,ID=" + groupId));
.orElseThrow(() -> new DException("组不存在,ID=" + groupId));
// 3. 获取该组所有成员(全部记录)
List<SchTeacherCustomGroupInTeacher> allMembers = groupInTeacherRepository.findByCgGroupId(groupId);
if (allMembers.isEmpty()) {
// 如果组没有成员,但设置了组长,可以先添加成员,但这里要求必须从组员中选,所以先提示无成员
// 根据业务,可以先添加组员再设组长,这里抛出异常
throw new IllegalArgumentException("该组暂无成员,无法设置组长");
throw new DException("该组暂无成员,无法设置组长");
}
// 4. 将传入的ID去重
@@ -462,7 +462,7 @@ public class SchCustomGroupService implements ISchCustomGroupService {
.filter(tid -> !existTeaIds.contains(tid))
.collect(Collectors.toList());
if (!invalidIds.isEmpty()) {
throw new IllegalArgumentException("以下教师不是该组成员,无法设为组长:" + invalidIds);
throw new DException("以下教师不是该组成员,无法设为组长:" + invalidIds);
}
// 6. 将当前所有组长降级为组员(groupType改为2)
@@ -508,12 +508,12 @@ public class SchCustomGroupService implements ISchCustomGroupService {
public void deleteSchCustomGroup(UserContext.UserInfo user, Integer groupId) {
// 1. 参数校验
if (groupId == null || groupId <= 0) {
throw new IllegalArgumentException("组ID无效");
throw new DException("组ID无效");
}
// 2. 查询组是否存在,并获取组基本信息(用于日志和缓存)
SchTeacherCustomGroup group = teacherCustomGroupRepository.findById(groupId)
.orElseThrow(() -> new IllegalArgumentException("组不存在,ID=" + groupId));
.orElseThrow(() -> new DException("组不存在,ID=" + groupId));
// 3. 级联删除关联数据
// 3.1 删除年级关联
@@ -80,7 +80,7 @@ public class SchDicCampusService implements ISchDicCampusService {
boolean isNew=entity.getId() == null || entity.getId() == 0;
// 参数校验
if (entity.getName() == null || entity.getName().trim().isEmpty())
throw new IllegalArgumentException("校区名称不能为空");
throw new DException("校区名称不能为空");
boolean nameExists;
SchDicCampus oldEntity=null;
@@ -89,7 +89,7 @@ public class SchDicCampusService implements ISchDicCampusService {
// 新增:检查同名校区
nameExists = schDicCampusRepository.existsBySchIdAndName(schId, entity.getName());
if (nameExists) {
throw new IllegalArgumentException("校区名称已存在:" + entity.getName());
throw new DException("校区名称已存在:" + entity.getName());
}
OtherUtil.setBaseEntityValue(user, entity);
@@ -98,11 +98,11 @@ public class SchDicCampusService implements ISchDicCampusService {
// 更新:排除自身,检查其他校区同名
nameExists = schDicCampusRepository.existsBySchIdAndNameAndIdNot(schId, entity.getName(), entity.getId());
if (nameExists) {
throw new IllegalArgumentException("校区名称已存在:" + entity.getName());
throw new DException("校区名称已存在:" + entity.getName());
}
Integer entityId=entity.getId();
SchDicCampus existing = schDicCampusRepository.findById(entityId)
.orElseThrow(() -> new IllegalArgumentException("校区不存在,ID=" + entityId));
.orElseThrow(() -> new DException("校区不存在,ID=" + entityId));
oldEntity=OtherUtil.deepCopy(existing,SchDicCampus.class);
@@ -128,11 +128,11 @@ public class SchDicCourseService implements ISchDicCourseService {
// 1. 基础校验
if (dto == null) {
throw new IllegalArgumentException("课程数据不能为空");
throw new DException("课程数据不能为空");
}
if (StringUtils.isBlank(dto.getName())) {
throw new IllegalArgumentException("课程名称不能为空");
throw new DException("课程名称不能为空");
}
// 2. VO → Entity 映射
@@ -144,7 +144,7 @@ public class SchDicCourseService implements ISchDicCourseService {
schDicCourseRepository.existsBySchIdAndName(schId, entity.getName()) :
schDicCourseRepository.existsBySchIdAndNameAndIdNot(schId, entity.getName(), entity.getId());
if (nameExists) {
throw new IllegalArgumentException("课程名称已存在:" + entity.getName());
throw new DException("课程名称已存在:" + entity.getName());
}
SchDicCourse oldEntity = null;
Set<Integer> oldMajors = null;
@@ -155,7 +155,7 @@ public class SchDicCourseService implements ISchDicCourseService {
entity = schDicCourseRepository.save(entity);
} else {
SchDicCourse existing = schDicCourseRepository.findById(dto.getId())
.orElseThrow(() -> new IllegalArgumentException("课程不存在,ID=" + dto.getId()));
.orElseThrow(() -> new DException("课程不存在,ID=" + dto.getId()));
oldEntity=OtherUtil.deepCopy(existing,SchDicCourse.class);
oldMajors = loadMajorsIdSet(dto.getId(),user.getSchId());
@@ -147,10 +147,10 @@ public class SchDicSubjectService implements ISchDicSubjectService {
// 1. 参数校验
if (entity.getSchSystemId() == null || entity.getSchSystemId() == 0) {
throw new IllegalArgumentException("学制ID不能为空");
throw new DException("学制ID不能为空");
}
if (StringUtils.isBlank(entity.getName())) {
throw new IllegalArgumentException("学科名称不能为空");
throw new DException("学科名称不能为空");
}
SchDicSubject oldEntity = null;
@@ -169,7 +169,7 @@ public class SchDicSubjectService implements ISchDicSubjectService {
.anyMatch(s -> !s.getId().equals(entity.getId()) && entity.getName().equals(s.getName()));
}
if (exists) {
throw new IllegalArgumentException("该学制下学科名称已存在:" + entity.getName());
throw new DException("该学制下学科名称已存在:" + entity.getName());
}
// 4. 设置默认值(新增时)
@@ -185,7 +185,7 @@ public class SchDicSubjectService implements ISchDicSubjectService {
} else {
// 更新:加载现有记录,只复制允许修改的字段
SchDicSubject existing = schDicSubjectRepository.findById(entity.getId())
.orElseThrow(() -> new IllegalArgumentException("学科不存在,ID=" + entity.getId()));
.orElseThrow(() -> new DException("学科不存在,ID=" + entity.getId()));
oldEntity=OtherUtil.deepCopy(existing,SchDicSubject.class);
@@ -52,28 +52,28 @@ public class SchClassHigherService {
Integer schId = user.getSchId();
Integer schType = schBinSchsystemService.getSchType(schId);
if (!schType.equals(SchType.VOCATIONALEDUCATION.getKey())) {
throw new IllegalArgumentException("学校类型不符合,请重新选择学制!");
throw new DException("学校类型不符合,请重新选择学制!");
}
Integer schsystemId = schBinSchsystemService.getSchBinSchsystemIds(schId).stream().findFirst()
.orElseThrow(() -> new DException("请选择学制!"));
if (entity.getEnrollYear() == null) {
throw new IllegalArgumentException("请选择年份(级)!");
throw new DException("请选择年份(级)!");
}
if (StringUtils.isBlank(entity.getName())) {
throw new IllegalArgumentException("班级名称不能为空");
throw new DException("班级名称不能为空");
}
boolean isNew = (entity.getId() == null || entity.getId() == 0);
if (isNew) {
boolean exists = schClassRepository.existsBySchIdAndGroupIdAndName(schId, entity.getGroupId(), entity.getName());
if (exists) {
throw new IllegalArgumentException("该年级组下班级名称已存在:" + entity.getName());
throw new DException("该年级组下班级名称已存在:" + entity.getName());
}
} else {
boolean exists = schClassRepository.existsBySchIdAndGroupIdAndNameAndIdNot(schId, entity.getGroupId(), entity.getName(), entity.getId());
if (exists) {
throw new IllegalArgumentException("该年级组下班级名称已存在:" + entity.getName());
throw new DException("该年级组下班级名称已存在:" + entity.getName());
}
}
@@ -85,7 +85,7 @@ public class SchClassHigherService {
// 同步组ID
List<SelectIntVO> gradeGroupList = comSchTreeService.getSchGroupTypeList(schId, NodeType.GRADE.getId()).get(schsystemId);
if (gradeGroupList == null || gradeGroupList.isEmpty()) {
throw new IllegalArgumentException("该学制下没有年级组,请先同步年级组数据!");
throw new DException("该学制下没有年级组,请先同步年级组数据!");
}
Map<String, Integer> gradeNameToIdMap = gradeGroupList.stream()
.collect(Collectors.toMap(SelectIntVO::getName, SelectIntVO::getId, (a, b) -> a));
@@ -98,13 +98,13 @@ public class SchClassHigherService {
Integer groupId = gradeNameToIdMap.get(entity.getEnrollYear().toString());
if (groupId == null || groupId < 1) {
throw new IllegalArgumentException(entity.getEnrollYear() + "该年级组不存在,请检查年级组名称!");
throw new DException(entity.getEnrollYear() + "该年级组不存在,请检查年级组名称!");
}
entity.setGroupId(groupId);
Integer classId = classNameToIdMap.get(entity.getName());
if (classId == null || classId < 1) {
throw new IllegalArgumentException("同步班级组失败,请检查班级组数据!");
throw new DException("同步班级组失败,请检查班级组数据!");
}
entity.setClassId(classId);
entity.setGraduate(false);
@@ -112,7 +112,7 @@ public class SchClassHigherService {
} else {
final Integer entityId = entity.getId();
SchClass existing = schClassRepository.findById(entityId)
.orElseThrow(() -> new IllegalArgumentException("班级不存在,ID=" + entityId));
.orElseThrow(() -> new DException("班级不存在,ID=" + entityId));
oldSchClass = OtherUtil.deepCopy(existing, SchClass.class);
BeanUtils.copyProperties(entity, existing,
@@ -73,7 +73,7 @@ public class SchClassImportService {
Map<Integer, List<SelectIntVO>> schGradeGroupMap = comSchTreeService.getSchGroupTypeList(user.getSchId(), NodeType.GRADE.getId());
if (schGradeGroupMap.isEmpty()) {
throw new IllegalArgumentException("该学制下没有年级组,请先同步年级组数据!");
throw new DException("该学制下没有年级组,请先同步年级组数据!");
}
Map<Integer, List<SelectIntVO>> schClassGroupMap = comSchTreeService.getSchGroupTypeList(user.getSchId(), NodeType.CLASS.getId());
@@ -220,7 +220,7 @@ public class SchClassImportService {
Map<Integer, List<SelectIntVO>> schGradeGroupMap = comSchTreeService.getSchGroupTypeList(user.getSchId(), NodeType.GRADE.getId());
if (schGradeGroupMap.isEmpty()) {
throw new IllegalArgumentException("该学制下没有学级,请先同步年级组数据!");
throw new DException("该学制下没有学级,请先同步年级组数据!");
}
//Map<Integer, List<SelectIntVO>> schClassGroupMap = comSchTreeService.getSchGroupTypeList(user.getSchId(), NodeType.CLASS.getId());
@@ -49,8 +49,8 @@ public class SchClassInfoService {
// ---------- 新增 K12 班级 ----------
public void addBaseSchClass(UserContext.UserInfo user, Integer gradeId, Integer number) {
if (gradeId == null || gradeId == 0) throw new IllegalArgumentException("年级ID不能为空");
if (number == null || number <= 0) throw new IllegalArgumentException("新增班级数量必须大于0");
if (gradeId == null || gradeId == 0) throw new DException("年级ID不能为空");
if (number == null || number <= 0) throw new DException("新增班级数量必须大于0");
Integer schId = user.getSchId();
Integer schsystemId = baseSchsystemGradeService.getSchGradeIdBySchsystemId(schId, gradeId);
@@ -64,7 +64,7 @@ public class SchClassInfoService {
List<SelectIntVO> gradeGroupList = comSchTreeService.getSchGroupTypeList(schId, NodeType.GRADE.getId()).get(schsystemId);
if (gradeGroupList == null || gradeGroupList.isEmpty()) {
throw new IllegalArgumentException("该学制下没有年级组,请先同步年级组数据!");
throw new DException("该学制下没有年级组,请先同步年级组数据!");
}
Map<String, Integer> gradeNameToIdMap = gradeGroupList.stream()
.collect(Collectors.toMap(SelectIntVO::getName, SelectIntVO::getId, (a, b) -> a));
@@ -89,13 +89,13 @@ public class SchClassInfoService {
Integer groupId = gradeNameToIdMap.get(year.toString());
if (groupId == null) {
throw new IllegalArgumentException("年级组 '" + year + "' 不存在,请检查年级组名称或同步树结构!");
throw new DException("年级组 '" + year + "' 不存在,请检查年级组名称或同步树结构!");
}
clazz.setGroupId(groupId);
Integer classId = classNameToIdMap.get(code);
if (classId == null) {
throw new IllegalArgumentException("班级组 '" + code + "' 不存在,请检查班级组数据或同步树结构!");
throw new DException("班级组 '" + code + "' 不存在,请检查班级组数据或同步树结构!");
}
clazz.setClassId(classId);
@@ -6,6 +6,7 @@ import com.yunhai.bschclassmanage.service.IBaseSchsystemGradeService;
import com.yunhai.bschclassmanage.service.ISchClassService;
import com.yunhai.bschclassmanage.utils.RedisConstants;
import com.yunhai.bschclassmanage.utils.RedisUtil;
import com.yunhai.platform.utils.exception.DException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -56,7 +57,7 @@ public class SchStudentCacheService {
*/
public List<SchStudent> getSchGradeClassStudentCacheList(Integer schId, Integer schsystemId, Integer gradeId, Integer classId) {
if (schId == null) {
throw new IllegalArgumentException("schId不能为空");
throw new DException("schId不能为空");
}
// 如果指定了班级,直接获取该班级的学生
@@ -136,10 +136,10 @@ public class SchClassTeachInfoService {
// 1. 参数校验
if (schId == null) {
throw new IllegalArgumentException("学校ID不能为空");
throw new DException("学校ID不能为空");
}
if (classId == null) {
throw new IllegalArgumentException("班级ID不能为空");
throw new DException("班级ID不能为空");
}
// 2. 获取待删除记录
@@ -174,13 +174,13 @@ public class SchClassTeachInfoService {
// 1. 参数校验
if (schsystemId == null) {
throw new IllegalArgumentException("学制ID不能为空");
throw new DException("学制ID不能为空");
}
// 2. 获取年级列表
List<SelectIntVO> gradeSelectList = baseSchsystemGradeService.getGradeSelect(schId, schsystemId, gradeId);
if (gradeSelectList.isEmpty()) {
throw new IllegalArgumentException("未找到相关学制年级");
throw new DException("未找到相关学制年级");
}
List<Integer> gradeIds = gradeSelectList.stream()
.map(SelectIntVO::getId)
@@ -1,5 +1,6 @@
package com.yunhai.bschclassmanage.utils;
import com.yunhai.platform.utils.exception.DException;
import org.apache.http.client.utils.DateUtils;
import java.time.DayOfWeek;
@@ -39,7 +40,7 @@ public class DateRangeUtil {
break;
default:
throw new IllegalArgumentException("不支持的type类型: " + type);
throw new DException("不支持的type类型: " + type);
}
return result;
@@ -144,7 +144,7 @@ public class OtherUtil {
public static <T extends BaseEntity> void setBaseEntityValue(UserContext.UserInfo user, T entity) {
if (user == null || entity == null) {
throw new IllegalArgumentException("参数不能为null");
throw new DException("参数不能为null");
}
Date now = new Date();
Integer userId = user.getUserId();
@@ -31,7 +31,7 @@ public class ValidationUtil {
*/
public static List<String> validateMsgs(Object object) {
if (object == null) {
return new ArrayList<>(); // 或 throw new IllegalArgumentException("校验对象不能为空")
return new ArrayList<>(); // 或 throw new DException("校验对象不能为空")
}
Set<ConstraintViolation<Object>> violations = validator.validate(object);
if (violations.isEmpty()) {