Skip to content

Commit 60cef37

Browse files
author
shimh-develop
committed
验证
1 parent 89401a3 commit 60cef37

File tree

7 files changed

+22
-10
lines changed

7 files changed

+22
-10
lines changed

blog-api/blog/blog.log

Whitespace-only changes.

blog-api/src/main/java/com/shimh/controller/CommentController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.util.List;
44

5+
import javax.validation.Valid;
6+
57
import org.apache.shiro.authz.annotation.RequiresAuthentication;
68
import org.apache.shiro.authz.annotation.RequiresRoles;
79
import org.springframework.beans.factory.annotation.Autowired;
@@ -87,7 +89,7 @@ public Result listCommentsByArticle(@PathVariable("id") Integer id){
8789

8890
@PostMapping("/create")
8991
@RequiresAuthentication
90-
public Result saveComment(@RequestBody Comment comment){
92+
public Result saveComment(@Validated @RequestBody Comment comment){
9193

9294
Integer commentId = commentService.saveComment(comment);
9395

blog-api/src/main/java/com/shimh/entity/Article.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import javax.persistence.Temporal;
1818
import javax.persistence.TemporalType;
1919

20+
import org.hibernate.validator.constraints.NotBlank;
2021
import org.springframework.format.annotation.DateTimeFormat;
2122

2223
import com.alibaba.fastjson.annotation.JSONField;
@@ -42,10 +43,11 @@ public class Article extends BaseEntity<Integer>{
4243
*/
4344
private static final long serialVersionUID = -4470366380115322213L;
4445

45-
46+
@NotBlank
4647
@Column(name = "title", length = 40)
4748
private String title;
4849

50+
@NotBlank
4951
@Column(name = "summary", length = 100)
5052
private String summary;
5153

blog-api/src/main/java/com/shimh/entity/Category.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import javax.persistence.Table;
55
import javax.persistence.Transient;
66

7+
import org.hibernate.validator.constraints.NotBlank;
8+
79
import com.shimh.common.entity.BaseEntity;
810
/**
911
* 文章分类
@@ -22,11 +24,12 @@ public class Category extends BaseEntity<Integer>{
2224
*/
2325
private static final long serialVersionUID = 5025313969040054182L;
2426

25-
27+
@NotBlank
2628
private String categoryname;
2729

2830
private String description;
2931

32+
@NotBlank
3033
private String avatar;
3134

3235

blog-api/src/main/java/com/shimh/entity/Comment.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import javax.persistence.TemporalType;
1313
import javax.persistence.Transient;
1414

15+
import org.hibernate.validator.constraints.NotBlank;
16+
1517
import com.alibaba.fastjson.annotation.JSONField;
1618
import com.shimh.common.entity.BaseEntity;
1719
/**
@@ -28,6 +30,7 @@ public class Comment extends BaseEntity<Integer>{
2830

2931
private static final long serialVersionUID = 7346271954336613146L;
3032

33+
@NotBlank
3134
private String content;
3235

3336
@ManyToOne(fetch = FetchType.LAZY)

blog-api/src/main/java/com/shimh/entity/Tag.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import javax.persistence.Entity;
44
import javax.persistence.Table;
55

6+
import org.hibernate.validator.constraints.NotBlank;
7+
68
import com.shimh.common.entity.BaseEntity;
79
/**
810
* 文章标签
@@ -21,10 +23,10 @@ public class Tag extends BaseEntity<Integer>{
2123
*/
2224
private static final long serialVersionUID = 5025313969040054182L;
2325

24-
26+
@NotBlank
2527
private String tagname;
2628

27-
29+
@NotBlank
2830
private String avatar;
2931

3032

blog-api/src/main/resources/log4j2-spring.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
</Console>
2323

2424
<!--文件会打印出所有信息,这个log每次运行程序会自动清空,由append属性决定,这个也挺有用的,适合临时测试用-->
25-
<File name="Log" fileName="me/test.log" append="false">
25+
<File name="Log" fileName="blog/blog.log" append="false">
2626
<PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n"/>
2727
</File>
2828

2929
<!-- 设置日志格式并配置日志压缩格式(service.log.年份.gz) -->
3030
<RollingRandomAccessFile name="RollingRandomAccessFileWarn"
31-
immediateFlush="false" fileName="${sys:user.home}/me/warn.log"
32-
filePattern="${sys:user.home}/me/$${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log">
31+
immediateFlush="false" fileName="${sys:user.home}/blog/warn.log"
32+
filePattern="${sys:user.home}/blog/$${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log">
3333
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
3434
<!--
3535
%d{yyyy-MM-dd HH:mm:ss, SSS} : 日志生产时间
@@ -51,8 +51,8 @@
5151
</Policies>
5252
</RollingRandomAccessFile>
5353

54-
<RollingFile name="RollingFileError" fileName="${sys:user.home}/me/error.log"
55-
filePattern="${sys:user.home}/me/$${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log">
54+
<RollingFile name="RollingFileError" fileName="${sys:user.home}/blog/error.log"
55+
filePattern="${sys:user.home}/blog/$${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log">
5656
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY"/>
5757
<!-- [%d{HH:mm:ss:SSS}] [%p] - %l - %m%n -->
5858
<PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M -- %msg%xEx%n"/>

0 commit comments

Comments
 (0)