sys_user_post.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // ==========================================================================
  2. // Code generated by GoFrame CLI tool. DO NOT EDIT.
  3. // ==========================================================================
  4. package internal
  5. import (
  6. "context"
  7. "github.com/gogf/gf/v2/database/gdb"
  8. "github.com/gogf/gf/v2/frame/g"
  9. )
  10. // SysUserPostDao is the data access object for table sys_user_post.
  11. type SysUserPostDao struct {
  12. table string // table is the underlying table name of the DAO.
  13. group string // group is the database configuration group name of current DAO.
  14. columns SysUserPostColumns // columns contains all the column names of Table for convenient usage.
  15. }
  16. // SysUserPostColumns defines and stores column names for table sys_user_post.
  17. type SysUserPostColumns struct {
  18. UserId string // 用户ID
  19. PostId string // 岗位ID
  20. }
  21. // sysUserPostColumns holds the columns for table sys_user_post.
  22. var sysUserPostColumns = SysUserPostColumns{
  23. UserId: "user_id",
  24. PostId: "post_id",
  25. }
  26. // NewSysUserPostDao creates and returns a new DAO object for table data access.
  27. func NewSysUserPostDao() *SysUserPostDao {
  28. return &SysUserPostDao{
  29. group: "default",
  30. table: "sys_user_post",
  31. columns: sysUserPostColumns,
  32. }
  33. }
  34. // DB retrieves and returns the underlying raw database management object of current DAO.
  35. func (dao *SysUserPostDao) DB() gdb.DB {
  36. return g.DB(dao.group)
  37. }
  38. // Table returns the table name of current dao.
  39. func (dao *SysUserPostDao) Table() string {
  40. return dao.table
  41. }
  42. // Columns returns all column names of current dao.
  43. func (dao *SysUserPostDao) Columns() SysUserPostColumns {
  44. return dao.columns
  45. }
  46. // Group returns the configuration group name of database of current dao.
  47. func (dao *SysUserPostDao) Group() string {
  48. return dao.group
  49. }
  50. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  51. func (dao *SysUserPostDao) Ctx(ctx context.Context) *gdb.Model {
  52. return dao.DB().Model(dao.table).Safe().Ctx(ctx)
  53. }
  54. // Transaction wraps the transaction logic using function f.
  55. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  56. // It commits the transaction and returns nil if function f returns nil.
  57. //
  58. // Note that, you should not Commit or Rollback the transaction in function f
  59. // as it is automatically handled by this function.
  60. func (dao *SysUserPostDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
  61. return dao.Ctx(ctx).Transaction(ctx, f)
  62. }