forked from Tencent/APIJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathController.java
More file actions
executable file
·122 lines (99 loc) · 3.82 KB
/
Copy pathController.java
File metadata and controls
executable file
·122 lines (99 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package apijson.demo.server;
import static zuo.biao.apijson.RequestMethod.GET;
import com.jfinal.kit.HttpKit;
import apijson.demo.server.model.Privacy;
import apijson.demo.server.model.User;
import apijson.demo.server.model.Verify;
import zuo.biao.apijson.JSONResponse;
import zuo.biao.apijson.RequestMethod;
import zuo.biao.apijson.server.JSONRequest;
public class Controller extends com.jfinal.core.Controller {
//通用接口,非事务型操作 和 简单事务型操作 都可通过这些接口自动化实现<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/**获取
* @param request 只用String,避免encode后未decode
* @param session
* @return
* @see {@link RequestMethod#GET}
*/
public void get() {
renderJson(new DemoParser(GET).setSession(getSession()).parse(HttpKit.readData(getRequest())));
}
/**计数
* @param request 只用String,避免encode后未decode
* @param session
* @return
* @see {@link RequestMethod#HEAD}
*/
public void head() {
renderJson(new DemoParser(GET).setSession(getSession()).parse(HttpKit.readData(getRequest())));
}
/**限制性GET,request和response都非明文,浏览器看不到,用于对安全性要求高的GET请求
* @param request 只用String,避免encode后未decode
* @param session
* @return
* @see {@link RequestMethod#GETS}
*/
public void gets() {
renderJson(new DemoParser(GET).setSession(getSession()).parse(HttpKit.readData(getRequest())));
}
/**限制性HEAD,request和response都非明文,浏览器看不到,用于对安全性要求高的HEAD请求
* @param request 只用String,避免encode后未decode
* @param session
* @return
* @see {@link RequestMethod#HEADS}
*/
public void heads() {
renderJson(new DemoParser(GET).setSession(getSession()).parse(HttpKit.readData(getRequest())));
}
/**新增
* @param request 只用String,避免encode后未decode
* @param session
* @return
* @see {@link RequestMethod#POST}
*/
public void post() {
renderJson(new DemoParser(GET).setSession(getSession()).parse(HttpKit.readData(getRequest())));
}
/**修改
* @param request 只用String,避免encode后未decode
* @param session
* @return
* @see {@link RequestMethod#PUT}
*/
public void put() {
renderJson(new DemoParser(GET).setSession(getSession()).parse(HttpKit.readData(getRequest())));
}
/**删除
* @param request 只用String,避免encode后未decode
* @param session
* @return
* @see {@link RequestMethod#DELETE}
*/
public void delete() {
renderJson(new DemoParser(GET).setSession(getSession()).parse(HttpKit.readData(getRequest())));
}
//通用接口,非事务型操作 和 简单事务型操作 都可通过这些接口自动化实现>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
public static final String USER_;
public static final String PRIVACY_;
public static final String VERIFY_; //加下划线后缀是为了避免 Verify 和 verify 都叫VERIFY,分不清
static {
USER_ = User.class.getSimpleName();
PRIVACY_ = Privacy.class.getSimpleName();
VERIFY_ = Verify.class.getSimpleName();
}
public static final String VERSION = JSONRequest.KEY_VERSION;
public static final String FORMAT = JSONRequest.KEY_FORMAT;
public static final String COUNT = JSONResponse.KEY_COUNT;
public static final String TOTAL = JSONResponse.KEY_TOTAL;
public static final String ID = "id";
public static final String USER_ID = "userId";
public static final String CURRENT_USER_ID = "currentUserId";
public static final String NAME = "name";
public static final String PHONE = "phone";
public static final String PASSWORD = "password";
public static final String _PASSWORD = "_password";
public static final String _PAY_PASSWORD = "_payPassword";
public static final String OLD_PASSWORD = "oldPassword";
public static final String VERIFY = "verify";
public static final String TYPE = "type";
}