sys_post.go 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // ==========================================================================
  2. // Code generated by GoFrame CLI tool. DO NOT EDIT. Created at 2022-04-07 23:26:21
  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. // SysPostDao is the data access object for table sys_post.
  11. type SysPostDao 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 SysPostColumns // columns contains all the column names of Table for convenient usage.
  15. }
  16. // SysPostColumns defines and stores column names for table sys_post.
  17. type SysPostColumns struct {
  18. PostId string // 岗位ID
  19. PostCode string // 岗位编码
  20. PostName string // 岗位名称
  21. PostSort string // 显示顺序
  22. Status string // 状态(0正常 1停用)
  23. Remark string // 备注
  24. CreatedBy string // 创建人
  25. UpdatedBy string // 修改人
  26. CreatedAt string // 创建时间
  27. UpdatedAt string // 修改时间
  28. DeletedAt string // 删除时间
  29. }
  30. // sysPostColumns holds the columns for table sys_post.
  31. var sysPostColumns = SysPostColumns{
  32. PostId: "post_id",
  33. PostCode: "post_code",
  34. PostName: "post_name",
  35. PostSort: "post_sort",
  36. Status: "status",
  37. Remark: "remark",
  38. CreatedBy: "created_by",
  39. UpdatedBy: "updated_by",
  40. CreatedAt: "created_at",
  41. UpdatedAt: "updated_at",
  42. DeletedAt: "deleted_at",
  43. }
  44. // NewSysPostDao creates and returns a new DAO object for table data access.
  45. func NewSysPostDao() *SysPostDao {
  46. return &SysPostDao{
  47. group: "default",
  48. table: "sys_post",
  49. columns: sysPostColumns,
  50. }
  51. }
  52. // DB retrieves and returns the underlying raw database management object of current DAO.
  53. func (dao *SysPostDao) DB() gdb.DB {
  54. return g.DB(dao.group)
  55. }
  56. // Table returns the table name of current dao.
  57. func (dao *SysPostDao) Table() string {
  58. return dao.table
  59. }
  60. // Columns returns all column names of current dao.
  61. func (dao *SysPostDao) Columns() SysPostColumns {
  62. return dao.columns
  63. }
  64. // Group returns the configuration group name of database of current dao.
  65. func (dao *SysPostDao) Group() string {
  66. return dao.group
  67. }
  68. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  69. func (dao *SysPostDao) Ctx(ctx context.Context) *gdb.Model {
  70. return dao.DB().Model(dao.table).Safe().Ctx(ctx)
  71. }
  72. // Transaction wraps the transaction logic using function f.
  73. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  74. // It commits the transaction and returns nil if function f returns nil.
  75. //
  76. // Note that, you should not Commit or Rollback the transaction in function f
  77. // as it is automatically handled by this function.
  78. func (dao *SysPostDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
  79. return dao.Ctx(ctx).Transaction(ctx, f)
  80. }