|
|
@@ -0,0 +1,50 @@ |
|
|
|
package implement |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func NewCloudBundleDb(engine *xorm.Engine) dao.CloudBundleDao { |
|
|
|
return &CloudBundleDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type CloudBundleDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (c CloudBundleDb) FindCloudBundleAndTotal(page, limit string) (*[]model.CloudBundle, int64, error) { |
|
|
|
var m []model.CloudBundle |
|
|
|
sess := c.Db.Where("1=1") |
|
|
|
start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) |
|
|
|
count, err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).OrderBy("id desc").FindAndCount(&m) |
|
|
|
if err != nil { |
|
|
|
return nil, count, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
return &m, count, nil |
|
|
|
} |
|
|
|
func (c CloudBundleDb) GetCloudBundle(id string) (m *model.CloudBundle, err error) { |
|
|
|
m = new(model.CloudBundle) |
|
|
|
has, err := c.Db.Where("id=?", id).Get(m) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return m, nil |
|
|
|
} |
|
|
|
func (c CloudBundleDb) GetCloudBundleLast(os string) (m *model.CloudBundle, err error) { |
|
|
|
m = new(model.CloudBundle) |
|
|
|
has, err := c.Db.Where("os=? and ep=0", os).Desc("id").Get(m) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return m, nil |
|
|
|
} |