user.go 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // ==========================================================================
  2. // Code generated by GoFrame CLI tool. DO NOT EDIT.
  3. // ==========================================================================
  4. package internal
  5. import (
  6. "context"
  7. "github.com/gogf/gf/database/gdb"
  8. "github.com/gogf/gf/frame/g"
  9. )
  10. // UserDao is the manager for logic model data accessing and custom defined data operations functions management.
  11. type UserDao 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 UserColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
  15. }
  16. // UserColumns defines and stores column names for table user.
  17. type UserColumns struct {
  18. Id string // 用户表id
  19. User string // 账号
  20. Username string // 后台用户名
  21. Password string // 用户密码
  22. RealName string // 真实姓名
  23. Role string // 角色 1,超级管理员; 2,管理员;3,企业用户
  24. Phone string // 绑定手机
  25. Email string // 电子邮件
  26. LastLoginTime string // 最后一次登录时间
  27. UserState string // 0,禁用,1,正常
  28. CreatedAt string // 创建时间
  29. UpdatedAt string // 更新时间
  30. }
  31. // userColumns holds the columns for table user.
  32. var userColumns = UserColumns{
  33. Id: "id",
  34. User: "user",
  35. Username: "username",
  36. Password: "password",
  37. RealName: "real_name",
  38. Role: "role",
  39. Phone: "phone",
  40. Email: "email",
  41. LastLoginTime: "last_login_time",
  42. UserState: "user_state",
  43. CreatedAt: "created_at",
  44. UpdatedAt: "updated_at",
  45. }
  46. // NewUserDao creates and returns a new DAO object for table data access.
  47. func NewUserDao() *UserDao {
  48. return &UserDao{
  49. Group: "default",
  50. Table: "user",
  51. Columns: userColumns,
  52. }
  53. }
  54. // DB retrieves and returns the underlying raw database management object of current DAO.
  55. func (dao *UserDao) DB() gdb.DB {
  56. return g.DB(dao.Group)
  57. }
  58. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  59. func (dao *UserDao) Ctx(ctx context.Context) *gdb.Model {
  60. return dao.DB().Model(dao.Table).Safe().Ctx(ctx)
  61. }
  62. // Transaction wraps the transaction logic using function f.
  63. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  64. // It commits the transaction and returns nil if function f returns nil.
  65. //
  66. // Note that, you should not Commit or Rollback the transaction in function f
  67. // as it is automatically handled by this function.
  68. func (dao *UserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
  69. return dao.Ctx(ctx).Transaction(ctx, f)
  70. }