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.5 KiB

3 weeks ago
  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. // LecturersDao is the data access object for table lecturers.
  11. type LecturersDao 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 LecturersColumns // columns contains all the column names of Table for convenient usage.
  15. }
  16. // LecturersColumns defines and stores column names for table lecturers.
  17. type LecturersColumns struct {
  18. Id string //
  19. Jwcode string //
  20. Avatar string //
  21. Name string //
  22. }
  23. // lecturersColumns holds the columns for table lecturers.
  24. var lecturersColumns = LecturersColumns{
  25. Id: "id",
  26. Jwcode: "jwcode",
  27. Avatar: "avatar",
  28. Name: "name",
  29. }
  30. // NewLecturersDao creates and returns a new DAO object for table data access.
  31. func NewLecturersDao() *LecturersDao {
  32. return &LecturersDao{
  33. group: "default",
  34. table: "lecturers",
  35. columns: lecturersColumns,
  36. }
  37. }
  38. // DB retrieves and returns the underlying raw database management object of current DAO.
  39. func (dao *LecturersDao) DB() gdb.DB {
  40. return g.DB(dao.group)
  41. }
  42. // Table returns the table name of current dao.
  43. func (dao *LecturersDao) Table() string {
  44. return dao.table
  45. }
  46. // Columns returns all column names of current dao.
  47. func (dao *LecturersDao) Columns() LecturersColumns {
  48. return dao.columns
  49. }
  50. // Group returns the configuration group name of database of current dao.
  51. func (dao *LecturersDao) 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 *LecturersDao) 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 *LecturersDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
  65. return dao.Ctx(ctx).Transaction(ctx, f)
  66. }