Rename ErrorResponse into BaseResponse

pull/137/head
johnniang 2019-03-19 11:19:23 +08:00
parent 6f18c6c5ba
commit b0b852a803
11 changed files with 25 additions and 25 deletions

View File

@ -12,7 +12,7 @@ import lombok.*;
@EqualsAndHashCode
@NoArgsConstructor
@AllArgsConstructor
public class ErrorResponse {
public class BaseResponse {
private Integer status;

View File

@ -1,7 +1,7 @@
package cc.ryanc.halo.security.handler;
import cc.ryanc.halo.exception.HaloException;
import cc.ryanc.halo.model.support.ErrorResponse;
import cc.ryanc.halo.model.support.BaseResponse;
import cc.ryanc.halo.utils.ExceptionUtils;
import cn.hutool.extra.servlet.ServletUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -36,7 +36,7 @@ public class DefaultAuthenticationFailureHandler implements AuthenticationFailur
public void onFailure(HttpServletRequest request, HttpServletResponse response, HaloException exception) throws IOException, ServletException {
log.warn("Handle unsuccessful authentication, ip: [{}]", ServletUtil.getClientIP(request));
ErrorResponse errorDetail = new ErrorResponse();
BaseResponse errorDetail = new BaseResponse();
errorDetail.setMessage(exception.getMessage());

View File

@ -18,5 +18,5 @@ public interface CommentService extends CrudService<Comment, Long> {
* @param top top number must not be less than 0
* @return a page of comments
*/
Page<CommentVO> listLatest(int top);
Page<CommentVO> pageLatest(int top);
}

View File

@ -18,5 +18,5 @@ public interface LogService extends CrudService<Log, Long> {
* @param top top number must not be less than 0
* @return a page of latest logs
*/
Page<LogOutputDTO> listLatest(int top);
Page<LogOutputDTO> pageLatest(int top);
}

View File

@ -44,7 +44,7 @@ public interface PostService extends CrudService<Post, Integer> {
* @return latest posts
*/
@NonNull
Page<PostSimpleOutputDTO> listLatest(int top);
Page<PostSimpleOutputDTO> pageLatest(int top);
/**
* List by status and type

View File

@ -39,7 +39,7 @@ public class CommentServiceImpl extends AbstractCrudService<Comment, Long> imple
}
@Override
public Page<CommentVO> listLatest(int top) {
public Page<CommentVO> pageLatest(int top) {
Assert.isTrue(top > 0, "Top number must not be less than 0");
// Build page request

View File

@ -28,7 +28,7 @@ public class LogServiceImpl extends AbstractCrudService<Log, Long> implements Lo
}
@Override
public Page<LogOutputDTO> listLatest(int top) {
public Page<LogOutputDTO> pageLatest(int top) {
Assert.isTrue(top > 0, "Top number must not be less than 0");
// Build page request

View File

@ -30,7 +30,7 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
}
/**
* Save one option
* Saves one option
*
* @param key key
* @param value value
@ -45,24 +45,24 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
return;
}
Option options = optionRepository.findByOptionKey(key).map(option -> {
Option option = optionRepository.findByOptionKey(key).map(anOption -> {
// Exist
option.setOptionValue(value);
return option;
anOption.setOptionValue(value);
return anOption;
}).orElseGet(() -> {
// Not exist
Option option = new Option();
option.setOptionKey(key);
option.setOptionValue(value);
return option;
Option anOption = new Option();
anOption.setOptionKey(key);
anOption.setOptionValue(value);
return anOption;
});
// Save or update the options
optionRepository.save(options);
optionRepository.save(option);
}
/**
* Save multiple options
* Saves multiple options
*
* @param options options
*/
@ -74,7 +74,7 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
}
/**
* Get all options
* Gets all options
*
* @return Map
*/
@ -84,7 +84,7 @@ public class OptionServiceImpl extends AbstractCrudService<Option, Integer> impl
}
/**
* Get option by key
* Gets option by key
*
* @param key key
* @return String

View File

@ -59,7 +59,7 @@ public class PostServiceImpl extends AbstractCrudService<Post, Integer> implemen
}
@Override
public Page<PostSimpleOutputDTO> listLatest(int top) {
public Page<PostSimpleOutputDTO> pageLatest(int top) {
Assert.isTrue(top > 0, "Top number must not be less than 0");
PageRequest latestPageable = PageRequest.of(0, top, Sort.by(Sort.Direction.DESC, "editTime"));

View File

@ -52,11 +52,11 @@ public class AdminController {
@GetMapping(value = {"", "index"})
public String admin(Model model) {
Page<PostSimpleOutputDTO> postPage = postService.listLatest(5);
Page<PostSimpleOutputDTO> postPage = postService.pageLatest(5);
Page<CommentVO> commentPage = commentService.listLatest(5);
Page<CommentVO> commentPage = commentService.pageLatest(5);
Page<LogOutputDTO> logPage = logService.listLatest(5);
Page<LogOutputDTO> logPage = logService.pageLatest(5);
model.addAttribute("postsCount", postPage.getTotalElements());
model.addAttribute("commentsCount", commentPage.getTotalElements());

View File

@ -18,7 +18,7 @@ spring:
# H2database 配置
driver-class-name: org.h2.Driver
url: jdbc:h2:file:~/halo/db/halo
url: jdbc:h2:file:~/halo-dev/db/halo
username: admin
password: 123456