|
@@ -12,7 +12,7 @@ import (
|
|
|
)
|
|
|
|
|
|
// EdbDataBusiness
|
|
|
-// @Description: 外部数据集合(指标库)
|
|
|
+// @Description: 自有数据集合(指标库)
|
|
|
type EdbDataBusiness struct {
|
|
|
ID primitive.ObjectID `json:"_id" bson:"_id,omitempty" ` // 文档id
|
|
|
EdbInfoId int `json:"edb_info_id" bson:"edb_info_id"` // 指标编码
|
|
@@ -61,9 +61,10 @@ func (m *EdbDataBusiness) GetCollection() *qmgo.Collection {
|
|
|
// @receiver m
|
|
|
// @datetime 2024-04-26 13:42:19
|
|
|
// @param whereParams interface{}
|
|
|
+// @param sort []string
|
|
|
// @return result []EdbDataBusiness
|
|
|
// @return err error
|
|
|
-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 {
|
|
|
err = errors.New("mongodb连接失败")
|
|
|
return
|
|
@@ -75,7 +76,7 @@ func (m *EdbDataBusiness) GetAllDataList(whereParams interface{}) (result []*Edb
|
|
|
fmt.Println("MgoGetColl Err:", err.Error())
|
|
|
return
|
|
|
}
|
|
|
- err = coll.Find(ctx, whereParams).All(&result)
|
|
|
+ err = coll.Find(ctx, whereParams).Sort(sort...).All(&result)
|
|
|
if err != nil {
|
|
|
return
|
|
|
}
|
|
@@ -89,6 +90,104 @@ func (m *EdbDataBusiness) GetAllDataList(whereParams interface{}) (result []*Edb
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// GetLimitDataList
|
|
|
+// @Description: 根据条件获取指定数量数据列表
|
|
|
+// @author: Roc
|
|
|
+// @receiver m
|
|
|
+// @datetime 2024-05-06 17:08:32
|
|
|
+// @param whereParams interface{}
|
|
|
+// @param size int64
|
|
|
+// @param sort []string
|
|
|
+// @return result []*BaseFromBusinessData
|
|
|
+// @return err error
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+// GetPageDataList
|
|
|
+// @Description: 根据条件获取分页数据列表
|
|
|
+// @author: Roc
|
|
|
+// @receiver m
|
|
|
+// @datetime 2024-05-07 10:21:07
|
|
|
+// @param whereParams interface{}
|
|
|
+// @param startSize int64
|
|
|
+// @param size int64
|
|
|
+// @param sort []string
|
|
|
+// @return result []*EdbDataBusiness
|
|
|
+// @return err error
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
+// GetCountDataList
|
|
|
+// @Description: 根据条件获取数据列表总数
|
|
|
+// @author: Roc
|
|
|
+// @receiver m
|
|
|
+// @datetime 2024-05-07 10:29:00
|
|
|
+// @param whereParams interface{}
|
|
|
+// @return count int64
|
|
|
+// @return err error
|
|
|
+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
|
|
|
+}
|
|
|
+
|
|
|
// BatchInsertData
|
|
|
// @Description: 批量写入数据
|
|
|
// @author: Roc
|