|
@@ -0,0 +1,91 @@
|
|
|
|
|
+package com.jeeplus.assess.program.issueRecord.service;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import cn.hutool.extra.spring.SpringUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import com.jeeplus.assess.program.commonIssue.mapper.CommonIssueMapper;
|
|
|
|
|
+import com.jeeplus.assess.program.issueRecord.domain.IssueRecord;
|
|
|
|
|
+import com.jeeplus.assess.program.issueRecord.mapper.IssueRecordMapper;
|
|
|
|
|
+import com.jeeplus.sys.feign.IUserApi;
|
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
+
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+
|
|
|
|
|
+@Service
|
|
|
|
|
+@Transactional
|
|
|
|
|
+public class IssueRecordService extends ServiceImpl<IssueRecordMapper, IssueRecord> {
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IssueRecordMapper issueRecordMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private CommonIssueMapper commonIssueMapper;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 批量保存漏洞标记记录(驳回时调用)
|
|
|
|
|
+ * @param projectId 项目ID
|
|
|
|
|
+ * @param auditId 校审记录ID
|
|
|
|
|
+ * @param auditLevel 校审级别
|
|
|
|
|
+ * @param issueIds 选中的漏洞ID列表
|
|
|
|
|
+ * @param targetUserId 被标记人(提交人)ID
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResponseEntity saveIssueRecords(String projectId, String auditId, String auditLevel,
|
|
|
|
|
+ List<String> issueIds, String targetUserId) {
|
|
|
|
|
+ if (issueIds == null || issueIds.isEmpty()) {
|
|
|
|
|
+ return ResponseEntity.ok("保存成功");
|
|
|
|
|
+ }
|
|
|
|
|
+ String currentUserId = SpringUtil.getBean(IUserApi.class).getById(targetUserId).getId();
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+ for (String issueId : issueIds) {
|
|
|
|
|
+ IssueRecord record = new IssueRecord();
|
|
|
|
|
+ record.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
|
|
+ record.setProjectId(projectId);
|
|
|
|
|
+ record.setAuditId(auditId);
|
|
|
|
|
+ record.setAuditLevel(auditLevel);
|
|
|
|
|
+ record.setIssueId(issueId);
|
|
|
|
|
+ record.setTargetUserId(targetUserId);
|
|
|
|
|
+ record.setMarkUserId(currentUserId);
|
|
|
|
|
+ record.setMarkTime(now);
|
|
|
|
|
+ record.setDelFlag(0);
|
|
|
|
|
+ record.setCreateById(currentUserId);
|
|
|
|
|
+ record.setCreateTime(now);
|
|
|
|
|
+ this.save(record);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResponseEntity.ok("保存成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除标记记录(管理员操作)
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResponseEntity deleteByIds(String ids) {
|
|
|
|
|
+ String[] idArray = ids.split(",");
|
|
|
|
|
+ this.removeByIds(Arrays.asList(idArray));
|
|
|
|
|
+ return ResponseEntity.ok("删除成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询用户在各校审级别下超过阈值的漏洞提醒
|
|
|
|
|
+ * @param targetUserId 被标记人ID
|
|
|
|
|
+ * @param auditLevel 校审级别
|
|
|
|
|
+ * @return 超过阈值的漏洞列表
|
|
|
|
|
+ */
|
|
|
|
|
+ public List<Map<String, Object>> findOverThresholdIssues(String targetUserId, String auditLevel) {
|
|
|
|
|
+ if (StrUtil.isBlank(targetUserId) || StrUtil.isBlank(auditLevel)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return issueRecordMapper.findOverThresholdIssues(targetUserId, auditLevel);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除某条校审记录关联的所有漏洞标记(用于管理员删除校审记录时联动)
|
|
|
|
|
+ */
|
|
|
|
|
+ public void deleteByAuditId(String auditId) {
|
|
|
|
|
+ if (StrUtil.isNotBlank(auditId)) {
|
|
|
|
|
+ this.remove(new QueryWrapper<IssueRecord>().eq("audit_id", auditId));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|