github.com/SupenBysz/gf-admin-community@v0.7.4/sys_model/sys_dao/internal/sys_audit.go (about)

     1  // ==========================================================================
     2  // Code generated by GoFrame CLI tool. DO NOT EDIT.
     3  // ==========================================================================
     4  
     5  package internal
     6  
     7  import (
     8  	"context"
     9  
    10  	"github.com/kysion/base-library/utility/daoctl"
    11  	"github.com/kysion/base-library/utility/daoctl/dao_interface"
    12  
    13  	"github.com/gogf/gf/v2/database/gdb"
    14  	"github.com/gogf/gf/v2/frame/g"
    15  )
    16  
    17  // SysAuditDao is the data access object for table sys_audit.
    18  type SysAuditDao struct {
    19  	table   string          // table is the underlying table name of the DAO.
    20  	group   string          // group is the database configuration group name of current DAO.
    21  	columns SysAuditColumns // columns contains all the column names of Table for convenient usage.
    22  }
    23  
    24  // SysAuditColumns defines and stores column names for table sys_audit.
    25  type SysAuditColumns struct {
    26  	Id             string //
    27  	State          string // 审核状态:-1不通过,0待审核,1通过
    28  	Reply          string // 不通过时回复的审核不通过原因
    29  	UnionMainId    string // 关联主体ID
    30  	Category       string // 业务类别:1个人资质审核、2主体资质审核、4数据审核
    31  	AuditData      string // 待审核的业务数据包
    32  	ExpireAt       string // 服务时限
    33  	AuditReplyAt   string // 审核回复时间
    34  	HistoryItems   string // 历史申请记录
    35  	CreatedAt      string //
    36  	AuditUserId    string // 审核操作者id
    37  	DataIdentifier string // 数据标识
    38  	UserId         string // 关联用户ID
    39  }
    40  
    41  // sysAuditColumns holds the columns for table sys_audit.
    42  var sysAuditColumns = SysAuditColumns{
    43  	Id:             "id",
    44  	State:          "state",
    45  	Reply:          "reply",
    46  	UnionMainId:    "union_main_id",
    47  	Category:       "category",
    48  	AuditData:      "audit_data",
    49  	ExpireAt:       "expire_at",
    50  	AuditReplyAt:   "audit_reply_at",
    51  	HistoryItems:   "history_Items",
    52  	CreatedAt:      "created_at",
    53  	AuditUserId:    "audit_user_id",
    54  	DataIdentifier: "data_identifier",
    55  	UserId:         "user_id",
    56  }
    57  
    58  // NewSysAuditDao creates and returns a new DAO object for table data access.
    59  func NewSysAuditDao(proxy ...dao_interface.IDao) *SysAuditDao {
    60  	var dao *SysAuditDao
    61  	if len(proxy) > 0 {
    62  		dao = &SysAuditDao{
    63  			group:   proxy[0].Group(),
    64  			table:   proxy[0].Table(),
    65  			columns: sysAuditColumns,
    66  		}
    67  		return dao
    68  	}
    69  
    70  	return &SysAuditDao{
    71  		group:   "default",
    72  		table:   "sys_audit",
    73  		columns: sysAuditColumns,
    74  	}
    75  }
    76  
    77  // DB retrieves and returns the underlying raw database management object of current DAO.
    78  func (dao *SysAuditDao) DB() gdb.DB {
    79  	return g.DB(dao.group)
    80  }
    81  
    82  // Table returns the table name of current dao.
    83  func (dao *SysAuditDao) Table() string {
    84  	return dao.table
    85  }
    86  
    87  // Group returns the configuration group name of database of current dao.
    88  func (dao *SysAuditDao) Group() string {
    89  	return dao.group
    90  }
    91  
    92  // Columns returns all column names of current dao.
    93  func (dao *SysAuditDao) Columns() SysAuditColumns {
    94  	return dao.columns
    95  }
    96  
    97  // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
    98  func (dao *SysAuditDao) Ctx(ctx context.Context, cacheOption ...*gdb.CacheOption) *gdb.Model {
    99  	return dao.DaoConfig(ctx, cacheOption...).Model
   100  }
   101  
   102  func (dao *SysAuditDao) DaoConfig(ctx context.Context, cacheOption ...*gdb.CacheOption) dao_interface.DaoConfig {
   103  	daoConfig := dao_interface.DaoConfig{
   104  		Dao:   dao,
   105  		DB:    dao.DB(),
   106  		Table: dao.table,
   107  		Group: dao.group,
   108  		Model: dao.DB().Model(dao.Table()).Safe().Ctx(ctx),
   109  	}
   110  
   111  	if len(cacheOption) == 0 {
   112  		daoConfig.CacheOption = daoctl.MakeDaoCache(dao.Table())
   113  		daoConfig.Model = daoConfig.Model.Cache(*daoConfig.CacheOption)
   114  	} else {
   115  		if cacheOption[0] != nil {
   116  			daoConfig.CacheOption = cacheOption[0]
   117  			daoConfig.Model = daoConfig.Model.Cache(*daoConfig.CacheOption)
   118  		}
   119  	}
   120  
   121  	daoConfig.Model = daoctl.RegisterDaoHook(daoConfig.Model)
   122  
   123  	return daoConfig
   124  }
   125  
   126  // Transaction wraps the transaction logic using function f.
   127  // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
   128  // It commits the transaction and returns nil if function f returns nil.
   129  //
   130  // Note that, you should not Commit or Rollback the transaction in function f
   131  // as it is automatically handled by this function.
   132  func (dao *SysAuditDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
   133  	return dao.Ctx(ctx).Transaction(ctx, f)
   134  }