// ==========================================================================
// Code generated by GoFrame CLI tool. DO NOT EDIT.
// ==========================================================================

package internal

import (
	"context"
	"github.com/gogf/gf/database/gdb"
	"github.com/gogf/gf/frame/g"
)

// YounggeeProductPhotoDao is the manager for logic model data accessing and custom defined data operations functions management.
type YounggeeProductPhotoDao struct {
	Table   string                      // Table is the underlying table name of the DAO.
	Group   string                      // Group is the database configuration group name of current DAO.
	Columns YounggeeProductPhotoColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
}

// YounggeeProductPhotoColumns defines and stores column names for table younggee_product_photo.
type YounggeeProductPhotoColumns struct {
	ProductPhotoId string // 商品图片id
	ProductId      string // 所属商品id
	Symbol         string // 图片为主图或详情图标志位，1为主图，2为详情图，3为视频
	PhotoUrl       string // 图片或视频url
	PhotoUid       string //
	CreatedAt      string // 创建时间
}

//  younggeeProductPhotoColumns holds the columns for table younggee_product_photo.
var younggeeProductPhotoColumns = YounggeeProductPhotoColumns{
	ProductPhotoId: "product_photo_id",
	ProductId:      "product_id",
	Symbol:         "symbol",
	PhotoUrl:       "photo_url",
	PhotoUid:       "photo_uid",
	CreatedAt:      "created_at",
}

// NewYounggeeProductPhotoDao creates and returns a new DAO object for table data access.
func NewYounggeeProductPhotoDao() *YounggeeProductPhotoDao {
	return &YounggeeProductPhotoDao{
		Group:   "default",
		Table:   "younggee_product_photo",
		Columns: younggeeProductPhotoColumns,
	}
}

// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *YounggeeProductPhotoDao) DB() gdb.DB {
	return g.DB(dao.Group)
}

// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *YounggeeProductPhotoDao) Ctx(ctx context.Context) *gdb.Model {
	return dao.DB().Model(dao.Table).Safe().Ctx(ctx)
}

// Transaction wraps the transaction logic using function f.
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
// It commits the transaction and returns nil if function f returns nil.
//
// Note that, you should not Commit or Rollback the transaction in function f
// as it is automatically handled by this function.
func (dao *YounggeeProductPhotoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
