瀏覽代碼

add 查询动态数据

tags/v0.0.2
shenjiachi 1 周之前
父節點
當前提交
0a49428505
共有 2 個文件被更改,包括 24 次插入0 次删除
  1. +3
    -0
      src/dao/egg_energy_available_energy_flow_dao.go
  2. +21
    -0
      src/implement/egg_energy_available_energy_flow_implement.go

+ 3
- 0
src/dao/egg_energy_available_energy_flow_dao.go 查看文件

@@ -1,5 +1,8 @@
package dao

import "code.fnuoos.com/EggPlanet/egg_models.git/src/model"

type EggEnergyAvailableEnergyFlowDao interface {
//TODO:: You can add specific method definitions here
EggEnergyAvailableEnergyFlowFindAndCount(kind, page, pageSize int, startAt, endAt string) ([]*model.EggEnergyAvailableEnergyFlow, int64, error)
}

+ 21
- 0
src/implement/egg_energy_available_energy_flow_implement.go 查看文件

@@ -2,6 +2,8 @@

import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"xorm.io/xorm"
)

@@ -12,3 +14,22 @@ func NewEggEnergyAvailableEnergyFlowDb(engine *xorm.Engine) dao.EggEnergyAvailab
type EggEnergyAvailableEnergyFlowDb struct {
Db *xorm.Engine
}

func (e EggEnergyAvailableEnergyFlowDb) EggEnergyAvailableEnergyFlowFindAndCount(kind, page, pageSize int, startAt, endAt string) ([]*model.EggEnergyAvailableEnergyFlow, int64, error) {
var m []*model.EggEnergyAvailableEnergyFlow
session := e.Db.Where("")
if kind > 0 {
session = session.And("kind = ?", kind)
}
if startAt != "" {
session = session.Where("create_time > ?", startAt)
}
if endAt != "" {
session = session.Where("create_time < ?", endAt)
}
total, err := session.Limit(pageSize, (page-1)*pageSize).Desc("create_time").FindAndCount(&m)
if err != nil {
return nil, 0, zhios_order_relate_logx.Error(err.Error())
}
return m, total, nil
}

Loading…
取消
儲存