Merge pull request '【修改】试卷任务白名单' (#9) from hyc into master

Reviewed-on: #9
This commit is contained in:
hyc
2025-10-20 06:22:43 +08:00
16 changed files with 215 additions and 11 deletions

View File

@@ -64,7 +64,7 @@ public class AppCheckController {
// 根据taskId查询下面有多少题型然后查找对应的软件环境在新增 // 根据taskId查询下面有多少题型然后查找对应的软件环境在新增
@GetMapping("/getAppCheckListByTaskId/{taskId}") @GetMapping("/getAppCheckListByTaskId/{taskId}")
public CommonResult<Boolean> getAppCheckListByTaskId(@PathVariable("taskId") String taskId){ public CommonResult<Boolean> getAppCheckListByTaskId(@PathVariable("taskId") String taskId){
List<AppCheckDO> appCheckDOList = new ArrayList<>(); List<AppCheckDO> appCheckDOList = appCheckService.getAppList(taskId);
// 根据试卷方案ID查询下面试卷的试题的组成部分 // 根据试卷方案ID查询下面试卷的试题的组成部分
List<EducationPaperScheme> list = educationPaperSchemeService.getInfoDataByTaskId(taskId); List<EducationPaperScheme> list = educationPaperSchemeService.getInfoDataByTaskId(taskId);
for (EducationPaperScheme educationPaperScheme : list) { for (EducationPaperScheme educationPaperScheme : list) {
@@ -80,16 +80,19 @@ public class AppCheckController {
// 判断是否在数组中存在 // 判断是否在数组中存在
boolean exists = appCheckDOList.stream() boolean exists = appCheckDOList.stream()
.anyMatch(a -> exams.getRoles().equals(a.getAppName())); // 根据 appName 判断 .anyMatch(a -> exams.getRoles().equals(a.getAppName())); // 根据 appName 判断
if (!exists) { if (!exists) {
appCheckDOList.add(appCheckDO); // appCheckDOList.add(appCheckDO);
// 添加
appCheckService.insertAppCheck(appCheckDO);
} }
} }
} }
} }
// 添加 // 添加
for (AppCheckDO appCheckDO : appCheckDOList) { // for (AppCheckDO appCheckDO : appCheckDOList) {
appCheckService.insertAppCheck(appCheckDO); // appCheckService.insertAppCheck(appCheckDO);
} // }
return success(true); return success(true);
} }

View File

