瀏覽代碼

后台操作日志

master
huangjiajun 21 小時之前
父節點
當前提交
ac9cda7c7f
共有 2 個檔案被更改,包括 48 行新增0 行删除
  1. +7
    -0
      src/dao/admin_log_dao.go
  2. +41
    -0
      src/implement/admin_log_implement.go

+ 7
- 0
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)
}

+ 41
- 0
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
}

Loading…
取消
儲存