demo_data_auth.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // ==========================================================================
  2. // GFast自动生成dao internal操作代码,无需手动修改,重新生成会自动覆盖.
  3. // 生成日期:2022-03-03 10:11:15
  4. // 生成路径: gfast/app/demo/dao/internal/demo_data_auth.go
  5. // 生成人:gfast
  6. // ==========================================================================
  7. package internal
  8. import (
  9. "context"
  10. "gfast/app/demo/model"
  11. "github.com/gogf/gf/database/gdb"
  12. "github.com/gogf/gf/frame/g"
  13. )
  14. // DemoDataAuthDao is the manager for logic model data accessing and custom defined data operations functions management.
  15. type DemoDataAuthDao struct {
  16. Table string // Table is the underlying table name of the DAO.
  17. Group string // Group is the database configuration group name of current DAO.
  18. Columns DemoDataAuthColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
  19. }
  20. // DemoDataAuthColumns defines and stores column names for table demo_data_auth.
  21. type DemoDataAuthColumns struct {
  22. Id string // ID
  23. Title string // 标题
  24. CreatedBy string // 创建人
  25. UpdatedBy string // 修改人
  26. CreatedAt string // 创建时间
  27. UpdatedAt string // 修改时间
  28. DeletedAt string // 删除时间
  29. }
  30. var demoDataAuthColumns = DemoDataAuthColumns{
  31. Id: "id",
  32. Title: "title",
  33. CreatedBy: "created_by",
  34. UpdatedBy: "updated_by",
  35. CreatedAt: "created_at",
  36. UpdatedAt: "updated_at",
  37. DeletedAt: "deleted_at",
  38. }
  39. // NewDemoDataAuthDao creates and returns a new DAO object for table data access.
  40. func NewDemoDataAuthDao() *DemoDataAuthDao {
  41. return &DemoDataAuthDao{
  42. Group: "default",
  43. Table: "demo_data_auth",
  44. Columns: demoDataAuthColumns,
  45. }
  46. }
  47. // DB retrieves and returns the underlying raw database management object of current DAO.
  48. func (dao *DemoDataAuthDao) DB() gdb.DB {
  49. return g.DB(dao.Group)
  50. }
  51. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  52. func (dao *DemoDataAuthDao) Ctx(ctx context.Context) *gdb.Model {
  53. return dao.DB().Model(model.DemoDataAuth{}).Safe().Ctx(ctx)
  54. }
  55. // Transaction wraps the transaction logic using function f.
  56. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  57. // It commits the transaction and returns nil if function f returns nil.
  58. //
  59. // Note that, you should not Commit or Rollback the transaction in function f
  60. // as it is automatically handled by this function.
  61. func (dao *DemoDataAuthDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
  62. return dao.Ctx(ctx).Transaction(ctx, f)
  63. }