|
@@ -12,7 +12,7 @@ import (
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
-
|
|
+
|
|
type EdbDataBusiness struct {
|
|
type EdbDataBusiness struct {
|
|
ID primitive.ObjectID `json:"_id" bson:"_id,omitempty" `
|
|
ID primitive.ObjectID `json:"_id" bson:"_id,omitempty" `
|
|
EdbInfoId int `json:"edb_info_id" bson:"edb_info_id"`
|
|
EdbInfoId int `json:"edb_info_id" bson:"edb_info_id"`
|
|
@@ -61,9 +61,10 @@ func (m *EdbDataBusiness) GetCollection() *qmgo.Collection {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
-func (m *EdbDataBusiness) GetAllDataList(whereParams interface{}) (result []*EdbDataBusiness, err error) {
|
|
+func (m *EdbDataBusiness) GetAllDataList(whereParams interface{}, sort []string) (result []*EdbDataBusiness, err error) {
|
|
if utils.MgoDataCli == nil {
|
|
if utils.MgoDataCli == nil {
|
|
err = errors.New("mongodb连接失败")
|
|
err = errors.New("mongodb连接失败")
|
|
return
|
|
return
|
|
@@ -75,7 +76,7 @@ func (m *EdbDataBusiness) GetAllDataList(whereParams interface{}) (result []*Edb
|
|
fmt.Println("MgoGetColl Err:", err.Error())
|
|
fmt.Println("MgoGetColl Err:", err.Error())
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- err = coll.Find(ctx, whereParams).All(&result)
|
|
+ err = coll.Find(ctx, whereParams).Sort(sort...).All(&result)
|
|
if err != nil {
|
|
if err != nil {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
@@ -89,6 +90,104 @@ func (m *EdbDataBusiness) GetAllDataList(whereParams interface{}) (result []*Edb
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func (m *EdbDataBusiness) GetLimitDataList(whereParams interface{}, size int64, sort []string) (result []*EdbDataBusiness, err error) {
|
|
|
|
+ if utils.MgoDataCli == nil {
|
|
|
|
+ err = errors.New("mongodb连接失败")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ db := utils.MgoDataCli.Database(m.DataBaseName())
|
|
|
|
+ coll := db.Collection(m.CollectionName())
|
|
|
|
+ ctx := context.TODO()
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("MgoGetColl Err:", err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ err = coll.Find(ctx, whereParams).Sort(sort...).Limit(size).All(&result)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, v := range result {
|
|
|
|
+ v.DataTime = v.DataTime.In(time.Local)
|
|
|
|
+ v.CreateTime = v.CreateTime.In(time.Local)
|
|
|
|
+ v.ModifyTime = v.ModifyTime.In(time.Local)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func (m *EdbDataBusiness) GetPageDataList(whereParams interface{}, startSize, size int64, sort []string) (result []*EdbDataBusiness, err error) {
|
|
|
|
+ if utils.MgoDataCli == nil {
|
|
|
|
+ err = errors.New("mongodb连接失败")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ db := utils.MgoDataCli.Database(m.DataBaseName())
|
|
|
|
+ coll := db.Collection(m.CollectionName())
|
|
|
|
+ ctx := context.TODO()
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("MgoGetColl Err:", err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ err = coll.Find(ctx, whereParams).Sort(sort...).Skip(startSize).Limit(size).All(&result)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for _, v := range result {
|
|
|
|
+ v.DataTime = v.DataTime.In(time.Local)
|
|
|
|
+ v.CreateTime = v.CreateTime.In(time.Local)
|
|
|
|
+ v.ModifyTime = v.ModifyTime.In(time.Local)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+func (m *EdbDataBusiness) GetCountDataList(whereParams interface{}) (count int64, err error) {
|
|
|
|
+ if utils.MgoDataCli == nil {
|
|
|
|
+ err = errors.New("mongodb连接失败")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ db := utils.MgoDataCli.Database(m.DataBaseName())
|
|
|
|
+ coll := db.Collection(m.CollectionName())
|
|
|
|
+ ctx := context.TODO()
|
|
|
|
+ if err != nil {
|
|
|
|
+ fmt.Println("MgoGetColl Err:", err.Error())
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ count, err = coll.Find(ctx, whereParams).Count()
|
|
|
|
+
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
|