Skip to content

Commit 20464b2

Browse files
committed
Server:新增登录时上传全局版本号
1 parent a907f71 commit 20464b2

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/apijson/demo/server/Controller.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ public String open_head(@PathVariable String request, HttpSession session) {
211211
VERIFY_ = Verify.class.getSimpleName();
212212
}
213213

214+
public static final String VERSION = JSONRequest.KEY_VERSION;
214215
public static final String COUNT = JSONResponse.KEY_COUNT;
215216
public static final String TOTAL = JSONResponse.KEY_TOTAL;
216217

@@ -232,6 +233,7 @@ public String open_head(@PathVariable String request, HttpSession session) {
232233
public static final String TYPE = "type";
233234
public static final String WAY = "way";
234235
public static final String CONTENT = "content";
236+
235237

236238

237239

@@ -400,9 +402,10 @@ private JSONObject newVerifyRequest(int type, String phone, String verify) {
400402
* @see
401403
* <pre>
402404
{
403-
"type": 0,
405+
"type": 0, //登录方式,非必须 0-密码 2-验证码
404406
"phone": "13000082001",
405-
"password": "1234567"
407+
"password": "1234567",
408+
"version": 1 //全局版本号,非必须
406409
}
407410
* </pre>
408411
*/
@@ -412,6 +415,7 @@ public JSONObject login(@RequestBody String request, HttpSession session) {
412415
boolean isPassword;
413416
String phone;
414417
String password;
418+
int version;
415419
try {
416420
requestObject = Parser.parseRequest(request, POST);
417421

@@ -432,6 +436,8 @@ public JSONObject login(@RequestBody String request, HttpSession session) {
432436
throw new IllegalArgumentException("验证码不合法!");
433437
}
434438
}
439+
440+
version = requestObject.getIntValue(VERSION);
435441
} catch (Exception e) {
436442
return Parser.extendErrorResult(requestObject, e);
437443
}
@@ -499,6 +505,7 @@ public JSONObject login(@RequestBody String request, HttpSession session) {
499505
session.setAttribute(TYPE, isPassword ? LOGIN_TYPE_PASSWORD : LOGIN_TYPE_VERIFY);//登录方式
500506
session.setAttribute(USER_, user);//用户
501507
session.setAttribute(PRIVACY_, privacy);//用户隐私信息
508+
session.setAttribute(VERSION, version);//用户隐私信息
502509
// session.setMaxInactiveInterval(1*60);//设置session过期时间
503510

504511
return response;

APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/zuo/biao/apijson/server/Parser.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.alibaba.fastjson.JSONObject;
3131

3232
import apijson.demo.server.Verifier;
33+
import apijson.demo.server.model.BaseModel;
3334
import apijson.demo.server.model.User;
3435
import zuo.biao.apijson.JSON;
3536
import zuo.biao.apijson.JSONResponse;
@@ -172,6 +173,11 @@ public JSONObject parseResponse(JSONObject request) {
172173
// Verifier.verifyLogin(session);
173174
// }
174175
if (noVerifyRequest == false) {
176+
//补充全局缺省版本号
177+
if (requestObject.getIntValue(JSONRequest.KEY_VERSION) <= 0) {
178+
requestObject.put(JSONRequest.KEY_VERSION, session.getAttribute(JSONRequest.KEY_VERSION));
179+
}
180+
175181
requestObject = getCorrectRequest(requestMethod, requestObject);
176182
}
177183
} catch (Exception e) {

0 commit comments

Comments
 (0)