diff --git a/src/main/java/net/educoder/ecsonar/controller/QualityInspectController.java b/src/main/java/net/educoder/ecsonar/controller/QualityInspectController.java index 4985fc5..f90dbb2 100644 --- a/src/main/java/net/educoder/ecsonar/controller/QualityInspectController.java +++ b/src/main/java/net/educoder/ecsonar/controller/QualityInspectController.java @@ -129,7 +129,7 @@ public class QualityInspectController { */ @GetMapping("/problemAnalysis") @ResponseBody - public ResponseResult problemAnalysis(@RequestParam Integer ruleId) { + public ResponseResult problemAnalysis(@RequestParam String ruleId) { ProblemAnalysisDTO problemAnalysis = qualityInspectService.getProblemAnalysis(ruleId); return ResponseResult.success(problemAnalysis); } diff --git a/src/main/java/net/educoder/ecsonar/dao/IssuesDao.java b/src/main/java/net/educoder/ecsonar/dao/IssuesDao.java index 1073116..fcd6447 100644 --- a/src/main/java/net/educoder/ecsonar/dao/IssuesDao.java +++ b/src/main/java/net/educoder/ecsonar/dao/IssuesDao.java @@ -2,6 +2,7 @@ package net.educoder.ecsonar.dao; import net.educoder.ecsonar.model.Issues; import net.educoder.ecsonar.model.dto.DegreeDTO; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -38,9 +39,10 @@ public interface IssuesDao { * 查询不同程度的漏洞、缺陷、代码规范数量 * @param projectUuid * @param issueType + * @param metricUUid * @return */ - DegreeDTO queryDegree(String projectUuid, Integer issueType, Integer metricId); + DegreeDTO queryDegree(String projectUuid, Integer issueType, String metricUUid); /** @@ -48,5 +50,5 @@ public interface IssuesDao { * @param issueId * @return */ - Issues queryById(Long issueId); + Issues queryById(@Param("issueId") String issueId); } diff --git a/src/main/java/net/educoder/ecsonar/dao/ProjectDao.java b/src/main/java/net/educoder/ecsonar/dao/ProjectDao.java index ccb1482..e63251a 100644 --- a/src/main/java/net/educoder/ecsonar/dao/ProjectDao.java +++ b/src/main/java/net/educoder/ecsonar/dao/ProjectDao.java @@ -13,42 +13,66 @@ import org.springframework.stereotype.Repository; @Mapper public interface ProjectDao { - @Select("select * from projects where name = #{name}") + @Select("select uuid,kee,qualifier,name from projects where name = #{name}") Project findByName(@Param("name")String name); - @Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_id = 19 order by id desc limit 1") + /** + * 复杂度 + * @param uuid + * @return + */ + @Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_uuid = 'AYeNSwarTEppvP7II92z' limit 1") Float getComplexity(@Param("uuid") String uuid); - @Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_id = 1 order by id desc limit 1") + /** + * 代码行数 + * @param uuid + * @return + */ + @Select("select COALESCE(value,0) from project_measures where component_uuid = #{uuid} and metric_uuid = 'AYeNSwakTEppvP7II92h' limit 1") Integer getLines(@Param("uuid") String uuid); - @Select("select text_value from project_measures where component_uuid = #{uuid} and metric_id = #{metric_id} order by id desc limit 1") - String getLevel(@Param("uuid") String uuid, @Param("metric_id") int metric_id); + /** + * 等级 + * @param uuid + * @param metricUUid + * @return + */ + @Select("select text_value from project_measures where component_uuid = #{uuid} and metric_uuid = #{metric_uuid} limit 1") + String getLevel(@Param("uuid") String uuid, @Param("metric_uuid") String metricUUid); @Select("SELECT count(*) FROM issues where project_uuid=#{uuid} and " + "status='OPEN' and issue_type=#{issue_type} and severity=#{severity}") int getIndicator(@Param("uuid") String uuid, @Param("issue_type") int issue_type, @Param("severity") String severity); + /** + * 93 == AYeNSwayTEppvP7II93_ + * 89 == AYeNSwayTEppvP7II94B + * 80 == AYeNSwaxTEppvP7II93y + * 19 == AYeNSwarTEppvP7II92z + * @param projectUuid + * @return + */ @Select("select " + - "(select COALESCE(value,0) complexity from project_measures where component_uuid = #{projectUuid} and metric_id = 19 order by id desc limit 1)," + - "(select COALESCE(value,0) lines from project_measures where component_uuid = #{projectUuid} and metric_id = 1 order by id desc limit 1)," + + "(select COALESCE(value,0) complexity from project_measures where component_uuid = #{projectUuid} and metric_uuid = 'AYeNSwarTEppvP7II92z' limit 1)," + + "(select COALESCE(value,0) lines from project_measures where component_uuid = #{projectUuid} and metric_uuid = 'AYeNSwakTEppvP7II92h' limit 1)," + "(SELECT COALESCE(count(*),0) block_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='BLOCKER'), " + "(SELECT COALESCE(count(*),0) critical_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='CRITICAL')," + "(SELECT COALESCE(count(*),0) major_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='MAJOR')," + "(SELECT COALESCE(count(*),0) minor_code_smells FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=1 and severity='MINOR')," + - "(select text_value code_smells from project_measures where component_uuid = #{projectUuid} and metric_id = 80 order by id desc limit 1)," + + "(select text_value code_smells from project_measures where component_uuid = #{projectUuid} and metric_uuid = 'AYeNSwaxTEppvP7II93y' limit 1)," + "(SELECT COALESCE(count(*),0) block_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='BLOCKER'), " + "(SELECT COALESCE(count(*),0) critical_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='CRITICAL')," + "(SELECT COALESCE(count(*),0) major_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MAJOR')," + "(SELECT COALESCE(count(*),0) minor_bugs FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=2 and severity='MINOR')," + - "(select text_value bugs from project_measures where component_uuid = #{projectUuid} and metric_id = 89 order by id desc limit 1)," + + "(select text_value bugs from project_measures where component_uuid = #{projectUuid} and metric_uuid = 'AYeNSwayTEppvP7II94B' limit 1)," + "(SELECT COALESCE(count(*),0) block_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='BLOCKER'), " + "(SELECT COALESCE(count(*),0) critical_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='CRITICAL')," + "(SELECT COALESCE(count(*),0) major_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MAJOR')," + "(SELECT COALESCE(count(*),0) minor_violations FROM issues where project_uuid=#{projectUuid} and status='OPEN' and issue_type=3 and severity='MINOR')," + - "(select text_value violations from project_measures where component_uuid = #{projectUuid} and metric_id = 93 order by id desc limit 1)") + "(select text_value violations from project_measures where component_uuid = #{projectUuid} and metric_uuid = 'AYeNSwayTEppvP7II93_' limit 1)") Metrics selectMetricsByProjectUuid(String projectUuid); @@ -62,8 +86,8 @@ public interface ProjectDao { /** * 查询rule - * @param id + * @param uuid * @return */ - Rule findRuleById(@Param("id") Integer id); + Rule findRuleById(@Param("uuid") String uuid); } diff --git a/src/main/java/net/educoder/ecsonar/enums/AnalyseTypeEnum.java b/src/main/java/net/educoder/ecsonar/enums/AnalyseTypeEnum.java index 730cdf8..d612e43 100644 --- a/src/main/java/net/educoder/ecsonar/enums/AnalyseTypeEnum.java +++ b/src/main/java/net/educoder/ecsonar/enums/AnalyseTypeEnum.java @@ -8,17 +8,20 @@ package net.educoder.ecsonar.enums; */ public enum AnalyseTypeEnum { - CodeSmell(1,80), - BUG(2, 89), - Vulnerability(3,93); + CodeSmell(1,80, "AYeNSwaxTEppvP7II93y"), + BUG(2, 89, "AYeNSwayTEppvP7II94B"), + Vulnerability(3,93, "AYeNSwayTEppvP7II93_"); private Integer type; private Integer metricId; + private String metricUUId; - AnalyseTypeEnum(Integer type, Integer metricId) { + + AnalyseTypeEnum(Integer type, Integer metricId, String metricUUId) { this.type = type; this.metricId = metricId; + this.metricUUId = metricUUId; } @@ -30,6 +33,10 @@ public enum AnalyseTypeEnum { return metricId; } + public String getMetricUUId() { + return metricUUId; + } + public static AnalyseTypeEnum getAnalyseTypeEnum(Integer type) { for (AnalyseTypeEnum analyseType : values()) { if (analyseType.type.equals(type)) { diff --git a/src/main/java/net/educoder/ecsonar/model/FileSource.java b/src/main/java/net/educoder/ecsonar/model/FileSource.java index 5ec9645..9947d7c 100644 --- a/src/main/java/net/educoder/ecsonar/model/FileSource.java +++ b/src/main/java/net/educoder/ecsonar/model/FileSource.java @@ -22,7 +22,7 @@ public class FileSource { private static final String SIZE_LIMIT_EXCEEDED_EXCEPTION_MESSAGE = "Protocol message was too large. May be malicious. " + "Use CodedInputStream.setSizeLimit() to increase the size limit."; - private Long id; + private String uuid; private String projectUuid; private String fileUuid; private String lineHashes; @@ -36,7 +36,7 @@ public class FileSource { return decodeRegularSourceData(binaryData); } catch (IOException e) { throw new IllegalStateException( - format("Fail to decompress and deserialize source data [id=%s,fileUuid=%s,projectUuid=%s]", id, fileUuid, projectUuid), + format("Fail to decompress and deserialize source data [id=%s,fileUuid=%s,projectUuid=%s]", uuid, fileUuid, projectUuid), e); } } diff --git a/src/main/java/net/educoder/ecsonar/model/Issues.java b/src/main/java/net/educoder/ecsonar/model/Issues.java index 8ecf9d5..d7920a6 100644 --- a/src/main/java/net/educoder/ecsonar/model/Issues.java +++ b/src/main/java/net/educoder/ecsonar/model/Issues.java @@ -11,9 +11,8 @@ import lombok.Data; @Data public class Issues { - private Long id; - private String kee; - private Integer ruleId; + private String id; + private String ruleId; private String severity; private String message; private String status; @@ -26,10 +25,6 @@ public class Issues { * bug名称 */ private String name; - /** - * bug描述 - */ - private String description; /** * 文件路径 */ diff --git a/src/main/java/net/educoder/ecsonar/model/Project.java b/src/main/java/net/educoder/ecsonar/model/Project.java index 96e5855..f51446f 100644 --- a/src/main/java/net/educoder/ecsonar/model/Project.java +++ b/src/main/java/net/educoder/ecsonar/model/Project.java @@ -2,35 +2,36 @@ package net.educoder.ecsonar.model; public class Project { - private int id; + private String uuid; - private boolean enabled; + private String kee; + + private String qualifier; - private String project_uuid; private String name; - public boolean isEnabled() { - return enabled; + public String getUuid() { + return uuid; } - public void setEnabled(boolean enabled) { - this.enabled = enabled; + public void setUuid(String uuid) { + this.uuid = uuid; } - public int getId() { - return id; + public String getKee() { + return kee; } - public void setId(int id) { - this.id = id; + public void setKee(String kee) { + this.kee = kee; } - public String getProject_uuid() { - return project_uuid; + public String getQualifier() { + return qualifier; } - public void setProject_uuid(String project_uuid) { - this.project_uuid = project_uuid; + public void setQualifier(String qualifier) { + this.qualifier = qualifier; } public String getName() { diff --git a/src/main/java/net/educoder/ecsonar/model/dto/AnalyseDetailListDTO.java b/src/main/java/net/educoder/ecsonar/model/dto/AnalyseDetailListDTO.java index ec63d5d..58b848c 100644 --- a/src/main/java/net/educoder/ecsonar/model/dto/AnalyseDetailListDTO.java +++ b/src/main/java/net/educoder/ecsonar/model/dto/AnalyseDetailListDTO.java @@ -43,8 +43,8 @@ public class AnalyseDetailListDTO { */ private String uuid; - private Integer ruleId; + private String ruleId; - private Long issueId; + private String issueId; } diff --git a/src/main/java/net/educoder/ecsonar/model/vo/CodeDetailVO.java b/src/main/java/net/educoder/ecsonar/model/vo/CodeDetailVO.java index 7319900..ce73f3d 100644 --- a/src/main/java/net/educoder/ecsonar/model/vo/CodeDetailVO.java +++ b/src/main/java/net/educoder/ecsonar/model/vo/CodeDetailVO.java @@ -12,6 +12,6 @@ public class CodeDetailVO { private String uuid; - private Integer ruleId; - private Long issueId; + private String ruleId; + private String issueId; } diff --git a/src/main/java/net/educoder/ecsonar/services/CloudBrainService.java b/src/main/java/net/educoder/ecsonar/services/CloudBrainService.java index 2cf837a..68db269 100644 --- a/src/main/java/net/educoder/ecsonar/services/CloudBrainService.java +++ b/src/main/java/net/educoder/ecsonar/services/CloudBrainService.java @@ -151,7 +151,7 @@ public class CloudBrainService { return resultVO; } - IssuesMetrics issuesMetrics = projectDao.selectIssuesMetrics(project.getProject_uuid()); + IssuesMetrics issuesMetrics = projectDao.selectIssuesMetrics(project.getUuid()); resultVO.setTaskName(projectName); resultVO.setBugs(issuesMetrics.getBugs()); resultVO.setVulnerability(issuesMetrics.getVulnerability()); diff --git a/src/main/java/net/educoder/ecsonar/services/DbOperateService.java b/src/main/java/net/educoder/ecsonar/services/DbOperateService.java index 24823e3..32fecca 100644 --- a/src/main/java/net/educoder/ecsonar/services/DbOperateService.java +++ b/src/main/java/net/educoder/ecsonar/services/DbOperateService.java @@ -56,7 +56,7 @@ public class DbOperateService { if (project == null) { return null; } - return ceActivityDao.queryActivityStatus(project.getProject_uuid()); + return ceActivityDao.queryActivityStatus(project.getUuid()); } diff --git a/src/main/java/net/educoder/ecsonar/services/QualityInspectService.java b/src/main/java/net/educoder/ecsonar/services/QualityInspectService.java index b15236a..8c77bac 100644 --- a/src/main/java/net/educoder/ecsonar/services/QualityInspectService.java +++ b/src/main/java/net/educoder/ecsonar/services/QualityInspectService.java @@ -240,9 +240,9 @@ public class QualityInspectService { throw new BusinessException(-1, String.format("找不到分析记录homeworkId:%s,studentNo:%s", analyseDetailVO.getHomeworkId(), analyseDetailVO.getStudentNo())); } - DegreeDTO codeSmall = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.CodeSmell.getType(), AnalyseTypeEnum.CodeSmell.getMetricId()); - DegreeDTO bug = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.BUG.getType(), AnalyseTypeEnum.BUG.getMetricId()); - DegreeDTO vulnerability = issuesDao.queryDegree(project.getProject_uuid(), AnalyseTypeEnum.Vulnerability.getType(), AnalyseTypeEnum.Vulnerability.getMetricId()); + DegreeDTO codeSmall = issuesDao.queryDegree(project.getUuid(), AnalyseTypeEnum.CodeSmell.getType(), AnalyseTypeEnum.CodeSmell.getMetricUUId()); + DegreeDTO bug = issuesDao.queryDegree(project.getUuid(), AnalyseTypeEnum.BUG.getType(), AnalyseTypeEnum.BUG.getMetricUUId()); + DegreeDTO vulnerability = issuesDao.queryDegree(project.getUuid(), AnalyseTypeEnum.Vulnerability.getType(), AnalyseTypeEnum.Vulnerability.getMetricUUId()); AnalyseDetailDTO analyseDetail = new AnalyseDetailDTO(); analyseDetail.setBug(bug == null ? new DegreeDTO() : bug); @@ -291,11 +291,11 @@ public class QualityInspectService { severity = degreeEnum.getValue(); } - Integer pageIssuesCount = issuesDao.getPageIssuesCount(project.getProject_uuid(), analyseTypeEnum.getType(), severity); + Integer pageIssuesCount = issuesDao.getPageIssuesCount(project.getUuid(), analyseTypeEnum.getType(), severity); rollPage.setRecordSum(pageIssuesCount); if (pageIssuesCount > 0) { int start = (analyseDetailListVO.getCurrentPage() - 1) * analyseDetailListVO.getPageSize(); - List pageIssues = issuesDao.getPageIssues(project.getProject_uuid(), analyseTypeEnum.getType(), severity, start, analyseDetailListVO.getPageSize()); + List pageIssues = issuesDao.getPageIssues(project.getUuid(), analyseTypeEnum.getType(), severity, start, analyseDetailListVO.getPageSize()); processPageIssues(pageIssues, rollPage); } else { rollPage.setRecordList(new ArrayList(0)); @@ -304,7 +304,7 @@ public class QualityInspectService { return rollPage; } - public ProblemAnalysisDTO getProblemAnalysis(Integer ruleId) { + public ProblemAnalysisDTO getProblemAnalysis(String ruleId) { Rule rule = projectDao.findRuleById(ruleId); ProblemAnalysisDTO problemAnalysisDTO = new ProblemAnalysisDTO(); if (rule != null) { diff --git a/src/main/java/net/educoder/ecsonar/services/ReportService.java b/src/main/java/net/educoder/ecsonar/services/ReportService.java index 19ea85c..f2e8457 100644 --- a/src/main/java/net/educoder/ecsonar/services/ReportService.java +++ b/src/main/java/net/educoder/ecsonar/services/ReportService.java @@ -32,7 +32,7 @@ public class ReportService { if (project==null){ return getDefault(); } - String uuid = project.getProject_uuid(); + String uuid = project.getUuid(); Metrics metrics = projectDao.selectMetricsByProjectUuid(uuid); @@ -162,7 +162,7 @@ public class ReportService { */ private String getViolations(String uuid) { //93 - return projectDao.getLevel(uuid, 93); + return projectDao.getLevel(uuid, "AYeNSwayTEppvP7II93_"); } @@ -209,7 +209,7 @@ public class ReportService { */ private String getBugs(String uuid) { //89 - return projectDao.getLevel(uuid, 89); + return projectDao.getLevel(uuid, "AYeNSwayTEppvP7II94B"); } @@ -256,7 +256,7 @@ public class ReportService { */ private String getCodeSmells(String uuid) { //80 - return projectDao.getLevel(uuid, 80); + return projectDao.getLevel(uuid, "AYeNSwaxTEppvP7II93y"); } diff --git a/src/main/java/net/educoder/ecsonar/services/SonarService.java b/src/main/java/net/educoder/ecsonar/services/SonarService.java index bc66a31..98c9343 100644 --- a/src/main/java/net/educoder/ecsonar/services/SonarService.java +++ b/src/main/java/net/educoder/ecsonar/services/SonarService.java @@ -42,8 +42,8 @@ public class SonarService { @Value("${sonar.url}") String sonarUrl; -// @Value("${sonar.token}") -// String sonarToken; + @Value("${sonar.token}") + String sonarToken; @Value("${extract.path}") String extractProgramPath; @@ -58,6 +58,7 @@ public class SonarService { concurrentHashMap.put(Constant.JAVA, param -> { String command = "sonar-scanner " + "-Dsonar.host.url=" + sonarUrl + " " + + "-Dsonar.token=" + sonarToken + " " + "-Dsonar.sourceEncoding=utf-8 " + "-Dsonar.projectKey=" + param.getProjectKey() + " " + "-Dsonar.java.binaries=./ " + @@ -70,6 +71,7 @@ public class SonarService { concurrentHashMap.put(Constant.PYTHON, param -> { String command = "sonar-scanner " + "-Dsonar.host.url=" + sonarUrl + " " + + "-Dsonar.token=" + sonarToken + " " + "-Dsonar.sourceEncoding=utf-8 " + "-Dsonar.projectKey=" + param.getProjectKey() + " " + "-Dsonar.projectBaseDir=" + param.getProjectPath(); @@ -81,6 +83,7 @@ public class SonarService { String command = "cppcheck --xml --xml-version=2 --enable=all " + param.getProjectPath() + " 2> " + param.getCppCheckReportPath() + "&& sonar-scanner " + "-Dsonar.host.url=" + sonarUrl + " " + + "-Dsonar.token=" + sonarToken + " " + "-Dsonar.sourceEncoding=utf-8 " + "-Dsonar.projectKey=" + param.getProjectKey() + " " + "-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " + @@ -92,6 +95,7 @@ public class SonarService { String command = "cppcheck --xml --xml-version=2 --enable=all " + param.getProjectPath() + " 2> " + param.getCppCheckReportPath() + "&& sonar-scanner " + "-Dsonar.host.url=" + sonarUrl + " " + + "-Dsonar.token=" + sonarToken + " " + "-Dsonar.sourceEncoding=utf-8 " + "-Dsonar.projectKey=" + param.getProjectKey() + " " + "-Dsonar.cxx.cppcheck.reportPath=" + param.getCppCheckReportPath() + " " + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 8a72a76..27d7c51 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -6,9 +6,9 @@ spring.datasource.initSize=20 #spring.datasource.master.url=jdbc:postgresql://127.0.0.1:5432/sonar7.7 -spring.datasource.master.url=jdbc:postgresql://117.50.14.123:5432/sonar -spring.datasource.master.username=sonar -spring.datasource.master.password=sonar +spring.datasource.master.url=jdbc:postgresql://106.75.223.53:5432/sonarqube10 +spring.datasource.master.username=postgres +spring.datasource.master.password=sonarqube spring.datasource.master.driverClassName=org.postgresql.Driver @@ -43,10 +43,12 @@ zip.save.path=/tmp/ #excel.template.path=/Users/guange/work/java/ecsonar/src/main/resources/template.xlsx excel.template.path=template.xlsx -sonar.url=http://127.0.0.1:9000 +sonar.url=http://106.75.223.53:9005 #sonar.url=http://117.50.14.123:9000 # token令牌 -sonar.token=0253a518e824a976ea2f11aec17938cb0f8c0495 +#sonar.token=0253a518e824a976ea2f11aec17938cb0f8c0495 +# ??token +sonar.token=sqa_6615790f07532bfb2cc180f63808548534f75544 extract.path=/usr/local/bin/unar #extract.path=/usr/bin/unar @@ -59,4 +61,4 @@ skip.checked=true server.port=8081 mybatis.mapper-locations=classpath:mapper/* -sonar.host=http://localhost:9000 +sonar.host=http://106.75.223.53:9005 diff --git a/src/main/resources/mapper/FileSourceMapper.xml b/src/main/resources/mapper/FileSourceMapper.xml index 7784976..e08f53c 100644 --- a/src/main/resources/mapper/FileSourceMapper.xml +++ b/src/main/resources/mapper/FileSourceMapper.xml @@ -5,7 +5,7 @@ select - i.id,i.kee,i.rule_id ruleId,i.severity,i.status,i.project_uuid projectUuid,i.issue_type issueType,i.locations,i.line lines,r.name,r.description,r.language,p.path,p.uuid,i.message + i.kee id,i.rule_uuid ruleId,i.severity,i.status,i.project_uuid projectUuid,i.issue_type issueType,i.locations,i.line lines, + r.name,c.path,c.uuid,r.language,i.message from issues i - inner join rules r on i.rule_id =r.id - inner join projects p on p.uuid =i.component_uuid + inner join rules r on i.rule_uuid =r.uuid + inner join projects p on p.uuid =i.project_uuid + inner join components c on c.branch_uuid =p.uuid where i.project_uuid = #{projectUuid,jdbcType=VARCHAR} and i.status='OPEN' - and p.root_uuid =#{projectUuid,jdbcType=VARCHAR} and p.uuid !=#{projectUuid,jdbcType=VARCHAR} and p."scope" ='FIL' + and p.uuid =#{projectUuid,jdbcType=VARCHAR} + and c.uuid !=#{projectUuid,jdbcType=VARCHAR} and c.branch_uuid =#{projectUuid,jdbcType=VARCHAR} and c."scope" ='FIL' and i.issue_type=#{issueType,jdbcType=INTEGER} @@ -47,12 +50,13 @@ (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'MINOR' and status='OPEN') minor, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'BLOCKER' and status='OPEN') blocker, (select count(1) from issues i where project_uuid =#{projectUuid} and issue_type=#{issueType} and severity = 'CRITICAL' and status='OPEN') critical, - (select text_value from project_measures i where component_uuid =#{projectUuid} and metric_id = #{metricId} order by id desc limit 1) levelStr + (select text_value from project_measures i where component_uuid =#{projectUuid} and metric_uuid = #{metricUUid} limit 1) levelStr - + select i.kee id,i.rule_uuid ruleId,i.severity,i.status,i.project_uuid projectUuid,i.issue_type issueType,i.locations,i.line lines,i.message + from issues i where kee=#{issueId} diff --git a/src/main/resources/mapper/ProjectMapper.xml b/src/main/resources/mapper/ProjectMapper.xml index c30008b..ebad7d0 100644 --- a/src/main/resources/mapper/ProjectMapper.xml +++ b/src/main/resources/mapper/ProjectMapper.xml @@ -3,16 +3,18 @@ - select - id, - name, - description, - language, - def_remediation_base_effort defRemediationBaseEffort, - system_tags tags, - created_at createTime - from rules where id=#{id,jdbcType=INTEGER} + r.uuid, + r.name, + r.language, + r.def_remediation_base_effort defRemediationBaseEffort, + r.system_tags tags, + r.created_at createTime, + rds.content description + from rules r + inner join rule_desc_sections rds on r.uuid=rds.rule_uuid + where r.uuid=#{uuid,jdbcType=VARCHAR}