From 949460188dbb6f7ca2428b987df257f76781166f Mon Sep 17 00:00:00 2001 From: zhengjie Date: Wed, 29 May 2019 10:03:23 +0800 Subject: [PATCH] update LogQueryService --- .../src/main/java/me/zhengjie/rest/LogController.java | 2 +- .../me/zhengjie/service/query/LogQueryService.java | 10 ++++++---- .../modules/security/config/SecurityConfig.java | 8 ++++---- .../zhengjie/modules/system/rest/UserController.java | 3 --- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java b/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java index 639480983..5300e18c9 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java +++ b/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java @@ -39,7 +39,7 @@ public ResponseEntity getLogs(Log log, Pageable pageable){ public ResponseEntity getUserLogs(Log log, Pageable pageable){ log.setLogType("INFO"); log.setUsername(SecurityUtils.getUsername()); - return new ResponseEntity(logQueryService.queryAll(log,pageable), HttpStatus.OK); + return new ResponseEntity(logQueryService.queryAllByUser(log,pageable), HttpStatus.OK); } @GetMapping(value = "/logs/error") diff --git a/eladmin-logging/src/main/java/me/zhengjie/service/query/LogQueryService.java b/eladmin-logging/src/main/java/me/zhengjie/service/query/LogQueryService.java index d1a1bf239..54af1ab04 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/service/query/LogQueryService.java +++ b/eladmin-logging/src/main/java/me/zhengjie/service/query/LogQueryService.java @@ -40,13 +40,15 @@ public class LogQueryService { public Object queryAll(Log log, Pageable pageable){ Page page = logRepository.findAll(new Spec(log),pageable); - if (!ObjectUtils.isEmpty(log.getUsername())) { - return PageUtil.toPage(page.map(logSmallMapper::toDto)); - } if (log.getLogType().equals("ERROR")) { return PageUtil.toPage(page.map(logErrorMapper::toDto)); } - return logRepository.findAll(new Spec(log),pageable); + return page; + } + + public Object queryAllByUser(Log log, Pageable pageable) { + Page page = logRepository.findAll(new Spec(log),pageable); + return PageUtil.toPage(page.map(logSmallMapper::toDto)); } class Spec implements Specification { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java index 260332822..2fe42d670 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java @@ -89,10 +89,10 @@ protected void configure(HttpSecurity httpSecurity) throws Exception { "/**/*.html", "/**/*.css", "/**/*.js" - ).permitAll() + ).anonymous() - .antMatchers( HttpMethod.POST,"/auth/"+loginPath).permitAll() - .antMatchers("/websocket/**").permitAll() + .antMatchers( HttpMethod.POST,"/auth/"+loginPath).anonymous() + .antMatchers("/websocket/**").anonymous() // 支付宝回调 .antMatchers("/api/aliPay/return").anonymous() .antMatchers("/api/aliPay/notify").anonymous() @@ -111,7 +111,7 @@ protected void configure(HttpSecurity httpSecurity) throws Exception { .antMatchers("/test/**").anonymous() .antMatchers(HttpMethod.OPTIONS, "/**").anonymous() - .antMatchers("/druid/**").permitAll() + .antMatchers("/druid/**").anonymous() // 所有请求都需要认证 .anyRequest().authenticated() // 防止iframe 造成跨域 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java index 1cd1ce3aa..9582ee048 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java @@ -100,9 +100,6 @@ public ResponseEntity getUsers(UserDTO userDTO, Pageable pageable){ @PostMapping(value = "/users") @PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_CREATE')") public ResponseEntity create(@Validated @RequestBody User resources){ - if (resources.getId() != null) { - throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID"); - } checkLevel(resources); return new ResponseEntity(userService.create(resources),HttpStatus.CREATED); }