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

package internal

import (
	"context"

	"github.com/gogf/gf/v2/database/gdb"
	"github.com/gogf/gf/v2/frame/g"
)

// V2RoadInfoDao is the data access object for table road_info.
type V2RoadInfoDao 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 V2RoadInfoColumns // columns contains all the column names of Table for convenient usage.
}

// V2RoadInfoColumns defines and stores column names for table road_info.
type V2RoadInfoColumns struct {
	Id                  string // 主键，自增
	Name                string // 通道名称
	PayType             string // 支付类型
	ServiceFee          string // 代付手续费
	TotalLimit          string // 通道总额度
	AllowedMm           string // 允许面额
	StartHour           string // 通道开始时间
	EndHour             string // 通道结束时间
	TodayIncome         string // 当天的收入
	TotalIncome         string // 通道总收入
	TodayProfit         string // 当天的收益
	TotalProfit         string // 通道总收益
	Balance             string // 通道的余额
	RequestAll          string // 请求总次数
	RequestSuccess      string // 请求成功次数
	TodayRequestAll     string //
	TodayRequestSuccess string //
	Params              string // 参数json格式
	Remark              string // 备注
	Status              string //
	CreatedAt           string // 创建时间
	UpdatedAt           string // 更新时间
	DeletedAt           string // 删除时间
}

// v2RoadInfoColumns holds the columns for table road_info.
var v2RoadInfoColumns = V2RoadInfoColumns{
	Id:                  "id",
	Name:                "name",
	PayType:             "pay_type",
	ServiceFee:          "service_fee",
	TotalLimit:          "total_limit",
	AllowedMm:           "allowed_mm",
	StartHour:           "start_hour",
	EndHour:             "end_hour",
	TodayIncome:         "today_income",
	TotalIncome:         "total_income",
	TodayProfit:         "today_profit",
	TotalProfit:         "total_profit",
	Balance:             "balance",
	RequestAll:          "request_all",
	RequestSuccess:      "request_success",
	TodayRequestAll:     "today_request_all",
	TodayRequestSuccess: "today_request_success",
	Params:              "params",
	Remark:              "remark",
	Status:              "status",
	CreatedAt:           "created_at",
	UpdatedAt:           "updated_at",
	DeletedAt:           "deleted_at",
}

// NewV2RoadInfoDao creates and returns a new DAO object for table data access.
func NewV2RoadInfoDao() *V2RoadInfoDao {
	return &V2RoadInfoDao{
		group:   "default",
		table:   "road_info",
		columns: v2RoadInfoColumns,
	}
}

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

// Table returns the table name of current dao.
func (dao *V2RoadInfoDao) Table() string {
	return dao.table
}

// Columns returns all column names of current dao.
func (dao *V2RoadInfoDao) Columns() V2RoadInfoColumns {
	return dao.columns
}

// Group returns the configuration group name of database of current dao.
func (dao *V2RoadInfoDao) Group() string {
	return dao.group
}

// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
func (dao *V2RoadInfoDao) 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 *V2RoadInfoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}
