diff --git a/.gitignore b/.gitignore index 3dbf3903..4ca38c6b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,22 +4,30 @@ .LSOverride Icon ._* - + # IDE - IntelliJ IDEA +.flattened-pom.xml .idea/ *.iml *.iws *.ipr out/ .idea_modules/ - + # IDE - VSCode .vscode/ *.code-workspace - + # Obsidian files .obsidian/ - + +# Java build directory +/target/ +# Java build output +target/ +*/target/ +**/target/ + # Compiled files *.class *.jar @@ -28,18 +36,18 @@ out/ *.zip *.tar.gz *.rar - + # Logs and databases *.log *.sqlite *.db - + # Node node_modules/ npm-debug.log* yarn-debug.log* yarn-error.log* - + # Python __pycache__/ *.py[cod] @@ -61,8 +69,8 @@ wheels/ *.egg-info/ .installed.cfg *.egg - + # Temporary files *.swp *.swo -*~ +*~ \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/ExamAuthorizeController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/authorize/ExamAuthorizeController.java similarity index 96% rename from exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/ExamAuthorizeController.java rename to exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/authorize/ExamAuthorizeController.java index 4837cab4..b83148b3 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/ExamAuthorizeController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/authorize/ExamAuthorizeController.java @@ -1,4 +1,4 @@ -package pc.exam.pp.module.exam.controller.admin; +package pc.exam.pp.module.exam.controller.admin.authorize; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/ClassController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/ClassController.java new file mode 100644 index 00000000..90b8fa7b --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/ClassController.java @@ -0,0 +1,118 @@ +package pc.exam.pp.module.exam.controller.admin.classs; + +import org.springframework.web.bind.annotation.*; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import jakarta.validation.constraints.*; +import jakarta.validation.*; +import jakarta.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import pc.exam.pp.framework.common.pojo.PageParam; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.framework.common.util.object.BeanUtils; +import static pc.exam.pp.framework.common.pojo.CommonResult.success; + +import pc.exam.pp.framework.excel.core.util.ExcelUtils; + +import pc.exam.pp.framework.apilog.core.annotation.ApiAccessLog; +import static pc.exam.pp.framework.apilog.core.enums.OperateTypeEnum.*; + +import pc.exam.pp.module.exam.controller.admin.classs.vo.*; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; +import pc.exam.pp.module.exam.service.classs.ClassService; + +@Tag(name = "管理后台 - 学生班级") +@RestController +@RequestMapping("/exam/class") +@Validated +public class ClassController { + + @Resource + private ClassService classService; + + @PostMapping("/create") + @Operation(summary = "创建学生班级") + @PreAuthorize("@ss.hasPermission('exam:class:create')") + public CommonResult createClass(@Valid @RequestBody ClassSaveReqVO createReqVO) { + return success(classService.createClass(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生班级") + @PreAuthorize("@ss.hasPermission('exam:class:update')") + public CommonResult updateClass(@Valid @RequestBody ClassSaveReqVO updateReqVO) { + classService.updateClass(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生班级") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('exam:class:delete')") + public CommonResult deleteClass(@RequestParam("id") Long id) { + classService.deleteClass(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生班级") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('exam:class:query')") + public CommonResult getClass(@RequestParam("id") Long id) { + ClassDO classs = classService.getClass(id); + return success(BeanUtils.toBean(classs, ClassRespVO.class)); + } + + @GetMapping("/getClassName") + @Operation(summary = "获得班级名称列表") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + public CommonResult> getClassName() { + List className = classService.getClassName(); + return success(BeanUtils.toBean(className, ClassNameReturnVO.class)); + } + + @GetMapping("/getClassIdName") + @Operation(summary = "获得班级名称ID列表") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + public CommonResult> getClassIdName() { + List classDo = classService.getClassIdName(); + return success(BeanUtils.toBean(classDo, ClassDoReturnVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生班级分页") + @PreAuthorize("@ss.hasPermission('exam:class:query')") + public CommonResult> getClassPage(@Valid ClassPageReqVO pageReqVO) { + PageResult pageResult = classService.getClassPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, ClassRespVO.class)); + } + + @PostMapping("/binding") + @Operation(summary = "班级绑定学生列表") + public CommonResult getClassPage(@RequestBody ClassStudentSaveReqVO reqVO) { + classService.createClassStudent(reqVO); + return success(true); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生班级 Excel") + @PreAuthorize("@ss.hasPermission('exam:class:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportClassExcel(@Valid ClassPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = classService.getClassPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生班级.xls", "数据", ClassRespVO.class, + BeanUtils.toBean(list, ClassRespVO.class)); + } + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassDoReturnVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassDoReturnVO.java new file mode 100644 index 00000000..25a16c7f --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassDoReturnVO.java @@ -0,0 +1,14 @@ +package pc.exam.pp.module.exam.controller.admin.classs.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.ToString; + +@Schema(description = "管理后台 - 学生班级分页 Request VO") +@Data +@ToString(callSuper = true) +public class ClassDoReturnVO { + private Long id; + + private String name; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassNameReturnVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassNameReturnVO.java new file mode 100644 index 00000000..a88edc65 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassNameReturnVO.java @@ -0,0 +1,13 @@ +package pc.exam.pp.module.exam.controller.admin.classs.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; + +@Schema(description = "管理后台 - 学生班级分页 Request VO") +@Data +@ToString(callSuper = true) +public class ClassNameReturnVO { + private String className; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassPageReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassPageReqVO.java new file mode 100644 index 00000000..878f153a --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassPageReqVO.java @@ -0,0 +1,24 @@ +package pc.exam.pp.module.exam.controller.admin.classs.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import pc.exam.pp.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static pc.exam.pp.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 学生班级分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class ClassPageReqVO extends PageParam { + + @Schema(description = "名字", example = "芋艿") + private String name; + + @Schema(description = "状态", example = "1") + private Integer status; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassRespVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassRespVO.java new file mode 100644 index 00000000..e5f45df9 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassRespVO.java @@ -0,0 +1,35 @@ +package pc.exam.pp.module.exam.controller.admin.classs.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 学生班级 Response VO") +@Data +@ExcelIgnoreUnannotated +public class ClassRespVO { + + @Schema(description = "班级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26824") + @ExcelProperty("班级编号") + private Long id; + + @Schema(description = "名字", example = "芋艿") + @ExcelProperty("名字") + private String name; + + @Schema(description = "状态", example = "1") + @ExcelProperty("状态") + private Integer status; + + @Schema(description = "备注", example = "你说的对") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassSaveReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassSaveReqVO.java new file mode 100644 index 00000000..7e5f68b5 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassSaveReqVO.java @@ -0,0 +1,24 @@ +package pc.exam.pp.module.exam.controller.admin.classs.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import jakarta.validation.constraints.*; + +@Schema(description = "管理后台 - 学生班级新增/修改 Request VO") +@Data +public class ClassSaveReqVO { + + @Schema(description = "班级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "26824") + private Long id; + + @Schema(description = "名字", example = "芋艿") + private String name; + + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "备注", example = "你说的对") + private String remark; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassStudentSaveReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassStudentSaveReqVO.java new file mode 100644 index 00000000..affef006 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/classs/vo/ClassStudentSaveReqVO.java @@ -0,0 +1,16 @@ +package pc.exam.pp.module.exam.controller.admin.classs.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentClassDO; + +import java.util.List; + +@Schema(description = "管理后台 - 学生班级绑定新增/修改 Request VO") +@Data +public class ClassStudentSaveReqVO { + + @Schema(description = "学生表") + private List studentClassDOS; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/enums/student/ErrorStudentEnums.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/enums/student/ErrorStudentEnums.java new file mode 100644 index 00000000..58384fbd --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/enums/student/ErrorStudentEnums.java @@ -0,0 +1,14 @@ +package pc.exam.pp.module.exam.controller.admin.enums.student; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum ErrorStudentEnums { + + STUDENT_NOT_EXISTS("没有"); + + private final String description; + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/ExamKnowledgePointsController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/ExamKnowledgePointsController.java new file mode 100644 index 00000000..ae4720c7 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/ExamKnowledgePointsController.java @@ -0,0 +1,180 @@ +//package pc.exam.pp.module.exam.controller.admin.knowledge; +// +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.web.bind.annotation.*; +//import pc.exam.pp.module.exam.service.knowledge.ExamKnowledgePointsService; +// +//import java.util.ArrayList; +//import java.util.List; +//import java.util.Objects; +// +///** +// * 知识点Controller +// * +// * @author pengchen +// * @date 2025-04-02 +// */ +//@RestController +//@RequestMapping("/exam/points") +//public class ExamKnowledgePointsController{ +// +// @Autowired +// private ExamKnowledgePointsService knowledgePointsService; +// +// /** +// * 查询知识点列表 +// */ +// @GetMapping("/list") +// public AjaxResult list(ExamKnowledgePoints knowledgePoints) { +// List list = knowledgePointsService.selectKnowledgePointsList(knowledgePoints, String.valueOf(getDeptId()), String.valueOf(getUserId())); +// return success(list); +// } +// +// /** +// * 导出知识点列表 +// */ +// @ApiOperation("导出知识点列表") +// @Log(title = "知识点", businessType = BusinessType.EXPORT) +// @PostMapping("/export") +// public void export(HttpServletResponse response, ExamKnowledgePoints knowledgePoints) { +// List list = knowledgePointsService.selectKnowledgePointsList(knowledgePoints, String.valueOf(getDeptId()), String.valueOf(getUserId())); +// ExcelUtil util = new ExcelUtil(ExamKnowledgePoints.class); +// util.exportExcel(response, list, "知识点数据"); +// } +// +// /** +// * 获取知识点详细信息 +// */ +// @ApiOperation("获取知识点详细信息") +// @GetMapping(value = "/{spId}") +// public AjaxResult getInfo(@PathVariable("spId") Long spId) { +// return success(knowledgePointsService.selectKnowledgePointsBySpId(spId)); +// } +// +// /** +// * 新增知识点 +// */ +// @ApiOperation("新增知识点") +// @Log(title = "知识点", businessType = BusinessType.INSERT) +// @PostMapping +// public AjaxResult add(@RequestBody ExamKnowledgePoints knowledgePoints) { +// //获取登录用户id +// knowledgePoints.setDeptId(String.valueOf(getDeptId())); +// //获取登录部门id +// knowledgePoints.setUserId(String.valueOf(getUserId())); +// //获取登录用户名 +// knowledgePoints.setCreateBy(getUsername()); +// //获取新增名称信息 +// String SpName = knowledgePoints.getSpName(); +// //修改祖籍列表 +// Long ParentId = knowledgePoints.getParentId(); +// if (SpName != null) { +// if (String.valueOf(ParentId).equals("0")) { +// return error("不可增加根节点!"); +// +// } else { +// //获取父节点的信息 +// ExamKnowledgePoints knowledgePointF = knowledgePointsService.selectKnowledgePointsBySpId(ParentId); +// //获取父节点的id +// String ancestors = knowledgePointF.getAncestors(); +// //父节点子树+1 +// knowledgePointF.setTreeNum(knowledgePointF.getTreeNum() + 1); +// knowledgePointsService.updateKnowledgePoints(knowledgePointF); +// +// //修改祖籍列表 +// knowledgePoints.setAncestors(ancestors + "," + ParentId); +// return toAjax(knowledgePointsService.insertKnowledgePoints(knowledgePoints)); +// } +// +// } else +// return error("输入名称不能为空!"); +// +// } +// +// /** +// * 修改知识点 +// */ +// @ApiOperation("修改知识点") +// @Log(title = "知识点", businessType = BusinessType.UPDATE) +// @PutMapping +// public AjaxResult edit(@RequestBody ExamKnowledgePoints knowledgePoints) { +// //判断是否修改的根节点 +// if (Objects.equals(knowledgePoints.getAncestors(), "0")) { +// return error("不可直接修改根节点,请在专业表中修改!"); +// } else { +// if (Objects.equals(knowledgePoints.getSpName(), "")) { +// return error("修改名称不得为空!"); +// } else { +// //获取修改人 +// knowledgePoints.setUpdateBy(getUsername()); +// //修改时间 +// knowledgePoints.setUpdateTime(DateUtils.getNowDate()); +// return toAjax(knowledgePointsService.updateKnowledgePoints(knowledgePoints)); +// } +// } +// } +// +// /** +// * 删除知识点 +// */ +// @ApiOperation("删除知识点") +// @Log(title = "知识点", businessType = BusinessType.DELETE) +// @DeleteMapping("/{spIds}") +// public AjaxResult remove(@PathVariable Long[] spIds) { +// //用于判断是否符合删除条件 +// for (Long spId : spIds) { +// //实例化节点 +// ExamKnowledgePoints knowledgePoint = knowledgePointsService.selectKnowledgePointsBySpId(spId); +// Long ParentId = knowledgePoint.getParentId(); +// // 根据父节点id查找是否为根节点,根节点为专业不可在此删除 +// if (ParentId == 0) { +// return error("删除失败,删除目录中含有专业,请在专业表中删除!"); +// } else { +// // 判断是否有子树 +// if (knowledgePoint.getTreeNum() != 0) { +// return error("删除失败,删除目录下还存在知识点!"); +// } +// } +// } +// // 用于操作节点数 +// for (Long spId : spIds) { +// //根据主键id查询,实例化节点 +// ExamKnowledgePoints knowledgePoint = knowledgePointsService.selectKnowledgePointsBySpId(spId); +// Long ParentId = knowledgePoint.getParentId(); +// //实例化父节点 +// ExamKnowledgePoints knowledgePointF = knowledgePointsService.selectKnowledgePointsBySpId(ParentId); +// //父节点子树-1 +// knowledgePointF.setTreeNum(knowledgePointF.getTreeNum() - 1); +// knowledgePointsService.updateKnowledgePoints(knowledgePointF); +// //获取删除人 +// knowledgePoint.setUpdateBy(getUsername()); +// //获取删除时间 +// knowledgePoint.setUpdateTime(DateUtils.getNowDate()); +// knowledgePointsService.updateKnowledgePoints(knowledgePoint); +// } +// +// return toAjax(knowledgePointsService.deleteKnowledgePointsBySpIds(spIds)); +// } +// +// +// /** +// * 构建知识点树状结构 +// */ +// @ApiOperation("构建知识点树状结构") +// @GetMapping("/tree") +// public AjaxResult listTree(ExamKnowledgePoints knowledgePoints) { +// //定义List +// List tree = new ArrayList<>(); +// //查询数据库表中全部数据 +// List list = knowledgePointsService.selectKnowledgePointsList(knowledgePoints, String.valueOf(getDeptId()), String.valueOf(getUserId())); +// //将SpId、ParentId、SpName添加至数组 +// for (ExamKnowledgePoints L : list) { +// tree.add(new Tree(String.valueOf(L.getSpId()), String.valueOf(L.getParentId()), L.getSpName())); +// } +// // 构建树状结构 +// BuildTree T = new BuildTree(); +// tree = T.builTree(tree); +// // 转为json +// return AjaxResult.success(tree); +// } +//} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java new file mode 100644 index 00000000..59984cde --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java @@ -0,0 +1,157 @@ +package pc.exam.pp.module.exam.controller.admin.specialty; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.framework.common.util.object.BeanUtils; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo; +import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; +import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; +import pc.exam.pp.module.exam.service.knowledge.ExamKnowledgePointsService; +import pc.exam.pp.module.exam.service.specialty.ExamSpecialtyService; + +import java.util.List; +import java.util.Objects; + +import static pc.exam.pp.framework.common.pojo.CommonResult.error; +import static pc.exam.pp.framework.common.pojo.CommonResult.success; + +/** + * 专业-课程-题型Controller + * + * @author pengchen + * @date 2025-03-24 + */ +@RestController +@RequestMapping("/exam/specialty") +public class ExamSpecialtyController{ + @Autowired + private ExamSpecialtyService examSpecialtyService; + @Autowired + private ExamKnowledgePointsService knowledgePointsService; + + + @GetMapping("/list") + @Operation(summary = "获取专业列表") + public CommonResult> getSpecialtyList(SpecialtListReqVo reqVO) { + List list = examSpecialtyService.selectExamSpecialtyList(reqVO); + return success(BeanUtils.toBean(list, SpecialtyQueryVo.class)); + } + + @GetMapping("/part") + @Operation(summary = "获取专业列表(不包含题型)") + public CommonResult> getSpecialtyPart() { + List list = examSpecialtyService.selectExamSpecialtyPart(); + return success(BeanUtils.toBean(list, SpecialtyQueryVo.class)); + } + /** + * 获取全部数据详细信息 + */ + @GetMapping(value = "/{spId}") + @Operation(summary = "获取专业-课程-题型ID对应数据", description = "获取专业-课程-题型ID对应数据") + @Parameter(name = "spId", description = "专业ID", required = true, example = "1024") + public CommonResult getInfo(@PathVariable("spId") Long spId) { + return success(examSpecialtyService.selectExamSpecialtyBySpId(spId)); + } + + /** + * 新增数据信息(一级:专业,二级:课程,三级:题型) + */ + @Operation(summary = "新增数据信息(一级:专业,二级:课程,三级:题型)", description = "新增数据信息(一级:专业,二级:课程,三级:题型)") + @Parameter(name = "examSpecialty", description = "专业数据", required = true, example = "1024") + @PostMapping + public CommonResult add(@RequestBody ExamSpecialty examSpecialty) { + //定义层的数量,LimitNodes>=3(专业、课程、题型) + int LimitNodes = 3; + //获取新增名称信息 + String SpName = examSpecialty.getSpName(); + //修改祖籍列表 + Long ParentId = examSpecialty.getParentId(); + if (SpName != null) { + if (String.valueOf(ParentId).equals("0")) { + examSpecialty.setAncestors("0"); + return success(examSpecialtyService.insertExamSpecialty(examSpecialty)); + } else { + //获取父亲节点的父ID + String ancestors = examSpecialtyService.selectExamSpecialtyBySpId(ParentId).getAncestors(); + //获取节点数量并判断是否可在添加 + int nodeNum = ancestors.split(",").length; + if (nodeNum == LimitNodes) { + return error(25530, "不可在添加更深节点!"); + } else { + //获取父节点的信息 + ExamSpecialty examSpecialtyF = examSpecialtyService.selectExamSpecialtyBySpId(ParentId); + //父节点子树+1 + examSpecialtyF.setTreeNum(examSpecialtyF.getTreeNum() + 1); + examSpecialtyService.updateExamSpecialty(examSpecialtyF); + //修改祖籍列表 + examSpecialty.setAncestors(ancestors + "," + ParentId); + return success(examSpecialtyService.insertExamSpecialty(examSpecialty)); + } + } + } else + return error(255301, "输入名称不能为空!"); + } + + /** + * 修改数据信息 + */ + @Operation(summary = "修改数据信息", description = "修改数据信息(一级:专业,二级:课程,三级:题型)") + @Parameter(name = "examSpecialty", description = "专业数据", required = true, example = "1024") + @PutMapping + public CommonResult edit(@RequestBody ExamSpecialty examSpecialty) { + //判断修改名称是否为空 + if (Objects.equals(examSpecialty.getSpName(), "")) { + return error(25532, "修改名称不能为空!"); + } else { + return success(examSpecialtyService.updateExamSpecialty(examSpecialty)); + } + } + + /** + * 删除数据信息 + */ + @Operation(summary = "删除数据信息", description = "删除数据信息(一级:专业,二级:课程,三级:题型)") + @Parameter(name = "examSpecialty", description = "专业数据", required = true, example = "1024") + @DeleteMapping("/{spIds}") + public CommonResult remove(@PathVariable Long[] spIds) { + //用于判断是否符合删除条件 + for (Long spId : spIds) { + //实例化节点 + ExamSpecialty examSpecialty = examSpecialtyService.selectExamSpecialtyBySpId(spId); + Long ParentId = examSpecialty.getParentId(); + // 判断是否有子树 + if (examSpecialty.getTreeNum() != 0) { + return error(25533, "删除失败,删除目录下还存在课程或题型!"); + } + ExamKnowledgePoints knowledgePoints = knowledgePointsService.selectKnowledgePointsBySpId(spId); + if (knowledgePoints != null) { + Long treeNum = knowledgePoints.getTreeNum(); + if (treeNum != 0) { + return error(255334, "删除失败,删除目录下还存在知识点!"); + } + } + } + // 用于操作节点数 + for (Long spId : spIds) { + //根据主键id查询,实例化节点 + ExamSpecialty examSpecialty = examSpecialtyService.selectExamSpecialtyBySpId(spId); + Long ParentId = examSpecialty.getParentId(); + //判断是不是根节点 + if (examSpecialty.getParentId() != 0) { + //实例化父节点 + ExamSpecialty examSpecialtyF = examSpecialtyService.selectExamSpecialtyBySpId(ParentId); + //父节点子树-1 + examSpecialtyF.setTreeNum(examSpecialtyF.getTreeNum() - 1); + // examSpecialtyService.updateExamSpecialty(examSpecialtyF); + } else { + knowledgePointsService.deleteKnowledgePointsBySpId(spId); + } + // examSpecialtyService.updateExamSpecialty(examSpecialty); + } + return success(examSpecialtyService.deleteExamSpecialtyBySpIds(spIds)); + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtListReqVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtListReqVo.java new file mode 100644 index 00000000..e8828044 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtListReqVo.java @@ -0,0 +1,20 @@ +package pc.exam.pp.module.exam.controller.admin.specialty.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 专业列表 Request VO") +@Data +public class SpecialtListReqVo { + + @Schema(description = "专业名称,模糊匹配", example = "计算机专业") + private String name; + + @Schema(description = "展示状态,参见 CommonStatusEnum 枚举类", example = "1") + private Integer status; + + @Schema(description = "创建时间") + private LocalDateTime createTime; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtyQueryVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtyQueryVo.java new file mode 100644 index 00000000..3746a950 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/vo/SpecialtyQueryVo.java @@ -0,0 +1,25 @@ +package pc.exam.pp.module.exam.controller.admin.specialty.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 专业列表 QueryResult VO") +@Data +public class SpecialtyQueryVo { + + private Long id; + + private Long parentId; + + private String name; + + private Integer status; + + private String ancestors; + + private Integer orderNum; + + private LocalDateTime createTime; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/StudentController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/StudentController.java new file mode 100644 index 00000000..44798f4b --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/StudentController.java @@ -0,0 +1,101 @@ +package pc.exam.pp.module.exam.controller.admin.student; + +import org.springframework.web.bind.annotation.*; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import jakarta.validation.*; +import jakarta.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import pc.exam.pp.framework.common.pojo.PageParam; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.framework.common.util.object.BeanUtils; +import static pc.exam.pp.framework.common.pojo.CommonResult.success; + +import pc.exam.pp.framework.excel.core.util.ExcelUtils; + +import pc.exam.pp.framework.apilog.core.annotation.ApiAccessLog; +import static pc.exam.pp.framework.apilog.core.enums.OperateTypeEnum.*; + +import pc.exam.pp.module.exam.controller.admin.student.vo.*; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentDO; +import pc.exam.pp.module.exam.service.student.StudentService; + +@Tag(name = "管理后台 - 学生") +@RestController +@RequestMapping("/exam/student") +@Validated +public class StudentController { + + @Resource + private StudentService studentService; + + @PostMapping("/create") + @Operation(summary = "创建学生") + @PreAuthorize("@ss.hasPermission('exam:student:create')") + public CommonResult createStudent(@Valid @RequestBody StudentSaveReqVO createReqVO) { + return success(studentService.createStudent(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新学生") + @PreAuthorize("@ss.hasPermission('exam:student:update')") + public CommonResult updateStudent(@Valid @RequestBody StudentSaveReqVO updateReqVO) { + studentService.updateStudent(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除学生") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('exam:student:delete')") + public CommonResult deleteStudent(@RequestParam("id") Long id) { + studentService.deleteStudent(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得学生") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('exam:student:query')") + public CommonResult getStudent(@RequestParam("id") Long id) { + StudentDO student = studentService.getStudent(id); + return success(BeanUtils.toBean(student, StudentRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得学生分页") + @PreAuthorize("@ss.hasPermission('exam:student:query')") + public CommonResult> getStudentPage(@Valid StudentPageReqVO pageReqVO) { + PageResult pageResult = studentService.getStudentPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, StudentRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出学生 Excel") + @PreAuthorize("@ss.hasPermission('exam:student:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportStudentExcel(@Valid StudentPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = studentService.getStudentPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "学生.xls", "数据", StudentRespVO.class, + BeanUtils.toBean(list, StudentRespVO.class)); + } + + @GetMapping("/getStuList") + @Operation(summary = "获得没有绑定过班级的学生列表") + public CommonResult> getStudentPage() { + List pageResult = studentService.getNobindingStudents(); + return success(BeanUtils.toBean(pageResult, StudentRespVO.class)); + } + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/vo/StudentPageReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/vo/StudentPageReqVO.java new file mode 100644 index 00000000..098f597e --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/vo/StudentPageReqVO.java @@ -0,0 +1,53 @@ +package pc.exam.pp.module.exam.controller.admin.student.vo; + +import lombok.*; +import io.swagger.v3.oas.annotations.media.Schema; +import pc.exam.pp.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static pc.exam.pp.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 学生分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class StudentPageReqVO extends PageParam { + + @Schema(description = "名字", example = "李四") + private String name; + + @Schema(description = "学号") + private String code; + + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "学生用户名", example = "王五") + private String userName; + + @Schema(description = "学生密码") + private String passWord; + + @Schema(description = "性别") + private Integer sex; + + @Schema(description = "电子邮件") + private String email; + + @Schema(description = "学生电话") + private String phone; + + @Schema(description = "简介", example = "随便") + private String description; + + @Schema(description = "头像") + private String avatar; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + private Long classId; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/vo/StudentRespVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/vo/StudentRespVO.java new file mode 100644 index 00000000..4413c6ec --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/vo/StudentRespVO.java @@ -0,0 +1,66 @@ +package pc.exam.pp.module.exam.controller.admin.student.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; + +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import pc.exam.pp.framework.excel.core.annotations.DictFormat; +import pc.exam.pp.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 学生 Response VO") +@Data +@ExcelIgnoreUnannotated +public class StudentRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25172") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @ExcelProperty("名字") + private String name; + + @Schema(description = "学号") + @ExcelProperty("学号") + private String code; + + @Schema(description = "状态", example = "1") + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer status; + + @Schema(description = "学生用户名", example = "王五") + @ExcelProperty("学生用户名") + private String userName; + + @Schema(description = "学生密码") + @ExcelProperty("学生密码") + private String passWord; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat("system_user_sex") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer sex; + + @Schema(description = "电子邮件") + @ExcelProperty("电子邮件") + private String email; + + @Schema(description = "学生电话") + @ExcelProperty("学生电话") + private String phone; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") + @ExcelProperty("简介") + private String description; + + @Schema(description = "头像") + @ExcelProperty("头像") + private String avatar; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/vo/StudentSaveReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/vo/StudentSaveReqVO.java new file mode 100644 index 00000000..0af3b8ef --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/student/vo/StudentSaveReqVO.java @@ -0,0 +1,47 @@ +package pc.exam.pp.module.exam.controller.admin.student.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import jakarta.validation.constraints.*; + +@Schema(description = "管理后台 - 学生新增/修改 Request VO") +@Data +public class StudentSaveReqVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25172") + private Long id; + + @Schema(description = "名字", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四") + @NotEmpty(message = "名字不能为空") + private String name; + + @Schema(description = "学号") + private String code; + + @Schema(description = "状态", example = "1") + private Integer status; + + @Schema(description = "学生用户名", example = "王五") + private String userName; + + @Schema(description = "学生密码") + private String passWord; + + @Schema(description = "性别", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "性别不能为空") + private Integer sex; + + @Schema(description = "电子邮件") + private String email; + + @Schema(description = "学生电话") + private String phone; + + @Schema(description = "简介", requiredMode = Schema.RequiredMode.REQUIRED, example = "随便") + @NotEmpty(message = "简介不能为空") + private String description; + + @Schema(description = "头像") + private String avatar; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/classs/ClassDO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/classs/ClassDO.java new file mode 100644 index 00000000..d08a905a --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/classs/ClassDO.java @@ -0,0 +1,43 @@ +package pc.exam.pp.module.exam.dal.dataobject.classs; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生班级 DO + * + * @author rwb + */ +@TableName("exam_class") +@KeySequence("exam_class_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ClassDO extends BaseDO { + + /** + * 班级编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 状态 + */ + private Integer status; + /** + * 备注 + */ + private String remark; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/classs/ClassTeacherDO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/classs/ClassTeacherDO.java new file mode 100644 index 00000000..ac1fa596 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/classs/ClassTeacherDO.java @@ -0,0 +1,35 @@ +package pc.exam.pp.module.exam.dal.dataobject.classs; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; +import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO; +import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; + +/** + * 班级老师 DO + * + * @author rwb + */ +@TableName("exam_class_teacher") +@Data +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ClassTeacherDO extends TenantBaseDO { + + /** + * Id + */ + @TableId + private Long id; + /** + * 班级编号 + */ + private Long classId; + /** + * 老师编号 + */ + private Long teacherId; +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/knowledge/ExamKnowledgePoints.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/knowledge/ExamKnowledgePoints.java new file mode 100644 index 00000000..accd6047 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/knowledge/ExamKnowledgePoints.java @@ -0,0 +1,41 @@ +package pc.exam.pp.module.exam.dal.dataobject.knowledge; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; + +/** + * 知识点对象 exam_knowledge_points + * + * @author pengchen + * @date 2025-04-02 + */ +@TableName("exam_knowledge_points") +@Data +@EqualsAndHashCode(callSuper = true) +public class ExamKnowledgePoints extends TenantBaseDO +{ + private static final long serialVersionUID = 1L; + + /** id */ + @TableId(value = "sp_id", type = IdType.AUTO) + private Long spId; + + private Long parentId; + + private String ancestors; + + private int orderNum; + + /** 名称 */ + private String spName; + + /** 状态(0正常 1停用) */ + private int status; + + /** 子树数量 */ + private Long treeNum; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java new file mode 100644 index 00000000..a18ec255 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/specialty/ExamSpecialty.java @@ -0,0 +1,37 @@ +package pc.exam.pp.module.exam.dal.dataobject.specialty; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; + +@TableName("exam_specialty") +@Data +@EqualsAndHashCode(callSuper = true) +public class ExamSpecialty extends TenantBaseDO { + private static final long serialVersionUID = 1L; + + /** id */ + @TableId(value = "sp_id", type = IdType.AUTO) + private Long spId; + + private Long parentId; + + private String ancestors; + + private int orderNum; + + /** 名称 */ + private String spName; + + /** 状态(0正常 1停用) */ + private int status; + + + private String unite; + + /** 子树数量 */ + private Long treeNum; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StudentClassDO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StudentClassDO.java new file mode 100644 index 00000000..5358fb1c --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StudentClassDO.java @@ -0,0 +1,34 @@ +package pc.exam.pp.module.exam.dal.dataobject.student; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; +import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; + +/** + * 学生班级 DO + * + * @author rwb + */ +@TableName("exam_student_class") +@Data +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StudentClassDO extends TenantBaseDO { + + /** + * Id + */ + @TableId + private Long id; + /** + * 班级编号 + */ + private Long classId; + /** + * 学生编号 + */ + private Long studentId; +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StudentDO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StudentDO.java new file mode 100644 index 00000000..28cf7d9b --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/student/StudentDO.java @@ -0,0 +1,72 @@ +package pc.exam.pp.module.exam.dal.dataobject.student; + +import lombok.*; +import com.baomidou.mybatisplus.annotation.*; +import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO; + +/** + * 学生 DO + * + * @author rwb + */ +@TableName("exam_student") +@KeySequence("exam_student_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class StudentDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 名字 + */ + private String name; + /** + * 学号 + */ + private String code; + /** + * 状态 + * + * 枚举 {@link TODO common_status 对应的类} + */ + private Integer status; + /** + * 学生用户名 + */ + private String userName; + /** + * 学生密码 + */ + private String passWord; + /** + * 性别 + * + * 枚举 {@link TODO system_user_sex 对应的类} + */ + private Integer sex; + /** + * 电子邮件 + */ + private String email; + /** + * 学生电话 + */ + private String phone; + /** + * 简介 + */ + private String description; + /** + * 头像 + */ + private String avatar; + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/classs/ClassMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/classs/ClassMapper.java new file mode 100644 index 00000000..43a1b0bc --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/classs/ClassMapper.java @@ -0,0 +1,34 @@ +package pc.exam.pp.module.exam.dal.mysql.classs; + +import java.util.*; + +import org.apache.ibatis.annotations.Param; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; +import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.module.exam.controller.admin.classs.vo.*; + +/** + * 学生班级 Mapper + * + * @author rwb + */ +@Mapper +public interface ClassMapper extends BaseMapperX { + + default PageResult selectPage(ClassPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(ClassDO::getName, reqVO.getName()) + .eqIfPresent(ClassDO::getStatus, reqVO.getStatus()) + .orderByDesc(ClassDO::getId)); + } + + List getClassName(); + + List getClassIdName(); + + ClassDO getClassNameOne(@Param("className") String className); + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/classs/ClassTeacherMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/classs/ClassTeacherMapper.java new file mode 100644 index 00000000..e3d269f6 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/classs/ClassTeacherMapper.java @@ -0,0 +1,10 @@ +package pc.exam.pp.module.exam.dal.mysql.classs; + + +import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassTeacherDO; + +@Mapper +public interface ClassTeacherMapper extends BaseMapperX { +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/knowledge/ExamKnowledgePointsMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/knowledge/ExamKnowledgePointsMapper.java new file mode 100644 index 00000000..4435f114 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/knowledge/ExamKnowledgePointsMapper.java @@ -0,0 +1,50 @@ +package pc.exam.pp.module.exam.dal.mysql.knowledge; + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; + +import java.util.List; + +/** + * 知识点Mapper接口 + * + * @author pengchen + * @date 2025-04-02 + */ +@Mapper +public interface ExamKnowledgePointsMapper extends BaseMapperX +{ + /** + * 查询知识点 + * + * @param spId 知识点主键 + * @return 知识点 + */ + public ExamKnowledgePoints selectKnowledgePointsBySpId(Long spId); + + /** + * 查询知识点列表 + * + * @param knowledgePoints 知识点 + * @return 知识点集合 + */ + public List selectKnowledgePointsList(@Param("knowledgePoints") ExamKnowledgePoints knowledgePoints); + + /** + * 删除知识点 + * + * @param spId 知识点主键 + * @return 结果 + */ + public int deleteKnowledgePointsBySpId(Long spId); + + /** + * 批量删除知识点 + * + * @param spIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteKnowledgePointsBySpIds(Long[] spIds); +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java new file mode 100644 index 00000000..631178f3 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/specialty/ExamSpecialtyMapper.java @@ -0,0 +1,83 @@ +package pc.exam.pp.module.exam.dal.mysql.specialty; +import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo; +import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; + +import java.util.List; + +/** + * 客户端Mapper接口 + * + * @author pengchen + * @date 2025-03-24 + */ +@Mapper +public interface ExamSpecialtyMapper extends BaseMapperX +{ + /** + * 查询数据 + * + * @param spId 数据主键 + * @return 数据信息 + */ + public ExamSpecialty selectExamSpecialtyBySpId(Long spId); + + /** + * 修改数据信息 + * + * @param examSpecialty 修改数据 + * @return 结果 + */ + public int updateExamSpecialty(ExamSpecialty examSpecialty); + + /** + * 查询数据信息列表 + * + * @param reqVo 查询数据信息 + * @return 数据集合 + */ + public List selectExamSpecialtyListVo(SpecialtListReqVo reqVo); + + /** + * 查询部分数据信息 + * + * @return 数据集合 + */ + public List selectExamSpecialtyPart(); + + /** + * 查询数据信息列表 + * + * @param reqVo 查询数据信息 + * @return 数据集合 + */ + public List selectExamSpecialtyList(SpecialtListReqVo reqVo); + + /** + * 根据主键列表查询 + * + * @param spIds 主键列表 + * @return 数据集合 + */ + public List selectSpIds(Long[] spIds); + + /** + * 删除数据 + * + * @param spId 数据主键 + * @return 结果 + */ + public int deleteExamSpecialtyBySpId(Long spId); + + /** + * 批量删除数据 + * + * @param spIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteExamSpecialtyBySpIds(Long[] spIds); + + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/student/StudentClassMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/student/StudentClassMapper.java new file mode 100644 index 00000000..7d22d607 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/student/StudentClassMapper.java @@ -0,0 +1,12 @@ +package pc.exam.pp.module.exam.dal.mysql.student; + + +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.module.exam.controller.admin.classs.vo.ClassStudentSaveReqVO; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentClassDO; + +@Mapper +public interface StudentClassMapper extends BaseMapperX { +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/student/StudentMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/student/StudentMapper.java new file mode 100644 index 00000000..b1707db1 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/student/StudentMapper.java @@ -0,0 +1,62 @@ +package pc.exam.pp.module.exam.dal.mysql.student; + +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.framework.mybatis.core.query.MPJLambdaWrapperX; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentClassDO; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentDO; +import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.module.exam.controller.admin.student.vo.*; + +import java.util.List; + +/** + * 学生 Mapper + * + * @author rwb + */ +@Mapper +public interface StudentMapper extends BaseMapperX { + +// default PageResult selectPage(StudentPageReqVO reqVO) { +// return selectPage(reqVO, new LambdaQueryWrapperX() +// .likeIfPresent(StudentDO::getName, reqVO.getName()) +// .eqIfPresent(StudentDO::getCode, reqVO.getCode()) +// .eqIfPresent(StudentDO::getStatus, reqVO.getStatus()) +// .likeIfPresent(StudentDO::getUserName, reqVO.getUserName()) +// .eqIfPresent(StudentDO::getPassWord, reqVO.getPassWord()) +// .eqIfPresent(StudentDO::getSex, reqVO.getSex()) +// .eqIfPresent(StudentDO::getEmail, reqVO.getEmail()) +// .eqIfPresent(StudentDO::getPhone, reqVO.getPhone()) +// .eqIfPresent(StudentDO::getDescription, reqVO.getDescription()) +// .eqIfPresent(StudentDO::getAvatar, reqVO.getAvatar()) +// .betweenIfPresent(StudentDO::getCreateTime, reqVO.getCreateTime()) +// .orderByDesc(StudentDO::getId)); +// } + + default PageResult selectPage(StudentPageReqVO reqVO) { + MPJLambdaWrapperX query = new MPJLambdaWrapperX() + .likeIfPresent(StudentDO::getName, reqVO.getName()) + .eqIfPresent(StudentDO::getCode, reqVO.getCode()) + .eqIfPresent(StudentDO::getStatus, reqVO.getStatus()) + .likeIfPresent(StudentDO::getUserName, reqVO.getUserName()) + .eqIfPresent(StudentDO::getPassWord, reqVO.getPassWord()) + .eqIfPresent(StudentDO::getSex, reqVO.getSex()) + .eqIfPresent(StudentDO::getEmail, reqVO.getEmail()) + .eqIfPresent(StudentDO::getPhone, reqVO.getPhone()) + .eqIfPresent(StudentDO::getDescription, reqVO.getDescription()) + .eqIfPresent(StudentDO::getAvatar, reqVO.getAvatar()) + .betweenIfPresent(StudentDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(StudentDO::getId); + if (reqVO.getClassId() != null) { + query.leftJoin(StudentClassDO.class, StudentClassDO::getStudentId, StudentDO::getId) + .eq(reqVO.getClassId() != null, StudentClassDO::getClassId, reqVO.getClassId()); // 避免 1 对多查询,产生相同的 1 + } + return selectJoinPage(reqVO, StudentDO.class, query); + } + + + List getBindingStudents(); + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/classs/ClassService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/classs/ClassService.java new file mode 100644 index 00000000..203a1f39 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/classs/ClassService.java @@ -0,0 +1,102 @@ +package pc.exam.pp.module.exam.service.classs; + +import java.util.*; +import jakarta.validation.*; +import pc.exam.pp.framework.common.util.collection.CollectionUtils; +import pc.exam.pp.module.exam.controller.admin.classs.vo.*; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.pojo.PageParam; + +/** + * 学生班级 Service 接口 + * + * @author rwb + */ +public interface ClassService { + + /** + * 创建学生班级 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createClass(@Valid ClassSaveReqVO createReqVO); + + /** + * 创建学生班级绑定关系 + * + * @param reqVO 创建信息 + */ + void createClassStudent(ClassStudentSaveReqVO reqVO); + + /** + * 解除学生班级绑定关系 + * + * @param reqVO 解除信息 + */ + void deleteClassStudent(ClassStudentSaveReqVO reqVO); + + /** + * 更新学生班级 + * + * @param updateReqVO 更新信息 + */ + void updateClass(@Valid ClassSaveReqVO updateReqVO); + + /** + * 删除学生班级 + * + * @param id 编号 + */ + void deleteClass(Long id); + + /** + * 获得学生班级 + * + * @param id 编号 + * @return 学生班级 + */ + ClassDO getClass(Long id); + + /** + * 获得班级名称 + * + * @return 班级名称 + */ + List getClassName(); + + /** + * 获得班级名称和ID + * + * @return 班级名称和ID + */ + List getClassIdName(); + + /** + * 获得学生班级分页 + * + * @param pageReqVO 分页查询 + * @return 学生班级分页 + */ + PageResult getClassPage(ClassPageReqVO pageReqVO); + + /** + * 获得指定编号的班级 Map + * + * @param ids 班级编号数组 + * @return 班级 Map + */ + default Map getClassMap(Collection ids) { + List list = getClassList(ids); + return CollectionUtils.convertMap(list, ClassDO::getId); + } + + /** + * 获得班级信息数组 + * + * @param ids 班级编号数组 + * @return 班级信息数组 + */ + List getClassList(Collection ids); +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/classs/ClassServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/classs/ClassServiceImpl.java new file mode 100644 index 00000000..d180f879 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/classs/ClassServiceImpl.java @@ -0,0 +1,119 @@ +package pc.exam.pp.module.exam.service.classs; + +import cn.hutool.core.collection.CollUtil; +import org.springframework.stereotype.Service; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +import pc.exam.pp.framework.common.enums.CommonStatusEnum; +import pc.exam.pp.module.exam.controller.admin.classs.vo.*; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.pojo.PageParam; +import pc.exam.pp.framework.common.util.object.BeanUtils; + +import pc.exam.pp.module.exam.dal.dataobject.student.StudentClassDO; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentDO; +import pc.exam.pp.module.exam.dal.mysql.classs.ClassMapper; +import pc.exam.pp.module.exam.dal.mysql.student.StudentClassMapper; + +import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.CLASS_NOT_EXISTS; + +/** + * 学生班级 Service 实现类 + * + * @author rwb + */ +@Service +@Validated +public class ClassServiceImpl implements ClassService { + + @Resource + private ClassMapper classMapper; + @Resource + private StudentClassMapper studentClassMapper; + + @Override + public Long createClass(ClassSaveReqVO createReqVO) { + // 插入 + createReqVO.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 + ClassDO classs = BeanUtils.toBean(createReqVO, ClassDO.class); + classMapper.insert(classs); + // 返回 + return classs.getId(); + } + + @Override + public void createClassStudent(ClassStudentSaveReqVO reqVO) { + // 循环插入或者更新数据 + for (StudentClassDO studentClassDO : reqVO.getStudentClassDOS()){ + studentClassMapper.insert(studentClassDO); + } + } + + @Override + public void deleteClassStudent(ClassStudentSaveReqVO reqVO) { + // 循环插入或者更新数据 +// for (Long longs : reqVO.getStudentClassDOS()){ +// StudentClassDO studentClassDO = new StudentClassDO(); +// studentClassDO.setStudentId(longs); +// studentClassMapper.deleteById(studentClassDO); +// } + } + + @Override + public void updateClass(ClassSaveReqVO updateReqVO) { + // 校验存在 + validateClassExists(updateReqVO.getId()); + // 更新 + ClassDO updateObj = BeanUtils.toBean(updateReqVO, ClassDO.class); + classMapper.updateById(updateObj); + } + + @Override + public void deleteClass(Long id) { + // 校验存在 + validateClassExists(id); + // 删除 + classMapper.deleteById(id); + } + + private void validateClassExists(Long id) { + if (classMapper.selectById(id) == null) { + throw exception(CLASS_NOT_EXISTS); + } + } + + @Override + public ClassDO getClass(Long id) { + return classMapper.selectById(id); + } + + @Override + public List getClassName() { + return classMapper.getClassName(); + } + + @Override + public List getClassIdName() { + return classMapper.getClassIdName(); + } + + @Override + public PageResult getClassPage(ClassPageReqVO pageReqVO) { + return classMapper.selectPage(pageReqVO); + } + + @Override + public List getClassList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } + return classMapper.selectBatchIds(ids); + } + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/knowledge/ExamKnowledgePointsService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/knowledge/ExamKnowledgePointsService.java new file mode 100644 index 00000000..047d98eb --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/knowledge/ExamKnowledgePointsService.java @@ -0,0 +1,62 @@ +package pc.exam.pp.module.exam.service.knowledge; + +import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; + +import java.util.List; + +/** + * 知识点Service接口 + * + * @author pengchen + * @date 2025-04-02 + */ +public interface ExamKnowledgePointsService +{ + /** + * 查询知识点 + * + * @param spId 知识点主键 + * @return 知识点 + */ + public ExamKnowledgePoints selectKnowledgePointsBySpId(Long spId); + + /** + * 查询知识点列表 + * + * @param knowledgePoints 知识点 + * @return 知识点集合 + */ + public List selectKnowledgePointsList(ExamKnowledgePoints knowledgePoints); + + /** + * 新增知识点 + * + * @param knowledgePoints 知识点 + * @return 结果 + */ + public int insertKnowledgePoints(ExamKnowledgePoints knowledgePoints); + + /** + * 修改知识点 + * + * @param knowledgePoints 知识点 + * @return 结果 + */ + public int updateKnowledgePoints(ExamKnowledgePoints knowledgePoints); + + /** + * 批量删除知识点 + * + * @param spIds 需要删除的知识点主键集合 + * @return 结果 + */ + public int deleteKnowledgePointsBySpIds(Long[] spIds); + + /** + * 删除知识点信息 + * + * @param spId 知识点主键 + * @return 结果 + */ + public int deleteKnowledgePointsBySpId(Long spId); +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/knowledge/ExamKnowledgePointsServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/knowledge/ExamKnowledgePointsServiceImpl.java new file mode 100644 index 00000000..853aa617 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/knowledge/ExamKnowledgePointsServiceImpl.java @@ -0,0 +1,120 @@ +package pc.exam.pp.module.exam.service.knowledge; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo; +import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; +import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; +import pc.exam.pp.module.exam.dal.mysql.knowledge.ExamKnowledgePointsMapper; +import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper; + +import java.util.List; +import java.util.Objects; + +/** + * 知识点Service业务层处理 + * + * @author pengchen + * @date 2025-04-02 + */ +@Service +public class ExamKnowledgePointsServiceImpl implements ExamKnowledgePointsService +{ + @Autowired + private ExamKnowledgePointsMapper knowledgePointsMapper; + + @Autowired + private ExamSpecialtyMapper examSpecialtyMapper; + + /** + * 查询知识点 + * + * @param spId 知识点主键 + * @return 知识点 + */ + @Override + public ExamKnowledgePoints selectKnowledgePointsBySpId(Long spId) + { + + return knowledgePointsMapper.selectKnowledgePointsBySpId(spId); + } + + /** + * 查询知识点列表 + * + * @param knowledgePoints 知识点 + * @return 知识点 + */ + @Override + public List selectKnowledgePointsList(ExamKnowledgePoints knowledgePoints) + { + SpecialtListReqVo reqVo = new SpecialtListReqVo(); + List examSpecialtyList = examSpecialtyMapper.selectExamSpecialtyList(reqVo); + for (ExamSpecialty Specialty:examSpecialtyList){ + // 根据ParentId是否为0判断是否为专业 + if (Objects.equals(String.valueOf(Specialty.getParentId()), "0") && Objects.equals(Specialty.getUnite(), "0")){ + // 实例化已经存在的专业 + ExamKnowledgePoints knowledgePoint = new ExamKnowledgePoints(); + knowledgePoint.setSpId(Specialty.getSpId()); + knowledgePoint.setParentId(Specialty.getParentId()); + knowledgePoint.setAncestors(Specialty.getAncestors()); + knowledgePoint.setSpName(Specialty.getSpName()); + knowledgePoint.setOrderNum(Specialty.getOrderNum()); + knowledgePoint.setStatus(Specialty.getStatus()); + // 新增专业 + knowledgePointsMapper.insert(knowledgePoint); + // 将合并标志改为1 + Specialty.setUnite("1"); + examSpecialtyMapper.updateById(Specialty); + } + } + return knowledgePointsMapper.selectKnowledgePointsList(knowledgePoints); + } + + /** + * 新增知识点 + * + * @param knowledgePoints 知识点 + * @return 结果 + */ + @Override + public int insertKnowledgePoints(ExamKnowledgePoints knowledgePoints) + { + return knowledgePointsMapper.insert(knowledgePoints); + } + + /** + * 修改知识点 + * + * @param knowledgePoints 知识点 + * @return 结果 + */ + @Override + public int updateKnowledgePoints(ExamKnowledgePoints knowledgePoints) + { + return knowledgePointsMapper.updateById(knowledgePoints); + } + + /** + * 批量删除知识点 + * + * @param spIds 需要删除的知识点主键 + * @return 结果 + */ + @Override + public int deleteKnowledgePointsBySpIds(Long[] spIds) + { + return knowledgePointsMapper.deleteKnowledgePointsBySpIds(spIds); + } + + /** + * 删除知识点信息 + * + * @param spId 知识点主键 + * @return 结果 + */ + @Override + public int deleteKnowledgePointsBySpId(Long spId) + { + return knowledgePointsMapper.deleteKnowledgePointsBySpId(spId); + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyService.java new file mode 100644 index 00000000..38e5ef24 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyService.java @@ -0,0 +1,80 @@ +package pc.exam.pp.module.exam.service.specialty; + +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo; +import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; + +import java.util.List; + +/** + * 专业——课程——题型Service接口 + * + * @author pengchen + * @date 2025-03-24 + */ +public interface ExamSpecialtyService +{ + /** + * 查询信息 + * + * @param spId 主键 + * @return 所有信息 + */ + public ExamSpecialty selectExamSpecialtyBySpId(Long spId); + + /** + * 查询全部信息列表 + * + * @param reqVO 信息数据 + * @return 全部信息集合 + */ + public List selectExamSpecialtyList(SpecialtListReqVo reqVO); + + /** + * 查询部分数据信息 + * + * @return 全部信息集合 + */ + public List selectExamSpecialtyPart(); + + /** + * 根据主键查询 + * + * @param spIds 主键id列表 + * @return 该主键id列表下的全部数据 + */ + public List selectSpIds(Long[] spIds); + + + /** + * 新增数据信息 + * + * @param examSpecialty 数据信息 + * @return 结果 + */ + public int insertExamSpecialty(ExamSpecialty examSpecialty); + + /** + * 修改数据 + * + * @param examSpecialty 数据信息 + * @return 结果 + */ + public int updateExamSpecialty(ExamSpecialty examSpecialty); + + /** + * 批量删除客户端 + * + * @param spIds 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteExamSpecialtyBySpIds(Long[] spIds); + + /** + * 删除客户端信息 + * + * @param spId 主键id + * @return 结果 + */ + public int deleteExamSpecialtyBySpId(Long spId); +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyServiceImpl.java new file mode 100644 index 00000000..aefe3375 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/specialty/ExamSpecialtyServiceImpl.java @@ -0,0 +1,123 @@ +package pc.exam.pp.module.exam.service.specialty; + + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import pc.exam.pp.framework.common.util.object.BeanUtils; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtListReqVo; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo; +import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; +import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; +import pc.exam.pp.module.exam.dal.mysql.knowledge.ExamKnowledgePointsMapper; +import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper; + +import java.util.List; +import java.util.Objects; + +@Service +public class ExamSpecialtyServiceImpl implements ExamSpecialtyService { + + @Autowired + private ExamSpecialtyMapper examSpecialtyMapper; + @Autowired + private ExamKnowledgePointsMapper knowledgePointsMapper; + + + /** + * 查询数据信息 + * + * @param spId 数据主键id + * @return 数据信息 + */ + @Override + public ExamSpecialty selectExamSpecialtyBySpId(Long spId) + { + return examSpecialtyMapper.selectExamSpecialtyBySpId(spId); + } + /** + * 查询数据信息列表 + * + * @param reqVo 查询数据信息 + * @return 数据信息 + */ + @Override + public List selectExamSpecialtyList(SpecialtListReqVo reqVo) + { + return examSpecialtyMapper.selectExamSpecialtyListVo(reqVo); + } + + @Override + public List selectExamSpecialtyPart() { + return examSpecialtyMapper.selectExamSpecialtyPart(); + } + + /** + * 根据主键列表查询 + * + * @param spIds 主键id列表 + * @return 数据信息 + */ + @Override + public List selectSpIds(Long[] spIds){ + return examSpecialtyMapper.selectSpIds(spIds); + } + + /** + * 新增数据信息 + * + * @param examSpecialty 新增数据 + * @return 结果 + */ + @Override + public int insertExamSpecialty(ExamSpecialty examSpecialty) + { + // 插入部门 + ExamSpecialty specialty = BeanUtils.toBean(examSpecialty, ExamSpecialty.class); + return examSpecialtyMapper.insert(specialty); + } + + /** + * 修改数据信息 + * + * @param examSpecialty 修改数据 + * @return 结果 + */ + @Override + public int updateExamSpecialty(ExamSpecialty examSpecialty) + { + // 对专业修改需判断是否已经互联 + // 已互联的情况需要对知识点表也进行修改 + ExamSpecialty Specialty = examSpecialtyMapper.selectExamSpecialtyBySpId(examSpecialty.getSpId()); + if (Objects.equals(Specialty.getUnite(), "1")){ + // 实例化需要修改的专业 + ExamKnowledgePoints knowledgePoint = new ExamKnowledgePoints(); + knowledgePoint.setSpId(examSpecialty.getSpId()); + knowledgePoint.setSpName(examSpecialty.getSpName()); + knowledgePointsMapper.updateById(knowledgePoint); + } + return examSpecialtyMapper.updateById(examSpecialty); + } + + /** + * 批量删除数据 + * + * @param spIds 需要删除的数据主键 + * @return 结果 + */ + @Override + public int deleteExamSpecialtyBySpIds(Long[] spIds) + { + return examSpecialtyMapper.deleteExamSpecialtyBySpIds(spIds); + } + /** + * 删除数据信息 + * + * @param spId 数据主键 + * @return 结果 + */ + @Override + public int deleteExamSpecialtyBySpId(Long spId) + { + return examSpecialtyMapper.deleteExamSpecialtyBySpId(spId); + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/student/StudentService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/student/StudentService.java new file mode 100644 index 00000000..9a82d2dd --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/student/StudentService.java @@ -0,0 +1,69 @@ +package pc.exam.pp.module.exam.service.student; + +import jakarta.validation.*; +import pc.exam.pp.module.exam.controller.admin.student.vo.*; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentDO; +import pc.exam.pp.framework.common.pojo.PageResult; + +import java.util.List; + +/** + * 学生 Service 接口 + * + * @author rwb + */ +public interface StudentService { + + /** + * 创建学生 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createStudent(@Valid StudentSaveReqVO createReqVO); + + /** + * 更新学生 + * + * @param updateReqVO 更新信息 + */ + void updateStudent(@Valid StudentSaveReqVO updateReqVO); + + /** + * 删除学生 + * + * @param id 编号 + */ + void deleteStudent(Long id); + + /** + * 根据班级ID查询学生列表(分页) + * + * @param id 编号 + */ +// PageResult getStudentListByClassId(Long id); + + /** + * 获得学生 + * + * @param id 编号 + * @return 学生 + */ + StudentDO getStudent(Long id); + + /** + * 获得学生分页 + * + * @param pageReqVO 分页查询 + * @return 学生分页 + */ + PageResult getStudentPage(StudentPageReqVO pageReqVO); + + /** + * 获得学生没有绑定班级的学生列表 + * + * @return 学生列表 + */ + List getNobindingStudents(); + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/student/StudentServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/student/StudentServiceImpl.java new file mode 100644 index 00000000..de3ea520 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/student/StudentServiceImpl.java @@ -0,0 +1,78 @@ +package pc.exam.pp.module.exam.service.student; + +import org.springframework.stereotype.Service; +import jakarta.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import pc.exam.pp.module.exam.controller.admin.student.vo.*; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentDO; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.util.object.BeanUtils; + +import pc.exam.pp.module.exam.dal.mysql.student.StudentMapper; + +import java.util.List; + +import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.STUDENT_NOT_EXISTS; + +/** + * 学生 Service 实现类 + * + * @author rwb + */ +@Service +@Validated +public class StudentServiceImpl implements StudentService { + + @Resource + private StudentMapper studentMapper; + + @Override + public Long createStudent(StudentSaveReqVO createReqVO) { + // 插入 + StudentDO student = BeanUtils.toBean(createReqVO, StudentDO.class); + studentMapper.insert(student); + // 返回 + return student.getId(); + } + + @Override + public void updateStudent(StudentSaveReqVO updateReqVO) { + // 校验存在 + validateStudentExists(updateReqVO.getId()); + // 更新 + StudentDO updateObj = BeanUtils.toBean(updateReqVO, StudentDO.class); + studentMapper.updateById(updateObj); + } + + @Override + public void deleteStudent(Long id) { + // 校验存在 + validateStudentExists(id); + // 删除 + studentMapper.deleteById(id); + } + + private void validateStudentExists(Long id) { + if (studentMapper.selectById(id) == null) { + throw exception(STUDENT_NOT_EXISTS); + } + } + + @Override + public StudentDO getStudent(Long id) { + return studentMapper.selectById(id); + } + + @Override + public PageResult getStudentPage(StudentPageReqVO pageReqVO) { + return studentMapper.selectPage(pageReqVO); + } + + @Override + public List getNobindingStudents() { + return studentMapper.getBindingStudents(); + } + +} \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/classs/ClassMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/classs/ClassMapper.xml new file mode 100644 index 00000000..ee50669d --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/classs/ClassMapper.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/knowledge/ExamKnowledgePointsMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/knowledge/ExamKnowledgePointsMapper.xml new file mode 100644 index 00000000..4d22bc93 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/knowledge/ExamKnowledgePointsMapper.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + select sp_id, parent_id, ancestors, sp_name, order_num, status, creator, create_time, updater, update_time, tree_num, tenant_id from exam_knowledge_points + + + + + + + + update exam_knowledge_points + + deleted = 1 + + where sp_id = #{spId} + + + +-- delete from knowledge_points + update exam_knowledge_points + + deleted = 1 + + where sp_id in + + #{spId} + + + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml new file mode 100644 index 00000000..76dbf730 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + select sp_id, parent_id, ancestors, sp_name, order_num, status, creator, create_time, updater, update_time, unite, tree_num, tenant_id from exam_specialty + + + + + + + + + + + + + + update exam_specialty + + parent_id = #{parentId}, + ancestors = #{ancestors}, + sp_name = #{spName}, + order_num = #{orderNum}, + status = #{status}, + unite = #{unite}, + tree_num = #{treeNum}, + + where sp_id = #{spId} + + + + + + update exam_specialty + + deleted = 1 + + where sp_id = #{spId} + + + + update exam_specialty + + deleted = 1 + + where sp_id in + + #{spId} + + + + diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StudentClassMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StudentClassMapper.xml new file mode 100644 index 00000000..e912b4ea --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StudentClassMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StudentMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StudentMapper.xml new file mode 100644 index 00000000..3c079c7d --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/student/StudentMapper.xml @@ -0,0 +1,20 @@ + + + + + + + + \ No newline at end of file diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/GccController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/GccController.java new file mode 100644 index 00000000..7076e9dc --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/GccController.java @@ -0,0 +1,4 @@ +package pc.exam.pp.module.judgement.controller.admin; + +public class GccController { +} diff --git a/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java b/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java index 46a7319e..d5ab7164 100644 --- a/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java +++ b/exam-module-system/exam-module-system-api/src/main/java/pc/exam/pp/module/system/enums/ErrorCodeConstants.java @@ -166,4 +166,10 @@ public interface ErrorCodeConstants { // ========== 站内信发送 1-002-028-000 ========== ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失"); + // ========== 学生相关 1-002-029-000 ========== + ErrorCode STUDENT_NOT_EXISTS = new ErrorCode(1_002_029_000, "没有学生信息"); + ErrorCode CLASS_NOT_EXISTS = new ErrorCode(1_002_029_001, "没有学生班级信息"); + ErrorCode STUDENT_USERNAME_LOGIN = new ErrorCode(1_002_029_002, "学生账号无法登陆!"); + ErrorCode STUDENT_USERNAME_NOTLOGIN = new ErrorCode(1_002_029_003, "非学生账号无法登陆!"); + } diff --git a/exam-module-system/exam-module-system-biz/pom.xml b/exam-module-system/exam-module-system-biz/pom.xml index a0ad7617..7a1d9a47 100644 --- a/exam-module-system/exam-module-system-biz/pom.xml +++ b/exam-module-system/exam-module-system-biz/pom.xml @@ -125,6 +125,12 @@ org.dromara.hutool hutool-extra + + pc.exam.gg + exam-module-exam-biz + 2.4.2-SNAPSHOT + compile + diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/auth/AuthController.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/auth/AuthController.java index 319cf0cf..6e413e5d 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/auth/AuthController.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/auth/AuthController.java @@ -35,9 +35,13 @@ import java.util.Collections; import java.util.List; import java.util.Set; +import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception; +import static pc.exam.pp.framework.common.pojo.CommonResult.error; import static pc.exam.pp.framework.common.pojo.CommonResult.success; import static pc.exam.pp.framework.common.util.collection.CollectionUtils.convertSet; import static pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.STUDENT_USERNAME_LOGIN; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.STUDENT_USERNAME_NOTLOGIN; @Tag(name = "管理后台 - 认证") @RestController @@ -66,6 +70,15 @@ public class AuthController { @PermitAll @Operation(summary = "使用账号密码登录") public CommonResult login(@RequestBody @Valid AuthLoginReqVO reqVO) { + // 判断账号类型 + AdminUserDO adminUserDO = userService.getUserByUsername(reqVO.getUsername()); + // 登陆非学生端,0,1 + if (Integer.parseInt(reqVO.getUserType()) <= 1) { + if (Integer.parseInt(adminUserDO.getUserType()) == 2) return error(STUDENT_USERNAME_LOGIN); + } + if (Integer.parseInt(reqVO.getUserType()) == 2) { + if (Integer.parseInt(adminUserDO.getUserType()) <= 1) return error(STUDENT_USERNAME_NOTLOGIN); + } return success(authService.login(reqVO)); } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/auth/vo/AuthLoginReqVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/auth/vo/AuthLoginReqVO.java index 3a2e6429..abf93eef 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/auth/vo/AuthLoginReqVO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/auth/vo/AuthLoginReqVO.java @@ -41,6 +41,9 @@ public class AuthLoginReqVO extends CaptchaVerificationReqVO { @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") private String socialCode; + @Schema(description = "用户类型") + private String userType; + @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") private String socialState; diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/permission/PermissionController.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/permission/PermissionController.java index f8bc5898..62a7bcc4 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/permission/PermissionController.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/permission/PermissionController.java @@ -43,6 +43,13 @@ public class PermissionController { return success(permissionService.getRoleMenuListByRoleId(roleId)); } + @Operation(summary = "获得教师拥有的专业编号") + @Parameter(name = "teacherId", description = "专业编号", required = true) + @GetMapping("/list-teacher-specialty") + public CommonResult> getTeaacherSpecoaltyList(Long teacherId) { + return success(permissionService.getSpecialtyListByTeacherId(teacherId)); + } + @PostMapping("/assign-role-menu") @Operation(summary = "赋予角色菜单") @PreAuthorize("@ss.hasPermission('system:permission:assign-role-menu')") diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/TenantController.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/TenantController.java index 74b9ac58..992df19b 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/TenantController.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/TenantController.java @@ -10,7 +10,9 @@ import pc.exam.pp.framework.excel.core.util.ExcelUtils; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantRespVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsVO; import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantSpcialtyDO; import pc.exam.pp.module.system.service.tenant.TenantService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -100,6 +102,14 @@ public class TenantController { return success(BeanUtils.toBean(tenant, TenantRespVO.class)); } + @GetMapping("/get-id-by-specialty") + @Operation(summary = "使用租户名,获得专业授权信息", description = "使用租户名,获得专业授权信息") + @Parameter(name = "name", description = "专业授权信息", required = true, example = "1024") + public CommonResult> getTenantIdBySpecialty(@RequestParam("id") Long id) { + List tenantSpcialtyDOS = tenantService.getTenantBySpecialty(id); + return success(tenantSpcialtyDOS); + } + @GetMapping("/page") @Operation(summary = "获得租户分页") @PreAuthorize("@ss.hasPermission('system:tenant:query')") @@ -108,6 +118,7 @@ public class TenantController { return success(BeanUtils.toBean(pageResult, TenantRespVO.class)); } + @GetMapping("/export-excel") @Operation(summary = "导出租户 Excel") @PreAuthorize("@ss.hasPermission('system:tenant:export')") diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java index c0d82ded..676cde1e 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java @@ -11,6 +11,7 @@ import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; import java.time.LocalDateTime; +import java.util.List; @Schema(description = "管理后台 - 租户创建/修改 Request VO") @Data @@ -66,5 +67,7 @@ public class TenantSaveReqVO { return id != null // 修改时,不需要传递 || (ObjectUtil.isAllNotEmpty(username, password)); // 新增时,必须都传递 username、password } + @Schema(description = "授权专业数量") + private List tenantSpecialtyPointsVOList; } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsPageVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsPageVO.java new file mode 100644 index 00000000..59ab4bc3 --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsPageVO.java @@ -0,0 +1,17 @@ +package pc.exam.pp.module.system.controller.admin.tenant.vo.tenant; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import pc.exam.pp.framework.common.pojo.PageParam; + + +@Schema(description = "管理后台 - 租户创建/修改 Request VO") +@Data +public class TenantSpecialtyPointsPageVO extends PageParam { + + private Long specialtyId; + + private Long tenantId; + + private String points; +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsVO.java new file mode 100644 index 00000000..628cfe91 --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsVO.java @@ -0,0 +1,18 @@ +package pc.exam.pp.module.system.controller.admin.tenant.vo.tenant; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import pc.exam.pp.framework.common.pojo.PageParam; + + +@Schema(description = "管理后台 - 租户创建/修改 Request VO") +@Data +public class TenantSpecialtyPointsVO { + private Long id; + + private Long specialtyId; + + private Long tenantId; + + private String points; +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java index 11cacc91..27cde911 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java @@ -7,6 +7,8 @@ import pc.exam.pp.framework.common.pojo.CommonResult; import pc.exam.pp.framework.common.pojo.PageParam; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.excel.core.util.ExcelUtils; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; +import pc.exam.pp.module.exam.service.classs.ClassService; import pc.exam.pp.module.system.controller.admin.user.vo.user.*; import pc.exam.pp.module.system.convert.user.UserConvert; import pc.exam.pp.module.system.dal.dataobject.dept.DeptDO; @@ -44,6 +46,8 @@ public class UserController { @Resource private AdminUserService userService; @Resource + private ClassService classService; + @Resource private DeptService deptService; @PostMapping("/create") @@ -54,6 +58,20 @@ public class UserController { return success(id); } + @PostMapping("/createStudent") + @Operation(summary = "新增用户学生用户") + public CommonResult createUserStudent(@Valid @RequestBody UserSaveReqVO reqVO) { + Long id = userService.createUserStudent(reqVO); + return success(id); + } + + @PostMapping("/createTeacher") + @Operation(summary = "新增用户教师用户") + public CommonResult createUserTeacher(@Valid @RequestBody UserSaveReqVO reqVO) { + Long id = userService.createUserTeacher(reqVO); + return success(id); + } + @PutMapping("update") @Operation(summary = "修改用户") @PreAuthorize("@ss.hasPermission('system:user:update')") @@ -62,6 +80,21 @@ public class UserController { return success(true); } + @PutMapping("updateStudent") + @Operation(summary = "修改用户 学生") + public CommonResult updateStudent(@Valid @RequestBody UserSaveReqVO reqVO) { + userService.updateStudent(reqVO); + return success(true); + } + + @PutMapping("updateTeacher") + @Operation(summary = "修改用户 教师") + public CommonResult updateTeacher(@Valid @RequestBody UserSaveReqVO reqVO) { + userService.updateTeacher(reqVO); + return success(true); + } + + @DeleteMapping("/delete") @Operation(summary = "删除用户") @Parameter(name = "id", description = "编号", required = true, example = "1024") @@ -103,6 +136,22 @@ public class UserController { pageResult.getTotal())); } + @GetMapping("/studentpage") + @Operation(summary = "获得学生分页列表") + public CommonResult> getStudentPage(@Valid UserPageReqVO pageReqVO) { + // 获得用户分页列表 + PageResult pageResult = userService.getStudentPage(pageReqVO); + if (CollUtil.isEmpty(pageResult.getList())) { + return success(new PageResult<>(pageResult.getTotal())); + } + // 拼接数据 班级数据 + // 拼接数据 + Map classDOMap = classService.getClassMap( + convertList(pageResult.getList(), AdminUserDO::getClassId)); + return success(new PageResult<>(UserConvert.INSTANCE.convertClassList(pageResult.getList(), classDOMap), + pageResult.getTotal())); + } + @GetMapping({"/list-all-simple", "/simple-list"}) @Operation(summary = "获取用户精简信息列表", description = "只包含被开启的用户,主要用于前端的下拉选项") public CommonResult> getSimpleUserList() { @@ -124,8 +173,22 @@ public class UserController { } // 拼接数据 DeptDO dept = deptService.getDept(user.getDeptId()); + // 学生-拼接班级数据 + if (user.getUserType().equals("2")) { + ClassDO classDO = classService.getClass(user.getClassId()); + return success(UserConvert.INSTANCE.convertClass(user, dept, classDO)); + } return success(UserConvert.INSTANCE.convert(user, dept)); } + @GetMapping("/getByThId") + @Operation(summary = "通过教师ID获取所有学生数据") + public CommonResult> getUserById(@RequestParam("id") Long id) { + List user = userService.getUserById(id); + if (user == null) { + return success(null); + } + return success(user); + } @GetMapping("/export") @Operation(summary = "导出用户") diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserPageReqVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserPageReqVO.java index 9018a1a8..e4ea5370 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserPageReqVO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserPageReqVO.java @@ -38,4 +38,10 @@ public class UserPageReqVO extends PageParam { @Schema(description = "角色编号", example = "1024") private Long roleId; + @Schema(description = "类型") + private String userType; + + @Schema(description = "班级") + private String className; + } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserRespVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserRespVO.java index 92bf9dfb..e59ea9aa 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserRespVO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserRespVO.java @@ -28,11 +28,16 @@ public class UserRespVO{ @ExcelProperty("用户昵称") private String nickname; + @Schema(description = "班级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") + @ExcelProperty("班级名称") + private String className; + @Schema(description = "备注", example = "我是一个用户") private String remark; @Schema(description = "部门ID", example = "我是一个用户") private Long deptId; + @Schema(description = "部门名称", example = "IT 部") @ExcelProperty("部门名称") private String deptName; @@ -40,6 +45,9 @@ public class UserRespVO{ @Schema(description = "岗位编号数组", example = "1") private Set postIds; + @Schema(description = "班级编号数组", example = "1") + private Set classIds; + @Schema(description = "用户邮箱", example = "exam@iocoder.cn") @ExcelProperty("用户邮箱") private String email; diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserSaveReqVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserSaveReqVO.java index 91042eed..17968f93 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserSaveReqVO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/vo/user/UserSaveReqVO.java @@ -41,10 +41,22 @@ public class UserSaveReqVO { @DiffLogField(name = "部门", function = DeptParseFunction.NAME) private Long deptId; + @Schema(description = "班级编号", example = "我是一个用户") + @DiffLogField(name = "班级", function = DeptParseFunction.NAME) + private String className; + @Schema(description = "岗位编号数组", example = "1") @DiffLogField(name = "岗位", function = PostParseFunction.NAME) private Set postIds; + @Schema(description = "班级编号数组", example = "1") + @DiffLogField(name = "班级", function = PostParseFunction.NAME) + private Set classIds; + + @Schema(description = "专业编号数组", example = "1") + @DiffLogField(name = "专业", function = PostParseFunction.NAME) + private Set specialtyIds; + @Schema(description = "用户邮箱", example = "exam@iocoder.cn") @Email(message = "邮箱格式不正确") @Size(max = 50, message = "邮箱长度不能超过 50 个字符") @@ -56,6 +68,9 @@ public class UserSaveReqVO { @DiffLogField(name = "手机号码") private String mobile; + @Schema(description = "用户类型", example = "1") + private String userType; + @Schema(description = "用户性别,参见 SexEnum 枚举类", example = "1") @DiffLogField(name = "用户性别", function = SexParseFunction.NAME) private Integer sex; diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/convert/user/UserConvert.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/convert/user/UserConvert.java index fbb623fc..44478687 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/convert/user/UserConvert.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/convert/user/UserConvert.java @@ -3,6 +3,7 @@ package pc.exam.pp.module.system.convert.user; import pc.exam.pp.framework.common.util.collection.CollectionUtils; import pc.exam.pp.framework.common.util.collection.MapUtils; import pc.exam.pp.framework.common.util.object.BeanUtils; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; import pc.exam.pp.module.system.controller.admin.dept.vo.dept.DeptSimpleRespVO; import pc.exam.pp.module.system.controller.admin.dept.vo.post.PostSimpleRespVO; import pc.exam.pp.module.system.controller.admin.permission.vo.role.RoleSimpleRespVO; @@ -29,6 +30,10 @@ public interface UserConvert { return CollectionUtils.convertList(list, user -> convert(user, deptMap.get(user.getDeptId()))); } + default List convertClassList(List list, Map classDOMap) { + return CollectionUtils.convertList(list, user -> convertOneClass(user, classDOMap.get(user.getClassId()))); + } + default UserRespVO convert(AdminUserDO user, DeptDO dept) { UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class); if (dept != null) { @@ -36,6 +41,20 @@ public interface UserConvert { } return userVO; } + default UserRespVO convertOneClass(AdminUserDO user, ClassDO classDO) { + UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class); + userVO.setClassName(classDO.getName()); + return userVO; + } + + default UserRespVO convertClass(AdminUserDO user, DeptDO dept, ClassDO classDO) { + UserRespVO userVO = BeanUtils.toBean(user, UserRespVO.class); + userVO.setClassName(classDO.getName()); + if (dept != null) { + userVO.setDeptName(dept.getName()); + } + return userVO; + } default List convertSimpleList(List list, Map deptMap) { return CollectionUtils.convertList(list, user -> { diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantSpcialtyDO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantSpcialtyDO.java new file mode 100644 index 00000000..81304c76 --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantSpcialtyDO.java @@ -0,0 +1,26 @@ +package pc.exam.pp.module.system.dal.dataobject.tenant; + + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +@TableName(value = "exam_tenant_specialty") +@Data +@ToString(callSuper = true) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TenantSpcialtyDO { + + @TableId(value = "id") + private Long id; + + private Long tenantId; + + private Long specialtyId; + + private String points; +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/AdminUserDO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/AdminUserDO.java index fade2122..4167ee50 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/AdminUserDO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/AdminUserDO.java @@ -55,11 +55,33 @@ public class AdminUserDO extends TenantBaseDO { * 部门 ID */ private Long deptId; + /** + * 班级 ID + */ + private Long classId; /** * 岗位编号数组 */ @TableField(typeHandler = JacksonTypeHandler.class) private Set postIds; + + /** + * 班级编号数组 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private Set classIds; + + /** + * 专业编号数组 + */ + @TableField(typeHandler = JacksonTypeHandler.class) + private Set specialtyIds; + + /** + * 用户类型 + */ + private String userType; + /** * 用户邮箱 */ @@ -93,4 +115,6 @@ public class AdminUserDO extends TenantBaseDO { */ private LocalDateTime loginDate; + + } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/TeacherClassDO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/TeacherClassDO.java new file mode 100644 index 00000000..ec17133b --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/TeacherClassDO.java @@ -0,0 +1,40 @@ +package pc.exam.pp.module.system.dal.dataobject.user; + +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; + +/** + * 教师班级关联 + * + * @author ruoyi + */ +@TableName("system_teacher_class") +@KeySequence("system_teacher_class_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +public class TeacherClassDO extends BaseDO { + + /** + * 自增主键 + */ + @TableId + private Long id; + /** + * 用户 ID + * + * 关联 {@link AdminUserDO#getId()} + */ + private Long userId; + /** + * 角色 ID + * + * 关联 {@link ClassDO#getId()} + */ + private Long classId; + +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/TeacherSpecialtyDO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/TeacherSpecialtyDO.java new file mode 100644 index 00000000..81ed4aee --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/user/TeacherSpecialtyDO.java @@ -0,0 +1,41 @@ +package pc.exam.pp.module.system.dal.dataobject.user; + +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import pc.exam.pp.framework.mybatis.core.dataobject.BaseDO; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; +import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; + +/** + * 教师专业关联 + * + * @author ruoyi + */ +@TableName("system_teacher_specialty") +@KeySequence("system_teacher_specialty_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +public class TeacherSpecialtyDO extends BaseDO { + + /** + * 自增主键 + */ + @TableId + private Long id; + /** + * 用户 ID + * + * 关联 {@link AdminUserDO#getId()} + */ + private Long userId; + /** + * 角色 ID + * + * 关联 {@link ExamSpecialty#getSpId()} + */ + private Long specialtyId; + +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantSpecialtyMapper.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantSpecialtyMapper.java new file mode 100644 index 00000000..36aca10a --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantSpecialtyMapper.java @@ -0,0 +1,34 @@ +package pc.exam.pp.module.system.dal.mysql.tenant; + +import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsPageVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsVO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantSpcialtyDO; + +import java.util.List; + +/** + * 租户 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface TenantSpecialtyMapper extends BaseMapperX { + + default PageResult selectPage(TenantSpecialtyPointsPageVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(TenantSpcialtyDO::getTenantId, String.valueOf(reqVO.getTenantId())) + .likeIfPresent(TenantSpcialtyDO::getSpecialtyId, String.valueOf(reqVO.getSpecialtyId())) + .likeIfPresent(TenantSpcialtyDO::getPoints, reqVO.getPoints()) + .orderByDesc(TenantSpcialtyDO::getPoints)); + } + + default List getSpecialtyPoints(Long id) { + return selectList(TenantSpcialtyDO::getTenantId, id); + } +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/AdminUserMapper.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/AdminUserMapper.java index 8eae5d44..642860af 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/AdminUserMapper.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/AdminUserMapper.java @@ -1,9 +1,15 @@ package pc.exam.pp.module.system.dal.mysql.user; +import org.apache.ibatis.annotations.Param; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.framework.mybatis.core.query.MPJLambdaWrapperX; +import pc.exam.pp.module.exam.controller.admin.student.vo.StudentPageReqVO; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentClassDO; +import pc.exam.pp.module.exam.dal.dataobject.student.StudentDO; import pc.exam.pp.module.system.controller.admin.user.vo.user.UserPageReqVO; +import pc.exam.pp.module.system.controller.admin.user.vo.user.UserRespVO; import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO; import org.apache.ibatis.annotations.Mapper; @@ -29,6 +35,20 @@ public interface AdminUserMapper extends BaseMapperX { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername()) .likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile()) + .eq(AdminUserDO::getUserType, reqVO.getUserType()) + .eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime()) + .inIfPresent(AdminUserDO::getDeptId, deptIds) + .inIfPresent(AdminUserDO::getId, userIds) + .orderByDesc(AdminUserDO::getId)); + } + + default PageResult selectStuPage(UserPageReqVO reqVO, Collection deptIds, Collection userIds, Long classId) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername()) + .likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile()) + .eq(AdminUserDO::getUserType, reqVO.getUserType()) + .eqIfPresent(AdminUserDO::getClassId, classId) .eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus()) .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime()) .inIfPresent(AdminUserDO::getDeptId, deptIds) @@ -48,4 +68,6 @@ public interface AdminUserMapper extends BaseMapperX { return selectList(AdminUserDO::getDeptId, deptIds); } + List selectUserByIdList(@Param("id") Long id); + } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/TeacherClassMapper.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/TeacherClassMapper.java new file mode 100644 index 00000000..3c63cc80 --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/TeacherClassMapper.java @@ -0,0 +1,24 @@ +package pc.exam.pp.module.system.dal.mysql.user; + +import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.module.system.dal.dataobject.dept.UserPostDO; +import pc.exam.pp.module.system.dal.dataobject.user.TeacherClassDO; + +import java.util.Collection; +import java.util.List; + +@Mapper +public interface TeacherClassMapper extends BaseMapperX { + + default List selectListByUserId(Long userId) { + return selectList(TeacherClassDO::getUserId, userId); + } + + default void deleteByUserIdAndTeacherId(Long userId, Collection classIds) { + delete(new LambdaQueryWrapperX() + .eq(TeacherClassDO::getUserId, userId) + .in(TeacherClassDO::getClassId, classIds)); + } +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/TeacherSpecialtyMapper.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/TeacherSpecialtyMapper.java new file mode 100644 index 00000000..d94dafe0 --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/user/TeacherSpecialtyMapper.java @@ -0,0 +1,29 @@ +package pc.exam.pp.module.system.dal.mysql.user; + +import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.module.system.dal.dataobject.permission.RoleMenuDO; +import pc.exam.pp.module.system.dal.dataobject.user.TeacherClassDO; +import pc.exam.pp.module.system.dal.dataobject.user.TeacherSpecialtyDO; + +import java.util.Collection; +import java.util.List; + +@Mapper +public interface TeacherSpecialtyMapper extends BaseMapperX { + + default List selectListByTeacherId(Collection teacherIds) { + return selectList(TeacherSpecialtyDO::getUserId, teacherIds); + } + + default List selectListByUserId(Long userId) { + return selectList(TeacherSpecialtyDO::getUserId, userId); + } + + default void deleteByUserIdAndSpecialtyId(Long userId, Collection specialtyIds) { + delete(new LambdaQueryWrapperX() + .eq(TeacherSpecialtyDO::getUserId, userId) + .in(TeacherSpecialtyDO::getSpecialtyId, specialtyIds)); + } +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/PermissionService.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/PermissionService.java index 9419f175..e07b76de 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/PermissionService.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/PermissionService.java @@ -67,6 +67,16 @@ public interface PermissionService { return getRoleMenuListByRoleId(singleton(roleId)); } + /** + * 获得教师拥有的专业编号集合 + * + * @param teacherId 教师ID + * @return 专业编号集合 + */ + default Set getSpecialtyListByTeacherId(Long teacherId) { + return getSpecialtyListByTeacherId(singleton(teacherId)); + } + /** * 获得角色们拥有的菜单编号集合 * @@ -75,6 +85,14 @@ public interface PermissionService { */ Set getRoleMenuListByRoleId(Collection roleIds); + /** + * 获得教师们拥有的专业编号集合 + * + * @param teacherIds 专业编号数组 + * @return 专业编号集合 + */ + Set getSpecialtyListByTeacherId(Collection teacherIds); + /** * 获得拥有指定菜单的角色编号数组,从缓存中获取 * diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/PermissionServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/PermissionServiceImpl.java index 21ffe9e6..4c320472 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/PermissionServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/PermissionServiceImpl.java @@ -12,8 +12,10 @@ import pc.exam.pp.module.system.dal.dataobject.permission.MenuDO; import pc.exam.pp.module.system.dal.dataobject.permission.RoleDO; import pc.exam.pp.module.system.dal.dataobject.permission.RoleMenuDO; import pc.exam.pp.module.system.dal.dataobject.permission.UserRoleDO; +import pc.exam.pp.module.system.dal.dataobject.user.TeacherSpecialtyDO; import pc.exam.pp.module.system.dal.mysql.permission.RoleMenuMapper; import pc.exam.pp.module.system.dal.mysql.permission.UserRoleMapper; +import pc.exam.pp.module.system.dal.mysql.user.TeacherSpecialtyMapper; import pc.exam.pp.module.system.dal.redis.RedisKeyConstants; import pc.exam.pp.module.system.enums.permission.DataScopeEnum; import pc.exam.pp.module.system.service.dept.DeptService; @@ -48,6 +50,8 @@ public class PermissionServiceImpl implements PermissionService { @Resource private RoleMenuMapper roleMenuMapper; @Resource + private TeacherSpecialtyMapper teacherSpecialtyMapper; + @Resource private UserRoleMapper userRoleMapper; @Resource @@ -193,6 +197,21 @@ public class PermissionServiceImpl implements PermissionService { // 如果是非管理员的情况下,获得拥有的菜单编号 return convertSet(roleMenuMapper.selectListByRoleId(roleIds), RoleMenuDO::getMenuId); } + @Override + public Set getSpecialtyListByTeacherId(Collection teacherIds) { + if (CollUtil.isEmpty(teacherIds)) { + return Collections.emptySet(); + } + + // 如果是管理员的情况下,获取全部菜单编号 +// if (roleService.hasAnySuperAdmin(teacherIds)) { +// return convertSet(menuService.getMenuList(), MenuDO::getId); +// } +// userService.getUserList(teacherIds); + // 如果是非管理员的情况下,获得拥有的菜单编号 + return convertSet(teacherSpecialtyMapper.selectListByTeacherId(teacherIds), TeacherSpecialtyDO::getSpecialtyId); + } + @Override @Cacheable(value = RedisKeyConstants.MENU_ROLE_ID_LIST, key = "#menuId") diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/RoleServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/RoleServiceImpl.java index 593c6a5f..de874f4b 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/RoleServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/permission/RoleServiceImpl.java @@ -230,6 +230,7 @@ public class RoleServiceImpl implements RoleService { }); } + @Override public void validateRoleList(Collection ids) { if (CollUtil.isEmpty(ids)) { diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantService.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantService.java index b9833fd3..96eb8a36 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantService.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantService.java @@ -4,7 +4,9 @@ import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsVO; import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantSpcialtyDO; import pc.exam.pp.module.system.service.tenant.handler.TenantInfoHandler; import pc.exam.pp.module.system.service.tenant.handler.TenantMenuHandler; @@ -73,6 +75,14 @@ public interface TenantService { */ TenantDO getTenantByName(String name); + /** + * 获得名字对应的租户的专业授权信息 + * + * @param id 租户ID + * @return 租户 + */ + List getTenantBySpecialty(Long id); + /** * 获得域名对应的租户 * diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java index b20125c2..c7a0c899 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java @@ -15,12 +15,15 @@ import pc.exam.pp.framework.tenant.core.util.TenantUtils; import pc.exam.pp.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsVO; import pc.exam.pp.module.system.convert.tenant.TenantConvert; import pc.exam.pp.module.system.dal.dataobject.permission.MenuDO; import pc.exam.pp.module.system.dal.dataobject.permission.RoleDO; import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; import pc.exam.pp.module.system.dal.dataobject.tenant.TenantPackageDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantSpcialtyDO; import pc.exam.pp.module.system.dal.mysql.tenant.TenantMapper; +import pc.exam.pp.module.system.dal.mysql.tenant.TenantSpecialtyMapper; import pc.exam.pp.module.system.enums.permission.RoleCodeEnum; import pc.exam.pp.module.system.enums.permission.RoleTypeEnum; import pc.exam.pp.module.system.service.permission.MenuService; @@ -37,6 +40,8 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import jakarta.annotation.Resource; + +import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.Set; @@ -62,6 +67,9 @@ public class TenantServiceImpl implements TenantService { @Resource private TenantMapper tenantMapper; + @Resource + private TenantSpecialtyMapper tenantSpecialtyMapper; + @Resource private TenantPackageService tenantPackageService; @Resource @@ -107,6 +115,15 @@ public class TenantServiceImpl implements TenantService { // 创建租户 TenantDO tenant = BeanUtils.toBean(createReqVO, TenantDO.class); tenantMapper.insert(tenant); + // 创建租户对应的专业的授权点数 + Long tenantId = tenant.getId(); + for (TenantSpecialtyPointsVO specialtyPointsVO : createReqVO.getTenantSpecialtyPointsVOList()) { + // 新增数据 + specialtyPointsVO.setTenantId(tenantId); + TenantSpcialtyDO tenantSpcialtyDO = new TenantSpcialtyDO(); + BeanUtils.copyProperties(specialtyPointsVO, tenantSpcialtyDO); + tenantSpecialtyMapper.insert(tenantSpcialtyDO); + } // 创建租户的管理员 TenantUtils.execute(tenant.getId(), () -> { // 创建角色 @@ -153,6 +170,15 @@ public class TenantServiceImpl implements TenantService { // 更新租户 TenantDO updateObj = BeanUtils.toBean(updateReqVO, TenantDO.class); tenantMapper.updateById(updateObj); + // 创建租户对应的专业的授权点数 + Long tenantId = tenant.getId(); + for (TenantSpecialtyPointsVO specialtyPointsVO : updateReqVO.getTenantSpecialtyPointsVOList()) { + // 新增数据 + specialtyPointsVO.setTenantId(tenantId); + TenantSpcialtyDO tenantSpcialtyDO = new TenantSpcialtyDO(); + BeanUtils.copyProperties(specialtyPointsVO, tenantSpcialtyDO); + tenantSpecialtyMapper.insertOrUpdate(tenantSpcialtyDO); + } // 如果套餐发生变化,则修改其角色的权限 if (ObjectUtil.notEqual(tenant.getPackageId(), updateReqVO.getPackageId())) { updateTenantRoleMenu(tenant.getId(), tenantPackage.getMenuIds()); @@ -250,6 +276,11 @@ public class TenantServiceImpl implements TenantService { return tenantMapper.selectByName(name); } + @Override + public List getTenantBySpecialty(Long id) { + return tenantSpecialtyMapper.getSpecialtyPoints(id); + } + @Override public TenantDO getTenantByWebsite(String website) { return tenantMapper.selectByWebsite(website); diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserService.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserService.java index d1f5370a..4be57a1c 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserService.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserService.java @@ -6,10 +6,7 @@ import pc.exam.pp.framework.common.util.collection.CollectionUtils; import pc.exam.pp.module.system.controller.admin.auth.vo.AuthRegisterReqVO; import pc.exam.pp.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO; import pc.exam.pp.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO; -import pc.exam.pp.module.system.controller.admin.user.vo.user.UserImportExcelVO; -import pc.exam.pp.module.system.controller.admin.user.vo.user.UserImportRespVO; -import pc.exam.pp.module.system.controller.admin.user.vo.user.UserPageReqVO; -import pc.exam.pp.module.system.controller.admin.user.vo.user.UserSaveReqVO; +import pc.exam.pp.module.system.controller.admin.user.vo.user.*; import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO; import jakarta.validation.Valid; @@ -33,6 +30,22 @@ public interface AdminUserService { * @return 用户编号 */ Long createUser(@Valid UserSaveReqVO createReqVO); + /** + * 创建用户 学生 + * + * @param createReqVO 用户信息 学生 + * @return 用户编号 学生 + */ + Long createUserStudent(@Valid UserSaveReqVO createReqVO); + + /** + * 创建用户 教师 + * + * @param createReqVO 用户信息 学生 + * @return 用户编号 学生 + */ + Long createUserTeacher(@Valid UserSaveReqVO createReqVO); + /** * 注册用户 @@ -49,6 +62,19 @@ public interface AdminUserService { */ void updateUser(@Valid UserSaveReqVO updateReqVO); + /** + * 修改用户 学生 + * + * @param updateReqVO 用户信息 + */ + void updateStudent(@Valid UserSaveReqVO updateReqVO); + /** + * 修改用户 教师 + * + * @param updateReqVO 教师信息 + */ + void updateTeacher(@Valid UserSaveReqVO updateReqVO); + /** * 更新用户的最后登陆信息 * @@ -128,6 +154,14 @@ public interface AdminUserService { */ PageResult getUserPage(UserPageReqVO reqVO); + /** + * 获得学生分页列表 + * + * @param reqVO 分页条件 + * @return 分页列表 + */ + PageResult getStudentPage(UserPageReqVO reqVO); + /** * 通过用户 ID 查询用户 * @@ -136,6 +170,13 @@ public interface AdminUserService { */ AdminUserDO getUser(Long id); + /** + * 通过教师 ID 查询学生列表 + * + * @param id 教师 ID + * @return 学生列表 + */ + List getUserById(Long id); /** * 获得指定部门的用户数组 * diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserServiceImpl.java index 8e0184c6..6ac4e625 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/user/AdminUserServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.StrUtil; +import org.bouncycastle.jcajce.provider.symmetric.TEA; import pc.exam.pp.framework.common.enums.CommonStatusEnum; import pc.exam.pp.framework.common.exception.ServiceException; import pc.exam.pp.framework.common.pojo.PageResult; @@ -11,20 +12,25 @@ import pc.exam.pp.framework.common.util.collection.CollectionUtils; import pc.exam.pp.framework.common.util.object.BeanUtils; import pc.exam.pp.framework.common.util.validation.ValidationUtils; import pc.exam.pp.framework.datapermission.core.util.DataPermissionUtils; +import pc.exam.pp.module.exam.controller.admin.classs.vo.ClassSaveReqVO; +import pc.exam.pp.module.exam.dal.dataobject.classs.ClassDO; +import pc.exam.pp.module.exam.dal.mysql.classs.ClassMapper; +import pc.exam.pp.module.exam.service.classs.ClassService; import pc.exam.pp.module.infra.api.config.ConfigApi; import pc.exam.pp.module.infra.api.file.FileApi; import pc.exam.pp.module.system.controller.admin.auth.vo.AuthRegisterReqVO; import pc.exam.pp.module.system.controller.admin.user.vo.profile.UserProfileUpdatePasswordReqVO; import pc.exam.pp.module.system.controller.admin.user.vo.profile.UserProfileUpdateReqVO; -import pc.exam.pp.module.system.controller.admin.user.vo.user.UserImportExcelVO; -import pc.exam.pp.module.system.controller.admin.user.vo.user.UserImportRespVO; -import pc.exam.pp.module.system.controller.admin.user.vo.user.UserPageReqVO; -import pc.exam.pp.module.system.controller.admin.user.vo.user.UserSaveReqVO; +import pc.exam.pp.module.system.controller.admin.user.vo.user.*; import pc.exam.pp.module.system.dal.dataobject.dept.DeptDO; import pc.exam.pp.module.system.dal.dataobject.dept.UserPostDO; import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO; +import pc.exam.pp.module.system.dal.dataobject.user.TeacherClassDO; +import pc.exam.pp.module.system.dal.dataobject.user.TeacherSpecialtyDO; import pc.exam.pp.module.system.dal.mysql.dept.UserPostMapper; import pc.exam.pp.module.system.dal.mysql.user.AdminUserMapper; +import pc.exam.pp.module.system.dal.mysql.user.TeacherClassMapper; +import pc.exam.pp.module.system.dal.mysql.user.TeacherSpecialtyMapper; import pc.exam.pp.module.system.service.dept.DeptService; import pc.exam.pp.module.system.service.dept.PostService; import pc.exam.pp.module.system.service.permission.PermissionService; @@ -64,6 +70,11 @@ public class AdminUserServiceImpl implements AdminUserService { @Resource private AdminUserMapper userMapper; + @Resource + private ClassMapper classMapper; + @Resource + private ClassService classService; + @Resource private DeptService deptService; @Resource @@ -78,6 +89,11 @@ public class AdminUserServiceImpl implements AdminUserService { @Resource private UserPostMapper userPostMapper; + @Resource + private TeacherClassMapper teacherClassMapper; + + @Resource + private TeacherSpecialtyMapper teacherSpecialtyMapper; @Resource private FileApi fileApi; @@ -114,6 +130,92 @@ public class AdminUserServiceImpl implements AdminUserService { LogRecordContext.putVariable("user", user); return user.getId(); } + @Override + @Transactional(rollbackFor = Exception.class) + @LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_CREATE_SUB_TYPE, bizNo = "{{#user.id}}", + success = SYSTEM_USER_CREATE_SUCCESS) + public Long createUserStudent(UserSaveReqVO createReqVO) { + // 1.1 校验账户配合 + tenantService.handleTenantInfo(tenant -> { + long count = userMapper.selectCount(); + if (count >= tenant.getAccountCount()) { + throw exception(USER_COUNT_MAX, tenant.getAccountCount()); + } + }); + // 1.2 校验正确性 + validateUserForCreateOrUpdate(null, createReqVO.getUsername(), + createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds()); + + // 2.1 插入用户 + AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class); + // 1.3 根据班级名称查询班级是否存在,如存在返回班级ID,如不存在创建并返回班级ID + ClassDO classDO = classMapper.getClassNameOne(createReqVO.getClassName()); + if (classDO == null) { + // 如果没有查询出来需要创建数据 + ClassSaveReqVO classSaveReqVO = new ClassSaveReqVO(); + classSaveReqVO.setName(createReqVO.getClassName()); + user.setClassId(classService.createClass(classSaveReqVO)); + } else { + // 查询出数据后进行赋值 + user.setClassId(classDO.getId()); + } + user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 + user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码s + userMapper.insert(user); + // 2.2 插入关联岗位 + if (CollectionUtil.isNotEmpty(user.getPostIds())) { + userPostMapper.insertBatch(convertList(user.getPostIds(), + postId -> new UserPostDO().setUserId(user.getId()).setPostId(postId))); + } + // 3. 记录操作日志上下文 + LogRecordContext.putVariable("user", user); + return user.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + @LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_CREATE_SUB_TYPE, bizNo = "{{#user.id}}", + success = SYSTEM_USER_CREATE_SUCCESS) + public Long createUserTeacher(UserSaveReqVO createReqVO) { + // 1.1 校验账户配合 + tenantService.handleTenantInfo(tenant -> { + long count = userMapper.selectCount(); + if (count >= tenant.getAccountCount()) { + throw exception(USER_COUNT_MAX, tenant.getAccountCount()); + } + }); + // 1.2 校验正确性 + validateUserForCreateOrUpdate(null, createReqVO.getUsername(), + createReqVO.getMobile(), createReqVO.getEmail(), createReqVO.getDeptId(), createReqVO.getPostIds()); + + // 2.1 插入用户 + AdminUserDO user = BeanUtils.toBean(createReqVO, AdminUserDO.class); + user.setStatus(CommonStatusEnum.ENABLE.getStatus()); // 默认开启 + user.setPassword(encodePassword(createReqVO.getPassword())); // 加密密码s + userMapper.insert(user); + // 2.2 插入关联岗位 + if (CollectionUtil.isNotEmpty(user.getPostIds())) { + userPostMapper.insertBatch(convertList(user.getPostIds(), + postId -> new UserPostDO().setUserId(user.getId()).setPostId(postId))); + } + + // 2.3 插入关联班级 + if (CollectionUtil.isNotEmpty(user.getClassIds())) { + teacherClassMapper.insertBatch(convertList(user.getClassIds(), + classId -> new TeacherClassDO().setUserId(user.getId()).setClassId(classId))); + } + + // 2.4 插入关联专业 + if (CollectionUtil.isNotEmpty(user.getSpecialtyIds())) { + teacherSpecialtyMapper.insertBatch(convertList(user.getSpecialtyIds(), + specialtyId -> new TeacherSpecialtyDO().setUserId(user.getId()).setSpecialtyId(specialtyId))); + } + + // 3. 记录操作日志上下文 + LogRecordContext.putVariable("user", user); + return user.getId(); + } + @Override public Long registerUser(AuthRegisterReqVO registerReqVO) { @@ -135,6 +237,64 @@ public class AdminUserServiceImpl implements AdminUserService { return user.getId(); } + @Override + @Transactional(rollbackFor = Exception.class) + @LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", + success = SYSTEM_USER_UPDATE_SUCCESS) + public void updateTeacher(UserSaveReqVO updateReqVO) { + updateReqVO.setPassword(null); // 特殊:此处不更新密码 + // 1. 校验正确性 + AdminUserDO oldUser = validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(), + updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds()); + + // 2.1 更新用户 + AdminUserDO updateObj = BeanUtils.toBean(updateReqVO, AdminUserDO.class); + userMapper.updateById(updateObj); + // 2.2 更新岗位 + updateUserPost(updateReqVO, updateObj); + // 2.3 更新专业 + updateTeacherSpecialty(updateReqVO, updateObj); + // 2.4 更新班级 + updateTeacherClass(updateReqVO, updateObj); + + // 3. 记录操作日志上下文 + LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldUser, UserSaveReqVO.class)); + LogRecordContext.putVariable("teacher", oldUser); + } + + @Override + @Transactional(rollbackFor = Exception.class) + @LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", + success = SYSTEM_USER_UPDATE_SUCCESS) + public void updateStudent(UserSaveReqVO updateReqVO) { + updateReqVO.setPassword(null); // 特殊:此处不更新密码 + // 1. 校验正确性 + AdminUserDO oldUser = validateUserForCreateOrUpdate(updateReqVO.getId(), updateReqVO.getUsername(), + updateReqVO.getMobile(), updateReqVO.getEmail(), updateReqVO.getDeptId(), updateReqVO.getPostIds()); + + // 1.3 根据班级名称查询班级是否存在,如存在返回班级ID,如不存在创建并返回班级ID + AdminUserDO updateObj = BeanUtils.toBean(updateReqVO, AdminUserDO.class); + ClassDO classDO = classMapper.getClassNameOne(updateReqVO.getClassName()); + if (classDO == null) { + // 如果没有查询出来需要创建数据 + ClassSaveReqVO classSaveReqVO = new ClassSaveReqVO(); + classSaveReqVO.setName(updateReqVO.getClassName()); + updateObj.setClassId(classService.createClass(classSaveReqVO)); + } else { + // 查询出数据后进行赋值 + updateObj.setClassId(classDO.getId()); + } + // 2.1 更新用户 + userMapper.updateById(updateObj); + // 2.2 更新岗位 + updateUserPost(updateReqVO, updateObj); + // 3. 记录操作日志上下文 + LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldUser, UserSaveReqVO.class)); + LogRecordContext.putVariable("student", oldUser); + } + + + @Override @Transactional(rollbackFor = Exception.class) @LogRecord(type = SYSTEM_USER_TYPE, subType = SYSTEM_USER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", @@ -156,6 +316,42 @@ public class AdminUserServiceImpl implements AdminUserService { LogRecordContext.putVariable("user", oldUser); } + private void updateTeacherClass(UserSaveReqVO reqVO, AdminUserDO updateObj) { + Long userId = reqVO.getId(); + Set dbClassIds = convertSet(teacherClassMapper.selectListByUserId(userId), TeacherClassDO::getClassId); + // 计算新增和删除的岗位编号 + Set classsIds = CollUtil.emptyIfNull(updateObj.getClassIds()); + Collection createClassIds = CollUtil.subtract(classsIds, dbClassIds); + Collection deleteClassIds = CollUtil.subtract(dbClassIds, classsIds); + + // 执行新增和删除。对于已经授权的班级,不用做任何处理 + if (!CollectionUtil.isEmpty(createClassIds)) { + teacherClassMapper.insertBatch(convertList(createClassIds, + classId -> new TeacherClassDO().setUserId(userId).setClassId(classId))); + } + if (!CollectionUtil.isEmpty(deleteClassIds)) { + teacherClassMapper.deleteByUserIdAndTeacherId(userId, deleteClassIds); + } + } + + private void updateTeacherSpecialty (UserSaveReqVO reqVO, AdminUserDO updateObj) { + Long userId = reqVO.getId(); + Set dbSpecialtyIds = convertSet(teacherSpecialtyMapper.selectListByUserId(userId), TeacherSpecialtyDO::getSpecialtyId); + // 计算新增和删除的岗位编号 + Set specialtyIds = CollUtil.emptyIfNull(updateObj.getSpecialtyIds()); + Collection createSpecialtyIds = CollUtil.subtract(specialtyIds, dbSpecialtyIds); + Collection deleteSpecialtyIds = CollUtil.subtract(dbSpecialtyIds, specialtyIds); + + // 执行新增和删除。对于已经授权的班级,不用做任何处理 + if (!CollectionUtil.isEmpty(createSpecialtyIds)) { + teacherSpecialtyMapper.insertBatch(convertList(createSpecialtyIds, + specialtyId -> new TeacherSpecialtyDO().setUserId(userId).setSpecialtyId(specialtyId))); + } + if (!CollectionUtil.isEmpty(deleteSpecialtyIds)) { + teacherSpecialtyMapper.deleteByUserIdAndSpecialtyId(userId, deleteSpecialtyIds); + } + } + private void updateUserPost(UserSaveReqVO reqVO, AdminUserDO updateObj) { Long userId = reqVO.getId(); Set dbPostIds = convertSet(userPostMapper.selectListByUserId(userId), UserPostDO::getPostId); @@ -279,10 +475,27 @@ public class AdminUserServiceImpl implements AdminUserService { return userMapper.selectPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds); } + @Override + public PageResult getStudentPage(UserPageReqVO reqVO) { + Long classId = null; + // 如果有角色编号,查询角色对应的用户编号 + Set userIds = reqVO.getRoleId() != null ? + permissionService.getUserRoleIdListByRoleId(singleton(reqVO.getRoleId())) : null; + + // 获取班级ID + ClassDO classDO = classMapper.getClassNameOne(reqVO.getClassName()); + // 分页查询 + return userMapper.selectStuPage(reqVO, getDeptCondition(reqVO.getDeptId()), userIds, classDO != null ? classDO.getId() : null); + } + @Override public AdminUserDO getUser(Long id) { return userMapper.selectById(id); } + @Override + public List getUserById(Long id) { + return userMapper.selectUserByIdList(id); + } @Override public List getUserListByDeptIds(Collection deptIds) { diff --git a/exam-module-system/exam-module-system-biz/src/main/resources/mapper/user/AdminUserMapper.xml b/exam-module-system/exam-module-system-biz/src/main/resources/mapper/user/AdminUserMapper.xml new file mode 100644 index 00000000..68b1a86a --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/resources/mapper/user/AdminUserMapper.xml @@ -0,0 +1,24 @@ + + + + + + + + \ No newline at end of file diff --git a/exam-server/src/main/resources/application-dev.yaml b/exam-server/src/main/resources/application-dev.yaml index e8565e08..7cae1b11 100644 --- a/exam-server/src/main/resources/application-dev.yaml +++ b/exam-server/src/main/resources/application-dev.yaml @@ -44,22 +44,22 @@ spring: primary: master datasource: master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 + url: jdbc:mysql://47.101.60.131:3306/pc-exam?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 + username: pc-exam + password: YGsyBWH3KdGpz8C7 slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 + url: jdbc:mysql://47.101.60.131:3306/pc-exam?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true&rewriteBatchedStatements=true # MySQL Connector/J 8.X 连接的示例 + username: pc-exam + password: YGsyBWH3KdGpz8C7 # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 data: redis: - host: 400-infra.server.iocoder.cn # 地址 + host: 47.101.60.131 # 地址 port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 + database: 0 # 数据库索引 + password: sadjklasnfasd # 密码,建议生产环境开启 --- #################### 定时任务相关配置 #################### @@ -101,10 +101,10 @@ rocketmq: spring: # RabbitMQ 配置项,对应 RabbitProperties 配置类 rabbitmq: - host: 127.0.0.1 # RabbitMQ 服务的地址 + host: 47.101.60.131 # RabbitMQ 服务的地址 port: 5672 # RabbitMQ 服务的端口 - username: guest # RabbitMQ 服务的账号 - password: guest # RabbitMQ 服务的密码 + username: admin # RabbitMQ 服务的账号 + password: KkbxwDnD # RabbitMQ 服务的密码 # Kafka 配置项,对应 KafkaProperties 配置类 kafka: bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 diff --git a/exam-server/src/main/resources/application.yaml b/exam-server/src/main/resources/application.yaml index 81dbcbc6..fd66c75a 100644 --- a/exam-server/src/main/resources/application.yaml +++ b/exam-server/src/main/resources/application.yaml @@ -63,7 +63,6 @@ flowable: check-process-definitions: false # 设置为 false,禁用 /resources/processes 自动部署 BPMN XML 流程 history-level: audit # full:保存历史数据的最高级别,可保存全部流程相关细节,包括流程流转各节点参数 -# MyBatis配置 mybatis: # 搜索指定包别名 type-aliases-package: pc.exam.pp.module.**.dal.dataobject @@ -293,6 +292,7 @@ exam: - /jmreport/* # 积木报表,无法携带租户编号 - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号 ignore-tables: + - exam_tenant_specialty - system_tenant - system_tenant_package - system_dict_data