mirror of https://github.com/halo-dev/halo
Translate some tips
parent
90d81b7871
commit
a6697c5d6b
|
@ -62,7 +62,7 @@ public class CacheLockInterceptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cacheResult) {
|
if (!cacheResult) {
|
||||||
throw new FrequentAccessException("Frequent access").setErrorData(cacheLockKey);
|
throw new FrequentAccessException("访问过于频繁,请稍后再试!").setErrorData(cacheLockKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Proceed the method
|
// Proceed the method
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class ControllerExceptionHandler {
|
||||||
public BaseResponse handleConstraintViolationException(ConstraintViolationException e) {
|
public BaseResponse handleConstraintViolationException(ConstraintViolationException e) {
|
||||||
BaseResponse<Map<String, String>> baseResponse = handleBaseException(e);
|
BaseResponse<Map<String, String>> baseResponse = handleBaseException(e);
|
||||||
baseResponse.setStatus(HttpStatus.BAD_REQUEST.value());
|
baseResponse.setStatus(HttpStatus.BAD_REQUEST.value());
|
||||||
baseResponse.setMessage("Field validation error");
|
baseResponse.setMessage("字段验证错误,请完善后重试!");
|
||||||
baseResponse.setData(ValidationUtils.mapWithValidError(e.getConstraintViolations()));
|
baseResponse.setData(ValidationUtils.mapWithValidError(e.getConstraintViolations()));
|
||||||
return baseResponse;
|
return baseResponse;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class ControllerExceptionHandler {
|
||||||
public BaseResponse handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
public BaseResponse handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
|
||||||
BaseResponse<Map<String, String>> baseResponse = handleBaseException(e);
|
BaseResponse<Map<String, String>> baseResponse = handleBaseException(e);
|
||||||
baseResponse.setStatus(HttpStatus.BAD_REQUEST.value());
|
baseResponse.setStatus(HttpStatus.BAD_REQUEST.value());
|
||||||
baseResponse.setMessage("Field validation error");
|
baseResponse.setMessage("字段验证错误,请完善后重试!");
|
||||||
Map<String, String> errMap = ValidationUtils.mapWithFieldError(e.getBindingResult().getFieldErrors());
|
Map<String, String> errMap = ValidationUtils.mapWithFieldError(e.getBindingResult().getFieldErrors());
|
||||||
baseResponse.setData(errMap);
|
baseResponse.setData(errMap);
|
||||||
return baseResponse;
|
return baseResponse;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.web.SortDefault;
|
import org.springframework.data.web.SortDefault;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import run.halo.app.cache.lock.CacheLock;
|
||||||
import run.halo.app.model.dto.BaseCommentDTO;
|
import run.halo.app.model.dto.BaseCommentDTO;
|
||||||
import run.halo.app.model.params.JournalCommentParam;
|
import run.halo.app.model.params.JournalCommentParam;
|
||||||
import run.halo.app.model.vo.BaseCommentVO;
|
import run.halo.app.model.vo.BaseCommentVO;
|
||||||
|
@ -56,6 +57,7 @@ public class JournalController {
|
||||||
|
|
||||||
@PostMapping("comments")
|
@PostMapping("comments")
|
||||||
@ApiOperation("Comments a post")
|
@ApiOperation("Comments a post")
|
||||||
|
@CacheLock(autoDelete = false, traceRequest = true)
|
||||||
public BaseCommentDTO comment(@RequestBody JournalCommentParam journalCommentParam) {
|
public BaseCommentDTO comment(@RequestBody JournalCommentParam journalCommentParam) {
|
||||||
return journalCommentService.convertTo(journalCommentService.createBy(journalCommentParam));
|
return journalCommentService.convertTo(journalCommentService.createBy(journalCommentParam));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.web.PageableDefault;
|
import org.springframework.data.web.PageableDefault;
|
||||||
import org.springframework.data.web.SortDefault;
|
import org.springframework.data.web.SortDefault;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import run.halo.app.cache.lock.CacheLock;
|
||||||
import run.halo.app.model.dto.BaseCommentDTO;
|
import run.halo.app.model.dto.BaseCommentDTO;
|
||||||
import run.halo.app.model.dto.post.BasePostDetailDTO;
|
import run.halo.app.model.dto.post.BasePostDetailDTO;
|
||||||
import run.halo.app.model.dto.post.BasePostSimpleDTO;
|
import run.halo.app.model.dto.post.BasePostSimpleDTO;
|
||||||
|
@ -91,6 +92,7 @@ public class PostController {
|
||||||
|
|
||||||
@PostMapping("comments")
|
@PostMapping("comments")
|
||||||
@ApiOperation("Comments a post")
|
@ApiOperation("Comments a post")
|
||||||
|
@CacheLock(autoDelete = false, traceRequest = true)
|
||||||
public BaseCommentDTO comment(@RequestBody PostCommentParam postCommentParam) {
|
public BaseCommentDTO comment(@RequestBody PostCommentParam postCommentParam) {
|
||||||
return postCommentService.convertTo(postCommentService.createBy(postCommentParam));
|
return postCommentService.convertTo(postCommentService.createBy(postCommentParam));
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.data.web.SortDefault;
|
import org.springframework.data.web.SortDefault;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import run.halo.app.cache.lock.CacheLock;
|
||||||
import run.halo.app.model.dto.BaseCommentDTO;
|
import run.halo.app.model.dto.BaseCommentDTO;
|
||||||
import run.halo.app.model.params.SheetCommentParam;
|
import run.halo.app.model.params.SheetCommentParam;
|
||||||
import run.halo.app.model.vo.BaseCommentVO;
|
import run.halo.app.model.vo.BaseCommentVO;
|
||||||
|
@ -57,6 +58,7 @@ public class SheetController {
|
||||||
|
|
||||||
@PostMapping("comments")
|
@PostMapping("comments")
|
||||||
@ApiOperation("Comments a post")
|
@ApiOperation("Comments a post")
|
||||||
|
@CacheLock(autoDelete = false, traceRequest = true)
|
||||||
public BaseCommentDTO comment(@RequestBody SheetCommentParam sheetCommentParam) {
|
public BaseCommentDTO comment(@RequestBody SheetCommentParam sheetCommentParam) {
|
||||||
return sheetCommentService.convertTo(sheetCommentService.createBy(sheetCommentParam));
|
return sheetCommentService.convertTo(sheetCommentService.createBy(sheetCommentParam));
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,20 +19,20 @@ import java.lang.reflect.ParameterizedType;
|
||||||
@Data
|
@Data
|
||||||
public abstract class BaseCommentParam<COMMENT> implements InputConverter<COMMENT> {
|
public abstract class BaseCommentParam<COMMENT> implements InputConverter<COMMENT> {
|
||||||
|
|
||||||
@NotBlank(message = "PostComment author name must not be blank")
|
@NotBlank(message = "评论者名称不能为空")
|
||||||
@Size(max = 50, message = "Length of comment author name must not be more than {max}")
|
@Size(max = 50, message = "Length of comment author name must not be more than {max}")
|
||||||
private String author;
|
private String author;
|
||||||
|
|
||||||
@NotBlank(message = "PostComment email must not be blank")
|
@NotBlank(message = "邮箱不能为空")
|
||||||
@Email(message = "PostComment email's format is incorrect")
|
@Email(message = "邮箱格式不正确")
|
||||||
@Size(max = 255, message = "Length of comment email must not be more than {max}")
|
@Size(max = 255, message = "邮箱的长度不能超过 {max}")
|
||||||
private String email;
|
private String email;
|
||||||
|
|
||||||
@Size(max = 127, message = "Length of comment author url must not be more than {max}")
|
@Size(max = 127, message = "评论者博客链接不能超过 {max}")
|
||||||
private String authorUrl;
|
private String authorUrl;
|
||||||
|
|
||||||
@NotBlank(message = "PostComment content must not be blank")
|
@NotBlank(message = "评论内容不能为空")
|
||||||
@Size(max = 1023, message = "Length of comment content must not be more than {max}")
|
@Size(max = 1023, message = "评论内容的长额不能超过 {max}")
|
||||||
private String content;
|
private String content;
|
||||||
|
|
||||||
@Min(value = 1, message = "Post id must not be less than {value}")
|
@Min(value = 1, message = "Post id must not be less than {value}")
|
||||||
|
|
Loading…
Reference in New Issue