Files
2026-10-20 19:08:49 +08:00

43 lines
1.6 KiB
Go

// =================================================================================
// 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"
)
// positionDao is the data access object for the table goframe_position.
// You can define custom methods on it to extend its functionality as needed.
type positionDao struct {
*internal.PositionDao
}
var (
// Position is a globally accessible object for table goframe_position operations.
Position = positionDao{
internal.NewPositionDao(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 *positionDao) Ctx(ctx context.Context) *gdb.Model {
return hooks.ApplyCtx(ctx, d.PositionDao.Ctx(ctx), "goframe_position")
}
// Add your custom methods and functionality below.