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