签入版本
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// =================================================================================
|
||||
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||
// 自定义模板:hack/tpl/dao_index.tpl
|
||||
// - 构造时挂载全局模型钩子(审计字段 / 软删除改写;主键交数据库自增)
|
||||
// - Ctx 覆写注入软删除与租户隔离条件(架构红线执行点)
|
||||
// =================================================================================
|
||||
|
||||
package dao
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
|
||||
"easygoadmin/internal/dao/internal"
|
||||
"easygoadmin/internal/model/hooks"
|
||||
)
|
||||
|
||||
// linkDao is the data access object for the table goframe_link.
|
||||
// You can define custom methods on it to extend its functionality as needed.
|
||||
type linkDao struct {
|
||||
*internal.LinkDao
|
||||
}
|
||||
|
||||
var (
|
||||
// Link is a globally accessible object for table goframe_link operations.
|
||||
Link = linkDao{
|
||||
internal.NewLinkDao(func(m *gdb.Model) *gdb.Model {
|
||||
// 全局钩子:Insert 补齐审计字段/租户ID(主键自增);Update 盖章;Delete 改写为软删除
|
||||
return m.Hook(hooks.Handler())
|
||||
}),
|
||||
}
|
||||
)
|
||||
|
||||
// Ctx 覆写:在 SQL 构建之前注入架构红线条件 ——
|
||||
// 所有表追加 del_flag=0;租户级表对租户上下文追加 tenant_id IN (0, 当前租户)。
|
||||
// 业务代码必须经由本方法访问模型,禁止绕过 dao 直连 DB。
|
||||
func (d *linkDao) Ctx(ctx context.Context) *gdb.Model {
|
||||
return hooks.ApplyCtx(ctx, d.LinkDao.Ctx(ctx), "goframe_link")
|
||||
}
|
||||
|
||||
// Add your custom methods and functionality below.
|
||||
Reference in New Issue
Block a user