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