Skip to content

Commit 3dc3073

Browse files
committed
Server:新增&|!逻辑运算符;Client:优化APIJSONTest工程
1 parent 086ece9 commit 3dc3073

10 files changed

Lines changed: 376 additions & 91 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ public static void getUserList(int range, long id, com.alibaba.fastjson.JSONObje
321321
}
322322
if (range == RANGE_USER_CIRCLE) {
323323
list.add(currentUser.getId());
324+
} else {//问题可能在于登录状态错误
325+
list.remove(currentUser.getId());//避免误添加
324326
}
325327
userItem.put(ID_IN, list);
326328
break;

APIJSON(Android)/APIJSON(ADT)/APIJSONTest/src/apijson/demo/RequestUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static JSONObject newComplexRequest(boolean encode) {
107107
request.put(User.class.getSimpleName(), new JSONRequest("id@", "/Moment/userId", encode), encode);
108108

109109
request.add(new JSONRequest(Comment.class.getSimpleName()
110-
, new JSONRequest("workId@", "[]/Moment/id", encode), encode).
110+
, new JSONRequest("momentId@", "[]/Moment/id", encode), encode).
111111
toArray(3, 0, Comment.class.getSimpleName()), encode);
112112

113113
return request.toArray(3, 0, encode);

APIJSON(Android)/APIJSON(ADT)/APIJSONTest/src/apijson/demo/model/BaseModel.java

Lines changed: 165 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,182 @@
1515
package apijson.demo.model;
1616

1717
import java.io.Serializable;
18+
import java.util.Collection;
19+
import java.util.Map;
1820

