File tree Expand file tree Collapse file tree 7 files changed +22
-10
lines changed Expand file tree Collapse file tree 7 files changed +22
-10
lines changed Original file line number Diff line number Diff line change 2
2
3
3
import java .util .List ;
4
4
5
+ import javax .validation .Valid ;
6
+
5
7
import org .apache .shiro .authz .annotation .RequiresAuthentication ;
6
8
import org .apache .shiro .authz .annotation .RequiresRoles ;
7
9
import org .springframework .beans .factory .annotation .Autowired ;
@@ -87,7 +89,7 @@ public Result listCommentsByArticle(@PathVariable("id") Integer id){
87
89
88
90
@ PostMapping ("/create" )
89
91
@ RequiresAuthentication
90
- public Result saveComment (@ RequestBody Comment comment ){
92
+ public Result saveComment (@ Validated @ RequestBody Comment comment ){
91
93
92
94
Integer commentId = commentService .saveComment (comment );
93
95
Original file line number Diff line number Diff line change 17
17
import javax .persistence .Temporal ;
18
18
import javax .persistence .TemporalType ;
19
19
20
+ import org .hibernate .validator .constraints .NotBlank ;
20
21
import org .springframework .format .annotation .DateTimeFormat ;
21
22
22
23
import com .alibaba .fastjson .annotation .JSONField ;
@@ -42,10 +43,11 @@ public class Article extends BaseEntity<Integer>{
42
43
*/
43
44
private static final long serialVersionUID = -4470366380115322213L ;
44
45
45
-
46
+ @ NotBlank
46
47
@ Column (name = "title" , length = 40 )
47
48
private String title ;
48
49
50
+ @ NotBlank
49
51
@ Column (name = "summary" , length = 100 )
50
52
private String summary ;
51
53
Original file line number Diff line number Diff line change 4
4
import javax .persistence .Table ;
5
5
import javax .persistence .Transient ;
6
6
7
+ import org .hibernate .validator .constraints .NotBlank ;
8
+
7
9
import com .shimh .common .entity .BaseEntity ;
8
10
/**
9
11
* 文章分类
@@ -22,11 +24,12 @@ public class Category extends BaseEntity<Integer>{
22
24
*/
23
25
private static final long serialVersionUID = 5025313969040054182L ;
24
26
25
-
27
+ @ NotBlank
26
28
private String categoryname ;
27
29
28
30
private String description ;
29
31
32
+ @ NotBlank
30
33
private String avatar ;
31
34
32
35
Original file line number Diff line number Diff line change 12
12
import javax .persistence .TemporalType ;
13
13
import javax .persistence .Transient ;
14
14
15
+ import org .hibernate .validator .constraints .NotBlank ;
16
+
15
17
import com .alibaba .fastjson .annotation .JSONField ;
16
18
import com .shimh .common .entity .BaseEntity ;
17
19
/**
@@ -28,6 +30,7 @@ public class Comment extends BaseEntity<Integer>{
28
30
29
31
private static final long serialVersionUID = 7346271954336613146L ;
30
32
33
+ @ NotBlank
31
34
private String content ;
32
35
33
36
@ ManyToOne (fetch = FetchType .LAZY )
Original file line number Diff line number Diff line change 3
3
import javax .persistence .Entity ;
4
4
import javax .persistence .Table ;
5
5
6
+ import org .hibernate .validator .constraints .NotBlank ;
7
+
6
8
import com .shimh .common .entity .BaseEntity ;
7
9
/**
8
10
* 文章标签
@@ -21,10 +23,10 @@ public class Tag extends BaseEntity<Integer>{
21
23
*/
22
24
private static final long serialVersionUID = 5025313969040054182L ;
23
25
24
-
26
+ @ NotBlank
25
27
private String tagname ;
26
28
27
-
29
+ @ NotBlank
28
30
private String avatar ;
29
31
30
32
Original file line number Diff line number Diff line change 22
22
</Console >
23
23
24
24
<!-- 文件会打印出所有信息,这个log每次运行程序会自动清空,由append属性决定,这个也挺有用的,适合临时测试用-->
25
- <File name =" Log" fileName =" me/test .log" append =" false" >
25
+ <File name =" Log" fileName =" blog/blog .log" append =" false" >
26
26
<PatternLayout pattern =" %d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n" />
27
27
</File >
28
28
29
29
<!-- 设置日志格式并配置日志压缩格式(service.log.年份.gz) -->
30
30
<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" >
33
33
<ThresholdFilter level =" info" onMatch =" ACCEPT" onMismatch =" DENY" />
34
34
<!--
35
35
%d{yyyy-MM-dd HH:mm:ss, SSS} : 日志生产时间
51
51
</Policies >
52
52
</RollingRandomAccessFile >
53
53
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" >
56
56
<ThresholdFilter level =" error" onMatch =" ACCEPT" onMismatch =" DENY" />
57
57
<!-- [%d{HH:mm:ss:SSS}] [%p] - %l - %m%n -->
58
58
<PatternLayout pattern =" %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %class{36} %L %M -- %msg%xEx%n" />
You can’t perform that action at this time.
0 commit comments