@@ -3,13 +3,20 @@ package pc.exam.pp.module.exam.controller.admin.paper;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.security.PermitAll;
import org.checkerframework.checker.units.qual.C; import org.checkerframework.checker.units.qual.C;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import pc.exam.pp.framework.common.pojo.CommonResult; import pc.exam.pp.framework.common.pojo.CommonResult;
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam;
import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO;
import pc.exam.pp.module.exam.dal.dataobject.app.AppCheckDO;
import pc.exam.pp.module.exam.service.paper.IEducationPaperParamService; import pc.exam.pp.module.exam.service.paper.IEducationPaperParamService;
import java.util.List;
import static pc.exam.pp.framework.common.pojo.CommonResult.success;
import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_PAPER_SESSION_EXISTS; import static pc.exam.pp.module.infra.enums.ErrorCodeConstants.DEMO03_PAPER_SESSION_EXISTS;
/** /**
@@ -102,5 +109,16 @@ public class EducationPaperParamController {
} }
return CommonResult.success("200"); return CommonResult.success("200");
} }
@GetMapping("/getAppWhiteList/{taskId}")
@PermitAll
@TenantIgnore
@Operation(summary = "查看白名单列表", description = "查看白名单列表")
public CommonResult<List<String>> getAppWhiteList(@PathVariable("taskId") String taskId){
// 使用传入的IP进行ping查看是否存在连接并返回信号的强度
System.out.println(educationPaperParamService.getAppWhiteList(taskId));
return success(educationPaperParamService.getAppWhiteList(taskId));
}
} }

View File

@@ -22,6 +22,7 @@ import pc.exam.pp.module.exam.service.paper.IEducationPaperTaskService;
import static pc.exam.pp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; import static pc.exam.pp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -72,6 +73,11 @@ public class EducationPaperTaskController {
@GetMapping("/stulist") @GetMapping("/stulist")
public CommonResult<PageResult<Map<String, Object>>> stulist(PaperTaskPageVo educationPaperTask) { public CommonResult<PageResult<Map<String, Object>>> stulist(PaperTaskPageVo educationPaperTask) {
PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskListByStu(educationPaperTask); PageResult<EducationPaperTask> pageResult = educationPaperTaskService.selectEducationPaperTaskListByStu(educationPaperTask);
// ✅ 防止 pageResult 或其 list 为空
if (pageResult == null || pageResult.getList() == null) {
PageResult<Map<String, Object>> emptyPage = new PageResult<>(Collections.emptyList(), 0L);
return CommonResult.success(emptyPage);
}
List<Map<String, Object>> newList = pageResult.getList().stream() List<Map<String, Object>> newList = pageResult.getList().stream()
.map(task -> { .map(task -> {
Map<String, Object> map = BeanUtil.beanToMap(task, false, true); Map<String, Object> map = BeanUtil.beanToMap(task, false, true);

View File

@@ -0,0 +1,16 @@
package pc.exam.pp.module.exam.controller.admin.paper.dto;
import lombok.Data;
import java.util.List;
@Data
public class ExamWhiteListSaveReqDTO {
private Long examId;
private List<WhiteApp> whiteList;
@Data
public static class WhiteApp {
private String name;
}
}

View File

@@ -1,14 +1,14 @@
package pc.exam.pp.module.exam.dal.dataobject; package pc.exam.pp.module.exam.dal.dataobject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.sql.Time; import java.sql.Time;
import java.util.List;
/** /**
* 通用参数对象 education_paper_param * 通用参数对象 education_paper_param
@@ -93,5 +93,7 @@ public class EducationPaperParam
private String isScoreDetail; private String isScoreDetail;
// 是否删除考生文件 // 是否删除考生文件
private String isDelete; private String isDelete;
// 白名单
@TableField(exist = false)
private List<ExamWhiteListDO> whiteList;
} }

View File

@@ -0,0 +1,19 @@
package pc.exam.pp.module.exam.dal.dataobject;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
@TableName("exam_white_list")
@Data
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ExamWhiteListDO {
@TableId
private Long id;
private String taskId;
private String name;
}

View File

@@ -0,0 +1,19 @@
package pc.exam.pp.module.exam.dal.mysql.paper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask;
import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO;
import java.util.List;
@Mapper
public interface ExamWhiteListMapper extends BaseMapperX<ExamWhiteListDO> {
List<ExamWhiteListDO> selectByTaskId(String taskId);
void deleteByTaskId(String taskId);
List<String> selectNameByTaskId(String taskId);
}

View File

@@ -480,7 +480,13 @@ public class MonitorServiceImpl implements MonitorService {
// redis_key // redis_key
String key = "userCache:" + taskId + ":" + stuId; String key = "userCache:" + taskId + ":" + stuId;
// 获取缓存数据 // 获取缓存数据
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class); // MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class);
MonitorDO info =monitorMapper.selectOne(
new QueryWrapper<MonitorDO>()
.eq("task_id", taskId)
.eq("stu_id", stuId)
);
// 如果考试状态存在,更新考试状态 // 如果考试状态存在,更新考试状态
if (status != null) { if (status != null) {
if (info != null) { if (info != null) {

View File

@@ -3,10 +3,13 @@ package pc.exam.pp.module.exam.service.paper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperParamMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperParamMapper;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper; import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper;
import pc.exam.pp.module.exam.dal.mysql.paper.ExamWhiteListMapper;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@@ -22,6 +25,9 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
private EducationPaperParamMapper educationPaperParamMapper; private EducationPaperParamMapper educationPaperParamMapper;
@Autowired @Autowired
private EducationPaperTaskMapper educationPaperTaskMapper; private EducationPaperTaskMapper educationPaperTaskMapper;
@Autowired
private ExamWhiteListMapper examWhiteListMapper;
/** /**
* 查询通用参数 * 查询通用参数
* *
@@ -55,6 +61,16 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
@Override @Override
public int insertEducationPaperParam(EducationPaperParam educationPaperParam) public int insertEducationPaperParam(EducationPaperParam educationPaperParam)
{ {
List<ExamWhiteListDO> whiteList = educationPaperParam.getWhiteList();
String taskId = educationPaperParam.getTaskId();
// ✅ 统一赋值
if (whiteList != null && !whiteList.isEmpty()) {
for (ExamWhiteListDO examWhiteListDO : whiteList) {
examWhiteListDO.setTaskId(taskId);
examWhiteListDO.setName(examWhiteListDO.getName());
}
examWhiteListMapper.insertBatch(whiteList);
}
return educationPaperParamMapper.insertEducationPaperParam(educationPaperParam); return educationPaperParamMapper.insertEducationPaperParam(educationPaperParam);
} }
@@ -67,6 +83,20 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
@Override @Override
public int updateEducationPaperParam(EducationPaperParam educationPaperParam) public int updateEducationPaperParam(EducationPaperParam educationPaperParam)
{ {
List<ExamWhiteListDO> whiteList = educationPaperParam.getWhiteList();
String taskId = educationPaperParam.getTaskId();
if (taskId!=null){
//删除旧白名单
examWhiteListMapper.deleteByTaskId(taskId);
//插入新白名单
if (whiteList != null && !whiteList.isEmpty()) {
for (ExamWhiteListDO examWhiteListDO : whiteList) {
examWhiteListDO.setTaskId(taskId);
examWhiteListDO.setName(examWhiteListDO.getName());
}
examWhiteListMapper.insertBatch(whiteList);
}
}
return educationPaperParamMapper.updateEducationPaperParam(educationPaperParam); return educationPaperParamMapper.updateEducationPaperParam(educationPaperParam);
} }
@@ -96,7 +126,19 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
@Override @Override
public EducationPaperParam selectEducationPaperParamByTaskId(String taskId) { public EducationPaperParam selectEducationPaperParamByTaskId(String taskId) {
return educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); List<ExamWhiteListDO> whiteList = examWhiteListMapper.selectByTaskId(taskId);
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
if (whiteList != null && !whiteList.isEmpty()) {
educationPaperParam.setWhiteList(whiteList);
}
return educationPaperParam;
}
@Override
public List<String> getAppWhiteList(String taskId) {
return examWhiteListMapper.selectNameByTaskId(taskId);
} }
} }

View File

@@ -81,6 +81,8 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
private ExamQuestionMapper examQuestionMapper; private ExamQuestionMapper examQuestionMapper;
@Resource @Resource
AppCheckMapper appCheckMapper; AppCheckMapper appCheckMapper;
@Autowired
private ExamWhiteListMapper examWhiteListMapper;
/** /**
* 查询试卷任务 * 查询试卷任务
@@ -190,6 +192,15 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
} else { } else {
educationPaperTask.setIsOne("1"); educationPaperTask.setIsOne("1");
} }
List<ExamWhiteListDO> whiteList = new ArrayList<>();
ExamWhiteListDO examWhiteListDO=new ExamWhiteListDO();
examWhiteListDO.setTaskId(uuid);
examWhiteListDO.setName("ExamStudent");
whiteList.add(examWhiteListDO);
examWhiteListMapper.insertBatch(whiteList);
// 新增任务参数 // 新增任务参数
educationPaperParamMapper.insertEducationPaperParam(educationPaperParam); educationPaperParamMapper.insertEducationPaperParam(educationPaperParam);
// 新增任务 // 新增任务
@@ -539,6 +550,14 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
educationPaperTask.setTaskName(educationPaperTask.getTaskName() + timeString); educationPaperTask.setTaskName(educationPaperTask.getTaskName() + timeString);
educationPaperTask.setCreateTime(now); educationPaperTask.setCreateTime(now);
educationPaperTask.setIsTemplate(1); educationPaperTask.setIsTemplate(1);
//白名单
List<ExamWhiteListDO> whiteList = examWhiteListMapper.selectByTaskId(taskId);
if (whiteList != null && !whiteList.isEmpty()) {
for (ExamWhiteListDO examWhiteListDO : whiteList) {
examWhiteListDO.setTaskId(newtaskId);
}
examWhiteListMapper.insertBatch(whiteList);
}
educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask); educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask);
if (options.contains("1")) { if (options.contains("1")) {

View File

@@ -0,0 +1,7 @@
package pc.exam.pp.module.exam.service.paper;
public interface ExamWhiteListService {
}

View File

@@ -0,0 +1,12 @@
package pc.exam.pp.module.exam.service.paper;
import jakarta.annotation.Resource;
import pc.exam.pp.module.exam.dal.mysql.paper.ExamWhiteListMapper;
public class ExamWhiteListServiceImpl implements ExamWhiteListService {
@Resource
ExamWhiteListMapper examWhiteListMapper;
}

View File

@@ -2,6 +2,7 @@ package pc.exam.pp.module.exam.service.paper;
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam;
import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO;
import java.util.List; import java.util.List;
@@ -63,5 +64,6 @@ public interface IEducationPaperParamService
EducationPaperParam selectEducationPaperParamByTaskId(String taskId); EducationPaperParam selectEducationPaperParamByTaskId(String taskId);
List<String> getAppWhiteList(String taskId);
} }

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pc.exam.pp.module.exam.dal.mysql.paper.ExamWhiteListMapper">
<resultMap type="ExamWhiteListDO" id="ExamWhiteListDOResult">
<result property="id" column="id"/>
<result property="taskId" column="task_id"/>
<result property="name" column="name"/>
</resultMap>
<insert id="insertBatch">
INSERT INTO exam_white_list (name,task_id)
VALUES
<foreach collection="list" item="item" separator=",">
(#{item.name}, #{item.taskId})
</foreach>
</insert>
<delete id="deleteByTaskId">
DELETE FROM exam_white_list WHERE task_id = #{taskId}
</delete>
<select id="selectByTaskId" resultMap="ExamWhiteListDOResult">
select name from exam_white_list where task_id =#{taskId}
</select>
<select id="selectNameByTaskId" resultType="java.lang.String">
select name from exam_white_list where task_id =#{taskId}
</select>
</mapper>

View File

@@ -118,7 +118,7 @@ public class CellIng {
String formula = cell.getCellFormula(); String formula = cell.getCellFormula();
// 转为小写再比较 // 转为小写再比较
if (formula.toLowerCase().contains(keyWords.toLowerCase())) { if (formula.toLowerCase().contains(keyWords.toLowerCase())) {
return formula; // 包含关键字时返回公式内容 return keyWords; // 包含关键字时返回公式内容
} else { } else {
return ""; // 不包含关键字 return ""; // 不包含关键字
} }

View File

@@ -293,6 +293,7 @@ exam:
- /jmreport/* # 积木报表,无法携带租户编号 - /jmreport/* # 积木报表,无法携带租户编号
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号 - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号
- /admin-api/exam/app/getAppCheckList/* # 学生端环境监测 - /admin-api/exam/app/getAppCheckList/* # 学生端环境监测
- /admin-api/exam/param/getAppWhiteList/* # 学生端环境监测
- /admin-api/system/auth/login_config # 学生端判断学生的登录方式 - /admin-api/system/auth/login_config # 学生端判断学生的登录方式
- /admin-api/system/auth/refreshLogout # 登出用户 - /admin-api/system/auth/refreshLogout # 登出用户
ignore-tables: ignore-tables:
@@ -303,6 +304,7 @@ exam:
- exam_knowledge_points - exam_knowledge_points
- exam_specialty - exam_specialty
- exam_app_check - exam_app_check
- exam_white_list
- system_tenant - system_tenant
- system_tenant_package - system_tenant_package
- system_dict_data - system_dict_data