From 9c456f2fa8d487b0bc94c150c9d404393b9ed02f Mon Sep 17 00:00:00 2001 From: huababa1 <2037205722@qq.com> Date: Wed, 29 Oct 2025 12:07:56 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=9D=83=E9=99=90=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95=EF=BC=8C=E4=BF=AE=E6=94=B9mac=E5=9C=B0?= =?UTF-8?q?=E5=9D=80=E7=9A=84=E6=A0=A1=E9=AA=8C=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paper/EducationPaperParamController.java | 12 +--- .../EducationPaperWhiteAppController.java | 65 ++++++++++++++++++ .../admin/paper/vo/PaperWhitePageVo.java | 22 ++++++ .../dal/dataobject/EducationPaperParam.java | 4 +- .../exam/dal/dataobject/ExamWhiteListDO.java | 8 ++- .../dal/mysql/paper/ExamWhiteListMapper.java | 15 ++++- .../paper/EducationPaperParamServiceImpl.java | 67 +++++++++---------- .../paper/EducationPaperTaskServiceImpl.java | 26 +++---- .../paper/IEducationPaperParamService.java | 2 +- .../paper/IEducationPaperWhiteService.java | 22 ++++++ .../IEducationPaperWhiteServiceImpl.java | 47 +++++++++++++ .../mapper/exam/ExamWhiteListMapper.xml | 6 +- .../system/enums/ErrorCodeConstants.java | 1 + .../permission/PermissionController.java | 10 +-- .../controller/admin/user/UserController.java | 16 ++--- .../system/dal/mysql/tenant/TenantMapper.java | 4 ++ .../service/auth/AdminAuthServiceImpl.java | 12 ++++ .../exam/pp/server/config/MacValidator.java | 49 -------------- .../pp/server/config/SystemMacProperties.java | 18 ----- .../src/main/resources/application-local.yaml | 3 +- .../src/main/resources/application.yaml | 1 - 21 files changed, 258 insertions(+), 152 deletions(-) create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperWhiteAppController.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/PaperWhitePageVo.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperWhiteService.java create mode 100644 exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperWhiteServiceImpl.java delete mode 100644 exam-server/src/main/java/pc/exam/pp/server/config/MacValidator.java delete mode 100644 exam-server/src/main/java/pc/exam/pp/server/config/SystemMacProperties.java diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperParamController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperParamController.java index 251a038d..a8ba3f8a 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperParamController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperParamController.java @@ -8,6 +8,7 @@ import org.checkerframework.checker.units.qual.C; 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.framework.tenant.core.aop.TenantIgnore; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO; @@ -109,16 +110,5 @@ public class EducationPaperParamController { } return CommonResult.success("200"); } - - @GetMapping("/getAppWhiteList/{taskId}") - @PermitAll - @TenantIgnore - @Operation(summary = "查看白名单列表", description = "查看白名单列表") - public CommonResult> getAppWhiteList(@PathVariable("taskId") String taskId){ - // 使用传入的IP,进行ping,查看是否存在连接,并返回信号的强度 - System.out.println(educationPaperParamService.getAppWhiteList(taskId)); - - return success(educationPaperParamService.getAppWhiteList(taskId)); - } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperWhiteAppController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperWhiteAppController.java new file mode 100644 index 00000000..67214023 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperWhiteAppController.java @@ -0,0 +1,65 @@ +package pc.exam.pp.module.exam.controller.admin.paper; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import pc.exam.pp.framework.common.pojo.CommonResult; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.common.util.object.BeanUtils; +import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo; +import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperWhitePageVo; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; +import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO; +import pc.exam.pp.module.exam.service.paper.IEducationPaperParamService; +import pc.exam.pp.module.exam.service.paper.IEducationPaperWhiteService; + +import java.util.List; + +import static pc.exam.pp.framework.common.pojo.CommonResult.success; +@Tag(name = "管理后台 - 试卷通用参数") +@RestController +@RequestMapping("/exam/white") +public class EducationPaperWhiteAppController { + @Autowired + private IEducationPaperWhiteService educationPaperWhiteService; + + + @Operation(summary = "新增白名单") + @PostMapping("/addAppWhite") + public CommonResult addAppWhite(@RequestBody ExamWhiteListDO ExamWhiteListDO) { + return CommonResult.success(educationPaperWhiteService.insertWhiteApp(ExamWhiteListDO)); + } + @Operation(summary = "获取白名单详细信息") + @GetMapping(value = "/getWhite") + public CommonResult getWhite(@RequestParam("id") String id) { + ExamWhiteListDO examWhiteListDO = educationPaperWhiteService.selectWhiteById(id); + return CommonResult.success(examWhiteListDO); + } + @PutMapping("/updateAppWhite") + @Operation(summary = "修改白名单列表", description = "修改白名单列表") + public CommonResult updateAppWhite(@RequestBody ExamWhiteListDO ExamWhiteListDO) { + + return success(educationPaperWhiteService.updateAppList(ExamWhiteListDO)); + } + + @GetMapping("/getAppWhiteList") + @Operation(summary = "学生端查看白名单列表", description = "查看白名单列表") + public CommonResult> getAppWhiteList(){ + + return success(educationPaperWhiteService.getAppWhiteListString()); + } + @GetMapping("/getAppWhiteListCenter") + @Operation(summary = "中心端查看白名单列表", description = "查看白名单列表") + public CommonResult> getAppWhiteListCenter(PaperWhitePageVo paperWhitePageVo) { + //获取租户id +// Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId(); + PageResult appWhiteList = educationPaperWhiteService.getAppWhiteList(paperWhitePageVo); + return CommonResult.success(BeanUtils.toBean(appWhiteList, ExamWhiteListDO.class)); + } + @Operation(summary = "删除白名单") + @DeleteMapping("/delWhite/{id}") + public CommonResult removeAppWhite(@PathVariable String id) { + return CommonResult.success(educationPaperWhiteService.deleteWhiteAppByParamIds(id)); + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/PaperWhitePageVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/PaperWhitePageVo.java new file mode 100644 index 00000000..f7f78f59 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/vo/PaperWhitePageVo.java @@ -0,0 +1,22 @@ +package pc.exam.pp.module.exam.controller.admin.paper.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; +import pc.exam.pp.framework.common.pojo.PageParam; + +import java.time.LocalDateTime; + +import static pc.exam.pp.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "白名单vo") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class PaperWhitePageVo extends PageParam { + + private String name; + +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java index a8c01fef..f210efb3 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperParam.java @@ -93,7 +93,5 @@ public class EducationPaperParam private String isScoreDetail; // 是否删除考生文件 private String isDelete; - // 白名单 - @TableField(exist = false) - private List whiteList; + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamWhiteListDO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamWhiteListDO.java index 0c37cb0e..d59d2b48 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamWhiteListDO.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamWhiteListDO.java @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.*; +import pc.exam.pp.framework.tenant.core.db.TenantBaseDO; @TableName("exam_white_list") @Data @@ -11,9 +12,12 @@ import lombok.*; @Builder @NoArgsConstructor @AllArgsConstructor -public class ExamWhiteListDO { +public class ExamWhiteListDO { @TableId private Long id; - private String taskId; private String name; + /** + * 多租户编号 + */ + private Long tenantId; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/ExamWhiteListMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/ExamWhiteListMapper.java index 21c2b18b..39abd567 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/ExamWhiteListMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/ExamWhiteListMapper.java @@ -3,7 +3,12 @@ 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.common.pojo.PageResult; import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo; +import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperWhitePageVo; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaperParam; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO; @@ -15,5 +20,13 @@ public interface ExamWhiteListMapper extends BaseMapperX { void deleteByTaskId(String taskId); - List selectNameByTaskId(String taskId); + List selectNameByTaskId(); + + + int deleteWhiteById(String id); + + default PageResult getAppWhiteList(PaperWhitePageVo paperWhitePageVo) { + return selectPage(paperWhitePageVo, new LambdaQueryWrapperX() + .likeIfPresent(ExamWhiteListDO::getName, paperWhitePageVo.getName())); + } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperParamServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperParamServiceImpl.java index cac7003a..51dde8ae 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperParamServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperParamServiceImpl.java @@ -25,8 +25,7 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi private EducationPaperParamMapper educationPaperParamMapper; @Autowired private EducationPaperTaskMapper educationPaperTaskMapper; - @Autowired - private ExamWhiteListMapper examWhiteListMapper; + /** * 查询通用参数 @@ -61,16 +60,16 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi @Override public int insertEducationPaperParam(EducationPaperParam educationPaperParam) { - List 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); - } +// List 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); } @@ -83,20 +82,20 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi @Override public int updateEducationPaperParam(EducationPaperParam educationPaperParam) { - List 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); - } - } +// List 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); } @@ -126,19 +125,13 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi @Override public EducationPaperParam selectEducationPaperParamByTaskId(String taskId) { - List whiteList = examWhiteListMapper.selectByTaskId(taskId); - EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); - if (whiteList != null && !whiteList.isEmpty()) { - educationPaperParam.setWhiteList(whiteList); - } - return educationPaperParam; +// List whiteList = examWhiteListMapper.selectByTaskId(taskId); +// if (whiteList != null && !whiteList.isEmpty()) { +// educationPaperParam.setWhiteList(whiteList); +// } + return educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); } - - @Override - public List getAppWhiteList(String taskId) { - return examWhiteListMapper.selectNameByTaskId(taskId); - } } 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 357052dd..806e6c0e 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 @@ -192,12 +192,12 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService } else { educationPaperTask.setIsOne("1"); } - List whiteList = new ArrayList<>(); - ExamWhiteListDO examWhiteListDO=new ExamWhiteListDO(); - examWhiteListDO.setTaskId(uuid); - examWhiteListDO.setName("ExamStudent"); - whiteList.add(examWhiteListDO); - examWhiteListMapper.insertBatch(whiteList); +// List whiteList = new ArrayList<>(); +// ExamWhiteListDO examWhiteListDO=new ExamWhiteListDO(); +// examWhiteListDO.setTaskId(uuid); +// examWhiteListDO.setName("ExamStudent"); +// whiteList.add(examWhiteListDO); +// examWhiteListMapper.insertBatch(whiteList); @@ -551,13 +551,13 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService educationPaperTask.setCreateTime(now); educationPaperTask.setIsTemplate(1); //白名单 - List whiteList = examWhiteListMapper.selectByTaskId(taskId); - if (whiteList != null && !whiteList.isEmpty()) { - for (ExamWhiteListDO examWhiteListDO : whiteList) { - examWhiteListDO.setTaskId(newtaskId); - } - examWhiteListMapper.insertBatch(whiteList); - } +// List whiteList = examWhiteListMapper.selectByTaskId(taskId); +// if (whiteList != null && !whiteList.isEmpty()) { +// for (ExamWhiteListDO examWhiteListDO : whiteList) { +// examWhiteListDO.setTaskId(newtaskId); +// } +// examWhiteListMapper.insertBatch(whiteList); +// } educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask); if (options.contains("1")) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperParamService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperParamService.java index b3fb3ceb..fb254364 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperParamService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperParamService.java @@ -64,6 +64,6 @@ public interface IEducationPaperParamService EducationPaperParam selectEducationPaperParamByTaskId(String taskId); - List getAppWhiteList(String taskId); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperWhiteService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperWhiteService.java new file mode 100644 index 00000000..fc487150 --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperWhiteService.java @@ -0,0 +1,22 @@ +package pc.exam.pp.module.exam.service.paper; + +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperWhitePageVo; +import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; +import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO; + +import java.util.List; + +public interface IEducationPaperWhiteService { + PageResult getAppWhiteList(PaperWhitePageVo paperWhitePageVo); + + int updateAppList(ExamWhiteListDO ExamWhiteListDO); + + int insertWhiteApp(ExamWhiteListDO examWhiteListDO); + + int deleteWhiteAppByParamIds(String id); + + ExamWhiteListDO selectWhiteById(String id); + + List getAppWhiteListString(); +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperWhiteServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperWhiteServiceImpl.java new file mode 100644 index 00000000..4710dbfd --- /dev/null +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperWhiteServiceImpl.java @@ -0,0 +1,47 @@ +package pc.exam.pp.module.exam.service.paper; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperWhitePageVo; +import pc.exam.pp.module.exam.dal.dataobject.ExamWhiteListDO; +import pc.exam.pp.module.exam.dal.mysql.paper.ExamWhiteListMapper; + +import java.util.List; + +@Service +public class IEducationPaperWhiteServiceImpl implements IEducationPaperWhiteService{ + @Autowired + private ExamWhiteListMapper examWhiteListMapper; + + + @Override + public PageResult getAppWhiteList(PaperWhitePageVo paperWhitePageVo) { + return examWhiteListMapper.getAppWhiteList(paperWhitePageVo); + } + + @Override + public int updateAppList(ExamWhiteListDO ExamWhiteListDO) { + return examWhiteListMapper.updateById(ExamWhiteListDO); + } + + @Override + public int insertWhiteApp(ExamWhiteListDO examWhiteListDO) { + return examWhiteListMapper.insert(examWhiteListDO); + } + + @Override + public int deleteWhiteAppByParamIds(String id) { + return examWhiteListMapper.deleteWhiteById(id); + } + + @Override + public ExamWhiteListDO selectWhiteById(String id) { + return examWhiteListMapper.selectById(id); + } + + @Override + public List getAppWhiteListString() { + return examWhiteListMapper.selectNameByTaskId(); + } +} diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamWhiteListMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamWhiteListMapper.xml index ac28b61c..8d0545d5 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamWhiteListMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamWhiteListMapper.xml @@ -20,11 +20,15 @@ DELETE FROM exam_white_list WHERE task_id = #{taskId} + + delete from exam_white_list where id =#{id} + 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 b951dbd8..90d6b655 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 @@ -19,6 +19,7 @@ public interface ErrorCodeConstants { ErrorCode AUTH_LOGIN_NICKNAME_NOT = new ErrorCode(1_002_000_009, "登录失败,账号昵称不正确"); ErrorCode AUTH_LOGIN_BAD_USERNAME_NOT = new ErrorCode(1_002_000_010, "登录失败,账号不正确"); + ErrorCode AUTH_LOGIN_BAD_MAC_NOT = new ErrorCode(1_002_000_011, "登录失败,MAC地址不正确"); // ========== 菜单模块 1-002-001-000 ========== ErrorCode MENU_NAME_DUPLICATE = new ErrorCode(1_002_001_000, "已经存在该名字的菜单"); ErrorCode MENU_PARENT_NOT_EXISTS = new ErrorCode(1_002_001_001, "父菜单不存在"); diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/permission/PermissionController.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/permission/PermissionController.java index 70606923..763d5e7b 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/permission/PermissionController.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/permission/PermissionController.java @@ -38,7 +38,7 @@ public class PermissionController { @Operation(summary = "获得角色拥有的菜单编号") @Parameter(name = "roleId", description = "角色编号", required = true) @GetMapping("/list-role-menus") - @PreAuthorize("@ss.hasPermission('system:permission:assign-role-menu')") +// @PreAuthorize("@ss.hasPermission('system:permission:assign-role-menu')") public CommonResult> getRoleMenuList(Long roleId) { return success(permissionService.getRoleMenuListByRoleId(roleId)); } @@ -52,7 +52,7 @@ public class PermissionController { @PostMapping("/assign-role-menu") @Operation(summary = "赋予角色菜单") - @PreAuthorize("@ss.hasPermission('system:permission:assign-role-menu')") +// @PreAuthorize("@ss.hasPermission('system:permission:assign-role-menu')") public CommonResult assignRoleMenu(@Validated @RequestBody PermissionAssignRoleMenuReqVO reqVO) { // 开启多租户的情况下,需要过滤掉未开通的菜单 tenantService.handleTenantMenu(menuIds -> reqVO.getMenuIds().removeIf(menuId -> !CollUtil.contains(menuIds, menuId))); @@ -64,7 +64,7 @@ public class PermissionController { @PostMapping("/assign-role-data-scope") @Operation(summary = "赋予角色数据权限") - @PreAuthorize("@ss.hasPermission('system:permission:assign-role-data-scope')") +// @PreAuthorize("@ss.hasPermission('system:permission:assign-role-data-scope')") public CommonResult assignRoleDataScope(@Valid @RequestBody PermissionAssignRoleDataScopeReqVO reqVO) { permissionService.assignRoleDataScope(reqVO.getRoleId(), reqVO.getDataScope(), reqVO.getDataScopeDeptIds()); return success(true); @@ -73,14 +73,14 @@ public class PermissionController { @Operation(summary = "获得管理员拥有的角色编号列表") @Parameter(name = "userId", description = "用户编号", required = true) @GetMapping("/list-user-roles") - @PreAuthorize("@ss.hasPermission('system:permission:assign-user-role')") +// @PreAuthorize("@ss.hasPermission('system:permission:assign-user-role')") public CommonResult> listAdminRoles(@RequestParam("userId") Long userId) { return success(permissionService.getUserRoleIdListByUserId(userId)); } @Operation(summary = "赋予用户角色") @PostMapping("/assign-user-role") - @PreAuthorize("@ss.hasPermission('system:permission:assign-user-role')") +// @PreAuthorize("@ss.hasPermission('system:permission:assign-user-role')") public CommonResult assignUserRole(@Validated @RequestBody PermissionAssignUserRoleReqVO reqVO) { permissionService.assignUserRole(reqVO.getUserId(), reqVO.getRoleIds()); return success(true); diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java index ac8ea81e..0073fcf9 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/user/UserController.java @@ -60,7 +60,7 @@ public class UserController { @PostMapping("/create") @Operation(summary = "新增用户") - @PreAuthorize("@ss.hasPermission('system:user:create')") +// @PreAuthorize("@ss.hasPermission('system:user:create')") public CommonResult createUser(@Valid @RequestBody UserSaveReqVO reqVO) { Long id = userService.createUser(reqVO); return success(id); @@ -82,7 +82,7 @@ public class UserController { @PutMapping("update") @Operation(summary = "修改用户") - @PreAuthorize("@ss.hasPermission('system:user:update')") +// @PreAuthorize("@ss.hasPermission('system:user:update')") public CommonResult updateUser(@Valid @RequestBody UserSaveReqVO reqVO) { userService.updateUser(reqVO); return success(true); @@ -106,7 +106,7 @@ public class UserController { @DeleteMapping("/delete") @Operation(summary = "删除用户") @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('system:user:delete')") +// @PreAuthorize("@ss.hasPermission('system:user:delete')") public CommonResult deleteUser(@RequestParam("id") Long id) { userService.deleteUser(id); return success(true); @@ -114,7 +114,7 @@ public class UserController { @PutMapping("/update-password") @Operation(summary = "重置用户密码") - @PreAuthorize("@ss.hasPermission('system:user:update-password')") +// @PreAuthorize("@ss.hasPermission('system:user:update-password')") public CommonResult updateUserPassword(@Valid @RequestBody UserUpdatePasswordReqVO reqVO) { userService.updateUserPassword(reqVO.getId(), reqVO.getPassword()); return success(true); @@ -122,7 +122,7 @@ public class UserController { @PutMapping("/update-status") @Operation(summary = "修改用户状态") - @PreAuthorize("@ss.hasPermission('system:user:update')") +// @PreAuthorize("@ss.hasPermission('system:user:update')") public CommonResult updateUserStatus(@Valid @RequestBody UserUpdateStatusReqVO reqVO) { userService.updateUserStatus(reqVO.getId(), reqVO.getStatus()); return success(true); @@ -172,7 +172,7 @@ public class UserController { @GetMapping("/get") @Operation(summary = "获得用户详情") @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('system:user:query')") +// @PreAuthorize("@ss.hasPermission('system:user:query')") public CommonResult getUser(@RequestParam("id") Long id) { AdminUserDO user = userService.getUser(id); if (user == null) { @@ -199,7 +199,7 @@ public class UserController { @GetMapping("/export") @Operation(summary = "导出用户") - @PreAuthorize("@ss.hasPermission('system:user:export')") +// @PreAuthorize("@ss.hasPermission('system:user:export')") @ApiAccessLog(operateType = EXPORT) public void exportUserList(@Validated UserPageReqVO exportReqVO, HttpServletResponse response) throws IOException { @@ -262,7 +262,7 @@ public class UserController { @Parameter(name = "file", description = "Excel 文件", required = true), @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true") }) - @PreAuthorize("@ss.hasPermission('system:user:import')") +// @PreAuthorize("@ss.hasPermission('system:user:import')") public CommonResult importExcel(@RequestParam("file") MultipartFile file, @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception { List list = ExcelUtils.read(file, UserImportExcelVO.class); diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantMapper.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantMapper.java index 614566d2..cf0f8a42 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantMapper.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantMapper.java @@ -47,4 +47,8 @@ public interface TenantMapper extends BaseMapperX { return selectList(TenantDO::getStatus, status); } + + default TenantDO selectMacByTenantId(Long tenantId) { + return selectOne(TenantDO::getId, tenantId); + } } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/auth/AdminAuthServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/auth/AdminAuthServiceImpl.java index 55c5c74d..bbb3201f 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/auth/AdminAuthServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/auth/AdminAuthServiceImpl.java @@ -16,7 +16,9 @@ import pc.exam.pp.module.system.api.social.dto.SocialUserRespDTO; import pc.exam.pp.module.system.controller.admin.auth.vo.*; import pc.exam.pp.module.system.convert.auth.AuthConvert; import pc.exam.pp.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; import pc.exam.pp.module.system.dal.dataobject.user.AdminUserDO; +import pc.exam.pp.module.system.dal.mysql.tenant.TenantMapper; import pc.exam.pp.module.system.enums.logger.LoginLogTypeEnum; import pc.exam.pp.module.system.enums.logger.LoginResultEnum; import pc.exam.pp.module.system.enums.oauth2.OAuth2ClientConstants; @@ -37,6 +39,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import pc.exam.pp.module.system.util.oauth2.MacUtils; import java.util.Objects; @@ -71,6 +74,8 @@ public class AdminAuthServiceImpl implements AdminAuthService { private SmsCodeApi smsCodeApi; @Resource private ConfigService configService; + @Resource + private TenantMapper tenantMapper; /** * 验证码的开关,默认为 true */ @@ -156,6 +161,13 @@ public class AdminAuthServiceImpl implements AdminAuthService { } else { // 使用账号密码,进行登录 user = authenticate(reqVO.getUsername(), reqVO.getPassword()); + Long tenantId = user.getTenantId(); + TenantDO tenantDO= tenantMapper.selectMacByTenantId(tenantId); + String website = tenantDO.getWebsite(); + String physicalMac = MacUtils.getPhysicalMac(); + if (!physicalMac.equals(website)){ + throw exception(AUTH_LOGIN_BAD_MAC_NOT); + } } // 如果 socialType 非空,说明需要绑定社交用户 if (reqVO.getSocialType() != null) { diff --git a/exam-server/src/main/java/pc/exam/pp/server/config/MacValidator.java b/exam-server/src/main/java/pc/exam/pp/server/config/MacValidator.java deleted file mode 100644 index f7c9d17e..00000000 --- a/exam-server/src/main/java/pc/exam/pp/server/config/MacValidator.java +++ /dev/null @@ -1,49 +0,0 @@ -package pc.exam.pp.server.config; - - -import jakarta.annotation.PostConstruct; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; -import pc.exam.pp.module.system.util.oauth2.MacUtils; - -import java.util.List; - -@Slf4j -@Component -public class MacValidator { - - private final SystemMacProperties macProperties; - - public MacValidator(SystemMacProperties macProperties) { - this.macProperties = macProperties; - } - - @PostConstruct - public void validateMac() { - try { - String localMac = String.valueOf(MacUtils.getPhysicalMac()); - if (localMac == null || localMac.isEmpty()) { - throw new IllegalStateException("无法获取本机 MAC 地址!"); - } - - String allowed = macProperties.getAllowedMac(); - if (allowed == null || allowed.isEmpty()) { - throw new IllegalStateException("系统未配置允许的 MAC 地址!"); - } - - boolean match = normalize(allowed).equals(normalize(localMac)); - if (!match) { - throw new IllegalStateException("该机器 MAC 地址未授权!本机:" + localMac); - } - - log.info("✅ MAC 验证通过,本机 MAC: {}", localMac); - } catch (Exception e) { - log.error("❌ MAC 验证失败: {}", e.getMessage()); - System.exit(1); // 阻止启动 - } - } - - private String normalize(String mac) { - return mac == null ? "" : mac.replaceAll("[-:]", "").toUpperCase(); - } -} diff --git a/exam-server/src/main/java/pc/exam/pp/server/config/SystemMacProperties.java b/exam-server/src/main/java/pc/exam/pp/server/config/SystemMacProperties.java deleted file mode 100644 index a5189b2a..00000000 --- a/exam-server/src/main/java/pc/exam/pp/server/config/SystemMacProperties.java +++ /dev/null @@ -1,18 +0,0 @@ -package pc.exam.pp.server.config; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -import java.util.List; - -@Data -@Component -@ConfigurationProperties(prefix = "system") // 对应 application.yml 中的 system: 节点 -public class SystemMacProperties { - - /** - * 允许的 MAC 地址列表 - */ - private String allowedMac; -} diff --git a/exam-server/src/main/resources/application-local.yaml b/exam-server/src/main/resources/application-local.yaml index 52a72db5..0fe9ddb3 100644 --- a/exam-server/src/main/resources/application-local.yaml +++ b/exam-server/src/main/resources/application-local.yaml @@ -263,5 +263,4 @@ justauth: pf4j: # pluginsDir: /tmp/ pluginsDir: ../plugins -system: - allowed-mac: E4-54-E8-25-F6-14 + diff --git a/exam-server/src/main/resources/application.yaml b/exam-server/src/main/resources/application.yaml index c5932993..237c17a8 100644 --- a/exam-server/src/main/resources/application.yaml +++ b/exam-server/src/main/resources/application.yaml @@ -304,7 +304,6 @@ exam: - exam_knowledge_points - exam_specialty - exam_app_check - - exam_white_list - system_tenant - system_tenant_package - system_dict_data -- 2.49.1