File tree 3 files changed +33
-50
lines changed
3 files changed +33
-50
lines changed Original file line number Diff line number Diff line change
1
+ package seed .config ;
2
+
3
+ import org .springframework .boot .autoconfigure .web .HttpMessageConverters ;
4
+ import org .springframework .context .annotation .Bean ;
5
+ import org .springframework .context .annotation .Configuration ;
6
+ import org .springframework .http .converter .HttpMessageConverter ;
7
+
8
+ import com .alibaba .fastjson .support .spring .FastJsonHttpMessageConverter ;
9
+
10
+ /**
11
+ * 配置fastjson替换jackson
12
+ *
13
+ * @author 马兆永
14
+ */
15
+ @ Configuration
16
+ public class FastJSONConfig {
17
+
18
+ @ Bean
19
+ public HttpMessageConverters customConverters () {
20
+ HttpMessageConverter <?> additional = new FastJsonHttpMessageConverter ();
21
+ return new HttpMessageConverters (additional );
22
+ }
23
+
24
+ }
Original file line number Diff line number Diff line change 1
1
package seed .core .model ;
2
2
3
- import com .fasterxml .jackson .annotation .JsonFormat ;
4
- import org .springframework .format .annotation .DateTimeFormat ;
3
+ import java .util .Date ;
5
4
6
5
import javax .persistence .Id ;
7
6
import javax .persistence .MappedSuperclass ;
8
- import java .util .Date ;
7
+
8
+ import com .alibaba .fastjson .annotation .JSONField ;
9
9
10
10
/**
11
11
* 模型的基础类
@@ -26,8 +26,7 @@ public abstract class BaseModel implements IBaseModel{
26
26
/**
27
27
* 时间戳
28
28
*/
29
- @ JsonFormat (pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8" )
30
- @ DateTimeFormat (pattern = "yyyy-MM-dd HH:mm:ss" )
29
+ @ JSONField (format ="yyyy-MM-dd HH:mm:ss" )
31
30
private Date ts ;
32
31
/**
33
32
*
Original file line number Diff line number Diff line change 1
1
package seed .demo .models ;
2
2
3
- import java .util .Date ;
4
-
5
3
import javax .persistence .Entity ;
6
- import javax .persistence .Id ;
7
4
import javax .persistence .Table ;
8
5
9
- import org .springframework .format .annotation .DateTimeFormat ;
10
-
11
- import com .fasterxml .jackson .annotation .JsonFormat ;
12
-
13
- import seed .core .model .IBaseModel ;
6
+ import seed .core .model .BaseModel ;
14
7
15
8
/**
16
9
* 用户数据模型
20
13
**/
21
14
@ Entity
22
15
@ Table (name ="sm_user" )
23
- public class User implements IBaseModel {
24
- @ Id
25
- private String id ;
16
+ public class User extends BaseModel {
17
+
18
+ private static final long serialVersionUID = 1657158559598921654L ;
26
19
27
- private String code ;
20
+ private String code ;
28
21
29
22
private String name ;
30
23
@@ -44,25 +37,11 @@ public class User implements IBaseModel {
44
37
45
38
private String memo ;
46
39
47
- @ JsonFormat (pattern = "yyyy-MM-dd HH:mm:ss" ,timezone ="GMT+8" )
48
- @ DateTimeFormat (pattern = "yyyy-MM-dd HH:mm:ss" )
49
- private Date ts ;
50
-
51
- private Short dr ;
52
40
53
41
public User () {
54
42
55
43
}
56
44
57
- @ Override
58
- public String getId () {
59
- return id ;
60
- }
61
-
62
- public void setId (String id ) {
63
- this .id = id ;
64
- }
65
-
66
45
public String getCode () {
67
46
return code ;
68
47
}
@@ -143,23 +122,4 @@ public void setMemo(String memo) {
143
122
this .memo = memo ;
144
123
}
145
124
146
- @ Override
147
- public Date getTs () {
148
- return ts ;
149
- }
150
-
151
- @ Override
152
- public void setTs (Date ts ) {
153
- this .ts = ts ;
154
- }
155
-
156
- @ Override
157
- public Short getDr () {
158
- return dr ;
159
- }
160
-
161
- @ Override
162
- public void setDr (Short dr ) {
163
- this .dr = dr ;
164
- }
165
125
}
You can’t perform that action at this time.
0 commit comments