You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.7 KiB

  1. // ==========================================================================
  2. // Code generated and maintained 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. // GoUsersDao is the data access object for table go_users.
  11. type GoUsersDao 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 GoUsersColumns // columns contains all the column names of Table for convenient usage.
  15. }
  16. // GoUsersColumns defines and stores column names for table go_users.
  17. type GoUsersColumns struct {
  18. Id string // 用户唯一ID,自增,长度为8位整数
  19. Username string // 用户名,最大长度255字符,不能为空
  20. Avatar string // 用户头像路径或相关标识,可为空
  21. Password string // 用户登录密码,最大长度255字符,不能为空
  22. }
  23. // goUsersColumns holds the columns for table go_users.
  24. var goUsersColumns = GoUsersColumns{
  25. Id: "id",
  26. Username: "username",
  27. Avatar: "avatar",
  28. Password: "password",
  29. }
  30. // NewGoUsersDao creates and returns a new DAO object for table data access.
  31. func NewGoUsersDao() *GoUsersDao {
  32. return &GoUsersDao{
  33. group: "default",
  34. table: "go_users",
  35. columns: goUsersColumns,
  36. }
  37. }
  38. // DB retrieves and returns the underlying raw database management object of current DAO.
  39. func (dao *GoUsersDao) DB() gdb.DB {
  40. return g.DB(dao.group)
  41. }
  42. // Table returns the table name of current dao.
  43. func (dao *GoUsersDao) Table() string {
  44. return dao.table
  45. }
  46. // Columns returns all column names of current dao.
  47. func (dao *GoUsersDao) Columns() GoUsersColumns {
  48. return dao.columns
  49. }
  50. // Group returns the configuration group name of database of current dao.
  51. func (dao *GoUsersDao) Group() string {
  52. return dao.group
  53. }
  54. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  55. func (dao *GoUsersDao) Ctx(ctx context.Context) *gdb.Model {
  56. return dao.DB().Model(dao.table).Safe().Ctx(ctx)
  57. }
  58. // Transaction wraps the transaction logic using function f.
  59. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  60. // It commits the transaction and returns nil if function f returns nil.
  61. //
  62. // Note that, you should not Commit or Rollback the transaction in function f
  63. // as it is automatically handled by this function.
  64. func (dao *GoUsersDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
  65. return dao.Ctx(ctx).Transaction(ctx, f)
  66. }