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.

89 lines
2.8 KiB

11 months 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. // SiteLinkDao is the data access object for table cms_site_link.
  11. type SiteLinkDao 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 SiteLinkColumns // columns contains all the column names of Table for convenient usage.
  15. }
  16. // SiteLinkColumns defines and stores column names for table cms_site_link.
  17. type SiteLinkColumns struct {
  18. Id string // 主键
  19. CreatedAt string // 创建时间
  20. UpdatedAt string // 更新时间
  21. Name string // 友链名称
  22. Link string // 链接
  23. SiteId string // 站点id
  24. Status string // 启用状态
  25. Sort string // 排序
  26. Target string // 打开方式
  27. }
  28. // siteLinkColumns holds the columns for table cms_site_link.
  29. var siteLinkColumns = SiteLinkColumns{
  30. Id: "id",
  31. CreatedAt: "created_at",
  32. UpdatedAt: "updated_at",
  33. Name: "name",
  34. Link: "link",
  35. SiteId: "site_id",
  36. Status: "status",
  37. Sort: "sort",
  38. Target: "target",
  39. }
  40. // NewSiteLinkDao creates and returns a new DAO object for table data access.
  41. func NewSiteLinkDao() *SiteLinkDao {
  42. return &SiteLinkDao{
  43. group: "cms",
  44. table: "cms_site_link",
  45. columns: siteLinkColumns,
  46. }
  47. }
  48. // DB retrieves and returns the underlying raw database management object of current DAO.
  49. func (dao *SiteLinkDao) DB() gdb.DB {
  50. return g.DB(dao.group)
  51. }
  52. // Table returns the table name of current dao.
  53. func (dao *SiteLinkDao) Table() string {
  54. return dao.table
  55. }
  56. // Columns returns all column names of current dao.
  57. func (dao *SiteLinkDao) Columns() SiteLinkColumns {
  58. return dao.columns
  59. }
  60. // Group returns the configuration group name of database of current dao.
  61. func (dao *SiteLinkDao) Group() string {
  62. return dao.group
  63. }
  64. // Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
  65. func (dao *SiteLinkDao) Ctx(ctx context.Context) *gdb.Model {
  66. return dao.DB().Model(dao.table).Safe().Ctx(ctx)
  67. }
  68. // Transaction wraps the transaction logic using function f.
  69. // It rollbacks the transaction and returns the error from function f if it returns non-nil error.
  70. // It commits the transaction and returns nil if function f returns nil.
  71. //
  72. // Note that, you should not Commit or Rollback the transaction in function f
  73. // as it is automatically handled by this function.
  74. func (dao *SiteLinkDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
  75. return dao.Ctx(ctx).Transaction(ctx, f)
  76. }