From ac9cda7c7f7b3599751e7759b851748b96af941d Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 11 Dec 2024 17:13:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8E=E5=8F=B0=E6=93=8D=E4=BD=9C=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/admin_log_dao.go | 7 +++++ src/implement/admin_log_implement.go | 41 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 src/dao/admin_log_dao.go create mode 100644 src/implement/admin_log_implement.go 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 +}