提交 f349f5ad authored 作者: 马晨俊's avatar 马晨俊

Merge branch 'master' of git.yfzx.zjtys.com.cn:912-system/monitor/inspect

# Conflicts: # src/main/java/com/zjty/inspect/dao/TechnologyDao.java
...@@ -23,10 +23,20 @@ ...@@ -23,10 +23,20 @@
</profiles> </profiles>
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<swagger.version>2.9.2</swagger.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.eclipse.jgit</groupId> <groupId>org.eclipse.jgit</groupId>
......
package com.zjty.inspect.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
//
@Configuration
@EnableSwagger2
public class Swagger2Configuration {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.zjty.inspect"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("评估api文档")
.description("评估api文档")
// .termsOfServiceUrl("/")
.version("1.0")
.build();
}
}
...@@ -7,6 +7,8 @@ import com.zjty.inspect.utils.FileUtil; ...@@ -7,6 +7,8 @@ import com.zjty.inspect.utils.FileUtil;
import com.zjty.inspect.utils.GitLabUtil; import com.zjty.inspect.utils.GitLabUtil;
import com.zjty.inspect.utils.MavenUtil; import com.zjty.inspect.utils.MavenUtil;
import com.zjty.inspect.utils.UUIDUtil; import com.zjty.inspect.utils.UUIDUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItem; import org.apache.tomcat.util.http.fileupload.disk.DiskFileItem;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -24,6 +26,7 @@ import java.io.*; ...@@ -24,6 +26,7 @@ import java.io.*;
*/ */
@RestController @RestController
@RequestMapping("/inspect") @RequestMapping("/inspect")
@Api(value = "cms页面管理接口",description = "cms页面管理接口,提供页面的增、删、改、查")
public class InspectController { public class InspectController {
@Autowired @Autowired
private InspectService inspectService; private InspectService inspectService;
...@@ -39,6 +42,7 @@ public class InspectController { ...@@ -39,6 +42,7 @@ public class InspectController {
* @throws IOException * @throws IOException
*/ */
@PostMapping("/path") @PostMapping("/path")
@ApiOperation("上传代码进行评估")
public ResponseEntity inspect(Integer years,Integer systemFund,Integer modules public ResponseEntity inspect(Integer years,Integer systemFund,Integer modules
,String valid,Double framework,Double safety,Double disaster,Integer data ,String valid,Double framework,Double safety,Double disaster,Integer data
,Integer admin, MultipartFile multfile) throws IOException { ,Integer admin, MultipartFile multfile) throws IOException {
...@@ -69,6 +73,7 @@ public class InspectController { ...@@ -69,6 +73,7 @@ public class InspectController {
* @return * @return
*/ */
@PostMapping("/git") @PostMapping("/git")
@ApiOperation("git下载代码进行评估")
public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter){ public ResponseEntity inspect1(@RequestBody InspectParameter inspectParameter){
String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress(),inspectParameter.getGitName()); String path = GitLabUtil.downLoadProject(inspectParameter.getGitAddress(),inspectParameter.getGitName());
inspectParameter.setId(UUIDUtil.getUUID()); inspectParameter.setId(UUIDUtil.getUUID());
...@@ -79,6 +84,7 @@ public class InspectController { ...@@ -79,6 +84,7 @@ public class InspectController {
} }
@PostMapping("/frontend") @PostMapping("/frontend")
@ApiOperation("git下载代码进行评估")
public ResponseEntity inspect(MultipartFile file) throws IOException { public ResponseEntity inspect(MultipartFile file) throws IOException {
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
......
...@@ -2,6 +2,8 @@ package com.zjty.inspect.controller; ...@@ -2,6 +2,8 @@ package com.zjty.inspect.controller;
import com.zjty.inspect.entity.InspectParameter; import com.zjty.inspect.entity.InspectParameter;
import com.zjty.inspect.service.ParameterService; import com.zjty.inspect.service.ParameterService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -12,17 +14,20 @@ import org.springframework.web.bind.annotation.*; ...@@ -12,17 +14,20 @@ import org.springframework.web.bind.annotation.*;
*/ */
@RestController @RestController
@RequestMapping("/param") @RequestMapping("/param")
@Api(value = "参数页面管理接口",description = "参数页面管理接口,提供页面的增、删、改、查")
public class ParamController { public class ParamController {
@Autowired @Autowired
private ParameterService parameterService; private ParameterService parameterService;
@GetMapping @GetMapping
@ApiOperation("获取参数")
public ResponseEntity getParam(String id){ public ResponseEntity getParam(String id){
return ResponseEntity.ok(parameterService.getParameterById(id)); return ResponseEntity.ok(parameterService.getParameterById(id));
} }
@PostMapping @PostMapping
@ApiOperation("保存参数")
public ResponseEntity saveParam(@RequestBody InspectParameter inspectParameter){ public ResponseEntity saveParam(@RequestBody InspectParameter inspectParameter){
parameterService.saveParameter(inspectParameter); parameterService.saveParameter(inspectParameter);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
......
...@@ -2,6 +2,8 @@ package com.zjty.inspect.controller; ...@@ -2,6 +2,8 @@ package com.zjty.inspect.controller;
import com.zjty.inspect.entity.RuleQo; import com.zjty.inspect.entity.RuleQo;
import com.zjty.inspect.service.RuleService; import com.zjty.inspect.service.RuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
@RestController @RestController
@RequestMapping("/rule") @RequestMapping("/rule")
@Api(value = "规则页面管理接口",description = "规则页面管理接口,提供页面的增、删、改、查")
public class RuleController { public class RuleController {
@Autowired @Autowired
...@@ -25,6 +28,7 @@ public class RuleController { ...@@ -25,6 +28,7 @@ public class RuleController {
* @return * @return
*/ */
@PostMapping @PostMapping
@ApiOperation("新增规则")
public ResponseEntity rule(@RequestBody RuleQo ruleQo){ public ResponseEntity rule(@RequestBody RuleQo ruleQo){
ruleService.addRule(ruleQo); ruleService.addRule(ruleQo);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
...@@ -36,6 +40,7 @@ public class RuleController { ...@@ -36,6 +40,7 @@ public class RuleController {
* @return * @return
*/ */
@PostMapping(value = "/{id}") @PostMapping(value = "/{id}")
@ApiOperation("修改规则")
public ResponseEntity update(@RequestBody RuleQo ruleQo,@PathVariable String id){ public ResponseEntity update(@RequestBody RuleQo ruleQo,@PathVariable String id){
ruleQo.setId(id); ruleQo.setId(id);
ruleService.upRule(ruleQo); ruleService.upRule(ruleQo);
...@@ -46,15 +51,23 @@ public class RuleController { ...@@ -46,15 +51,23 @@ public class RuleController {
* @param id id * @param id id
* @return * @return
*/ */
@ApiOperation("根据id删除规则")
@DeleteMapping(value = "/{id}") @DeleteMapping(value = "/{id}")
public ResponseEntity deleteById(@PathVariable String id){ public ResponseEntity deleteById(@PathVariable String id){
ruleService.deleteById(id); ruleService.deleteById(id);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
} }
@ApiOperation("根据name查询规则")
@GetMapping(value = "/{name}")
public ResponseEntity getName(@PathVariable String name) {
ruleService.findByName(name);
return ResponseEntity.ok(200);
}
/** /**
* 查询所有规则 * 查询所有规则
* @return 规则 * @return 规则
*/ */
@ApiOperation("查询所有规则")
@GetMapping @GetMapping
public ResponseEntity getRules(){ public ResponseEntity getRules(){
return ResponseEntity.ok(ruleService.findAll()); return ResponseEntity.ok(ruleService.findAll());
......
package com.zjty.inspect.controller; package com.zjty.inspect.controller;
import com.zjty.inspect.entity.Technology;
import com.zjty.inspect.entity.TechnologyQo; import com.zjty.inspect.entity.TechnologyQo;
import com.zjty.inspect.service.TechnologyService; import com.zjty.inspect.service.TechnologyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.*; ...@@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
@RequestMapping("/technology") @RequestMapping("/technology")
@RestController @RestController
@Api(value = "适配技术页面管理接口",description = "适配技术页面管理接口,提供页面的增、删、改、查")
public class TechnologyController { public class TechnologyController {
@Autowired @Autowired
...@@ -24,15 +28,22 @@ public class TechnologyController { ...@@ -24,15 +28,22 @@ public class TechnologyController {
* @return List * @return List
*/ */
@GetMapping @GetMapping
@ApiOperation("获取所有关键技术")
public ResponseEntity getTechnologies(){ public ResponseEntity getTechnologies(){
return ResponseEntity.ok(technologyService.findAllTechnology()); return ResponseEntity.ok(technologyService.findAllTechnology());
} }
@GetMapping("/names")
@ApiOperation("获取所有关键技术name")
public ResponseEntity getTechnologiesName(){
return ResponseEntity.ok(technologyService.findAllTechnologyNames());
}
/** /**
* 获取所有关键技术 * 获取所有关键技术
* @return List * @return List
*/ */
@GetMapping(value = "/{name}") @GetMapping(value = "/{name}")
@ApiOperation("根据name获取所有关键技术")
public ResponseEntity getTechnologies(@PathVariable String name){ public ResponseEntity getTechnologies(@PathVariable String name){
return ResponseEntity.ok(technologyService.findAllTechnology(name)); return ResponseEntity.ok(technologyService.findAllTechnology(name));
} }
...@@ -41,8 +52,23 @@ public class TechnologyController { ...@@ -41,8 +52,23 @@ public class TechnologyController {
* @return List * @return List
*/ */
@PostMapping @PostMapping
@ApiOperation("添加关键技术")
public ResponseEntity addTechnologies(@RequestBody TechnologyQo technologyQo){ public ResponseEntity addTechnologies(@RequestBody TechnologyQo technologyQo){
technologyService.addAdvice(technologyQo); technologyService.addAdvice(technologyQo);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
} }
@PostMapping("/add")
@ApiOperation("新添加关键技术")
public ResponseEntity addTechnologies(@RequestBody Technology technology){
technologyService.add(technology);
return ResponseEntity.ok(200);
}
@PostMapping(value = "/{id}")
@ApiOperation("修改关键技术")
public ResponseEntity update(@RequestBody Technology technology,@PathVariable String id){
technology.setId(id);
technologyService.update(technology);
return ResponseEntity.ok(200);
}
} }
...@@ -4,6 +4,8 @@ package com.zjty.inspect.dao; ...@@ -4,6 +4,8 @@ package com.zjty.inspect.dao;
import com.zjty.inspect.entity.Rule; import com.zjty.inspect.entity.Rule;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface RuleDao extends JpaRepository<Rule,String> { public interface RuleDao extends JpaRepository<Rule,String> {
/** /**
* 根据目标关键字查询规则 * 根据目标关键字查询规则
...@@ -19,4 +21,6 @@ public interface RuleDao extends JpaRepository<Rule,String> { ...@@ -19,4 +21,6 @@ public interface RuleDao extends JpaRepository<Rule,String> {
* @return * @return
*/ */
Rule findAllByTargetEqualsAndTechnologyIdEquals(String target,String techId); Rule findAllByTargetEqualsAndTechnologyIdEquals(String target,String techId);
List<Rule> findAllByTargetLike(String target);
} }
...@@ -2,6 +2,7 @@ package com.zjty.inspect.dao; ...@@ -2,6 +2,7 @@ package com.zjty.inspect.dao;
import com.zjty.inspect.entity.Technology; import com.zjty.inspect.entity.Technology;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List; import java.util.List;
...@@ -14,11 +15,6 @@ public interface TechnologyDao extends JpaRepository<Technology,String> { ...@@ -14,11 +15,6 @@ public interface TechnologyDao extends JpaRepository<Technology,String> {
*/ */
Technology findAllByTechnologyNameEquals(String name); Technology findAllByTechnologyNameEquals(String name);
/**
* 根据名称模糊查询
* @param name 技术名称
* @return
*/
List<Technology> findAllByTechnologyNameLike(String name); List<Technology> findAllByTechnologyNameLike(String name);
/** /**
...@@ -27,4 +23,8 @@ public interface TechnologyDao extends JpaRepository<Technology,String> { ...@@ -27,4 +23,8 @@ public interface TechnologyDao extends JpaRepository<Technology,String> {
* @return * @return
*/ */
List<Technology> findAllByIdIn(List<String> ids); List<Technology> findAllByIdIn(List<String> ids);
@Query("select technologyName from Technology ")
List<String> getTechnologyNames();
} }
...@@ -29,6 +29,10 @@ public class Rule { ...@@ -29,6 +29,10 @@ public class Rule {
@Id @Id
@Column(length = 48) @Column(length = 48)
private String id; private String id;
/**
* 关键技术名称
*/
private String technologyName;
/** /**
* 目标关键字 * 目标关键字
*/ */
......
...@@ -27,4 +27,6 @@ public class RuleQo { ...@@ -27,4 +27,6 @@ public class RuleQo {
* 适配技术id * 适配技术id
*/ */
private String technologyId; private String technologyId;
private String technologyName;
} }
...@@ -46,10 +46,9 @@ public class Technology { ...@@ -46,10 +46,9 @@ public class Technology {
private Integer support; private Integer support;
/** /**
* 1:前端技术 * 技术类型
* 2:后端技术
*/ */
private Integer backOrFront = 2; private String backOrFront;
/** /**
* 数据创建时间 * 数据创建时间
*/ */
......
...@@ -38,4 +38,6 @@ public interface RuleService { ...@@ -38,4 +38,6 @@ public interface RuleService {
* @return 规则 * @return 规则
*/ */
List<Rule> findAll(); List<Rule> findAll();
List<Rule> findByName(String name);
} }
...@@ -14,12 +14,16 @@ public interface TechnologyService { ...@@ -14,12 +14,16 @@ public interface TechnologyService {
* 新增关键技术点 * 新增关键技术点
*/ */
public void addAdvice(TechnologyQo technologyQo); public void addAdvice(TechnologyQo technologyQo);
public void add(Technology technology);
/** /**
* 查询所有技术 * 查询所有技术
* @return List * @return List
*/ */
public List<Technology> findAllTechnology(); public List<Technology> findAllTechnology();
public List<String> findAllTechnologyNames();
public List<Technology> findAllTechnology(String name); public List<Technology> findAllTechnology(String name);
void update(Technology technology);
} }
...@@ -39,6 +39,7 @@ public class RuleServiceImpl implements RuleService { ...@@ -39,6 +39,7 @@ public class RuleServiceImpl implements RuleService {
// TODO: 2020-02-27 适配技术与扫描关键字关联 // TODO: 2020-02-27 适配技术与扫描关键字关联
Rule rule = new Rule(); Rule rule = new Rule();
rule.setTarget(ruleQo.getTarget()); rule.setTarget(ruleQo.getTarget());
rule.setTechnologyName(ruleQo.getTechnologyName());
rule.setSuffix(ruleQo.getSuffix()); rule.setSuffix(ruleQo.getSuffix());
rule.setTechnologyId(ruleQo.getTechnologyId()); rule.setTechnologyId(ruleQo.getTechnologyId());
rule.setId(UUIDUtil.getUUID()); rule.setId(UUIDUtil.getUUID());
...@@ -50,6 +51,7 @@ public class RuleServiceImpl implements RuleService { ...@@ -50,6 +51,7 @@ public class RuleServiceImpl implements RuleService {
Rule rule = new Rule(); Rule rule = new Rule();
rule.setTarget(ruleQo.getTarget()); rule.setTarget(ruleQo.getTarget());
rule.setSuffix(ruleQo.getSuffix()); rule.setSuffix(ruleQo.getSuffix());
rule.setTechnologyName(ruleQo.getTechnologyName());
rule.setTechnologyId(ruleQo.getTechnologyId()); rule.setTechnologyId(ruleQo.getTechnologyId());
rule.setId(ruleQo.getId()); rule.setId(ruleQo.getId());
ruleDao.save(rule); ruleDao.save(rule);
...@@ -74,4 +76,13 @@ public class RuleServiceImpl implements RuleService { ...@@ -74,4 +76,13 @@ public class RuleServiceImpl implements RuleService {
public List<Rule> findAll() { public List<Rule> findAll() {
return ruleDao.findAll(); return ruleDao.findAll();
} }
@Override
public List<Rule> findByName(String name) {
List<Rule> rules = ruleDao.findAllByTargetLike("%" + name + "%");
if(rules!=null&&rules.size()>0){
return rules;
}
return null;
}
} }
...@@ -48,11 +48,30 @@ public class TechnologyServiceImpl implements TechnologyService { ...@@ -48,11 +48,30 @@ public class TechnologyServiceImpl implements TechnologyService {
technologyDao.save(technology); technologyDao.save(technology);
} }
@Override
public void add(Technology technology) {
if (technology.getId() == null) {
technology.setId(UUIDUtil.getUUID());
Technology te = technologyDao.findAllByTechnologyNameEquals(technology.getTechnologyName());
if(te!=null){
return;
}
} else {
technology.setId(technology.getId());
}
technologyDao.save(technology);
}
@Override @Override
public List<Technology> findAllTechnology() { public List<Technology> findAllTechnology() {
return technologyDao.findAll(); return technologyDao.findAll();
} }
@Override
public List<String> findAllTechnologyNames() {
return technologyDao.getTechnologyNames();
}
@Override @Override
public List<Technology> findAllTechnology(String name) { public List<Technology> findAllTechnology(String name) {
List<Technology> allByTechnologyNameLike = technologyDao.findAllByTechnologyNameLike("%" + name + "%"); List<Technology> allByTechnologyNameLike = technologyDao.findAllByTechnologyNameLike("%" + name + "%");
...@@ -61,4 +80,9 @@ public class TechnologyServiceImpl implements TechnologyService { ...@@ -61,4 +80,9 @@ public class TechnologyServiceImpl implements TechnologyService {
} }
return technologyDao.findAllByTechnologyNameLike("%"+name+"%"); return technologyDao.findAllByTechnologyNameLike("%"+name+"%");
} }
@Override
public void update(Technology technology) {
technologyDao.save(technology);
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论