提交 6a1ea083 authored 作者: 孙洁清's avatar 孙洁清

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

...@@ -105,7 +105,22 @@ ...@@ -105,7 +105,22 @@
<artifactId>zip4j</artifactId> <artifactId>zip4j</artifactId>
<version>1.3.2</version> <version>1.3.2</version>
</dependency> </dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>3.2.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>3.2.0</version>
</dependency>
<!--解压rar压缩--> <!--解压rar压缩-->
<dependency> <dependency>
<groupId>com.github.junrar</groupId> <groupId>com.github.junrar</groupId>
......
...@@ -11,7 +11,11 @@ import org.aspectj.lang.annotation.Pointcut; ...@@ -11,7 +11,11 @@ import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -38,17 +42,24 @@ public class AopIntercept { ...@@ -38,17 +42,24 @@ public class AopIntercept {
@Around("doPointCut()") @Around("doPointCut()")
public Object aroundMethod(ProceedingJoinPoint joinPoint) throws Throwable { public Object aroundMethod(ProceedingJoinPoint joinPoint) throws Throwable {
long startMillis = System.currentTimeMillis(); AuthAnnotation authAnnotation = ((MethodSignature)joinPoint.getSignature()).getMethod().getAnnotation(AuthAnnotation.class);
Object proceed = joinPoint.proceed(); String[] code = authAnnotation.code();
long endMillis = System.currentTimeMillis(); List<String> authorityCode = user.getAuthorityCode();
for (String s : code) {
long time = (endMillis - startMillis); if (authorityCode.contains(s)) {
log.info("评估总耗时{}毫秒",time); long startMillis = System.currentTimeMillis();
log.info("PersonAspect2 ==> before method : {}", joinPoint.getSignature().getName()); Object proceed = joinPoint.proceed();
log.info("注解的类型名称为{}",joinPoint.getSignature().getDeclaringTypeName()); long endMillis = System.currentTimeMillis();
log.info("方法修饰符个数为{}",joinPoint.getSignature().getModifiers()); long time = (endMillis - startMillis);
log.info("方法名称为{}",joinPoint.getSignature().getName()); log.info("评估总耗时{}毫秒", time);
log.info("方法参数{}",joinPoint.getArgs()); log.info("PersonAspect2 ==> before method : {}", joinPoint.getSignature().getName());
return proceed; log.info("注解的类型名称为{}", joinPoint.getSignature().getDeclaringTypeName());
log.info("方法修饰符个数为{}", joinPoint.getSignature().getModifiers());
log.info("方法名称为{}", joinPoint.getSignature().getName());
log.info("方法参数{}", joinPoint.getArgs());
return proceed;
}
}
return ResponseEntity.status(403).build();
} }
} }
...@@ -10,6 +10,7 @@ import org.springframework.web.servlet.HandlerInterceptor; ...@@ -10,6 +10,7 @@ import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Objects;
/** /**
* @author Mcj * @author Mcj
...@@ -28,9 +29,8 @@ public class LoginInterceptor implements HandlerInterceptor { ...@@ -28,9 +29,8 @@ public class LoginInterceptor implements HandlerInterceptor {
String sessionId = request.getHeader("sessionId"); String sessionId = request.getHeader("sessionId");
String url = "http://120.55.57.35:12345/user/getLogin/"+sessionId; String url = "http://120.55.57.35:12345/user/getLogin/"+sessionId;
ServerResponse user = restTemplate.getForObject(url, ServerResponse.class); ServerResponse user = restTemplate.getForObject(url, ServerResponse.class);
if(user==null){ if(Objects.requireNonNull(user).getData()==null){
//不符合条件的给出提示信息,并转发到登录页面 //不符合条件的给出提示信息,并转发到登录页面
request.setAttribute("msg", "您还没有登录,请先登录!");
response.setStatus(403); response.setStatus(403);
return false; return false;
} }
......
...@@ -23,6 +23,10 @@ public class MvcConfig extends WebMvcConfigurationSupport { ...@@ -23,6 +23,10 @@ public class MvcConfig extends WebMvcConfigurationSupport {
// 多个拦截器组成一个拦截器链 // 多个拦截器组成一个拦截器链
// addPathPatterns 用于添加拦截规则,/**表示拦截所有请求 // addPathPatterns 用于添加拦截规则,/**表示拦截所有请求
// excludePathPatterns 用户排除拦截 // excludePathPatterns 用户排除拦截
registry.addInterceptor(loginInterceptor)
.addPathPatterns("/**")
.excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
;
super.addInterceptors(registry); super.addInterceptors(registry);
} }
@Override @Override
......
package com.zjty.inspect.controller; package com.zjty.inspect.controller;
import com.zjty.inspect.aop.AuthAnnotation;
import com.zjty.inspect.entity.Config; import com.zjty.inspect.entity.Config;
import com.zjty.inspect.entity.RuleQo; import com.zjty.inspect.entity.RuleQo;
import com.zjty.inspect.service.ConfigService; import com.zjty.inspect.service.ConfigService;
...@@ -38,6 +39,7 @@ public class ConfigController { ...@@ -38,6 +39,7 @@ public class ConfigController {
*/ */
@PostMapping("/updates") @PostMapping("/updates")
@ApiOperation("根据id修改参数,需要传id和value") @ApiOperation("根据id修改参数,需要传id和value")
@AuthAnnotation(code = {"1300"})
public ResponseEntity update(@RequestBody List<Config> configs){ public ResponseEntity update(@RequestBody List<Config> configs){
configService.updateConfig(configs); configService.updateConfig(configs);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
......
package com.zjty.inspect.controller; package com.zjty.inspect.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.zjty.inspect.aop.AuthAnnotation;
import com.zjty.inspect.dao.ConfigParamDao; import com.zjty.inspect.dao.ConfigParamDao;
import com.zjty.inspect.dao.TechnologyDao; import com.zjty.inspect.dao.TechnologyDao;
import com.zjty.inspect.entity.*; import com.zjty.inspect.entity.*;
...@@ -380,7 +381,7 @@ public class InspectController { ...@@ -380,7 +381,7 @@ public class InspectController {
} }
@PostMapping("/uploads") @PostMapping("/uploads")
private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile, String s) { private ResponseEntity uploads(@RequestParam(value = "file") MultipartFile multfile) {
try { try {
File file = FileUtil.saveToLocal(multfile); File file = FileUtil.saveToLocal(multfile);
String name = file.getName(); String name = file.getName();
...@@ -388,7 +389,7 @@ public class InspectController { ...@@ -388,7 +389,7 @@ public class InspectController {
return ResponseEntity.ok(new com.zjty.inspect.entity.File(name, path)); return ResponseEntity.ok(new com.zjty.inspect.entity.File(name, path));
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return ResponseEntity.ok("上传失败"); return ResponseEntity.status(500).build();
} }
} }
......
...@@ -7,6 +7,7 @@ import io.swagger.annotations.Api; ...@@ -7,6 +7,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -21,7 +22,7 @@ import java.util.Map; ...@@ -21,7 +22,7 @@ import java.util.Map;
* @author Mcj * @author Mcj
* @date 2020-02-26 14:42 * @date 2020-02-26 14:42
*/ */
@Slf4j
@RestController @RestController
@RequestMapping("/rule") @RequestMapping("/rule")
@Api(value = "规则页面管理接口",description = "规则页面管理接口,提供页面的增、删、改、查") @Api(value = "规则页面管理接口",description = "规则页面管理接口,提供页面的增、删、改、查")
...@@ -38,6 +39,7 @@ public class RuleController { ...@@ -38,6 +39,7 @@ public class RuleController {
*/ */
@PostMapping @PostMapping
@ApiOperation("新增规则") @ApiOperation("新增规则")
@AuthAnnotation(code = {"1200","1400"})
public ResponseEntity rule(@RequestBody Rule rule){ public ResponseEntity rule(@RequestBody Rule rule){
Rule rule1 = ruleService.addRulePlus(rule); Rule rule1 = ruleService.addRulePlus(rule);
if(rule1!=null){ if(rule1!=null){
...@@ -52,6 +54,7 @@ public class RuleController { ...@@ -52,6 +54,7 @@ public class RuleController {
*/ */
@PostMapping(value = "/update") @PostMapping(value = "/update")
@ApiOperation("修改规则") @ApiOperation("修改规则")
@AuthAnnotation(code = {"1200","1400"})
public ResponseEntity update(@RequestBody Rule rule){ public ResponseEntity update(@RequestBody Rule rule){
ruleService.upRulePlus(rule); ruleService.upRulePlus(rule);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
...@@ -63,6 +66,7 @@ public class RuleController { ...@@ -63,6 +66,7 @@ public class RuleController {
*/ */
@ApiOperation("根据数据封装删除规则") @ApiOperation("根据数据封装删除规则")
@DeleteMapping @DeleteMapping
@AuthAnnotation(code = {"1200","1400"})
public ResponseEntity deleteByQo(@RequestBody String id){ public ResponseEntity deleteByQo(@RequestBody String id){
ruleService.deleteRulePlus(id); ruleService.deleteRulePlus(id);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
...@@ -99,6 +103,7 @@ public class RuleController { ...@@ -99,6 +103,7 @@ public class RuleController {
} }
@PostMapping("/importRules") @PostMapping("/importRules")
@ApiOperation("导入所有规则") @ApiOperation("导入所有规则")
@AuthAnnotation(code = {"1200"})
public ResponseEntity importRules(@RequestParam("file") MultipartFile file){ public ResponseEntity importRules(@RequestParam("file") MultipartFile file){
ruleService.importRules(file); ruleService.importRules(file);
return null; return null;
......
...@@ -60,6 +60,7 @@ public class TechnologyController { ...@@ -60,6 +60,7 @@ public class TechnologyController {
*/ */
@PostMapping("/add") @PostMapping("/add")
@ApiOperation("新添加关键技术") @ApiOperation("新添加关键技术")
@AuthAnnotation(code = {"1100"})
public ResponseEntity addTechnologies(@RequestBody Technology technology){ public ResponseEntity addTechnologies(@RequestBody Technology technology){
technologyService.add(technology); technologyService.add(technology);
return ResponseEntity.ok(200); return ResponseEntity.ok(200);
...@@ -67,6 +68,7 @@ public class TechnologyController { ...@@ -67,6 +68,7 @@ public class TechnologyController {
} }
@PostMapping(value = "/{id}") @PostMapping(value = "/{id}")
@ApiOperation("修改关键技术") @ApiOperation("修改关键技术")
@AuthAnnotation(code = {"1100"})
public ResponseEntity update(@RequestBody Technology technology,@PathVariable String id){ public ResponseEntity update(@RequestBody Technology technology,@PathVariable String id){
technology.setId(id); technology.setId(id);
technologyService.update(technology); technologyService.update(technology);
......
...@@ -17,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -17,6 +17,7 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
...@@ -33,9 +34,8 @@ public class ExcelUtil { ...@@ -33,9 +34,8 @@ public class ExcelUtil {
public static Reform parseExcel(MultipartFile f1) { public static Reform parseExcel(MultipartFile f1) {
try { try {
File f = new File("/Users/mcj/文章/工作文档/调研表.xlsx"); InputStream fileInputStream = f1.getInputStream();
FileInputStream fileInputStream = new FileInputStream(f); String[] split = Objects.requireNonNull(f1.getOriginalFilename()).split("\\.");
String[] split = Objects.requireNonNull(f.getName()).split("\\.");
if (xlsx.equals(split[1])) { if (xlsx.equals(split[1])) {
XSSFWorkbook xwb = new XSSFWorkbook(fileInputStream); XSSFWorkbook xwb = new XSSFWorkbook(fileInputStream);
//3、得到Excel工作表对象 //3、得到Excel工作表对象
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论