refactor: 根包由 com.bestsch.bschclassmanage 重命名为 com.yunhai.bschclassmanage
- git mv src/main/java/com/bestsch/bschclassmanage -> src/main/java/com/yunhai/bschclassmanage - 255 个 Java 文件的 package/import 同步替换为 com.yunhai.bschclassmanage - pom.xml 项目 groupId 设为 com.yunhai(与外部依赖 com.bestsch:bsch-* 无关,未改动) - IDE 缓存 workspace.xml 路径同步更新(外部依赖坐标 com.bestsch:bsch-* 保持不动)
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
package com.yunhai.bschclassmanage.controller.api;
|
||||
|
||||
|
||||
import com.yunhai.bschclassmanage.annotation.OperationLog;
|
||||
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;
|
||||
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.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping(Config.API_PATH+"/schsystem/")
|
||||
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
|
||||
public class SchsystemController {
|
||||
|
||||
@Autowired
|
||||
private ISchBinSchsystemService schBinSchsystemService; // 使用接口
|
||||
|
||||
@Autowired
|
||||
private IComSchTreeService comSchTreeService; // 使用接口
|
||||
/**
|
||||
* 获取学段枚举 + 学制列表
|
||||
* @return 学段分组后的学制列表
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public List<AcademicStageSchsystemVO> getAcademicStageSchsystemList(BoaUser authUserWithDept, UserSysRole curRole,
|
||||
@RequestParam(required = false) Integer schId) {
|
||||
|
||||
int roleId = curRole.getRoleId();
|
||||
boolean isSuperAdmin = UserType.SUPER_ADMINISTRATOR.getId().equals(authUserWithDept.getType());
|
||||
boolean isAreaAdmin = UserRole.AREAADMIN.getValue().equals(roleId);
|
||||
|
||||
if (!isSuperAdmin && !isAreaAdmin) {
|
||||
throw new NullPointerException("无权操作,仅超级管理员或学校管理员可设置学制");
|
||||
}
|
||||
|
||||
// 3. 确定最终操作的学校ID,并校验
|
||||
Integer targetSchId;
|
||||
if (isAreaAdmin) {
|
||||
// 区域管理员:强制使用自己所属的学校,忽略前端传入的schId
|
||||
targetSchId = curRole.getSchId();
|
||||
if (targetSchId == null || targetSchId <= 0) {
|
||||
throw new NullPointerException("当前学校管理员未关联有效的学校");
|
||||
}
|
||||
} else { // 超管
|
||||
if (schId == null || schId <= 0) {
|
||||
throw new NullPointerException("学校ID不能为空且必须为正整数");
|
||||
}
|
||||
targetSchId = schId;
|
||||
}
|
||||
|
||||
|
||||
return schBinSchsystemService.getAcademicStageSchsystemList(targetSchId);
|
||||
}
|
||||
|
||||
@GetMapping("getType")
|
||||
public Integer getSchType(UserSysRole curRole) {
|
||||
return schBinSchsystemService.getSchType(curRole.getSchId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 学校选择学制
|
||||
* @return 学段分组后的学制列表
|
||||
*/
|
||||
@PostMapping("save")
|
||||
@OperationLog(module = "绑定学制")
|
||||
public void saveSchBinSchsystem(BoaUser authUserWithDept, UserSysRole curRole,
|
||||
@RequestParam(required = false) Integer schId,
|
||||
@RequestParam("schsystemIds") String schsystemIdsStr) {
|
||||
|
||||
UserContext.UserInfo user= UserContext.getCurrentUserInfo();
|
||||
// 2. 角色权限校验
|
||||
int roleId = user.getRoleId();
|
||||
boolean isSuperAdmin = UserType.SUPER_ADMINISTRATOR.getId().equals(authUserWithDept.getType());
|
||||
boolean isAreaAdmin = UserRole.AREAADMIN.getValue().equals(roleId);
|
||||
|
||||
if (!isSuperAdmin && !isAreaAdmin) {
|
||||
throw new NullPointerException("无权操作,仅超级管理员或学校管理员可设置学制");
|
||||
}
|
||||
|
||||
// 3. 确定最终操作的学校ID,并校验
|
||||
Integer targetSchId;
|
||||
if (isAreaAdmin) {
|
||||
// 区域管理员:强制使用自己所属的学校,忽略前端传入的schId
|
||||
targetSchId = curRole.getSchId();
|
||||
if (targetSchId == null || targetSchId <= 0) {
|
||||
throw new NullPointerException("当前学校管理员未关联有效的学校");
|
||||
}
|
||||
} else { // 超管
|
||||
if (schId == null || schId <= 0) {
|
||||
throw new NullPointerException("学校ID不能为空且必须为正整数");
|
||||
}
|
||||
targetSchId = schId;
|
||||
}
|
||||
String schName= comSchTreeService.getSchoolName(targetSchId);
|
||||
// 4. 转换学制ID数组
|
||||
Integer[] schsystemIds = OtherUtil.convertToArray(schsystemIdsStr);
|
||||
|
||||
List<String> schsystemNames= schBinSchsystemService.selectSchBinSchsystem(targetSchId)
|
||||
.stream().filter(s-> Arrays.asList(schsystemIds).contains(s.getId()))
|
||||
.map(s->s.getName()).collect(Collectors.toList());
|
||||
|
||||
LogContextHolder.setDescription(String.format("为学校 %d 绑定学制:%s", schName,String.join(",",schsystemNames) ));
|
||||
if (schsystemIds == null || schsystemIds.length == 0) {
|
||||
throw new NullPointerException("学制ID列表无效");
|
||||
}
|
||||
SchBinSchsystem entity=new SchBinSchsystem();
|
||||
OtherUtil.setBaseEntityValue(user, entity);
|
||||
entity.setSchId(targetSchId);
|
||||
// 5. 调用服务
|
||||
schBinSchsystemService.saveSchBinSchsystem(entity, schsystemIds);
|
||||
}
|
||||
|
||||
@GetMapping("select")
|
||||
public List<SelectIntVO> selectSchBinSchsystem(UserSysRole curRole) {
|
||||
return schBinSchsystemService.selectSchBinSchsystem(curRole.getSchId());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user