|
@@ -55,6 +55,52 @@ func (m *EdbDataBusiness) GetCollection() *qmgo.Collection {
|
|
|
return db.Collection(m.CollectionName())
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *EdbDataBusiness) GetItem(whereParams interface{}) (item *EdbDataBusiness, err error) {
|
|
|
+ if utils.MgoDataCli == nil {
|
|
|
+ err = errors.New("mongodb连接失败")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ db := utils.MgoDataCli.Database(m.DataBaseName())
|
|
|
+ coll := db.Collection(m.CollectionName())
|
|
|
+
|
|
|
+ return m.GetItemByColl(coll, whereParams)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+func (m *EdbDataBusiness) GetItemByColl(coll *qmgo.Collection, whereParams interface{}) (item *EdbDataBusiness, err error) {
|
|
|
+ ctx := context.TODO()
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("MgoGetColl Err:", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = coll.Find(ctx, whereParams).One(&item)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ item.DataTime = item.DataTime.In(time.Local)
|
|
|
+ item.CreateTime = item.CreateTime.In(time.Local)
|
|
|
+ item.ModifyTime = item.ModifyTime.In(time.Local)
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
|
|
|
|