19-
/**基础model,继承它可减少部分代码
21+
/**base model for reduce model codes
2022
* @author Lemon
2123
* @use extends BaseModel
2224
*/
25+
@SuppressWarnings("serial")
2326
public abstract class BaseModel implements Serializable {
24-
private static final long serialVersionUID = 7560533944342381808L;
2527

26-
public Long id;
28+
private Long id;
29+
private Long date;
2730

2831
public Long getId() {
2932
return id;
3033
}
31-
public void setId(Long id) {
34+
public BaseModel setId(Long id) {
3235
this.id = id;
36+
return this;
3337
}
38+
public Long getDate() {
39+
return date;
40+
}
41+
public BaseModel setDate(Long date) {
42+
this.date = date;
43+
return this;
44+
}
45+
46+
//判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
47+
/**判断collection是否为空
48+
* @param collection
49+
* @return
50+
*/
51+
public static <T> boolean isEmpty(Collection<T> collection) {
52+
return collection == null || collection.isEmpty();
53+
}
54+
/**判断map是否为空
55+
* @param <K>
56+
* @param <V>
57+
* @param map
58+
* @return
59+
*/
60+
public static <K, V> boolean isEmpty(Map<K, V> map) {
61+
return map == null || map.isEmpty();
62+
}
63+
//判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
64+
65+
//判断是否包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
66+
/**判断collection是否包含object
67+
* @param collection
68+
* @param object
69+
* @return
70+
*/
71+
public static <T> boolean isContain(Collection<T> collection, T object) {
72+
return collection != null && collection.contains(object);
73+
}
74+
/**判断map是否包含key
75+
* @param <K>
76+
* @param <V>
77+
* @param map
78+
* @param key
79+
* @return
80+
*/
81+
public static <K, V> boolean isContainKey(Map<K, V> map, K key) {
82+
return map != null && map.containsKey(key);
83+
}
84+
/**判断map是否包含value
85+
* @param <K>
86+
* @param <V>
87+
* @param map
88+
* @param value
89+
* @return
90+
*/
91+
public static <K, V> boolean isContainValue(Map<K, V> map, V value) {
92+
return map != null && map.containsValue(value);
93+
}
94+
//判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
95+
96+
97+
//获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
98+
/**获取数量
99+
* @param <T>
100+
* @param array
101+
* @return
102+
*/
103+
public static <T> int count(T[] array) {
104+
return array == null ? 0 : array.length;
105+
}
106+
/**获取数量
107+
* @param <T>
108+
* @param collection collection, Vector, Set等都是Collection的子类
109+
* @return
110+
*/
111+
public static <T> int count(Collection<T> collection) {
112+
return collection == null ? 0 : collection.size();
113+
}
114+
/**获取数量
115+
* @param <K>
116+
* @param <V>
117+
* @param map
118+
* @return
119+
*/
120+
public static <K, V> int count(Map<K, V> map) {
121+
return map == null ? 0 : map.size();
122+
}
123+
//获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
124+
125+
126+
//获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
127+
/**获取
128+
* @param <T>
129+
* @param array
130+
* @return
131+
*/
132+
public static <T> T get(T[] array, int position) {
133+
return position < 0 || position >= count(array) ? null : array[position];
134+
}
135+
/**获取
136+
* @param <T>
137+
* @param collection List, Vector, Set等都是Collection的子类
138+
* @return
139+
*/
140+
@SuppressWarnings("unchecked")
141+
public static <T> T get(Collection<T> collection, int position) {
142+
return (T) (collection == null ? null : get(collection.toArray(), position));
143+
}
144+
/**获取
145+
* @param <K>
146+
* @param <V>
147+
* @param map null ? null
148+
* @param key null ? null : map.get(key);
149+
* @return
150+
*/
151+
public static <K, V> V get(Map<K, V> map, K key) {
152+
return key == null || map == null ? null : map.get(key);
153+
}
154+
//获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
155+
156+
157+
158+
//获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
159+
/**获取非空值
160+
* @param value
161+
* @return
162+
*/
163+
public static boolean value(Boolean value) {
164+
return value == null ? false : value;
165+
}
166+
/**获取非空值
167+
* @param value
168+
* @return
169+
*/
170+
public static int value(Integer value) {
171+
return value == null ? 0 : value;
172+
}
173+
/**获取非空值
174+
* @param value
175+
* @return
176+
*/
177+
public static long value(Long value) {
178+
return value == null ? 0 : value;
179+
}
180+
/**获取非空值
181+
* @param value
182+
* @return
183+
*/
184+
public static float value(Float value) {
185+
return value == null ? 0 : value;
186+
}
187+
/**获取非空值
188+
* @param value
189+
* @return
190+
*/
191+
public static double value(Double value) {
192+
return value == null ? 0 : value;
193+
}
194+
//获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>
34195

35196
}

APIJSON(Android)/APIJSON(ADT)/APIJSONTest/src/apijson/demo/model/Comment.java

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,70 +14,59 @@
1414

1515
package apijson.demo.model;
1616

17+
import zuo.biao.apijson.APIJSONRequest;
18+
import zuo.biao.apijson.RequestMethod;
19+
1720
/**评论类
1821
* @author Lemon
1922
*/
23+
@APIJSONRequest(
24+
method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE},
25+
DELETE = "{necessaryColumns:id}"
26+
)
2027
public class Comment extends BaseModel {
2128
private static final long serialVersionUID = -1011007127735372824L;
2229

23-
public Long workId;
24-
public Long parentId;
25-
public Long userId;
26-
public Long targetUserId;
27-
public String userName;
28-
public String targetUserName;
29-
public String content;
30+
private Long toId;
31+
private Long userId;
32+
private Long momentId;
33+
private String content;
3034
public Comment() {
3135
super();
3236
}
33-
public Comment(Long id, String content) {
37+
public Comment(long id) {
3438
this();
35-
this.id = id;
36-
this.content = content;
39+
setId(id);
3740
}
3841

39-
public Long getWorkId() {
40-
return workId;
41-
}
42-
public void setWorkId(Long workId) {
43-
this.workId = workId;
44-
}
45-
public Long getParentId() {
46-
return parentId;
42+
43+
public Long getToId() {
44+
return toId;
4745
}
48-
public void setParentId(Long parentId) {
49-
this.parentId = parentId;
46+
public Comment setToId(Long toId) {
47+
this.toId = toId;
48+
return this;
5049
}
5150
public Long getUserId() {
5251
return userId;
5352
}
54-
public void setUserId(Long userId) {
53+
public Comment setUserId(Long userId) {
5554
this.userId = userId;
55+
return this;
5656
}
57-
public Long getTargetUserId() {
58-
return targetUserId;
59-
}
60-
public void setTargetUserId(Long targetUserId) {
61-
this.targetUserId = targetUserId;
57+
public Long getMomentId() {
58+
return momentId;
6259
}
63-
public String getUserName() {
64-
return userName;
65-
}
66-
public void setUserName(String userName) {
67-
this.userName = userName;
68-
}
69-
public String getTargetUserName() {
70-
return targetUserName;
71-
}
72-
public void setTargetUserName(String targetUserName) {
73-
this.targetUserName = targetUserName;
60+
public Comment setMomentId(Long momentId) {
61+
this.momentId = momentId;
62+
return this;
7463
}
7564
public String getContent() {
7665
return content;
7766
}
78-
public void setContent(String content) {
67+
public Comment setContent(String content) {
7968
this.content = content;
69+
return this;
8070
}
81-
82-
71+
8372
}

APIJSON(Android)/APIJSON(ADT)/APIJSONTest/src/apijson/demo/model/Moment.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,16 @@
1616

1717
import java.util.List;
1818

19+
import zuo.biao.apijson.APIJSONRequest;
20+
import zuo.biao.apijson.RequestMethod;
21+
1922
/**作品类
2023
* @author Lemon
2124
*/
25+
@APIJSONRequest(
26+
method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE},
27+
DELETE = "{necessaryColumns:id}"
28+
)
2229
public class Moment extends BaseModel {
2330
private static final long serialVersionUID = -7437225320551780084L;
2431

0 commit comments

Comments
 (0)