From 5167e6e268bb501162ae3c2c56fdd9e707cca279 Mon Sep 17 00:00:00 2001 From: "YOHO\\20373" <2037305722@qq.com> Date: Mon, 19 May 2025 22:00:57 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E8=BA=AB=E4=BB=BD=E8=AF=81=E5=AD=97=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E8=BF=9B=E5=85=A5=E8=AF=95=E5=8D=B7=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E4=BF=A1=E6=81=AF=E7=A1=AE=E8=AE=A4=20=E3=80=90?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E3=80=91=E7=9F=A5=E8=AF=86=E7=82=B9=EF=BC=8C?= =?UTF-8?q?=E9=80=89=E6=8B=A9=E9=A2=98excel=E6=89=B9=E9=87=8F=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E6=96=B0=E5=A2=9E=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pp/framework/security/core/LoginUser.java | 3 +- .../core/util/SecurityFrameworkUtils.java | 21 +- .../ExamKnowledgePointsController.java | 337 +++++++++--------- .../admin/knowledge/vo/BuildTree.java | 43 +++ .../admin/knowledge/vo/PointsPageVo.java | 39 ++ .../controller/admin/knowledge/vo/Tree.java | 58 +++ .../paper/EducationPaperTaskController.java | 6 +- .../controller/admin/paper/vo/TreeEntity.java | 4 +- .../question/ExamQuestionController.java | 40 +++ .../admin/question/vo/QueImportRespVO.java | 24 ++ .../admin/question/vo/QuemportExcelVO.java | 61 ++++ .../admin/question/vo/QuestionSaveReqVO.java | 75 ++++ .../controller/admin/test/TestController.java | 20 ++ .../knowledge/ExamKnowledgePoints.java | 2 +- .../knowledge/ExamKnowledgePointsMapper.java | 5 + .../mysql/question/ExamQuestionMapper.java | 8 + .../mysql/specialty/ExamSpecialtyMapper.java | 3 + .../knowledge/ExamKnowledgePointsService.java | 4 + .../ExamKnowledgePointsServiceImpl.java | 27 ++ .../paper/EducationPaperQuServiceImpl.java | 6 + .../paper/EducationPaperServiceImpl.java | 10 +- .../paper/EducationPaperTaskServiceImpl.java | 7 +- .../question/ExamQuestionServiceImpl.java | 219 +++++++++++- .../question/IExamQuestionService.java | 5 + .../mapper/exam/EducationPaperQuMapper.xml | 4 +- .../mapper/exam/EducationPaperTaskMapper.xml | 6 +- .../mapper/exam/ExamQuestionMapper.xml | 10 + .../knowledge/ExamKnowledgePointsMapper.xml | 9 + .../mapper/specialty/ExamSpecialtyMapper.xml | 13 + .../system/enums/ErrorCodeConstants.java | 3 + .../admin/user/vo/user/UserRespVO.java | 3 + .../admin/user/vo/user/UserSaveReqVO.java | 4 + .../dal/dataobject/user/AdminUserDO.java | 4 + .../oauth2/OAuth2TokenServiceImpl.java | 2 + 34 files changed, 888 insertions(+), 197 deletions(-) create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/BuildTree.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/PointsPageVo.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/Tree.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QueImportRespVO.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuemportExcelVO.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionSaveReqVO.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/test/TestController.java diff --git a/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/LoginUser.java b/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/LoginUser.java index 66e7a4a6..0e170fa7 100644 --- a/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/LoginUser.java +++ b/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/LoginUser.java @@ -17,7 +17,8 @@ import java.util.Map; */ @Data public class LoginUser { - + public static final String INFO_KEY_SFZ = "sfz"; + public static final String INFO_KEY_USERNAME = "username"; public static final String INFO_KEY_NICKNAME = "nickname"; public static final String INFO_KEY_DEPT_ID = "deptId"; public static final String INFO_KEY_QUEUE = "queueName"; diff --git a/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/util/SecurityFrameworkUtils.java b/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/util/SecurityFrameworkUtils.java index b266b3f5..1756de24 100644 --- a/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/util/SecurityFrameworkUtils.java +++ b/exam-framework/exam-spring-boot-starter-security/src/main/java/pc/exam/pp/framework/security/core/util/SecurityFrameworkUtils.java @@ -89,7 +89,26 @@ public class SecurityFrameworkUtils { LoginUser loginUser = getLoginUser(); return loginUser != null ? loginUser.getId() : null; } - + /** + * 获得当前用户的账号,从上下文中 + * + * @return 用户编号 + */ + @Nullable + public static String getLoginUserName() { + LoginUser loginUser = getLoginUser(); + return loginUser != null ? MapUtil.getStr(loginUser.getInfo(), LoginUser.INFO_KEY_USERNAME) : null; + } + /** + * 获得当前用户的身份证,从上下文中 + * + * @return 用户编号 + */ + @Nullable + public static String getLoginUserSFZ() { + LoginUser loginUser = getLoginUser(); + return loginUser != null ? MapUtil.getStr(loginUser.getInfo(), LoginUser.INFO_KEY_SFZ) : null; + } /** * 获得当前用户的租户ID,从上下文中 * 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 index ae4720c7..08b2d2ca 100644 --- 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 @@ -1,180 +1,169 @@ -//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) +package pc.exam.pp.module.exam.controller.admin.knowledge; + +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.java.Log; +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.security.core.util.SecurityFrameworkUtils; +import pc.exam.pp.module.exam.controller.admin.knowledge.vo.BuildTree; +import pc.exam.pp.module.exam.controller.admin.knowledge.vo.Tree; +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.service.knowledge.ExamKnowledgePointsService; +import pc.exam.pp.module.exam.utils.date.DateUtils; + +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 CommonResult list(ExamKnowledgePoints knowledgePoints) { + + List list = knowledgePointsService.selectKnowledgePointsListPage(knowledgePoints); + return CommonResult.success(list); + } + + /** + * 导出知识点列表 + */ // @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); -// } -//} + + /** + * 获取知识点详细信息 + */ + @GetMapping(value = "/{spId}") + public CommonResult getInfo(@PathVariable("spId") Long spId) { + return CommonResult.success(knowledgePointsService.selectKnowledgePointsBySpId(spId)); + } + + /** + * 新增知识点 + */ + + @PostMapping + public CommonResult add(@RequestBody ExamKnowledgePoints knowledgePoints) { + //获取登录用户id + //获取新增名称信息 + String SpName = knowledgePoints.getSpName(); + //修改祖籍列表 + Long ParentId = knowledgePoints.getParentId(); + if (SpName != null) { + if (String.valueOf(ParentId).equals("0")) { + return CommonResult.error(122_333_444,"不可增加根节点!"); + + } 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 CommonResult.success(knowledgePointsService.insertKnowledgePoints(knowledgePoints)); + } + + } else + return CommonResult.error(122_333_444,"输入名称不能为空!"); + + } + + /** + * 修改知识点 + */ + @PutMapping + public CommonResult edit(@RequestBody ExamKnowledgePoints knowledgePoints) { + //判断是否修改的根节点 + if (Objects.equals(knowledgePoints.getAncestors(), "0")) { + return CommonResult.error(122_333_444,"不可直接修改根节点,请在专业表中修改!"); + } else { + if (Objects.equals(knowledgePoints.getSpName(), "")) { + return CommonResult.error(122_333_444,"修改名称不得为空!"); + } else { + + return CommonResult.success(knowledgePointsService.updateKnowledgePoints(knowledgePoints)); + } + } + } + + /** + * 删除知识点 + */ + @DeleteMapping("/{spIds}") + public CommonResult remove(@PathVariable Long[] spIds) { + //用于判断是否符合删除条件 + for (Long spId : spIds) { + //实例化节点 + ExamKnowledgePoints knowledgePoint = knowledgePointsService.selectKnowledgePointsBySpId(spId); + Long ParentId = knowledgePoint.getParentId(); + // 根据父节点id查找是否为根节点,根节点为专业不可在此删除 + if (ParentId == 0) { + return CommonResult.error(122_333_444,"删除失败,删除目录中含有专业,请在专业表中删除!"); + } else { + // 判断是否有子树 + if (knowledgePoint.getTreeNum() != 0) { + return CommonResult.error(122_333_444,"删除失败,删除目录下还存在知识点!"); + } + } + } + // 用于操作节点数 + 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); + knowledgePointsService.updateKnowledgePoints(knowledgePoint); + } + + return CommonResult.success(knowledgePointsService.deleteKnowledgePointsBySpIds(spIds)); + } + + + /** + * 构建知识点树状结构 + */ + @GetMapping("/tree") + public CommonResult listTree(ExamKnowledgePoints knowledgePoints) { + //定义List + List tree = new ArrayList<>(); + //查询数据库表中全部数据 + List list = knowledgePointsService.selectKnowledgePointsList(knowledgePoints); + //将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 CommonResult.success(tree); + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/BuildTree.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/BuildTree.java new file mode 100644 index 00000000..cd0843ff --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/BuildTree.java @@ -0,0 +1,43 @@ +package pc.exam.pp.module.exam.controller.admin.knowledge.vo; + +import java.util.ArrayList; +import java.util.List; + + +public class BuildTree { + // 定义构建树方法 + public List builTree(List list) { + List treeList = new ArrayList<>(); + for (Tree tree : this.getRootNode(list)) { + //建立子树节点 + tree = this.buildChilTree(tree, list); + //为根节点设置子树节点 + treeList.add(tree); + } + return treeList; + } + + // @description 通过递归来创建子树形结构 + private Tree buildChilTree(Tree tree, List list) { + List treeList = new ArrayList<>(); + for (Tree t : list) { + //判断当前父节点是否存在子节点 + if (t.getP_id().equals(tree.getId())) { + treeList.add(this.buildChilTree(t, list)); + } + } + tree.setChildren(treeList); + return tree; + } + + // @description 获取全部根节点 + private List getRootNode(List list) { + List rootList = new ArrayList<>(); + for (Tree tree : list) { + if (tree.getP_id().equals("0")) { + rootList.add(tree); + } + } + return rootList; + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/PointsPageVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/PointsPageVo.java new file mode 100644 index 00000000..ce750b17 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/PointsPageVo.java @@ -0,0 +1,39 @@ +package pc.exam.pp.module.exam.controller.admin.knowledge.vo; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import pc.exam.pp.framework.common.pojo.PageParam; +import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; +@Schema(description = "知识点vo") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class PointsPageVo extends PageParam { + + 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/controller/admin/knowledge/vo/Tree.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/Tree.java new file mode 100644 index 00000000..eeb7d8bb --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/knowledge/vo/Tree.java @@ -0,0 +1,58 @@ +package pc.exam.pp.module.exam.controller.admin.knowledge.vo; + +import java.util.List; + +/** + + * @className : Tree + + */ + +public class Tree { + + private String id; + + private String p_id; + + private String label; + + private List children; + + public Tree(String id, String p_id, String label) { + this.id = id; + this.p_id = p_id; + this.label = label; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getP_id() { + return p_id; + } + + public void setP_id(String p_id) { + this.p_id = p_id; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java index 87c7e656..4f730022 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperTaskController.java @@ -33,7 +33,7 @@ public class EducationPaperTaskController private IEducationPaperTaskService educationPaperTaskService; /** - * 查询试卷任务列表 + * 查询试卷任务列表(服务器端) */ @GetMapping("/list") public CommonResult> list(PaperTaskPageVo educationPaperTask) @@ -46,7 +46,9 @@ public class EducationPaperTaskController return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class)); } - + /** + * 查询试卷任务列表(学生端) + */ @GetMapping("/stulist") public CommonResult> stulist(PaperTaskPageVo educationPaperTask) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/TreeEntity.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/TreeEntity.java index f4e35794..4c3c952e 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/TreeEntity.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/TreeEntity.java @@ -1,5 +1,7 @@ package pc.exam.pp.module.exam.controller.admin.paper.vo; +import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; + import java.util.ArrayList; import java.util.List; @@ -8,7 +10,7 @@ import java.util.List; * * @author pengchen */ -public class TreeEntity +public class TreeEntity extends TenantBaseDO { private static final long serialVersionUID = 1L; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java index 814a9086..afafe917 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/ExamQuestionController.java @@ -1,26 +1,39 @@ package pc.exam.pp.module.exam.controller.admin.question; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.record.DVALRecord; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import pc.exam.pp.framework.common.enums.CommonStatusEnum; import pc.exam.pp.framework.common.pojo.CommonResult; import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.excel.core.util.ExcelUtils; import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; +import pc.exam.pp.module.exam.controller.admin.question.vo.QueImportRespVO; +import pc.exam.pp.module.exam.controller.admin.question.vo.QuemportExcelVO; import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; import pc.exam.pp.module.exam.service.question.IExamQuestionService; +import pc.exam.pp.module.system.enums.common.SexEnum; +import java.io.IOException; +import java.util.Arrays; import java.util.List; import static pc.exam.pp.framework.common.pojo.CommonResult.error; @@ -150,6 +163,33 @@ public class ExamQuestionController return success(examQuestionService.deleteExamQuestionByQuIds(ids)); } + @PostMapping("/import") + @Operation(summary = "导入试题") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true") + }) + public CommonResult importExcel(@RequestParam("file") MultipartFile file, + @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception { + List list = ExcelUtils.read(file, QuemportExcelVO.class); + System.out.println(list); + return success(examQuestionService.importUserList(list, updateSupport)); + } + + @GetMapping("/get-import-template") + @Operation(summary = "获得导入试题模板") + public void importTemplate(HttpServletResponse response) throws IOException { + // 手动创建导出 demo + List list = Arrays.asList( + QuemportExcelVO.builder().chapteridDictText("章节一").specialtyName("计算机专业").courseName("计算机基础") + .subjectName("选择题").quLevel("0、简单 1、一般 2、困难").analysis("解析").content("试题内容") + .pointNames("知识点").keywords("").a("内容").b("内容").c("内容").d("内容").answer("A").build() + ); + // 输出 + ExcelUtils.write(response, "试题导入模板.xls", "试题列表", QuemportExcelVO.class, list); + } + + /** *获得学校分页列表 * @return diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QueImportRespVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QueImportRespVO.java new file mode 100644 index 00000000..0192f0fa --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QueImportRespVO.java @@ -0,0 +1,24 @@ +package pc.exam.pp.module.exam.controller.admin.question.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +@Schema(description = "管理后台 - 用户导入 Response VO") +@Data +@Builder +public class QueImportRespVO { + + @Schema(description = "创建成功的试题数组", requiredMode = Schema.RequiredMode.REQUIRED) + private List createUsernames; + + @Schema(description = "更新成功的试题数组", requiredMode = Schema.RequiredMode.REQUIRED) + private List updateUsernames; + + @Schema(description = "导入失败的试题集合,key 为用户名,value 为失败原因", requiredMode = Schema.RequiredMode.REQUIRED) + private Map failureUsernames; + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuemportExcelVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuemportExcelVO.java new file mode 100644 index 00000000..6dca2871 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuemportExcelVO.java @@ -0,0 +1,61 @@ +package pc.exam.pp.module.exam.controller.admin.question.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; +import pc.exam.pp.framework.excel.core.annotations.DictFormat; +import pc.exam.pp.framework.excel.core.convert.DictConvert; +import pc.exam.pp.module.system.enums.DictTypeConstants; + +/** + * 试题 Excel 导入 VO + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题 +public class QuemportExcelVO { + + @ExcelProperty( "章节") + private String chapteridDictText; + + @ExcelProperty("专业") + private String specialtyName; + + @ExcelProperty( "课程") + private String courseName; + + @ExcelProperty("题型") + private String subjectName; + + @ExcelProperty("题型难度") + private String quLevel; + + @ExcelProperty( "试题内容") + private String content; + + @ExcelProperty( "解析") + private String analysis; + + @ExcelProperty("知识点") + private String pointNames; + + @ExcelProperty( "关键字") + private String keywords; + + @ExcelProperty( "选项A(必填)") + private String a; + @ExcelProperty( "选项B(必填)") + private String b; + @ExcelProperty( "选项C") + private String c; + @ExcelProperty( "选项D") + private String d; + @ExcelProperty( "正确答案") + private String answer; +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionSaveReqVO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionSaveReqVO.java new file mode 100644 index 00000000..4ba68b9f --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionSaveReqVO.java @@ -0,0 +1,75 @@ +package pc.exam.pp.module.exam.controller.admin.question.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import jakarta.validation.constraints.*; + +@Schema(description = "管理后台 - 试题表(hyc)新增/修改 Request VO") +@Data +public class QuestionSaveReqVO { + + @Schema(description = "试题id", requiredMode = Schema.RequiredMode.REQUIRED, example = "370") + private String quId; + + @Schema(description = "题库id", example = "20950") + private String quBankId; + + @Schema(description = "题库名称", example = "李四") + private String quBankName; + + @Schema(description = "章节名称") + private String chapteridDictText; + + @Schema(description = "专业分类", example = "赵六") + private String specialtyName; + + @Schema(description = "课程类别", example = "芋艿") + private String courseName; + + @Schema(description = "题型名称", example = "李四") + private String subjectName; + + @Schema(description = "题型难度(0:简单,1:一般,2:困难)") + private String quLevel; + + @Schema(description = "试题内容)") + private String content; + + @Schema(description = "审核(0是1否)") + private String audit; + + @Schema(description = "状态", example = "2") + private String status; + + @Schema(description = "试题内容(纯文本)") + private String contentText; + + @Schema(description = "解析(带样式)") + private String analysis; + + @Schema(description = "知识点") + private String pointNames; + + @Schema(description = "关键字") + private String keywords; + + @Schema(description = "是否人工(0否1是,简答题专用)") + private String manual; + + @Schema(description = "预留") + private String field2; + + @Schema(description = "预留") + private String field3; + + @Schema(description = "预留") + private String field4; + + @Schema(description = "预留") + private String field5; + + @Schema(description = "预留") + private String field6; + +} \ 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/test/TestController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/test/TestController.java new file mode 100644 index 00000000..15f64c3e --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/test/TestController.java @@ -0,0 +1,20 @@ +package pc.exam.pp.module.exam.controller.admin.test; + +import jakarta.annotation.security.PermitAll; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import pc.exam.pp.framework.common.pojo.CommonResult; + +import java.io.IOException; + +@RestController +@RequestMapping("/test") +public class TestController { + @PostMapping("/test") + public CommonResult get_file_point() throws IOException { + return CommonResult.success("连接成功"); + } + +} 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 index accd6047..77de7c65 100644 --- 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 @@ -16,7 +16,7 @@ import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; @TableName("exam_knowledge_points") @Data @EqualsAndHashCode(callSuper = true) -public class ExamKnowledgePoints extends TenantBaseDO +public class ExamKnowledgePoints extends TenantBaseDO { private static final long serialVersionUID = 1L; 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 index 4435f114..e3f01414 100644 --- 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 @@ -3,6 +3,7 @@ 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.controller.admin.specialty.vo.SpecialtyQueryVo; import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; import java.util.List; @@ -47,4 +48,8 @@ public interface ExamKnowledgePointsMapper extends BaseMapperX selectKnowledgePointsListPage(@Param("knowledgePoints")ExamKnowledgePoints knowledgePoints); + + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java index ddd6926a..827e9fdc 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java @@ -12,6 +12,7 @@ import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion; +import pc.exam.pp.module.exam.dal.dataobject.monitor.MonitorDO; import java.util.List; @@ -46,6 +47,7 @@ public interface ExamQuestionMapper extends BaseMapperX .likeIfPresent(ExamQuestion::getSubjectName , questionVo.getSubjectName()) .likeIfPresent(ExamQuestion::getStatus, questionVo.getStatus()) .likeIfPresent(ExamQuestion::getAudit, questionVo.getAudit()) + .orderByDesc(ExamQuestion::getCreateTime) ); } @@ -126,4 +128,10 @@ public interface ExamQuestionMapper extends BaseMapperX long selectTenantId(); + ExamQuestion selectByTypes(@Param("specialtyName")String specialtyName + ,@Param("courseName") String courseName + ,@Param("subjectName") String subjectName + ,@Param("content") String content); + + String selectSchoolnameBytId(Long loginTenantId); } 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 index dc7cb6e7..601f2f8d 100644 --- 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 @@ -98,4 +98,7 @@ public interface ExamSpecialtyMapper extends BaseMapperX String getRoleById(String id); + ExamSpecialty selectBySpecCourseSub(@Param("specialtyName") String specialtyName + ,@Param("courseName") String courseName + ,@Param("subjectName") String subjectName); } 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 index 047d98eb..3d888d3f 100644 --- 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 @@ -1,5 +1,6 @@ package pc.exam.pp.module.exam.service.knowledge; +import pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo; import pc.exam.pp.module.exam.dal.dataobject.knowledge.ExamKnowledgePoints; import java.util.List; @@ -59,4 +60,7 @@ public interface ExamKnowledgePointsService * @return 结果 */ public int deleteKnowledgePointsBySpId(Long spId); + + List selectKnowledgePointsListPage(ExamKnowledgePoints knowledgePoints); + } 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 index 853aa617..1d53a2ba 100644 --- 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 @@ -2,6 +2,7 @@ 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.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; @@ -91,6 +92,7 @@ public class ExamKnowledgePointsServiceImpl implements ExamKnowledgePointsServic @Override public int updateKnowledgePoints(ExamKnowledgePoints knowledgePoints) { + System.out.println(knowledgePoints); return knowledgePointsMapper.updateById(knowledgePoints); } @@ -117,4 +119,29 @@ public class ExamKnowledgePointsServiceImpl implements ExamKnowledgePointsServic { return knowledgePointsMapper.deleteKnowledgePointsBySpId(spId); } + + @Override + public List selectKnowledgePointsListPage(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.selectKnowledgePointsListPage(knowledgePoints); + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java index 79c868d7..3d3fb579 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperQuServiceImpl.java @@ -146,15 +146,21 @@ public class EducationPaperQuServiceImpl implements IEducationPaperQuService if (educationPaperPerson!=null){ stuInfoPaper.setBatch(educationPaperPerson.getBatch()); } + Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); + String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId); + stuInfoPaper.setSchoolName(schoolName); stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); stuInfoPaper.setPaperScore(educationPaper.getPaperScore()); stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); + stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName()); + stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ()); ExamPaperVo examPaperVo=new ExamPaperVo(); examPaperVo.setPaperId(paperId); examPaperVo.setExamQuestionList(examQuestionList); examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); examPaperVo.setEducationPaperParam(educationPaperParam); examPaperVo.setStuInfoPaper(stuInfoPaper); + return examPaperVo; } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java index 7df74146..ad96c8c0 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java @@ -328,7 +328,7 @@ public class EducationPaperServiceImpl implements IEducationPaperService public ExamPaperVo stuInfoPaper(String taskid) { - EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskid); + EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskid); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskid); String taskSpecialty = educationPaperTask.getTaskSpecialty(); @@ -439,9 +439,11 @@ public class EducationPaperServiceImpl implements IEducationPaperService stuInfoPaper.setAnswerTime(educationPaperParam.getExamTime()); stuInfoPaper.setPaperScore(educationPaper.getPaperScore()); stuInfoPaper.setTaskName(educationPaperTask.getTaskName()); - - - + stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName()); + stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ()); + Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); + String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId); + stuInfoPaper.setSchoolName(schoolName); ExamPaperVo examPaperVo=new ExamPaperVo(); examPaperVo.setExamQuestionList(examQuestionList); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java index 4fdbd9f9..dde860bd 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java @@ -432,13 +432,18 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService if (educationPaperPerson!=null){ stuInfoPaper.setBatch(educationPaperPerson.getBatch()); } - + Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); + String schoolName= examQuestionMapper.selectSchoolnameBytId(loginTenantId); + stuInfoPaper.setUserName(SecurityFrameworkUtils.getLoginUserName()); + stuInfoPaper.setSfz(SecurityFrameworkUtils.getLoginUserSFZ()); + stuInfoPaper.setSchoolName(schoolName); ExamPaperVo examPaperVo=new ExamPaperVo(); examPaperVo.setExamQuestionList(examQuestionList); examPaperVo.setEducationPaperSchemeList(educationPaperSchemeList); examPaperVo.setPaperId(paperId); examPaperVo.setEducationPaperParam(educationPaperParam); examPaperVo.setStuInfoPaper(stuInfoPaper); + return examPaperVo; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java index df6c1126..ce28d78b 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java @@ -1,28 +1,40 @@ package pc.exam.pp.module.exam.service.question; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import com.alibaba.excel.util.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.google.common.annotations.VisibleForTesting; +import jakarta.validation.ConstraintViolationException; import org.checkerframework.checker.units.qual.A; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import pc.exam.pp.framework.common.exception.ServiceException; import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.util.object.BeanUtils; +import pc.exam.pp.framework.common.util.validation.ValidationUtils; import pc.exam.pp.framework.security.core.util.SecurityFrameworkUtils; import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; -import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; -import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; +import pc.exam.pp.module.exam.controller.admin.question.vo.*; import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; import pc.exam.pp.module.exam.controller.admin.rabbitmq.vo.RabbitMQSendInfoVO; import pc.exam.pp.module.exam.dal.dataobject.*; +import pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty; import pc.exam.pp.module.exam.dal.mysql.question.*; import pc.exam.pp.module.exam.dal.mysql.questionexamine.QuestionExamineMapper; +import pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper; import pc.exam.pp.module.exam.service.questionexamine.QuestionExamineService; import pc.exam.pp.module.exam.utils.date.DateUtils; import pc.exam.pp.module.exam.utils.rabbitmq.RabbitmqUtils; import pc.exam.pp.module.exam.utils.uuid.IdUtils; -import java.util.ArrayList; -import java.util.List; +import java.time.LocalDateTime; +import java.util.*; + +import static pc.exam.pp.framework.common.exception.util.ServiceExceptionUtil.exception; +import static pc.exam.pp.module.system.enums.ErrorCodeConstants.*; /** * 试题(hyc)Service业务层处理 @@ -48,6 +60,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService @Autowired private QuestionExamineMapper questionExamineMapper; @Autowired + private ExamSpecialtyMapper examSpecialtyMapper; + @Autowired private RabbitmqUtils rabbitMqService; /** * 查询试题(hyc) @@ -360,7 +374,7 @@ public class ExamQuestionServiceImpl implements IExamQuestionService ExamQuestion examQuestion_obj = selectExamQuestionByQuId(quId); examQuestion_obj.setType(rabbitMQSendInfoVO.getType()); examQuestion_obj.setSource(SecurityFrameworkUtils.getLoginTenantId()); - examQuestion_obj.setCreateTeacher(SecurityFrameworkUtils.getLoginUserNickname()); + examQuestion_obj.setCreateTeacher(examQuestion_obj.getCreator()); System.out.println(rabbitMQSendInfoVO.getQueueName()); // 3、上传至Rabbitmq rabbitMqService.sendMessage(rabbitMQSendInfoVO.getQueueName(), examQuestion_obj); @@ -462,8 +476,8 @@ public class ExamQuestionServiceImpl implements IExamQuestionService @Override public int auditQueByIds(List quIds) { -examQuestionMapper.updateExamQuestionByIds(SecurityFrameworkUtils.getLoginUserNickname(),quIds); - return examQuestionMapper.auditQueByIds(quIds); + examQuestionMapper.updateExamQuestionByIds(SecurityFrameworkUtils.getLoginUserNickname(),quIds); + return examQuestionMapper.auditQueByIds(quIds); } @Override @@ -476,6 +490,8 @@ examQuestionMapper.updateExamQuestionByIds(SecurityFrameworkUtils.getLoginUserNi return examQuestionMapper.getSchoolNameNaPage(); } + + public boolean getExamQuestionToRabbitMQInsertData(String queueName) { // 最先判断类型 // TODO 1、拉取数据,保存至数据库 2、回调服务器是否拉取成功(中心服务器) @@ -521,4 +537,193 @@ examQuestionMapper.updateExamQuestionByIds(SecurityFrameworkUtils.getLoginUserNi return quCount; } + + @Override + @Transactional(rollbackFor = Exception.class) // 添加事务,异常则回滚所有导入 + public QueImportRespVO importUserList(List list, Boolean updateSupport) { + // 1.1 参数校验 + if (CollUtil.isEmpty(list)) { + throw exception(USER_IMPORT_LIST_IS_EMPTY); + } + + // 2. 遍历,逐个创建 or 更新 + QueImportRespVO respVO = QueImportRespVO.builder().createUsernames(new ArrayList<>()) + .updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build(); + + + list.forEach(importUser -> { + + // 校验,判断是否有不符合的原因 + try { + //校验 是否有 专业课程题型 + validateQueForCreateOrUpdate(importUser.getSpecialtyName(), importUser.getCourseName(),importUser.getSubjectName()); + //校验 选项 + validateChoice(importUser.getA(),importUser.getB(),importUser.getC(),importUser.getD(),importUser.getAnswer()); + + + } catch (ServiceException ex) { + respVO.getFailureUsernames().put(importUser.getContent(), ex.getMessage()); + return; + } + // 2.2.1 判断如果不存在,在进行插入 + ExamQuestion examQuestionSelect = examQuestionMapper.selectByTypes(importUser.getSpecialtyName(),importUser.getCourseName(),importUser.getSubjectName(),importUser.getContent()); + if (examQuestionSelect==null){ + if ("选择题".equals(importUser.getSubjectName())){ + String quId = IdUtils.simpleUUID(); + ExamQuestion examQuestion = new ExamQuestion(); + examQuestion.setChapteridDictText(importUser.getChapteridDictText()); + examQuestion.setSpecialtyName(importUser.getSpecialtyName()); + examQuestion.setCourseName(importUser.getCourseName()); + examQuestion.setSubjectName(importUser.getSubjectName()); + examQuestion.setQuLevel(importUser.getQuLevel()); + examQuestion.setContent(importUser.getContent()); + examQuestion.setAnalysis(importUser.getAnalysis()); + examQuestion.setPointNames(importUser.getPointNames()); + examQuestion.setKeywords(importUser.getKeywords()); + examQuestion.setCreator(SecurityFrameworkUtils.getLoginUserNickname()); + examQuestion.setQuId(quId); + examQuestion.setCreateTime(DateUtils.getNowLocalDateTime()); + examQuestionMapper.insertExamQuestion(examQuestion); + System.out.println(examQuestion); + Map validAnswerMap = new LinkedHashMap<>(); + validAnswerMap.put("A", importUser.getA()); + validAnswerMap.put("B", importUser.getB()); + if (!StringUtils.isBlank(importUser.getC())) { + validAnswerMap.put("C", importUser.getC()); + } + if (!StringUtils.isBlank(importUser.getD())) { + validAnswerMap.put("D", importUser.getD()); + } + List examQuestionAnswerList=new ArrayList<>(); + int i=1; + for (Map.Entry entry : validAnswerMap.entrySet()) { + String option = entry.getKey(); // A, B, C, D + String content = entry.getValue(); // 实际内容 + + ExamQuestionAnswer examQuestionAnswer = new ExamQuestionAnswer(); + examQuestionAnswer.setAnswerId(IdUtils.simpleUUID()); + examQuestionAnswer.setQuId(quId); + examQuestionAnswer.setSort(String.valueOf(i++)); + // 判断是否为正确答案,忽略大小写和空格 + if (option.equalsIgnoreCase(importUser.getAnswer().trim())) { + examQuestionAnswer.setIsRight("1"); // 正确 + } else { + examQuestionAnswer.setIsRight("0"); // 错误 + } + examQuestionAnswer.setContent(content); + examQuestionAnswerList.add(examQuestionAnswer); + // TODO: 保存到集合或数据库 + } + + System.out.println(examQuestionAnswerList); + examQuestionAnswerMapper.insertExamQuestionAnswerList(examQuestionAnswerList); + + + } + + respVO.getCreateUsernames().add(importUser.getContent()); + + + + } else { + if ("选择题".equals(importUser.getSubjectName())){ + + String quId=examQuestionSelect.getQuId(); + ExamQuestion examQuestion = new ExamQuestion(); + examQuestion.setChapteridDictText(importUser.getChapteridDictText()); + examQuestion.setSpecialtyName(importUser.getSpecialtyName()); + examQuestion.setCourseName(importUser.getCourseName()); + examQuestion.setSubjectName(importUser.getSubjectName()); + examQuestion.setQuLevel(importUser.getQuLevel()); + examQuestion.setContent(importUser.getContent()); + examQuestion.setAnalysis(importUser.getAnalysis()); + examQuestion.setPointNames(importUser.getPointNames()); + examQuestion.setKeywords(importUser.getKeywords()); + examQuestion.setQuId(quId); + examQuestion.setUpdater(SecurityFrameworkUtils.getLoginUserNickname()); + examQuestion.setUpdateTime(DateUtils.getNowLocalDateTime()); + examQuestionMapper.updateById(examQuestion); + + Map validAnswerMap = new LinkedHashMap<>(); + validAnswerMap.put("A", importUser.getA()); + validAnswerMap.put("B", importUser.getB()); + if (!StringUtils.isBlank(importUser.getC())) { + validAnswerMap.put("C", importUser.getC()); + } + if (!StringUtils.isBlank(importUser.getD())) { + validAnswerMap.put("D", importUser.getD()); + } + List examQuestionAnswerList=new ArrayList<>(); + int i=1; + for (Map.Entry entry : validAnswerMap.entrySet()) { + String option = entry.getKey(); // A, B, C, D + String content = entry.getValue(); // 实际内容 + + ExamQuestionAnswer examQuestionAnswer = new ExamQuestionAnswer(); + examQuestionAnswer.setAnswerId(IdUtils.simpleUUID()); + examQuestionAnswer.setQuId(quId); + examQuestionAnswer.setSort(String.valueOf(i++)); + // 判断是否为正确答案,忽略大小写和空格 + if (option.equalsIgnoreCase(importUser.getAnswer().trim())) { + examQuestionAnswer.setIsRight("1"); // 正确 + } else { + examQuestionAnswer.setIsRight("0"); // 错误 + } + examQuestionAnswer.setContent(content); + examQuestionAnswerList.add(examQuestionAnswer); + examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(quId); + + } + // 保存到集合或数据库 + examQuestionAnswerMapper.insertExamQuestionAnswerList(examQuestionAnswerList); + } + + respVO.getUpdateUsernames().add(importUser.getContent()); + + + } + }); + + + + return respVO; + } + + private void validateChoice(String a, String b, String c, String d, String answer) { + // A 和 B 必须存在 + if (StringUtils.isBlank(a) || StringUtils.isBlank(b)) { + throw exception(QESESTION_CHOICEAB_ERROR); + } + + // 构造有效答案列表(非空的) + List validAnswers = new ArrayList<>(); + validAnswers.add("A"); + validAnswers.add("B"); + if (!StringUtils.isBlank(c)) validAnswers.add("C"); + if (!StringUtils.isBlank(d)) validAnswers.add("D"); + + // 校验 answer 是否在有效答案列表中 + if (!validAnswers.contains(answer.toUpperCase())) { + throw exception(QESESTION_CHOICE_ERROR); + } + } + + + private void validateQueForCreateOrUpdate(String specialtyName, String courseName, String subjectName) { + // 校验专业课程题型 + validateSpecCourseSub(specialtyName, courseName,subjectName); + + } + + + + @VisibleForTesting + void validateSpecCourseSub(String specialtyName, String courseName, String subjectName) { + + ExamSpecialty examSpecialty= examSpecialtyMapper.selectBySpecCourseSub(specialtyName,courseName,subjectName); + if (examSpecialty==null){ + throw exception(QESESTION_TYPE_ERROR); + } + } + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java index caa82a2f..7e12df36 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/IExamQuestionService.java @@ -3,6 +3,8 @@ package pc.exam.pp.module.exam.service.question; import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.module.exam.controller.admin.question.dto.ExamQuestionDto; import pc.exam.pp.module.exam.controller.admin.question.dto.TenantDto; +import pc.exam.pp.module.exam.controller.admin.question.vo.QueImportRespVO; +import pc.exam.pp.module.exam.controller.admin.question.vo.QuemportExcelVO; import pc.exam.pp.module.exam.controller.admin.question.vo.QuestionVo; import pc.exam.pp.module.exam.controller.admin.question.vo.TenantVo; import pc.exam.pp.module.exam.controller.admin.questionexamine.vo.QuestionExaminePageReqVO; @@ -98,4 +100,7 @@ public interface IExamQuestionService List getSchoolNameNaPage(); + + QueImportRespVO importUserList(List list, Boolean updateSupport); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperQuMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperQuMapper.xml index b49c5d92..5ec6bb85 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperQuMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperQuMapper.xml @@ -50,10 +50,10 @@ - INSERT INTO education_paper_qu (paper_id ,qu_id )VALUES + INSERT INTO education_paper_qu (paper_id ,qu_id ,sort )VALUES ( - #{item.paperId}, #{item.quId} + #{item.paperId}, #{item.quId}, #{item.sort} ) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml index f8ce9991..c61ed92b 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperTaskMapper.xml @@ -62,9 +62,9 @@ @@ -78,7 +78,7 @@ select tenant_id from system_users limit 1 + + 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 index 4d22bc93..43395578 100644 --- 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 @@ -35,6 +35,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where sp_id = #{spId} + update exam_knowledge_points 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 index 8e75dcfc..808295d9 100644 --- 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 @@ -95,6 +95,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select roles from exam_specialty where sp_id =#{id}; + update exam_specialty 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 8b9b8f2d..e3db8368 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 @@ -209,6 +209,9 @@ public interface ErrorCodeConstants { // ========== 试题中间 ========== ErrorCode QESESTION_NOT_NULL = new ErrorCode(1_008_008_012, "审核试题不能为空"); ErrorCode QESESTION_AUDIT_ERROR = new ErrorCode(1_008_008_022, "操作试题失败"); + ErrorCode QESESTION_TYPE_ERROR = new ErrorCode(1_008_009_023, "没有对应的专业课程题型"); + ErrorCode QESESTION_CHOICEAB_ERROR = new ErrorCode(1_008_010_024, "选项 A 和 B 为必填项"); + ErrorCode QESESTION_CHOICE_ERROR = new ErrorCode(1_008_010_024, "答案不在有效选项范围内"); // ========== rabbit ========== ErrorCode RABBITMQ_CONNECT_EXISTS = new ErrorCode(1_005_005_111, "连接失败"); ErrorCode RABBITMQ_NOT_EXISTS = new ErrorCode(1_005_005_011, "接收试题出错"); 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 e59ea9aa..9198d4a6 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 @@ -27,6 +27,9 @@ public class UserRespVO{ @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") @ExcelProperty("用户昵称") private String nickname; + @Schema(description = "身份证", requiredMode = Schema.RequiredMode.REQUIRED, example = "123") + @ExcelProperty("身份证") + private String sfz; @Schema(description = "班级名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") @ExcelProperty("班级名称") 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 7ab33c53..558a10b4 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 @@ -33,6 +33,10 @@ public class UserSaveReqVO { @DiffLogField(name = "用户昵称") private String nickname; + @Schema(description = "身份证", example = "31231") + @DiffLogField(name = "身份证") + private String sfz; + @Schema(description = "备注", example = "我是一个用户") @DiffLogField(name = "备注") private String remark; 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 31b233a8..349c8471 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 @@ -43,6 +43,10 @@ public class AdminUserDO extends TenantBaseDO { * 因为目前使用 {@link BCryptPasswordEncoder} 加密器,所以无需自己处理 salt 盐 */ private String password; + /** + * 身份证 + */ + private String sfz; /** * 用户昵称 */ diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/oauth2/OAuth2TokenServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/oauth2/OAuth2TokenServiceImpl.java index 8456a5ac..a08b4c0e 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/oauth2/OAuth2TokenServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/oauth2/OAuth2TokenServiceImpl.java @@ -202,6 +202,8 @@ public class OAuth2TokenServiceImpl implements OAuth2TokenService { return MapUtil.builder(LoginUser.INFO_KEY_NICKNAME, user.getNickname()) .put(LoginUser.INFO_KEY_DEPT_ID, StrUtil.toStringOrNull(user.getDeptId())) .put(LoginUser.INFO_KEY_QUEUE, StrUtil.toStringOrNull(user.getQueueName())) + .put(LoginUser.INFO_KEY_USERNAME,StrUtil.toStringOrNull(user.getUsername())) + .put(LoginUser.INFO_KEY_SFZ,StrUtil.toStringOrNull(user.getSfz())) .build(); } else if (userType.equals(UserTypeEnum.MEMBER.getValue())) { // 注意:目前 Member 暂时不读取,可以按需实现