Skip to content

Commit

Permalink
update LogQueryService
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengjie committed May 29, 2019
1 parent c2155c4 commit 9494601
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ public class LogQueryService {

public Object queryAll(Log log, Pageable pageable){
Page<Log> 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<Log> page = logRepository.findAll(new Spec(log),pageable);
return PageUtil.toPage(page.map(logSmallMapper::toDto));
}

class Spec implements Specification<Log> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 造成跨域
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 9494601

Please sign in to comment.