2026-04-29 15:54:14 +08:00
|
|
|
package dao
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
|
2026-05-15 14:56:26 +08:00
|
|
|
"model-gateway/consts/public"
|
|
|
|
|
"model-gateway/model/entity"
|
2026-04-29 15:54:14 +08:00
|
|
|
|
|
|
|
|
"gitea.com/red-future/common/db/gfdb"
|
2026-05-21 10:41:37 +08:00
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
2026-04-29 15:54:14 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type opLogDao struct{}
|
|
|
|
|
|
|
|
|
|
var OpLog = &opLogDao{}
|
|
|
|
|
|
2026-05-21 10:41:37 +08:00
|
|
|
// Insert 插入
|
|
|
|
|
func (d *opLogDao) Insert(ctx context.Context, req *entity.LogsModelOp) (id int64, err error) {
|
|
|
|
|
m := new(entity.LogsModelOp)
|
|
|
|
|
err = gconv.Struct(req, &m)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
r, err := gfdb.DB(ctx, public.DbNameModelGateway).Model(ctx, public.TableNameOpLog).
|
|
|
|
|
Insert(m)
|
2026-04-29 15:54:14 +08:00
|
|
|
if err != nil {
|
|
|
|
|
return 0, err
|
|
|
|
|
}
|
|
|
|
|
return r.LastInsertId()
|
|
|
|
|
}
|