【修改】删除权限,增加白名单,修改mac地址的校验方式
This commit is contained in:
@@ -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<List<String>> getAppWhiteList(@PathVariable("taskId") String taskId){
|
||||
// 使用传入的IP,进行ping,查看是否存在连接,并返回信号的强度
|
||||
System.out.println(educationPaperParamService.getAppWhiteList(taskId));
|
||||
|
||||
return success(educationPaperParamService.getAppWhiteList(taskId));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<List<String>> getAppWhiteList(){
|
||||
|
||||
return success(educationPaperWhiteService.getAppWhiteListString());
|
||||
}
|
||||
@GetMapping("/getAppWhiteListCenter")
|
||||
@Operation(summary = "中心端查看白名单列表", description = "查看白名单列表")
|
||||
public CommonResult<PageResult<ExamWhiteListDO>> getAppWhiteListCenter(PaperWhitePageVo paperWhitePageVo) {
|
||||
//获取租户id
|
||||
// Long loginTenantId = SecurityFrameworkUtils.getLoginTenantId();
|
||||
PageResult<ExamWhiteListDO> 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));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -93,7 +93,5 @@ public class EducationPaperParam
|
||||
private String isScoreDetail;
|
||||
// 是否删除考生文件
|
||||
private String isDelete;
|
||||
// 白名单
|
||||
@TableField(exist = false)
|
||||
private List<ExamWhiteListDO> whiteList;
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<ExamWhiteListDO> {
|
||||
|
||||
void deleteByTaskId(String taskId);
|
||||
|
||||
List<String> selectNameByTaskId(String taskId);
|
||||
List<String> selectNameByTaskId();
|
||||
|
||||
|
||||
int deleteWhiteById(String id);
|
||||
|
||||
default PageResult<ExamWhiteListDO> getAppWhiteList(PaperWhitePageVo paperWhitePageVo) {
|
||||
return selectPage(paperWhitePageVo, new LambdaQueryWrapperX<ExamWhiteListDO>()
|
||||
.likeIfPresent(ExamWhiteListDO::getName, paperWhitePageVo.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<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);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -83,20 +82,20 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
|
||||
@@ -126,19 +125,13 @@ public class EducationPaperParamServiceImpl implements IEducationPaperParamServi
|
||||
|
||||
@Override
|
||||
public EducationPaperParam selectEducationPaperParamByTaskId(String taskId) {
|
||||
List<ExamWhiteListDO> whiteList = examWhiteListMapper.selectByTaskId(taskId);
|
||||
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
|
||||
if (whiteList != null && !whiteList.isEmpty()) {
|
||||
educationPaperParam.setWhiteList(whiteList);
|
||||
}
|
||||
return educationPaperParam;
|
||||
// List<ExamWhiteListDO> whiteList = examWhiteListMapper.selectByTaskId(taskId);
|
||||
// if (whiteList != null && !whiteList.isEmpty()) {
|
||||
// educationPaperParam.setWhiteList(whiteList);
|
||||
// }
|
||||
return educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAppWhiteList(String taskId) {
|
||||
return examWhiteListMapper.selectNameByTaskId(taskId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -192,12 +192,12 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
||||
} else {
|
||||
educationPaperTask.setIsOne("1");
|
||||
}
|
||||
List<ExamWhiteListDO> whiteList = new ArrayList<>();
|
||||
ExamWhiteListDO examWhiteListDO=new ExamWhiteListDO();
|
||||
examWhiteListDO.setTaskId(uuid);
|
||||
examWhiteListDO.setName("ExamStudent");
|
||||
whiteList.add(examWhiteListDO);
|
||||
examWhiteListMapper.insertBatch(whiteList);
|
||||
// List<ExamWhiteListDO> 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<ExamWhiteListDO> whiteList = examWhiteListMapper.selectByTaskId(taskId);
|
||||
if (whiteList != null && !whiteList.isEmpty()) {
|
||||
for (ExamWhiteListDO examWhiteListDO : whiteList) {
|
||||
examWhiteListDO.setTaskId(newtaskId);
|
||||
}
|
||||
examWhiteListMapper.insertBatch(whiteList);
|
||||
}
|
||||
// List<ExamWhiteListDO> 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")) {
|
||||
|
||||
@@ -64,6 +64,6 @@ public interface IEducationPaperParamService
|
||||
|
||||
EducationPaperParam selectEducationPaperParamByTaskId(String taskId);
|
||||
|
||||
List<String> getAppWhiteList(String taskId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ExamWhiteListDO> getAppWhiteList(PaperWhitePageVo paperWhitePageVo);
|
||||
|
||||
int updateAppList(ExamWhiteListDO ExamWhiteListDO);
|
||||
|
||||
int insertWhiteApp(ExamWhiteListDO examWhiteListDO);
|
||||
|
||||
int deleteWhiteAppByParamIds(String id);
|
||||
|
||||
ExamWhiteListDO selectWhiteById(String id);
|
||||
|
||||
List<String> getAppWhiteListString();
|
||||
}
|
||||
@@ -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<ExamWhiteListDO> 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<String> getAppWhiteListString() {
|
||||
return examWhiteListMapper.selectNameByTaskId();
|
||||
}
|
||||
}
|
||||
@@ -20,11 +20,15 @@
|
||||
<delete id="deleteByTaskId">
|
||||
DELETE FROM exam_white_list WHERE task_id = #{taskId}
|
||||
</delete>
|
||||
<delete id="deleteWhiteById">
|
||||
delete from exam_white_list where id =#{id}
|
||||
</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 DISTINCT name
|
||||
FROM exam_white_list
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user