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:
Allen
2026-08-12 17:21:22 +08:00
parent 66cd0f1515
commit dc217ca7a9
258 changed files with 1082 additions and 1067 deletions
@@ -0,0 +1,70 @@
package com.yunhai.bschclassmanage.controller;
import com.yunhai.bschclassmanage.model.vo.PageVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@Slf4j
public class BaseController {
/**
* 根据请求参数构建PageVO对象,设置当前页和每页大小,并提供默认值。
* @param page 页码字符串(从1开始)
* @param pageSize 每页大小字符串
* @return PageVO对象
*/
protected PageVO getPageVO(String page, String pageSize) {
int defaultPage = 1;
int defaultSize = 10;
int maxSize = 100; // 可配置
int current = defaultPage;
int size = defaultSize;
if (StringUtils.isNumeric(page)) {
try {
current = Integer.parseInt(page);
if (current < 1) {
current = defaultPage;
}
} catch (NumberFormatException ignored) {
// 保持默认
}
}
if (StringUtils.isNumeric(pageSize)) {
try {
size = Integer.parseInt(pageSize);
if (size < 1) {
size = defaultSize;
} else if (size > maxSize) {
size = maxSize;
}
} catch (NumberFormatException ignored) {
// 保持默认
}
}
PageVO pageVO = new PageVO();
pageVO.setCurrent(current);
pageVO.setPageSize(size);
return pageVO;
}
/**
* 安全地将字符串转换为Integer,若转换失败返回null。
* @param str 待转换字符串
* @return Integer值或null
*/
public static Integer getIntByString(String str) {
if (str == null || str.trim().isEmpty() || "null".equalsIgnoreCase(str.trim())) {
return null;
}
try {
return Integer.parseInt(str.trim());
} catch (NumberFormatException e) {
return null; // 静默失败,不抛异常
}
}
}
@@ -0,0 +1,43 @@
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);
}
}
@@ -0,0 +1,33 @@
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.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
@RestControllerAdvice
public class ValidationExceptionHandler {
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseEntity<Map<String, Object>> handleValidationExceptions(MethodArgumentNotValidException ex) {
List<String> msgList = new ArrayList<>();
ex.getBindingResult().getAllErrors().forEach(error -> {
String errorMessage = error.getDefaultMessage();
msgList.add(errorMessage);
});
Map<String, Object> response = new LinkedHashMap<>();
response.put("code", ErrorCode.ERROR.getCode());
response.put("msg", String.join(";", msgList));
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);
}
}
@@ -0,0 +1,35 @@
package com.yunhai.bschclassmanage.controller.api;
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;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(Config.API_PATH+"/log/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class LogController extends BaseController {
@Autowired
private ILogService logService; // 使用接口
@GetMapping("systemSearch")
public PageVO<OperationLogRecord> systemSearch(UserSysRole curRole,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return logService.search(curRole.getSchId(),keyword,true,pageable);
}
@GetMapping("search")
public PageVO<OperationLogRecord> search(UserSysRole curRole,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return logService.search(curRole.getSchId(),keyword,false,pageable);
}
}
@@ -0,0 +1,48 @@
package com.yunhai.bschclassmanage.controller.api;
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;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Enumeration;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH)
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class LoginUserController {
@GetMapping("GetUserMod")
public List<BoaModule> getUserMod(BoaUser authUserWithDept, UserSysRole curRole) {
return YschBaseOpenApi.getUserModule(authUserWithDept.getId(),curRole.getSchId());
}
@GetMapping("GetUserInfo")
public BoaUser getUserInfo(BoaUser authUserWithDept) {
return authUserWithDept;
}
@GetMapping("Logout")
protected void logout(HttpServletRequest request) {
HttpSession session = request.getSession();
Enumeration<String> names = session.getAttributeNames();
while (names.hasMoreElements()) {
System.out.print(names.nextElement() + ",");
}
session.invalidate();
System.out.println("logout over");
}
}
@@ -0,0 +1,285 @@
package com.yunhai.bschclassmanage.controller.api;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.yunhai.bschclassmanage.config.Config;
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;
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;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.API_PATH+"/schclass/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchClassController {
@Autowired
private ISchClassService schClassService;
@Autowired
private IComSchTreeService comSchTreeService;
@Autowired
private IBaseSchsystemGradeService baseSchsystemGradeService;
@Autowired
private ISchTeacherService schTeacherService;
@Autowired
private ISchDicCampusService schDicCampusService;
@Autowired
private ISchDicDivisionService schDicDivisionService;
@Autowired
private ISchDicMajorsService schDicMajorsService;
@GetMapping("searcBaseSchClass")
public List<BaseSchClassVO> searcBaseSchClass(UserSysRole curRole,
@RequestParam(required = false) Integer schsystemId,
@RequestParam(required = false) Integer gradeId) {
return schClassService.searcBaseSchClass(curRole.getSchId(),schsystemId,gradeId,null);
}
@PostMapping("addBaseSchClass")
public void addBaseSchClass(BoaUser authUserWithDept, UserSysRole curRole, Integer gradeId, Integer number) {
schClassService.addBaseSchClass(UserContext.getCurrentUserInfo(),gradeId,number);
}
@PostMapping("editClassName")
public void editClassName(BoaUser authUserWithDept, UserSysRole curRole,Integer id,String cname) {
schClassService.editClassName(UserContext.getCurrentUserInfo(),id,cname);
}
@PostMapping("editClassFirstTeacher")
public void editClassfirstTeacher(BoaUser authUserWithDept, UserSysRole curRole,Integer id,Integer firstTeacherId) {
schClassService.editClassFirstTeacher(UserContext.getCurrentUserInfo(),id,firstTeacherId);
}
@PostMapping("editClassSecondTeacher")
public void editClassSecondTeacher(BoaUser authUserWithDept, UserSysRole curRole,Integer id,Integer secondTeacherId) {
schClassService.editClassSecondTeacher(UserContext.getCurrentUserInfo(),id,secondTeacherId);
}
@PostMapping("editClassCampus")
public void editClassCampus(BoaUser authUserWithDept, UserSysRole curRole,Integer id,Integer campusId) {
schClassService.editClassCampus(UserContext.getCurrentUserInfo(),id,campusId);
}
@GetMapping("searcHigherSchClass")
public PageVO<HigherSchClassVO> searcHigherSchClass(UserSysRole curRole,
@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);
}
@PostMapping("saveHigherSchClass")
public void addHigherSchClass(BoaUser authUserWithDept, UserSysRole curRole,@RequestBody SchClass model) {
schClassService.saveHigherSchClass(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("delete/{id}")
public void deleteSchClass(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable Integer id) {
schClassService.deleteSchClass(UserContext.getCurrentUserInfo(),id,curRole.getSchId());
}
@GetMapping("select")
public List<SelectIntVO> getClassSelect(UserSysRole curRole, @RequestParam Integer gradeId) {
return schClassService.getClassSelect(curRole.getSchId(),gradeId);
}
@GetMapping("selectBySchIdAndGradeId")
public List<SelectIntVO> getClassSelect(@RequestParam Integer schId, @RequestParam Integer gradeId) {
return schClassService.getClassSelect(schId,gradeId);
}
@GetMapping("downloadTemplate")
public void downloadTemplate(HttpServletResponse response,Integer schId) {
String fileName="班级导入模板";
List<Map<String, Object>> sheets = new ArrayList<>();
List<SchClassExcelColumn> classList=new ArrayList<>();
{
SchClassExcelColumn column=new SchClassExcelColumn();
column.setGradeName("示例:初一");
column.setClazzName("示例:1班");
column.setClazzCName("示例:一班");
column.setBzr("示例:张三");
classList.add(column);
}
List<String> gradeNames=baseSchsystemGradeService.getGradeSelect(schId,null,null)
.stream().map(s->s.getName()).collect(Collectors.toList());
List<String> teaNames=schTeacherService.getSchTeacherList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
List<ImportRuleExcelColumn> ruleList = new ArrayList<>();
ImportRuleExcelColumn rule1 = new ImportRuleExcelColumn();
rule1.setRuleItem("年级");
rule1.setDescription("必填");
rule1.setContent(String.join("、",gradeNames));
ruleList.add(rule1);
ImportRuleExcelColumn rule2 = new ImportRuleExcelColumn();
rule2.setRuleItem("班级");
rule2.setDescription("必填");
rule2.setContent("1班、2班、3班~n班");
ruleList.add(rule2);
ImportRuleExcelColumn rule3 = new ImportRuleExcelColumn();
rule3.setRuleItem("班主任、副班主任");
rule3.setDescription("选填");
rule3.setContent(String.join("、",teaNames));
ruleList.add(rule3);
ExportParams params1 = new ExportParams("班级导入",comSchTreeService.getSchoolName(schId));
Map<String, Object> sheet1 = new HashMap<>();
sheet1.put("title",params1);
sheet1.put("entity", SchClassExcelColumn.class);
sheet1.put("data", classList);
sheets.add(sheet1);
ExportParams params2 = new ExportParams("导入规则", "导入规则");
Map<String, Object> sheet2 = new HashMap<>();
sheet2.put("title", params2);
sheet2.put("entity", ImportRuleExcelColumn.class);
sheet2.put("data", ruleList);
sheets.add(sheet2);
Workbook workbook = ExcelExportUtil.exportExcel(sheets, ExcelType.HSSF);
EasyPoiUtils.downLoadExcel(fileName + ".xls", response, workbook);
}
@PostMapping("importClasses")
public void importClasses(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
schClassService.importClasses(UserContext.getCurrentUserInfo(),file);
}
@GetMapping("downloadHeightTemplate")
public void downloadHeightTemplate(HttpServletResponse response,Integer schId) {
String fileName="班级导入模板";
List<Map<String, Object>> sheets = new ArrayList<>();
List<SchHeightClassExcelColumn> classList=new ArrayList<>();
{
SchHeightClassExcelColumn column=new SchHeightClassExcelColumn();
column.setGradeName("示例:2026级");
column.setClazzCode("");
column.setClazzName("示例:南校1班");
column.setClazzCName("");
column.setCampus("示例:南校区");
column.setDivistion("示例:信息工程");
column.setDivistion("示例:软件开发");
column.setBzr("示例:张三");
classList.add(column);
}
List<String> campusNames=schDicCampusService.getSchDicCampusCacheList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
List<String> divisionNames=schDicDivisionService.getSchDicDivisionCacheList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
List<String> majorsNames=schDicMajorsService.getSchDicMajorsCacheList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
List<String> teaNames=schTeacherService.getSchTeacherList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
List<ImportRuleExcelColumn> ruleList = new ArrayList<>();
ImportRuleExcelColumn rule1 = new ImportRuleExcelColumn();
rule1.setRuleItem("校区");
rule1.setDescription("选填");
rule1.setContent(String.join("、",campusNames));
ruleList.add(rule1);
ImportRuleExcelColumn rule2 = new ImportRuleExcelColumn();
rule2.setRuleItem("系部");
rule2.setDescription("必填");
rule2.setContent(String.join("、",divisionNames));
ruleList.add(rule2);
ImportRuleExcelColumn rule3 = new ImportRuleExcelColumn();
rule3.setRuleItem("专业");
rule3.setDescription("必填");
rule3.setContent(String.join("、",majorsNames));
ruleList.add(rule3);
ImportRuleExcelColumn rule4 = new ImportRuleExcelColumn();
rule4.setRuleItem("班主任");
rule4.setDescription("选填");
rule4.setContent(String.join("、",teaNames));
ruleList.add(rule4);
ExportParams params1 = new ExportParams("班级导入",comSchTreeService.getSchoolName(schId));
Map<String, Object> sheet1 = new HashMap<>();
sheet1.put("title",params1);
sheet1.put("entity", SchHeightClassExcelColumn.class);
sheet1.put("data", classList);
sheets.add(sheet1);
ExportParams params2 = new ExportParams("导入规则", "导入规则");
Map<String, Object> sheet2 = new HashMap<>();
sheet2.put("title", params2);
sheet2.put("entity", ImportRuleExcelColumn.class);
sheet2.put("data", ruleList);
sheets.add(sheet2);
Workbook workbook = ExcelExportUtil.exportExcel(sheets, ExcelType.HSSF);
EasyPoiUtils.downLoadExcel(fileName + ".xls", response, workbook);
}
@PostMapping("importHeightClasses")
public void importHeightClasses(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
schClassService.importHeightClasses(UserContext.getCurrentUserInfo(),file);
}
@GetMapping("backupAllSnapshot")
public void backupAllSnapshot() {
schClassService.backupAllSnapshot();
}
@GetMapping("upgradeAllClasses")
public void upgradeAllClasses() {
schClassService.upgradeAllClasses();
}
}
@@ -0,0 +1,161 @@
package com.yunhai.bschclassmanage.controller.api;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.enums.CustomGroupType;
import com.yunhai.bschclassmanage.model.dto.AddMemberDTO;
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.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.API_PATH+"/group/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchCustomGroupController {
@Autowired
private ISchCustomGroupService schCustomGroupService; // 使用接口
@Autowired
private IBaseSchsystemGradeService baseSchsystemGradeService;
@Autowired
private ISchDicSubjectService schDicSubjectService; //使用接口
@Autowired
private IComSchTreeService comSchTreeService;
@Autowired
private ISchTeacherService schTeacherService;
@GetMapping("getSchCustomGroup")
public List<SchCustomGroupVO> getSchCustomGroup(UserSysRole curRole, @RequestParam Integer type) {
return schCustomGroupService.getSchCustomGroup(curRole.getSchId(),type);
}
@PostMapping("saveSchCustomGroup")
public void saveSchCustomGroup(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchCustomGroupDTO dto) {
schCustomGroupService.saveSchCustomGroup(UserContext.getCurrentUserInfo(),dto);
}
@PostMapping("saveMembers")
public void saveMembers(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody AddMemberDTO dto) {
schCustomGroupService.saveMembers(UserContext.getCurrentUserInfo(),dto);
}
@PostMapping("setLeaders")
public void setLeaders(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody SetLeaderDTO dto) {
schCustomGroupService.setLeaders(UserContext.getCurrentUserInfo(),dto);
}
@PostMapping("deleteSchCustomGroup")
public void deleteSchCustomGroup(UserSysRole curRole,@RequestParam Integer groupId) {
schCustomGroupService.deleteSchCustomGroup(UserContext.getCurrentUserInfo(),groupId);
}
@GetMapping("downloadTemplate")
public void downloadTemplate(HttpServletResponse response, Integer schId) {
String fileName = "教师分组导入模板";
List<Map<String, Object>> sheets = new ArrayList<>();
List<CustomGroupExcelColumn> list = new ArrayList<>();
{
CustomGroupExcelColumn column = new CustomGroupExcelColumn();
column.setGroupName("示例:语文组");
column.setGroupType("示例:年级组");
column.setGradeBin("示例:高一年级");
column.setGradeBin("示例:语文,数学");
column.setLeaderName("示例:张三");
column.setMemberName("示例:张三");
list.add(column);
}
List<String> teaNames=schTeacherService.getSchTeacherList(schId).stream().map(s->s.getName()).collect(Collectors.toList());
List<String> gradeNames=baseSchsystemGradeService.getGradeSelect(schId,null,null)
.stream().map(s->s.getName()).collect(Collectors.toList());
List<String> subjectNames=schDicSubjectService.getSchSubList(schId,null)
.stream().map(s->s.getName()).collect(Collectors.toList());
List<String> groupNames=CustomGroupType.list().stream()
.map(s->s.getName()).collect(Collectors.toList());
ExportParams params1 = new ExportParams("自定义组导入",comSchTreeService.getSchoolName(schId));
Map<String, Object> sheet1 = new HashMap<>();
sheet1.put("title",params1);
sheet1.put("entity", CustomGroupExcelColumn.class);
sheet1.put("data", list);
sheets.add(sheet1);
List<ImportRuleExcelColumn> ruleList = new ArrayList<>();
ImportRuleExcelColumn rule1 = new ImportRuleExcelColumn();
rule1.setRuleItem("组长/组员");
rule1.setDescription("多选");
rule1.setContent(String.join(",",teaNames));
ruleList.add(rule1);
ImportRuleExcelColumn rule2 = new ImportRuleExcelColumn();
rule2.setRuleItem("年级");
rule2.setDescription("多选");
rule2.setContent(String.join(",",gradeNames));
ruleList.add(rule2);
ImportRuleExcelColumn rule3 = new ImportRuleExcelColumn();
rule3.setRuleItem("学科");
rule3.setDescription("多选");
rule3.setContent(String.join(",",subjectNames));
ruleList.add(rule3);
ImportRuleExcelColumn rule4 = new ImportRuleExcelColumn();
rule4.setRuleItem("组类型");
rule4.setDescription("单选");
rule4.setContent(String.join(",",groupNames));
ruleList.add(rule4);
ExportParams params2 = new ExportParams("导入规则", "导入规则");
Map<String, Object> sheet2 = new HashMap<>();
sheet2.put("title", params2);
sheet2.put("entity", ImportRuleExcelColumn.class);
sheet2.put("data", ruleList);
sheets.add(sheet2);
Workbook workbook = ExcelExportUtil.exportExcel(sheets, ExcelType.HSSF);
EasyPoiUtils.downLoadExcel(fileName + ".xls", response, workbook);
}
@PostMapping("importCustomGroup")
public void importCustomGroup(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
schCustomGroupService.importCustomGroup(UserContext.getCurrentUserInfo(),file);
}
}
@@ -0,0 +1,50 @@
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.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH+"/campus/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchDicCampusController {
@Autowired
private ISchDicCampusService schDicCampusService; // 使用接口
@GetMapping("list")
public List<SchDicCampus> getSchDicCampusCacheList(UserSysRole curRole) {
return schDicCampusService.getSchDicCampusCacheList(curRole.getSchId());
}
@PostMapping("save")
public void saveSchCampus(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchDicCampus model) {
schDicCampusService.saveSchCampus(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("sort")
public void sortSchCampus(BoaUser authUserWithDept, UserSysRole curRole, @RequestBody List<Integer> ids) {
schDicCampusService.sortSchCampus(UserContext.getCurrentUserInfo(),ids);
}
@PostMapping("delete/{id}")
public void delete(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable Integer id) {
schDicCampusService.delete(UserContext.getCurrentUserInfo(),id);
}
@GetMapping("select")
public List<SelectIntVO> select(UserSysRole curRole) {
return schDicCampusService.select(curRole.getSchId());
}
}
@@ -0,0 +1,59 @@
package com.yunhai.bschclassmanage.controller.api;
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.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH+"/course/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchDicCourseController extends BaseController {
@Autowired
private ISchDicCourseService schDicCourseService; // 使用接口
@GetMapping("search")
public PageVO<SchDicCourseVO> search(UserSysRole curRole,
@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);
}
@PostMapping("save")
public void saveSchMajors(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchDicCourseDTO dto) {
schDicCourseService.saveSchCourse(UserContext.getCurrentUserInfo(),dto);
}
@PostMapping("delete/{id}")
public void delete(BoaUser authUserWithDept, UserSysRole curRole, @PathVariable Integer id) {
schDicCourseService.delete(UserContext.getCurrentUserInfo(),id);
}
@GetMapping("typeSelect")
public List<SelectIntVO> typeSelect() {
return CourseType.select();
}
}
@@ -0,0 +1,50 @@
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.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH+"/division/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchDicDivisionController {
@Autowired
private ISchDicDivisionService schDicDivisionService; // 使用接口
@GetMapping("list")
public List<SchDicDivision> getSchDicDivisionCacheList(UserSysRole curRole) {
return schDicDivisionService.getSchDicDivisionCacheList(curRole.getSchId());
}
@PostMapping("save")
public void saveSchDivision(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchDicDivision model) {
schDicDivisionService.saveSchDivision(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("sort")
public void sortSchDivision(BoaUser authUserWithDept, UserSysRole curRole,@RequestBody List<Integer> ids) {
schDicDivisionService.sortSchDivision(UserContext.getCurrentUserInfo(),ids);
}
@PostMapping("delete/{id}")
public void delete(BoaUser authUserWithDept, UserSysRole curRole, @PathVariable Integer id) {
schDicDivisionService.delete(UserContext.getCurrentUserInfo(),id);
}
@GetMapping("select")
public List<SelectIntVO> select(UserSysRole curRole) {
return schDicDivisionService.select(curRole.getSchId());
}
}
@@ -0,0 +1,52 @@
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.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH+"/majors/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchDicMajorsController {
@Autowired
private ISchDicMajorsService schDicMajorsService; // 使用接口
@GetMapping("list")
public List<SchDicMajors> getSchDicMajorsList(UserSysRole curRole,
@RequestParam(required = false)String keyword) {
return schDicMajorsService.getSchDicMajorsList(curRole.getSchId(),keyword);
}
@PostMapping("save")
public void saveSchMajors(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchDicMajors model) {
schDicMajorsService.saveSchMajors(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("sort")
public void sortSchMajors(BoaUser authUserWithDept, UserSysRole curRole, @RequestBody List<Integer> ids) {
schDicMajorsService.sortSchMajors(UserContext.getCurrentUserInfo(),ids);
}
@PostMapping("delete/{id}")
public void delete(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable Integer id) {
schDicMajorsService.delete(UserContext.getCurrentUserInfo(),id);
}
@GetMapping("select")
public List<SelectIntVO> select(UserSysRole curRole) {
return schDicMajorsService.select(curRole.getSchId());
}
}
@@ -0,0 +1,43 @@
package com.yunhai.bschclassmanage.controller.api;
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;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH+"/grade/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchGradeController {
@Autowired
private IBaseSchsystemGradeService baseSchsystemGradeService; // 使用接口
@GetMapping("select")
public List<SelectIntVO> getGradeSelect(UserSysRole curRole) {
return baseSchsystemGradeService.getGradeSelect(curRole.getSchId(),null,null);
}
@GetMapping("selectBySchsystemId")
public List<SelectIntVO> getGradeSelect(UserSysRole curRole,@RequestParam Integer schsystemId) {
return baseSchsystemGradeService.getGradeSelect(curRole.getSchId(),schsystemId,null);
}
@GetMapping("selectBySchId")
public List<SelectIntVO> getGradeSelect(@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);
}
}
@@ -0,0 +1,233 @@
package com.yunhai.bschclassmanage.controller.api;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.controller.BaseController;
import com.yunhai.bschclassmanage.entity.SchClass;
import com.yunhai.bschclassmanage.enums.StuAbnormalStatus;
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;
import com.yunhai.bschclassmanage.service.IBaseSchsystemGradeService;
import com.yunhai.bschclassmanage.service.IComSchTreeService;
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;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.API_PATH+"/student/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchStudentController extends BaseController {
@Autowired
private ISchStudentService schStudentService; // 使用接口
@Autowired
private IBaseSchsystemGradeService baseSchsystemGradeService;
@Autowired
private ISchClassService schClassService;
@Autowired
private IComSchTreeService comSchTreeService; // 使用接口
@GetMapping("baseSchSearch")
public PageVO<SchStudentVO> searchBaseSchStudentVO(UserSysRole curRole,
@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);
}
@GetMapping("higherSchSearch")
public PageVO<SchStudentVO> searchHigherSchStudentVO(UserSysRole curRole,
@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);
}
@GetMapping("baseSchAbnormalSearch")
public PageVO<SchStudentVO> baseSchAbnormalSearch(UserSysRole curRole,
@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);
}
@GetMapping("higherSchAbnormalSearch")
public PageVO<SchStudentVO> higherSchAbnormalSearch(UserSysRole curRole,
@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);
}
@GetMapping("searchSchClassStudent")
public List<SchStudentVO> searchSchClassStudentVO(UserSysRole curRole,
@RequestParam Integer gradeId,
@RequestParam Integer classId) {
return schStudentService.searchSchClassStudentVO(curRole.getSchId(),gradeId,classId,true);
}
@PostMapping("save")
public void saveStudent(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody SchStudentVO model) {
schStudentService.saveStudent(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("delete/{ids}")
public void deleteStudent(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable String ids) {
schStudentService.deleteStudent(UserContext.getCurrentUserInfo(),ids);
}
@GetMapping("abnormal")
public List<SelectIntVO> abnormal() {
return StuAbnormalStatus.select();
}
@PostMapping("transferClass")
public void transferClass(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody StuTransferClassDTO model) {
schStudentService.transferClass(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("setAbnormalStatus")
public void setAbnormalStatus(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody StuAbnormalStatusDTO model) {
schStudentService.setAbnormalStatus(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("setTransferOut/{ids}")
public void setTransferOut(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable String ids){
schStudentService.setTransferOut(UserContext.getCurrentUserInfo(),ids);
}
@PostMapping("setTransferIn")
public void setTransferIn(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody StuTransferClassDTO model) {
schStudentService.setTransferIn(UserContext.getCurrentUserInfo(),model);
}
@GetMapping("transferOutSchSelect")
public List<SelectIntVO> transferOutSchSelect(){
return schStudentService.transferOutSchSelect();
}
@GetMapping("searchTransferOut")
public PageVO<SchStudentVO> searchTransferOutStudent(@RequestParam(required = false) Integer schId,
@RequestParam(required = false) Integer gradeId,
@RequestParam(required = false) Integer classId,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return schStudentService.searchTransferOutStudent(schId,gradeId,classId,keyword,pageable);
}
@GetMapping("downloadTemplate")
public void downloadTemplate(HttpServletResponse response,Integer schId) {
String fileName="学生导入模板";
List<Map<String, Object>> sheets = new ArrayList<>();
List<StudentExcelColumn> stuList=new ArrayList<>();
{
StudentExcelColumn column=new StudentExcelColumn();
column.setGradeName("示例:初一");
column.setClazzName("示例:1班");
column.setStuName("示例:小明");
column.setAccount ("示例:430********4321");
column.setPassword ("示例:p123456@");
column.setIdCard("示例:430********4321");
column.setClazzNo("示例:01");
column.setGender("示例:男");
stuList.add(column);
}
List<SelectIntVO> gradeList=baseSchsystemGradeService.getGradeSelect(schId,null,null)
.stream().collect(Collectors.toList());
List<SchClass> schClassList=schClassService.getSchClassCacheList(schId);
List<ImportRuleExcelColumn> ruleList = new ArrayList<>();
for(SelectIntVO grade:gradeList){
ImportRuleExcelColumn rule = new ImportRuleExcelColumn();
rule.setRuleItem(grade.getName());
rule.setDescription("选择班级:");
List<String> clazzNames=schClassList.stream()
.filter(s->s.getGradeId().equals(grade.getId()))
.map(s->s.getName())
.collect(Collectors.toList());
rule.setContent(clazzNames.isEmpty() ? "暂无班级":String.join("、",clazzNames));
ruleList.add(rule);
}
ExportParams params1 = new ExportParams("学生导入",comSchTreeService.getSchoolName(schId));
Map<String, Object> sheet1 = new HashMap<>();
sheet1.put("title",params1);
sheet1.put("entity", StudentExcelColumn.class);
sheet1.put("data", stuList);
sheets.add(sheet1);
ExportParams params2 = new ExportParams("导入规则", "导入规则");
Map<String, Object> sheet2 = new HashMap<>();
sheet2.put("title", params2);
sheet2.put("entity", ImportRuleExcelColumn.class);
sheet2.put("data", ruleList);
sheets.add(sheet2);
Workbook workbook = ExcelExportUtil.exportExcel(sheets, ExcelType.HSSF);
EasyPoiUtils.downLoadExcel(fileName + ".xls", response, workbook);
}
@GetMapping("studentClassNoTemplate")
public void studentClassNoTemplate(HttpServletResponse response, Integer schId,
@RequestParam(required = false) Integer schsystemId,
@RequestParam(required = false) Integer gradeId,
@RequestParam(required = false) Integer classId){
schStudentService.studentClassNoTemplate(response,schId,schsystemId,gradeId,classId);
}
@PostMapping("importStudents")
public void importStudents(BoaUser authUserWithDept, UserSysRole curRole, @RequestPart("file") MultipartFile file) {
schStudentService.importStudents(UserContext.getCurrentUserInfo(),file);
}
@PostMapping("importStudentClassNo")
public void importStudentClassNo(BoaUser authUserWithDept, UserSysRole curRole, @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);
}
}
@@ -0,0 +1,51 @@
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;
import com.yunhai.platform.utils.model.BoaUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH+"/subject/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchSubjectController {
@Autowired
private ISchDicSubjectService schDicSubjectService; // 使用接口
@GetMapping("list")
public List<SchDicSubject> getSchSubList(UserSysRole curRole, Integer schSystemId) {
return schDicSubjectService.getSchSubList(curRole.getSchId(),schSystemId);
}
@PostMapping("save")
public void saveSchSub(BoaUser authUserWithDept,UserSysRole curRole,@Valid @RequestBody SchDicSubject model) {
schDicSubjectService.saveSchSub(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("sort")
public void schSubSort(BoaUser authUserWithDept, UserSysRole curRole, Integer schSystemId, @RequestBody List<String> subIds) {
schDicSubjectService.schSubSort(UserContext.getCurrentUserInfo(),subIds,schSystemId);
}
@PostMapping("delete/{id}")
public void delSchSub(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable Integer id) {
UserContext.UserInfo user=UserContext.getCurrentUserInfo();
schDicSubjectService.delSchSub(user,id);
}
@GetMapping("select")
public List<SelectStrVO> select(UserSysRole curRole,@RequestParam(required = false) Integer schSystemId) {
return schDicSubjectService.select(curRole.getSchId(),schSystemId);
}
}
@@ -0,0 +1,181 @@
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;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*;
@RestController
@RequestMapping(Config.API_PATH+"/teachs/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchTeachController extends BaseController {
@Autowired
private ISchClassTeachService schClassTeachService; //使用接口
@Autowired
private ISchDicSubjectService schDicSubjectService; //使用接口
@Autowired
private ISchClassService schClassService; //使用接口
@Autowired
private ISchTeacherService schTeacherService; //使用接口
@GetMapping("search")
public SchTeachMapVO getSchTeachMapVO(UserSysRole curRole,
@RequestParam(required = true) Integer schsystemId,
@RequestParam(required = false) Integer gradeId) {
return schClassTeachService.getSchTeachMapVO(curRole.getSchId(),schsystemId,gradeId);
}
@GetMapping("getSchClassTeach")
public List<SchTeachMapIdVO> getSchClassTeachMapVO(UserSysRole curRole, @RequestParam Integer gradeId,@RequestParam Integer classId) {
return schClassTeachService.getSchClassTeachMapVO(curRole.getSchId(),gradeId,classId);
}
@PostMapping("save")
public void saveTeach(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody SchClassTeach model) {
schClassTeachService.saveTeach(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("delete/{id}")
public void delTeachById(BoaUser authUserWithDept, UserSysRole curRole, @PathVariable Integer id) {
schClassTeachService.delTeachById(UserContext.getCurrentUserInfo(),id);
}
@PostMapping("delClassTeach")
public void delClassTeach(BoaUser authUserWithDept, UserSysRole curRole,@RequestParam Integer classId) {
schClassTeachService.delClassTeach(UserContext.getCurrentUserInfo(),classId);
}
@PostMapping("delBatch")
public void delBatch(BoaUser authUserWithDept, UserSysRole curRole,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) {
schClassTeachService.delBatch(UserContext.getCurrentUserInfo(),schsystemId,gradeId);
}
@GetMapping("downloadTemplate")
public void downloadTemplate(HttpServletResponse response,@RequestParam Integer schId,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) throws IOException {
// 2. 获取科目和班级
List<SelectStrVO> subList = schDicSubjectService.select(schId, schsystemId);
if (subList == null) subList = Collections.emptyList();
List<BaseSchClassVO> schClassList = schClassService.searcBaseSchClass(schId, schsystemId, gradeId,null);
if (schClassList == null) schClassList = Collections.emptyList();
// 3. 创建工作簿
Workbook workbook = new HSSFWorkbook(); // 或 XSSFWorkbook
Sheet sheet = workbook.createSheet("教师任教导入");
// 4. 构建表头
Row headerRow = sheet.createRow(0);
int colIdx = 0;
headerRow.createCell(colIdx++).setCellValue("年级");
headerRow.createCell(colIdx++).setCellValue("班级");
for (SelectStrVO sub : subList) {
headerRow.createCell(colIdx++).setCellValue(sub.getName());
}
// 5. 填充数据行
int rowIdx = 1;
for (BaseSchClassVO clzz : schClassList) {
Row row = sheet.createRow(rowIdx++);
colIdx = 0;
row.createCell(colIdx++).setCellValue(clzz.getGradeName());
row.createCell(colIdx++).setCellValue(clzz.getName());
for (int i = 0; i < subList.size(); i++) {
row.createCell(colIdx++).setCellValue("");
}
}
// 6. 自动调整列宽(可选)
for (int i = 0; i < 2 + subList.size(); i++) {
sheet.autoSizeColumn(i);
}
// 7. 下载
String fileName = "教师任教导入模板.xls";
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
workbook.write(response.getOutputStream());
workbook.close();
}
@GetMapping("export")
public void export(HttpServletResponse response,@RequestParam Integer schId,@RequestParam Integer schsystemId, @RequestParam(required = false) Integer gradeId) throws IOException {
// 2. 获取科目和班级
List<SelectStrVO> subList = schDicSubjectService.select(schId, schsystemId);
if (subList == null) subList = Collections.emptyList();
List<BaseSchClassVO> schClassList = schClassService.searcBaseSchClass(schId, schsystemId, gradeId,null);
if (schClassList == null) schClassList = Collections.emptyList();
Map<Integer,String> schTeacherMap=schTeacherService.toIdAndNameMap(schId);
List<SchClassTeach> schClassTeachList=schClassTeachService.getSchClassTeachCacheList(schId,gradeId,null);
// 3. 创建工作簿
Workbook workbook = new HSSFWorkbook(); // 或 XSSFWorkbook
Sheet sheet = workbook.createSheet("教师任教导出");
// 4. 构建表头
Row headerRow = sheet.createRow(0);
int colIdx = 0;
headerRow.createCell(colIdx++).setCellValue("年级");
headerRow.createCell(colIdx++).setCellValue("班级");
for (SelectStrVO sub : subList) {
headerRow.createCell(colIdx++).setCellValue(sub.getName());
}
// 5. 填充数据行
int rowIdx = 1;
for (BaseSchClassVO clzz : schClassList) {
Row row = sheet.createRow(rowIdx++);
colIdx = 0;
row.createCell(colIdx++).setCellValue(clzz.getGradeName());
row.createCell(colIdx++).setCellValue(clzz.getName());
for (SelectStrVO sub:subList) {
Optional<SchClassTeach> classTeachOpt= schClassTeachList.stream().filter(s->s.getClassId().equals(clzz.getClassId())&&s.getSubId().equals(sub.getId())).findFirst();
row.createCell(colIdx++).setCellValue(classTeachOpt.isPresent()?schTeacherMap.get(classTeachOpt.get().getTeaId()):"");
}
}
// 6. 自动调整列宽(可选)
for (int i = 0; i < 2 + subList.size(); i++) {
sheet.autoSizeColumn(i);
}
// 7. 下载
String fileName = "教师任教导出.xls";
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
workbook.write(response.getOutputStream());
workbook.close();
}
@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);
}
}
@@ -0,0 +1,143 @@
package com.yunhai.bschclassmanage.controller.api;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.controller.BaseController;
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;
import com.yunhai.bschclassmanage.model.vo.SelectIntVO;
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;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH+"/teacher/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchTeacherController extends BaseController {
@Autowired
private ISchTeacherService schTeacherService; // 使用接口
@Autowired
private IComSchTreeService comSchTreeService; // 使用接口
@GetMapping("search")
public PageVO<SchTeacherVO> searchSchTeacher(UserSysRole curRole,
@RequestParam(required = false) Integer groupId,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return schTeacherService.searchSchTeacher(curRole.getSchId(),groupId,keyword,pageable);
}
@GetMapping("searchTransferOut")
public PageVO<SchTeacherTOutVO> searchTransferOutTeacher(@RequestParam(required = false) Integer schId,
@RequestParam(required = false) Integer groupId,
@RequestParam(required = false) String keyword,
Pageable pageable) {
return schTeacherService.searchTransferOutTeacher(schId,groupId,keyword,pageable);
}
@PostMapping("save")
public void saveTeacher(BoaUser authUserWithDept, UserSysRole curRole, @Valid @RequestBody SchTeacherDTO model) {
schTeacherService.saveTeacher(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("delete/{ids}")
public void deleteTeacher(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable String ids ) {
schTeacherService.deleteTeacher(UserContext.getCurrentUserInfo(),ids);
}
@PostMapping("moveGroup")
public void moveGroup(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody TeaTransferGroupDTO model) {
schTeacherService.moveGroup(UserContext.getCurrentUserInfo(),model);
}
@PostMapping("setStatus")
public void setTeacherStatus(BoaUser authUserWithDept, UserSysRole curRole, String ids,Integer status){
schTeacherService.setTeacherStatus(UserContext.getCurrentUserInfo(),ids,status);
}
@GetMapping("groupSelect") // 当前用户
public List<SelectIntVO> toTeacherGroupSelect(UserSysRole curRole) {
return schTeacherService.toTeacherGroupSelect(curRole.getSchId());
}
@GetMapping("groupSelectBySchId")
public List<SelectIntVO> toTeacherGroupSelect(@RequestParam Integer schId) {
return schTeacherService.toTeacherGroupSelect(schId);
}
@GetMapping("select")
public List<SelectIntVO> toIdAndNameSelect(UserSysRole curRole,@RequestParam(required = false) Integer groupId) {
return schTeacherService.toIdAndNameSelect(groupId,curRole.getSchId());
}
@GetMapping("transferOutSchSelect")
public List<SelectIntVO> transferOutSchSelect() {
return schTeacherService.transferOutSchSelect();
}
@PostMapping("setTransferOut/{ids}")
public void setTransferOut(BoaUser authUserWithDept, UserSysRole curRole,@PathVariable String ids){
schTeacherService.setTransferOut(UserContext.getCurrentUserInfo(),ids);
}
@PostMapping("setTransferIn")
public void setTransferIn(BoaUser authUserWithDept, UserSysRole curRole,@Valid @RequestBody TeaTransferInGroupDTO model) {
schTeacherService.setTransferIn(UserContext.getCurrentUserInfo(),model);
}
@GetMapping("downloadTemplate")
public void downloadTemplate(UserSysRole curRole,HttpServletResponse response) {
List<TeacherExcelColumn> list=new ArrayList<>();
String fileName="教师导入模板";
String titleName ="教师信息导入" ;
ExportParams exportParams = new ExportParams(titleName, "");
List<SelectIntVO> teaGroupNameList = comSchTreeService.getTeaGroupNameList(curRole.getSchId(),null);
for (SelectIntVO group:teaGroupNameList)
{
TeacherExcelColumn column=new TeacherExcelColumn();
column.setGroupName(group.getName());
column.setAccount("");
column.setPassword("");
column.setTeaName("");
column.setIdCard("");
column.setTel("");
column.setGender("");
list.add(column);
}
Workbook workbook2 = ExcelExportUtil.exportExcel(exportParams, TeacherExcelColumn.class, list);
EasyPoiUtils.downLoadExcel(fileName + ".xls", response, workbook2);
}
@PostMapping("importTeachers")
public void importTeachers(BoaUser authUserWithDept, UserSysRole curRole,@RequestPart("file") MultipartFile file) {
schTeacherService.importTeachers(UserContext.getCurrentUserInfo(),file);
}
}
@@ -0,0 +1,84 @@
package com.yunhai.bschclassmanage.controller.api;
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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH+"/tree/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchTreeController {
@Autowired
private IComSchTreeService comSchTreeService;
@GetMapping("getGroupTree")
public List<BaseTree> getGroupTree()
{
return comSchTreeService.getGroupTree();
}
@GetMapping("getTeacherTree")
public BaseTree getTeacherTree(UserSysRole curRole)
{
return comSchTreeService.getTeacherTree(curRole.getSchId());
}
@GetMapping("getSchoolList")
public List<SelectIntVO> getSchoolList()
{
return comSchTreeService.getSchoolList();
}
@GetMapping("getGradeTree")
public SchSystemTreeVO getGradeTree(UserSysRole curRole)
{
return comSchTreeService.getGradeTree(curRole.getSchId());
}
@GetMapping("getClassTree")
public SchSystemTreeVO getClassTree(UserSysRole curRole)
{
return comSchTreeService.getClassTree(curRole.getSchId());
}
@GetMapping("getClassHistoryTree")
public SchSystemTreeVO getClassHistoryTree(UserSysRole curRole)
{
return comSchTreeService.getClassHistoryTree(curRole.getSchId());
}
@GetMapping("getHigherSchGradeTree")
public SchSystemTreeVO getHigherSchGradeTree(UserSysRole curRole)
{
return comSchTreeService.getHigherSchGradeTree(curRole.getSchId());
}
@GetMapping("getHigherSchClassTree")
public SchSystemTreeVO getHigherSchClassTree(UserSysRole curRole)
{
return comSchTreeService.getHigherSchClassTree(curRole.getSchId());
}
@GetMapping("getTeaTree")
public BaseTree getTeaTree(UserSysRole curRole)
{
return comSchTreeService.getTeaTree(curRole.getSchId());
}
}
@@ -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());
}
}
@@ -0,0 +1,54 @@
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.*;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH+"/yearterm/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SystemYearTermController {
@Autowired
private IBaseYearTermService baseYearTermService; // 使用接口
@GetMapping("list")
public List<BaseYearTermVO> getAllYearTerm() {
return baseYearTermService.getAllYearTermVO();
}
@PostMapping("add")
public void createYearTerm(BoaUser authUserWithDept, UserSysRole curRole,
@Valid @RequestBody BaseYearTermDTO dto) {
BaseYearTerm entity = new BaseYearTerm();
entity.setCreateDate(new Date());
entity.setCreateUserId(authUserWithDept.getId());
BeanUtils.copyProperties(dto, entity);
baseYearTermService.createNowYearTerm(UserContext.getCurrentUserInfo(),entity);
}
@PostMapping("edit")
public void updateYearTerm(BoaUser authUserWithDept, UserSysRole curRole,
@Valid @RequestBody BaseYearTermDTO dto) {
BaseYearTerm entity = new BaseYearTerm();
entity.setUpdateDate(new Date());
entity.setUpdateUserId(authUserWithDept.getId());
BeanUtils.copyProperties(dto, entity);
baseYearTermService.updateYearTerm(UserContext.getCurrentUserInfo(),entity);
}
}
@@ -0,0 +1,46 @@
package com.yunhai.bschclassmanage.controller.api;
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;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Enumeration;
import java.util.List;
@RestController
@RequestMapping(Config.API_PATH +"/base/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class UserController {
@GetMapping("getUserMod")
public List<BoaModule> getUserMod(BoaUser authUserWithDept, UserSysRole curRole) {
return YschBaseOpenApi.getUserModule(authUserWithDept.getId(),curRole.getSchId());
}
@GetMapping("getUserInfo")
public BoaUser getUserInfo(BoaUser authUserWithDept) {
return authUserWithDept;
}
@GetMapping("logout")
protected void logout(HttpServletRequest request) {
HttpSession session = request.getSession();
Enumeration<String> names = session.getAttributeNames();
while (names.hasMoreElements()) {
System.out.print(names.nextElement() + ",");
}
session.invalidate();
System.out.println("logout over");
}
}
@@ -0,0 +1,20 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.model.vo.oa.SchInfoVO;
import com.yunhai.bschclassmanage.service.ISchInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(Config.OAPI+"/SchGroup/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchGroupController {
}
@@ -0,0 +1,31 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.model.vo.oa.SchInfoVO;
import com.yunhai.bschclassmanage.service.ISchInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(Config.OAPI+"/SchInfo/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SchInfoController {
@Autowired
private ISchInfoService schInfoService;
@GetMapping("GetSchlist")
public ResponseEntity<List<SchInfoVO>> GetSchlist(@RequestParam(required = false)String SchIDArr) {
return ResponseEntity.ok(schInfoService.getSchVOList(SchIDArr));
}
@GetMapping("GetSchFirst")
public ResponseEntity<SchInfoVO> GetSchFirst(@RequestParam String SchID) {
return ResponseEntity.ok(schInfoService.GetSchFirst(SchID));
}
}
@@ -0,0 +1,139 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.Repository.SchTeacherRepository;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchTeacher;
import com.yunhai.bschclassmanage.entity.SchTeacherGroup;
import com.yunhai.bschclassmanage.enums.UserGender;
import com.yunhai.bschclassmanage.enums.UserRole;
import com.yunhai.bschclassmanage.model.oa.TeaInfoVO;
import com.yunhai.bschclassmanage.model.vo.oa.SchInfoVO;
import com.yunhai.bschclassmanage.service.ISchInfoService;
import com.yunhai.bschclassmanage.service.ISchTeacherService;
import com.yunhai.bschclassmanage.utils.OtherUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.OAPI+"/OATea/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class TeainfoController {
@Autowired
private ISchTeacherService schTeacherService;
@Autowired
private SchTeacherRepository schTeacherRepository;
@Autowired
private ISchInfoService schInfoService;
@GetMapping("GetTeainfo")
public ResponseEntity<TeaInfoVO> getTeainfo(@RequestParam Integer uid) {
// 1. 参数校验
if (uid == null) {
return ResponseEntity.badRequest().build();
}
// 2. 直接使用 uid 查询
return schTeacherRepository.findByTeaId(uid) // 假设 findByTeaId 返回 Optional<SchTeacher>
.map(this::convertToTeaInfoVO) // 将 SchTeacher 转为 TeaInfoVO
.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}
private TeaInfoVO convertToTeaInfoVO(SchTeacher teacher) {
if (teacher == null) {
return null;
}
TeaInfoVO vo = new TeaInfoVO();
// 直接映射
vo.setAccount(teacher.getAccount());
vo.setName(teacher.getName());
vo.setTeaIDCard(teacher.getIdCard());
vo.setTel(teacher.getTel());
vo.setTeaNo(teacher.getSort());
vo.setRole(UserRole.TEACHER_USER.getValue());
if (teacher.getGender() != null) {
String sex = UserGender.nameById(teacher.getGender());
vo.setTeaSex(sex);
}
// TeaSerID 使用 teaId(转为字符串)或 id
if (teacher.getTeaId() != null) {
vo.setTeaSerID(teacher.getTeaId().toString());
} else {
vo.setTeaSerID(teacher.getId().toString());
}
List<SchTeacherGroup> groupList=teacher.getGroupList();
if(groupList==null||groupList.isEmpty())
return null;
// 其他字段默认 null(或根据业务设置默认值)
SchInfoVO schInfoVO= schInfoService.GetSchFirst(groupList.stream().findFirst().get().getSchId());
vo.setSchSerID(schInfoVO==null?null:schInfoVO.getSchSerId());
vo.setGroupID(groupList.stream().findFirst().get().getGroupId());
vo.setSchSerIDs(schInfoVO==null?null:schInfoVO.getSchSerId());
return vo;
}
@PostMapping("GetArrTeainfo")
public ResponseEntity<List<TeaInfoVO>> getArrTeainfo(@RequestBody String userIds) {
// 1. 参数校验
if (userIds == null) {
return ResponseEntity.badRequest().build();
}
List<Integer> uids= Arrays.asList(OtherUtil.convertToArray(userIds));
List<SchTeacher> teachers = schTeacherRepository.findByTeaIdIn(uids);
List<TeaInfoVO> voList = teachers.stream()
.map(this::convertToTeaInfoVO)
.collect(Collectors.toList());
return voList.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(voList);
}
@GetMapping("GetSchTeainfo")
public ResponseEntity<List<TeaInfoVO>> getSchTeainfo(@RequestParam String SchSerID) {
// 1. 参数校验
if (SchSerID == null) {
return ResponseEntity.badRequest().build();
}
SchInfoVO schInfoVO= schInfoService.GetSchFirst(SchSerID);
if(schInfoVO==null)
{
return ResponseEntity.badRequest().build();
}
Integer schId=schInfoVO.getUserSchSerId();
List<SchTeacher> teachers = schTeacherService.getSchTeacherList(schId);
List<TeaInfoVO> voList = teachers.stream()
.map(this::convertToTeaInfoVO)
.collect(Collectors.toList());
return voList.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(voList);
}
@GetMapping("GetSchTeaList")
public ResponseEntity<List<TeaInfoVO>> getSchTeaList(@RequestParam String SchSerID) {
return getSchTeainfo(SchSerID);
}
}
@@ -0,0 +1,177 @@
package com.yunhai.bschclassmanage.controller.oapi.oa;
import com.yunhai.bschclassmanage.Repository.SchStudentRepository;
import com.yunhai.bschclassmanage.Repository.SchTeacherRepository;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.entity.SchStudent;
import com.yunhai.bschclassmanage.entity.SchTeacher;
import com.yunhai.bschclassmanage.entity.SchTeacherGroup;
import com.yunhai.bschclassmanage.enums.UserRole;
import com.yunhai.bschclassmanage.enums.UserType;
import com.yunhai.bschclassmanage.model.oa.UserInfoVO;
import com.yunhai.bschclassmanage.model.vo.oa.SchInfoVO;
import com.yunhai.bschclassmanage.service.ISchInfoService;
import com.yunhai.bschclassmanage.service.ISchStudentService;
import com.yunhai.bschclassmanage.service.ISchTeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
@RestController
@RequestMapping(Config.OAPI + "/UserInfo/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class UserInfoController {
@Autowired
private ISchTeacherService schTeacherService;
@Autowired
private ISchStudentService schStudentService;
@Autowired
private SchTeacherRepository schTeacherRepository;
@Autowired
private SchStudentRepository schStudentRepository;
@Autowired
private ISchInfoService schInfoService;
@GetMapping("GetUserList")
public ResponseEntity<List<UserInfoVO>> getUserList(@RequestParam String SchSerID) {
// 1. 参数校验
if (SchSerID == null || SchSerID.trim().isEmpty()) {
return ResponseEntity.badRequest().build();
}
SchInfoVO schInfoVO = schInfoService.GetSchFirst(SchSerID);
if (schInfoVO == null) {
return ResponseEntity.badRequest().build();
}
Integer schId = schInfoVO.getUserSchSerId();
// 2. 获取教师和学生列表(判空)
List<SchTeacher> teachers = schTeacherService.getSchTeacherCacheList(schId);
List<SchStudent> students = schStudentService.getSchGradeClassStudentCacheList(schId, null, null, null);
// 3. 转换为 UserInfoVO
List<UserInfoVO> voList = new ArrayList<>();
if (teachers != null) {
voList.addAll(teachers.stream()
.map(this::convertToUserInfoVO)
.filter(vo -> vo != null) // 过滤转换失败的
.collect(Collectors.toList()));
}
if (students != null) {
voList.addAll(students.stream()
.map(this::convertToUserInfoVO)
.filter(vo -> vo != null)
.collect(Collectors.toList()));
}
// 4. 返回结果
return voList.isEmpty() ? ResponseEntity.noContent().build() : ResponseEntity.ok(voList);
}
// ===== 转换教师 =====
private UserInfoVO convertToUserInfoVO(SchTeacher teacher) {
if (teacher == null) {
return null;
}
UserInfoVO vo = new UserInfoVO();
// 基础字段
vo.setUids(teacher.getAccount());
vo.setName(teacher.getName());
vo.setIDCard(teacher.getIdCard());
vo.setTel(teacher.getTel());
vo.setNo(teacher.getSort());
vo.setSex(teacher.getGender());
vo.setUserID(teacher.getTeaId()); // 教师用户ID
vo.setUsertype(1); // 假设教师类型为1
// 获取学校ID和组ID
List<SchTeacherGroup> groupList = teacher.getGroupList();
if (groupList != null && !groupList.isEmpty()) {
SchTeacherGroup firstGroup = groupList.get(0);
vo.setGroupID(firstGroup.getGroupId());
// 通过组获取学校信息
SchInfoVO schInfo = schInfoService.GetSchFirst(firstGroup.getSchId());
// 若没有直接按组查学校的方法,可改为通过组的schId查
if (schInfo != null) {
vo.setSchSerID(schInfo.getSchSerId());
}
} else {
// 无分组,可能是管理员或特殊用户,可设置默认或 null
vo.setGroupID(null);
vo.setSchSerID(null);
}
// 其他字段(如 Photo, SerID 等)如果 SchTeacher 没有,可置 null 或从别处获取
vo.setPhoto(null); // 可根据 teacher 的某字段补充
vo.setSerID(null);
return vo;
}
// ===== 转换学生 =====
private UserInfoVO convertToUserInfoVO(SchStudent student) {
if (student == null) {
return null;
}
UserInfoVO vo = new UserInfoVO();
vo.setUids(student.getAccount());
vo.setName(student.getName());
vo.setIDCard(student.getIdCard());
vo.setTel(null); // 学生表可能无电话,如有则补充
vo.setNo(null); // 学生表没有 No 字段,可置 null 或从 stuClassNo 转换
vo.setSex(student.getGender());
vo.setUserID(student.getStuId()); // 学生用户ID
vo.setUsertype(UserRole.STU_USER.getValue()); // 假设学生类型为2
vo.setGroupID(student.getGroupId());
SchInfoVO schInfo = schInfoService.GetSchFirst(student.getSchId());
// 若没有直接按组查学校的方法,可改为通过组的schId查
if (schInfo != null) {
vo.setSchSerID(schInfo.getSchSerId());
}
vo.setPhoto(null);
vo.setSerID(null);
return vo;
}
@GetMapping("getUserIdList")
public ResponseEntity<List<UserInfoVO>> getUserIdList(@RequestParam Integer userid) {
if (userid == null) {
return ResponseEntity.badRequest().build();
}
Optional<SchTeacher> teacherOpt = schTeacherRepository.findByTeaId(userid);
if (teacherOpt.isPresent()) {
UserInfoVO vo = convertToUserInfoVO(teacherOpt.get());
if (vo != null) {
return ResponseEntity.ok(Collections.singletonList(vo));
}
}
Optional<SchStudent> studentOpt = schStudentRepository.findByStuId(userid);
if (studentOpt.isPresent()) {
UserInfoVO vo = convertToUserInfoVO(studentOpt.get());
if (vo != null) {
return ResponseEntity.ok(Collections.singletonList(vo));
}
}
return ResponseEntity.notFound().build();
}
}
@@ -0,0 +1,38 @@
package com.yunhai.bschclassmanage.controller.oapi.sync;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.model.tool.BaseGroup;
import com.yunhai.bschclassmanage.service.ISyncGroupService;
import com.yunhai.bschclassmanage.utils.OtherUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(Config.OAPI+"/group/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SyncGroupController {
@Autowired
private ISyncGroupService syncGroupService;
@PostMapping("AddGroup")
public void AddGroup(@RequestBody String jsonString) {
//判断 2,"学校组" 4, "班级组"
BaseGroup group = OtherUtil.jsonParseObject(jsonString, BaseGroup.class);
syncGroupService.syncAddOrUpdate(group);
}
@PostMapping("UpdateGroup")
public void UpdateGroup(@RequestBody String jsonString) {
BaseGroup group = OtherUtil.jsonParseObject(jsonString, BaseGroup.class);
syncGroupService.syncAddOrUpdate(group);
}
@PostMapping("DeleteGroup")
public void DeleteGroup(@RequestBody String jsonString) {
}
}
@@ -0,0 +1,41 @@
package com.yunhai.bschclassmanage.controller.oapi.sync;
import com.yunhai.bschclassmanage.config.Config;
import com.yunhai.bschclassmanage.model.tool.BaseGroup;
import com.yunhai.bschclassmanage.model.tool.BaseUser;
import com.yunhai.bschclassmanage.model.tool.DeleteUser;
import com.yunhai.bschclassmanage.service.ISyncUserService;
import com.yunhai.bschclassmanage.service.impl.sync.SyncGroupService;
import com.yunhai.bschclassmanage.service.impl.sync.SyncUserService;
import com.yunhai.bschclassmanage.utils.OtherUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(Config.OAPI+"/user/")
@CrossOrigin(originPatterns = {"*"}, allowCredentials = "true")
public class SyncUserController {
@Autowired
private ISyncUserService syncUserService;
@PostMapping("AddUser")
public void AddUser(@RequestBody String jsonString) {
List<BaseUser> userlist = OtherUtil.jsonParseList(jsonString, BaseUser.class);
syncUserService.syncAddOrUpdate(userlist);
}
@PostMapping("UpdateUser")
public void UpdateUser(@RequestBody String jsonString) {
List<BaseUser> userList = OtherUtil.jsonParseList(jsonString, BaseUser.class);
syncUserService.syncAddOrUpdate(userList);
}
@PostMapping("DeleteUser")
public void DeleteUser(@RequestBody String jsonString) {
List<DeleteUser> deleteUserList= OtherUtil.jsonParseList(jsonString, DeleteUser.class);
syncUserService.deleteUser(deleteUserList);
}
}