Skip to content

Commit cdf3937

Browse files
committed
Server:同步eclipse版至idea版;注释session过期设置;UserPrivacy重命名为Privacy;Client:适配Server
1 parent c1b880c commit cdf3937

File tree

43 files changed

+1243
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1243
-500
lines changed

APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/client/activity_fragment/PasswordActivity.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
import apijson.demo.client.model.User;
3939
import apijson.demo.client.model.Verify;
4040
import apijson.demo.client.util.HttpRequest;
41-
import apijson.demo.server.model.UserPrivacy;
41+
import apijson.demo.server.model.Privacy;
4242

4343
/**注册、验证码登录、重置密码等密码相关界面
4444
* @author Lemon
@@ -345,7 +345,7 @@ public void onHttpResponse(int requestCode, String resultJson, Exception e) {
345345
dismissProgressDialog();
346346
switch (requestCode) {
347347
case HTTP_CHECK_REGISTER:
348-
response2 = response.getJSONResponse(HttpRequest.USER_PRIVACY_);
348+
response2 = response.getJSONResponse(HttpRequest.PRIVACY_);
349349
Log.i(TAG, "checkPassword result = " + resultJson);
350350
runUiThread(new Runnable() {
351351
@Override
@@ -428,7 +428,7 @@ public void run() {
428428
}
429429
break;
430430
case HTTP_RESET_PASSWORD:
431-
response2 = response.getJSONResponse(UserPrivacy.class.getSimpleName());
431+
response2 = response.getJSONResponse(Privacy.class.getSimpleName());
432432
dismissProgressDialog();
433433
if (JSONResponse.isSucceed(response2) == false) {
434434
EditTextUtil.showInputedError(context, etPasswordVerify

APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/client/activity_fragment/WalletActivity.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import apijson.demo.client.R;
3232
import apijson.demo.client.model.Wallet;
3333
import apijson.demo.client.util.HttpRequest;
34-
import apijson.demo.server.model.UserPrivacy;
34+
import apijson.demo.server.model.Privacy;
3535

3636
/**钱包界面
3737
* @author Lemon
@@ -84,8 +84,8 @@ public void initView() {//必须调用
8484
}
8585

8686

87-
private UserPrivacy privacy;
88-
public void setWallet(UserPrivacy privacy_) {
87+
private Privacy privacy;
88+
public void setWallet(Privacy privacy_) {
8989
this.privacy = privacy_;
9090
runUiThread(new Runnable() {
9191

@@ -94,7 +94,7 @@ public void run() {
9494
dismissProgressDialog();
9595
tvBaseTitle.setText(getTitleName());
9696
if (privacy == null) {
97-
privacy = new UserPrivacy();
97+
privacy = new Privacy();
9898
}
9999
tvWalletCount.setText(StringUtil.getPrice(privacy.getBalance(), StringUtil.PRICE_FORMAT_PREFIX));
100100
}
@@ -118,7 +118,7 @@ public void run() {
118118
public void initData() {//必须调用
119119

120120
showProgressDialog(getTitleName());
121-
HttpRequest.getUserPrivacy(HTTP_GET, this);
121+
HttpRequest.getPrivacy(HTTP_GET, this);
122122
}
123123

124124
public String getTitleName() {
@@ -187,7 +187,7 @@ public void run() {
187187
break;
188188
case HTTP_GET:
189189
if (isSucceed) {
190-
setWallet(response.getObject(UserPrivacy.class));
190+
setWallet(response.getObject(Privacy.class));
191191
} else {
192192
showShortToast(R.string.get_failed);
193193
}

APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/client/model/User.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
import android.support.annotation.NonNull;
1818
import apijson.demo.client.application.APIJSONApplication;
19-
import apijson.demo.server.model.UserPrivacy;
19+
import apijson.demo.server.model.Privacy;
2020

2121
/**用户类
2222
* @author Lemon
2323
*/
2424
public class User extends apijson.demo.server.model.User {
2525
private static final long serialVersionUID = 1L;
2626

27-
private UserPrivacy privacy;
27+
private Privacy privacy;
2828

2929
public User() {
3030
super();
@@ -34,13 +34,13 @@ public User(long id) {
3434
}
3535

3636
@NonNull
37-
public UserPrivacy getPrivacy() {
37+
public Privacy getPrivacy() {
3838
if (privacy == null) {
39-
privacy = new UserPrivacy(getId());
39+
privacy = new Privacy(getId());
4040
}
4141
return privacy;
4242
}
43-
public User setPrivacy(UserPrivacy privacy) {
43+
public User setPrivacy(Privacy privacy) {
4444
this.privacy = privacy;
4545
return this;
4646
}

APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/client/util/HttpRequest.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import zuo.biao.apijson.JSONObject;
2121
import zuo.biao.apijson.JSONRequest;
2222
import zuo.biao.apijson.JSONResponse;
23-
import zuo.biao.apijson.RequestRole;
2423
import zuo.biao.library.manager.HttpManager.OnHttpResponseListener;
2524
import zuo.biao.library.util.Log;
2625
import zuo.biao.library.util.SettingUtil;
@@ -32,8 +31,8 @@
3231
import apijson.demo.server.model.Login;
3332
import apijson.demo.server.model.Moment;
3433
import apijson.demo.server.model.Password;
34+
import apijson.demo.server.model.Privacy;
3535
import apijson.demo.server.model.User;
36-
import apijson.demo.server.model.UserPrivacy;
3736
import apijson.demo.server.model.Verify;
3837
import apijson.demo.server.model.Wallet;
3938

@@ -135,14 +134,14 @@ public static void delete(JSONObject request, int requestCode, OnHttpResponseLis
135134

136135
//加 _ 表示class名,避免PASSWORD不知道是 Password 还是 password 这种冲突
137136
public static final String USER_;
138-
public static final String USER_PRIVACY_;
137+
public static final String PRIVACY_;
139138
public static final String MOMENT_;
140139
public static final String COMMENT_;
141140
public static final String WALLET_;
142141
public static final String VERIFY_;
143142
static {
144143
USER_ = User.class.getSimpleName();
145-
USER_PRIVACY_ = UserPrivacy.class.getSimpleName();
144+
PRIVACY_ = Privacy.class.getSimpleName();
146145
MOMENT_ = Moment.class.getSimpleName();
147146
COMMENT_ = Comment.class.getSimpleName();
148147
WALLET_ = Wallet.class.getSimpleName();
@@ -240,7 +239,7 @@ public static void setPassword(String verify, String phone, String password
240239
* @param listener
241240
*/
242241
public static void checkRegister(String phone, int requestCode, OnHttpResponseListener listener) {
243-
head(new JSONRequest(new UserPrivacy().setPhone(phone)), requestCode, listener);
242+
head(new JSONRequest(new Privacy().setPhone(phone)), requestCode, listener);
244243
}
245244

246245
/**登录
@@ -649,10 +648,10 @@ public static void deleteComment(long id, int requestCode, OnHttpResponseListene
649648
* @param requestCode
650649
* @param listener
651650
*/
652-
public static void getUserPrivacy(int requestCode, OnHttpResponseListener listener) {
651+
public static void getPrivacy(int requestCode, OnHttpResponseListener listener) {
653652
postGet(new JSONRequest(
654-
new UserPrivacy(application.getCurrentUserId())
655-
).setTag(USER_PRIVACY_), requestCode, listener);
653+
new Privacy(application.getCurrentUserId())
654+
).setTag(PRIVACY_), requestCode, listener);
656655
}
657656

658657
/**修改余额
@@ -662,13 +661,13 @@ public static void getUserPrivacy(int requestCode, OnHttpResponseListener listen
662661
* @param listener
663662
*/
664663
public static void changeBalance(double change, String payPassword, int requestCode, OnHttpResponseListener listener) {
665-
JSONObject userPrivacy = new JSONObject(
666-
new UserPrivacy(application.getCurrentUserId()).setPayPassword(payPassword)
664+
JSONObject privacy = new JSONObject(
665+
new Privacy(application.getCurrentUserId()).setPayPassword(payPassword)
667666
);
668-
userPrivacy.put("balance+", change, true);
669-
JSONRequest request = new JSONRequest(USER_PRIVACY_, userPrivacy);
667+
privacy.put("balance+", change, true);
668+
JSONRequest request = new JSONRequest(PRIVACY_, privacy);
670669

671-
HttpManager.getInstance().post(URL_BASE + "put/balance", request.setTag(USER_PRIVACY_), requestCode, listener);
670+
HttpManager.getInstance().post(URL_BASE + "put/balance", request.setTag(PRIVACY_), requestCode, listener);
672671
}
673672

674673

APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/BaseModel.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
package apijson.demo.server.model;
1616

1717
import java.io.Serializable;
18+
import java.sql.Timestamp;
1819
import java.util.Arrays;
1920
import java.util.Collection;
21+
import java.util.Date;
2022
import java.util.Map;
2123

2224
import com.alibaba.fastjson.JSON;
@@ -28,8 +30,9 @@
2830
public abstract class BaseModel implements Serializable {
2931
private static final long serialVersionUID = 1L;
3032

31-
private Long id;
32-
private Long date;
33+
private Long id; //主键,唯一标识
34+
private Long userId; //对应User表中的id,外键
35+
private Long date; //创建时间,JSON没有Date,TimeStamp类型,都会被转成Long,不能用!
3336

3437
public Long getId() {
3538
return id;
@@ -38,6 +41,13 @@ public BaseModel setId(Long id) {
3841
this.id = id;
3942
return this;
4043
}
44+
public Long getUserId() {
45+
return userId;
46+
}
47+
public BaseModel setUserId(Long userId) {
48+
this.userId = userId;
49+
return this;
50+
}
4151
public Long getDate() {
4252
return date;
4353
}
@@ -52,7 +62,29 @@ public String toString() {
5262
return JSON.toJSONString(this);
5363
}
5464

55-
65+
66+
/**获取当前时间戳
67+
* @return
68+
*/
69+
public static Timestamp currentTimeStamp() {
70+
return new Timestamp(new Date().getTime());
71+
}
72+
/**获取时间戳 TODO 判空? 还是要报错?
73+
* @param time
74+
* @return
75+
*/
76+
public static Timestamp getTimeStamp(String time) {
77+
return Timestamp.valueOf(time);
78+
}
79+
/**获取时间毫秒值 TODO 判空? 还是要报错?
80+
* @param time
81+
* @return
82+
*/
83+
public static long getTimeMillis(String time) {
84+
return getTimeStamp(time).getTime();
85+
}
86+
87+
5688
//判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
5789
/**判断array是否为空
5890
* @param array

APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/Comment.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public class Comment extends BaseModel {
3333
private static final long serialVersionUID = 1L;
3434

3535
private Long toId;
36-
private Long userId;
3736
private Long momentId;
3837
private String content;
3938
public Comment() {
@@ -52,11 +51,8 @@ public Comment setToId(Long toId) {
5251
this.toId = toId;
5352
return this;
5453
}
55-
public Long getUserId() {
56-
return userId;
57-
}
5854
public Comment setUserId(Long userId) {
59-
this.userId = userId;
55+
super.setUserId(userId);
6056
return this;
6157
}
6258
public Long getMomentId() {

APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/Moment.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
public class Moment extends BaseModel {
5151
private static final long serialVersionUID = 1L;
5252

53-
private Long userId;
5453
private String content;
5554
private List<String> pictureList;
5655
private List<Long> praiseUserIdList;
@@ -64,11 +63,9 @@ public Moment(long id) {
6463
setId(id);
6564
}
6665

67-
public Long getUserId() {
68-
return userId;
69-
}
66+
7067
public Moment setUserId(Long userId) {
71-
this.userId = userId;
68+
super.setUserId(userId);
7269
return this;
7370
}
7471
public String getContent() {

APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/Password.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import zuo.biao.apijson.MethodAccess;
2323
import zuo.biao.apijson.StringUtil;
2424

25-
/**密码类,已用UserPrivacy替代
25+
/**密码类,已用privacy替代
2626
* @author Lemon
2727
* @see
2828
* <br >POST_HEAD:<pre>

APIJSON-Java-Server/APIJSON-Eclipse/src/main/java/apijson/demo/server/model/UserPrivacy.java renamed to APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/Privacy.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import zuo.biao.apijson.MethodAccess;
88

9-
/**会员隐私信息表
9+
/**用户隐私信息类
1010
* @author Lemon
1111
*/
1212
@MethodAccess(
@@ -15,24 +15,24 @@
1515
POST = {UNKNOWN, ADMIN},
1616
DELETE = {ADMIN}
1717
)
18-
public class UserPrivacy extends BaseModel {
18+
public class Privacy extends BaseModel {
1919
private static final long serialVersionUID = 1L;
2020

2121
private String phone; //手机
2222
private String password; //登录密码,隐藏字段
2323
private String payPassword; //支付密码,隐藏字段
2424
private Double balance; //余额
2525

26-
public UserPrivacy() {
26+
public Privacy() {
2727
super();
2828
}
2929

30-
public UserPrivacy(long id) {
30+
public Privacy(long id) {
3131
this();
3232
setId(id);
3333
}
3434

35-
public UserPrivacy(String phone, String password) {
35+
public Privacy(String phone, String password) {
3636
this();
3737
setPhone(phone);
3838
setPassword(password);
@@ -43,7 +43,7 @@ public UserPrivacy(String phone, String password) {
4343
public String getPhone() {
4444
return phone;
4545
}
46-
public UserPrivacy setPhone(String phone) {
46+
public Privacy setPhone(String phone) {
4747
this.phone = phone;
4848
return this;
4949
}
@@ -54,7 +54,7 @@ public UserPrivacy setPhone(String phone) {
5454
public String get__password() {
5555
return password;
5656
}
57-
public UserPrivacy setPassword(String password) {
57+
public Privacy setPassword(String password) {
5858
this.password = password;
5959
return this;
6060
}
@@ -65,15 +65,15 @@ public UserPrivacy setPassword(String password) {
6565
public String get__payPassword() {
6666
return payPassword;
6767
}
68-
public UserPrivacy setPayPassword(String payPassword) {
68+
public Privacy setPayPassword(String payPassword) {
6969
this.payPassword = payPassword;
7070
return this;
7171
}
7272

7373
public Double getBalance() {
7474
return balance;
7575
}
76-
public UserPrivacy setBalance(Double balance) {
76+
public Privacy setBalance(Double balance) {
7777
this.balance = balance;
7878
return this;
7979
}

APIJSON-Android/APIJSON-ADT/APIJSONApp/APIJSONApp/src/apijson/demo/server/model/User.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
POST = {UNKNOWN, ADMIN},
5656
DELETE = {ADMIN}
5757
)
58-
public class User extends BaseModel{
58+
public class User extends BaseModel {
5959
private static final long serialVersionUID = 1L;
6060

6161
public static final int SEX_MAIL = 0;

0 commit comments

Comments
 (0)