Skip to content

Commit

Permalink
Server:新增支持登录时传全局默认 格式化[]等特殊字符的配置 format:Boolean
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyLemon committed Sep 9, 2018
1 parent e482237 commit 4cd9e7e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public String openHead(@PathVariable String request, HttpSession session) {
}

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;

Expand Down Expand Up @@ -419,6 +420,7 @@ public JSONObject login(@RequestBody String request, HttpSession session) {
String phone;
String password;
int version;
Boolean format;
try {
requestObject = DemoParser.parseRequest(request);

Expand All @@ -440,9 +442,11 @@ public JSONObject login(@RequestBody String request, HttpSession session) {
}
}

//全局版本号
//全局版本号,是否格式化
version = requestObject.getIntValue(VERSION);
format = requestObject.getBoolean(FORMAT);
requestObject.remove(VERSION);
requestObject.remove(FORMAT);
} catch (Exception e) {
return DemoParser.extendErrorResult(requestObject, e);
}
Expand Down Expand Up @@ -511,6 +515,7 @@ public JSONObject login(@RequestBody String request, HttpSession session) {
session.setAttribute(USER_, user);//用户
session.setAttribute(PRIVACY_, privacy);//用户隐私信息
session.setAttribute(VERSION, version);//全局默认版本号
session.setAttribute(FORMAT, format);//全局默认格式化配置
// session.setMaxInactiveInterval(1*60);//设置session过期时间

return response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,17 @@ public SQLConfig createSQLConfig() {
public SQLExecutor createSQLExecutor() {
return new DemoSQLExecutor();
}




@Override
public JSONObject parseResponse(JSONObject request) {
//补充format
if (session != null && request != null && request.get(JSONRequest.KEY_FORMAT) == null) {
request.put(JSONRequest.KEY_FORMAT, session.getAttribute(JSONRequest.KEY_FORMAT));
}
return super.parseResponse(request);
}


@Override
public DemoObjectParser createObjectParser(JSONObject request, String parentPath, String name, SQLConfig arrayConfig) throws Exception {

Expand Down Expand Up @@ -106,12 +114,12 @@ public JSONObject parseResponse(JSONRequest request) throws Exception {
}.setMethod(requestMethod).setParser(this);
}



@Override
protected void onVerifyContent() throws Exception {
//补充全局缺省版本号
if (session != null && requestObject.getIntValue(JSONRequest.KEY_VERSION) <= 0) {
//补充全局缺省版本号 //可能在默认为1的前提下这个请求version就需要为0 requestObject.getIntValue(JSONRequest.KEY_VERSION) <= 0) {
if (session != null && requestObject.get(JSONRequest.KEY_VERSION) == null) {
requestObject.put(JSONRequest.KEY_VERSION, session.getAttribute(JSONRequest.KEY_VERSION));
}
super.onVerifyContent();
Expand Down

0 comments on commit 4cd9e7e

Please sign in to comment.