mirror of https://github.com/elunez/eladmin
update LogQueryService
parent
c2155c428e
commit
949460188d
|
@ -39,7 +39,7 @@ public class LogController {
|
||||||
public ResponseEntity getUserLogs(Log log, Pageable pageable){
|
public ResponseEntity getUserLogs(Log log, Pageable pageable){
|
||||||
log.setLogType("INFO");
|
log.setLogType("INFO");
|
||||||
log.setUsername(SecurityUtils.getUsername());
|
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")
|
@GetMapping(value = "/logs/error")
|
||||||
|
|
|
@ -40,13 +40,15 @@ public class LogQueryService {
|
||||||
|
|
||||||
public Object queryAll(Log log, Pageable pageable){
|
public Object queryAll(Log log, Pageable pageable){
|
||||||
Page<Log> page = logRepository.findAll(new Spec(log),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")) {
|
if (log.getLogType().equals("ERROR")) {
|
||||||
return PageUtil.toPage(page.map(logErrorMapper::toDto));
|
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> {
|
class Spec implements Specification<Log> {
|
||||||
|
|
|
@ -89,10 +89,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
"/**/*.html",
|
"/**/*.html",
|
||||||
"/**/*.css",
|
"/**/*.css",
|
||||||
"/**/*.js"
|
"/**/*.js"
|
||||||
).permitAll()
|
).anonymous()
|
||||||
|
|
||||||
.antMatchers( HttpMethod.POST,"/auth/"+loginPath).permitAll()
|
.antMatchers( HttpMethod.POST,"/auth/"+loginPath).anonymous()
|
||||||
.antMatchers("/websocket/**").permitAll()
|
.antMatchers("/websocket/**").anonymous()
|
||||||
// 支付宝回调
|
// 支付宝回调
|
||||||
.antMatchers("/api/aliPay/return").anonymous()
|
.antMatchers("/api/aliPay/return").anonymous()
|
||||||
.antMatchers("/api/aliPay/notify").anonymous()
|
.antMatchers("/api/aliPay/notify").anonymous()
|
||||||
|
@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||||
.antMatchers("/test/**").anonymous()
|
.antMatchers("/test/**").anonymous()
|
||||||
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
|
.antMatchers(HttpMethod.OPTIONS, "/**").anonymous()
|
||||||
|
|
||||||
.antMatchers("/druid/**").permitAll()
|
.antMatchers("/druid/**").anonymous()
|
||||||
// 所有请求都需要认证
|
// 所有请求都需要认证
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
// 防止iframe 造成跨域
|
// 防止iframe 造成跨域
|
||||||
|
|
|
@ -100,9 +100,6 @@ public class UserController {
|
||||||
@PostMapping(value = "/users")
|
@PostMapping(value = "/users")
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_CREATE')")
|
@PreAuthorize("hasAnyRole('ADMIN','USER_ALL','USER_CREATE')")
|
||||||
public ResponseEntity create(@Validated @RequestBody User resources){
|
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);
|
checkLevel(resources);
|
||||||
return new ResponseEntity(userService.create(resources),HttpStatus.CREATED);
|
return new ResponseEntity(userService.create(resources),HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue