【新增】学生身份证字段,学生进入试卷返回信息确认
【新增】知识点,选择题excel批量导入新增修改
This commit is contained in:
@@ -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";
|
||||
|
@@ -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,从上下文中
|
||||
*
|
||||
|
@@ -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<ExamKnowledgePoints> 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<SpecialtyQueryVo> list = knowledgePointsService.selectKnowledgePointsListPage(knowledgePoints);
|
||||
return CommonResult.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出知识点列表
|
||||
*/
|
||||
// @PostMapping("/export")
|
||||
// public void export(HttpServletResponse response, ExamKnowledgePoints knowledgePoints) {
|
||||
// List<ExamKnowledgePoints> list = knowledgePointsService.selectKnowledgePointsList(knowledgePoints, String.valueOf(getDeptId()), String.valueOf(getUserId()));
|
||||
// ExcelUtil<ExamKnowledgePoints> util = new ExcelUtil<ExamKnowledgePoints>(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> tree = new ArrayList<>();
|
||||
// //查询数据库表中全部数据
|
||||
// List<ExamKnowledgePoints> 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> tree = new ArrayList<>();
|
||||
//查询数据库表中全部数据
|
||||
List<ExamKnowledgePoints> 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);
|
||||
}
|
||||
}
|
||||
|
@@ -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<Tree> builTree(List<Tree> list) {
|
||||
List<Tree> 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<Tree> list) {
|
||||
List<Tree> 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<Tree> getRootNode(List<Tree> list) {
|
||||
List<Tree> rootList = new ArrayList<>();
|
||||
for (Tree tree : list) {
|
||||
if (tree.getP_id().equals("0")) {
|
||||
rootList.add(tree);
|
||||
}
|
||||
}
|
||||
return rootList;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
|
||||
|
||||
}
|
@@ -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<Tree> 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<Tree> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<Tree> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
}
|
@@ -33,7 +33,7 @@ public class EducationPaperTaskController
|
||||
private IEducationPaperTaskService educationPaperTaskService;
|
||||
|
||||
/**
|
||||
* 查询试卷任务列表
|
||||
* 查询试卷任务列表(服务器端)
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public CommonResult<PageResult<EducationPaperTask>> list(PaperTaskPageVo educationPaperTask)
|
||||
@@ -46,7 +46,9 @@ public class EducationPaperTaskController
|
||||
return CommonResult.success(BeanUtils.toBean(pageResult, EducationPaperTask.class));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询试卷任务列表(学生端)
|
||||
*/
|
||||
@GetMapping("/stulist")
|
||||
public CommonResult<PageResult<EducationPaperTask>> stulist(PaperTaskPageVo educationPaperTask)
|
||||
{
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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<QueImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
|
||||
@RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
|
||||
List<QuemportExcelVO> 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<QuemportExcelVO> 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
|
||||
|
@@ -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<String> createUsernames;
|
||||
|
||||
@Schema(description = "更新成功的试题数组", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<String> updateUsernames;
|
||||
|
||||
@Schema(description = "导入失败的试题集合,key 为用户名,value 为失败原因", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private Map<String, String> failureUsernames;
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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;
|
||||
|
||||
}
|
@@ -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("连接成功");
|
||||
}
|
||||
|
||||
}
|
@@ -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;
|
||||
|
||||
|
@@ -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<ExamKnowledgePoin
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteKnowledgePointsBySpIds(Long[] spIds);
|
||||
|
||||
List<SpecialtyQueryVo> selectKnowledgePointsListPage(@Param("knowledgePoints")ExamKnowledgePoints knowledgePoints);
|
||||
|
||||
|
||||
}
|
||||
|
@@ -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<ExamQuestion>
|
||||
.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<ExamQuestion>
|
||||
long selectTenantId();
|
||||
|
||||
|
||||
ExamQuestion selectByTypes(@Param("specialtyName")String specialtyName
|
||||
,@Param("courseName") String courseName
|
||||
,@Param("subjectName") String subjectName
|
||||
,@Param("content") String content);
|
||||
|
||||
String selectSchoolnameBytId(Long loginTenantId);
|
||||
}
|
||||
|
@@ -98,4 +98,7 @@ public interface ExamSpecialtyMapper extends BaseMapperX<ExamSpecialty>
|
||||
|
||||
String getRoleById(String id);
|
||||
|
||||
ExamSpecialty selectBySpecCourseSub(@Param("specialtyName") String specialtyName
|
||||
,@Param("courseName") String courseName
|
||||
,@Param("subjectName") String subjectName);
|
||||
}
|
||||
|
@@ -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<SpecialtyQueryVo> selectKnowledgePointsListPage(ExamKnowledgePoints knowledgePoints);
|
||||
|
||||
}
|
||||
|
@@ -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<SpecialtyQueryVo> selectKnowledgePointsListPage(ExamKnowledgePoints knowledgePoints) {
|
||||
SpecialtListReqVo reqVo = new SpecialtListReqVo();
|
||||
List<ExamSpecialty> 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);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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<String> 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<QuemportExcelVO> 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<String, String> 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<ExamQuestionAnswer> examQuestionAnswerList=new ArrayList<>();
|
||||
int i=1;
|
||||
for (Map.Entry<String, String> 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<String, String> 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<ExamQuestionAnswer> examQuestionAnswerList=new ArrayList<>();
|
||||
int i=1;
|
||||
for (Map.Entry<String, String> 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<String> 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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<TenantVo> getSchoolNameNaPage();
|
||||
|
||||
QueImportRespVO importUserList(List<QuemportExcelVO> list, Boolean updateSupport);
|
||||
|
||||
}
|
||||
|
@@ -50,10 +50,10 @@
|
||||
</trim>
|
||||
</insert>
|
||||
<insert id="insertEducationPaperQuList">
|
||||
INSERT INTO education_paper_qu (paper_id ,qu_id )VALUES
|
||||
INSERT INTO education_paper_qu (paper_id ,qu_id ,sort )VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.paperId}, #{item.quId}
|
||||
#{item.paperId}, #{item.quId}, #{item.sort}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
@@ -62,9 +62,9 @@
|
||||
<select id="getPoints" resultMap="ExamSpecialtyResult">
|
||||
|
||||
SELECT sp_id, parent_id, ancestors, sp_name, order_num
|
||||
FROM knowledge_points
|
||||
FROM exam_knowledge_points
|
||||
WHERE FIND_IN_SET(#{id}, ancestors)
|
||||
and del_flag='0'
|
||||
and deleted='0'
|
||||
ORDER BY order_num;
|
||||
|
||||
</select>
|
||||
@@ -78,7 +78,7 @@
|
||||
</foreach>
|
||||
</select>
|
||||
<select id="getPointIdByName" resultType="java.lang.Long">
|
||||
select sp_id from knowledge_points where sp_name =#{name} limit 1
|
||||
select sp_id from exam_knowledge_points where sp_name =#{name} limit 1
|
||||
|
||||
</select>
|
||||
<select id="getQuCount" resultType="java.lang.Integer">
|
||||
|
@@ -118,6 +118,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="selectTenantId" resultType="java.lang.Long">
|
||||
select tenant_id from system_users limit 1
|
||||
</select>
|
||||
<select id="selectByTypes" resultMap="ExamQuestionResult">
|
||||
select * from exam_question where specialty_name =#{specialtyName}
|
||||
and course_name=#{courseName}
|
||||
and subject_name =#{subjectName}
|
||||
and content =#{content}
|
||||
limit 1;
|
||||
</select>
|
||||
<select id="selectSchoolnameBytId" resultType="java.lang.String">
|
||||
select name from system_tenant where id =#{loginTenantId}
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="insertExamQuestion" parameterType="ExamQuestion">
|
||||
|
@@ -35,6 +35,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<include refid="selectKnowledgePointsVo"/>
|
||||
where sp_id = #{spId}
|
||||
</select>
|
||||
<select id="selectKnowledgePointsListPage"
|
||||
resultType="pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo">
|
||||
select sp_id as id, sp_name as name, parent_id,order_num ,status, create_time from exam_knowledge_points
|
||||
<where>
|
||||
<if test="knowledgePoints.spName != null and knowledgePoints.spName != ''"> and sp_name like concat('%', #{knowledgePoints.spName}, '%')</if>
|
||||
<if test="knowledgePoints.status != null and knowledgePoints.status != ''"> and 'status' = #{knowledgePoints.status}</if>
|
||||
and deleted = 0
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="deleteKnowledgePointsBySpId" parameterType="Long">
|
||||
update exam_knowledge_points
|
||||
|
@@ -95,6 +95,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select roles
|
||||
from exam_specialty where sp_id =#{id};
|
||||
</select>
|
||||
<select id="selectBySpecCourseSub" resultMap="ExamSpecialtyResult">
|
||||
SELECT
|
||||
q3.*
|
||||
FROM exam_specialty q1
|
||||
JOIN exam_specialty q2 ON q2.parent_id = q1.sp_id
|
||||
JOIN exam_specialty q3 ON q3.parent_id = q2.sp_id
|
||||
WHERE q1.sp_name = #{specialtyName}
|
||||
AND q2.sp_name = #{courseName}
|
||||
AND q3.sp_name = #{subjectName}
|
||||
AND q1.deleted = '0'
|
||||
AND q2.deleted = '0'
|
||||
AND q3.deleted = '0';
|
||||
</select>
|
||||
|
||||
<update id="deleteExamSpecialtyBySpId" parameterType="Long">
|
||||
update exam_specialty
|
||||
|
@@ -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, "接收试题出错");
|
||||
|
@@ -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("班级名称")
|
||||
|
@@ -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;
|
||||
|
@@ -43,6 +43,10 @@ public class AdminUserDO extends TenantBaseDO {
|
||||
* 因为目前使用 {@link BCryptPasswordEncoder} 加密器,所以无需自己处理 salt 盐
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 身份证
|
||||
*/
|
||||
private String sfz;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
|
@@ -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 暂时不读取,可以按需实现
|
||||
|
Reference in New Issue
Block a user