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

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

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