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
@@ -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();
}