Skip to content

Commit

Permalink
Merge pull request #34 from T-baby/dev
Browse files Browse the repository at this point in the history
1.0.8.2
  • Loading branch information
T-baby authored Mar 17, 2017
2 parents c13b0e6 + edf420a commit a9cb8b4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.cybermkd</groupId>
<artifactId>MongodbPlugin</artifactId>
<version>1.0.8.1</version>
<version>1.0.8.2</version>
<packaging>jar</packaging>

<name>MongodbPlugin</name>
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/cybermkd/mongo/kit/MongoBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ public JSONObject toJSONObject() {
return (JSONObject) JSON.toJSON(this);
}

public String toJSONString() {
return JSON.toJSONString(this);
}


}
10 changes: 10 additions & 0 deletions src/main/java/com/cybermkd/mongo/kit/MongoDocumentKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public static Document toDocument(Object obj) {

Map<String, Object> map;


if (Document.class.isInstance(obj)) {
return (Document) obj;
}

if (!Map.class.isInstance(obj)) {
map = MongoKit.INSTANCE.toMap(obj);
} else {
Expand Down Expand Up @@ -50,6 +55,11 @@ public static Document toDocument(Object obj) {

}
}
String id = (String) map.get("id");
if (id == null || id.equals("")) {
map.remove("id");
}

return new Document(map);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public MongoPaginate(MongoQuery query, int count, int page) {
this.count = (int) totalRow;
}

if (this.count <= 0 || this.page <= 0 || this.page > totalPage) {
if (totalRow != 0 && this.count <= 0 || this.page <= 0) {
throw new RuntimeException("MongPage tips: (づ ̄ 3 ̄)づ count or page is error !");
}

Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/cybermkd/Time.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.cybermkd;

import com.alibaba.fastjson.annotation.JSONField;
import com.cybermkd.mongo.kit.MongoValidate;

import java.util.Date;

public class Time extends MongoValidate{

@JSONField(format="yyyy-MM-dd HH:mm:ss")
private Date date=new Date();

public Date getDate() {
Expand Down

0 comments on commit a9cb8b4

Please sign in to comment.