diff --git a/src/dao/admin_log_dao.go b/src/dao/admin_log_dao.go new file mode 100644 index 0000000..713fc42 --- /dev/null +++ b/src/dao/admin_log_dao.go @@ -0,0 +1,7 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type AdminLogDao interface { + FindAdminLogAndTotal(page, limit, types, memo, startTime, endTime string) (*[]model.AdminLog, int64, error) +} diff --git a/src/implement/admin_log_implement.go b/src/implement/admin_log_implement.go new file mode 100644 index 0000000..29ba3c5 --- /dev/null +++ b/src/implement/admin_log_implement.go @@ -0,0 +1,41 @@ +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 NewAdminLogDb(engine *xorm.Engine) dao.AdminLogDao { + return &AdminLogDb{Db: engine} +} + +type AdminLogDb struct { + Db *xorm.Engine +} + +func (a AdminLogDb) FindAdminLogAndTotal(page, limit, types, memo, startTime, endTime string) (*[]model.AdminLog, int64, error) { + var m []model.AdminLog + sess := a.Db.Where("1=1") + + if startTime != "" { + sess.And("time>=?", startTime) + } + if endTime != "" { + sess.And("time<=?", endTime) + } + if types != "" { + sess.And("type=?", types) + } + if memo != "" { + sess.And("memo like ?", "%"+memo+"%") + } + 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 +}