// ==========================================================================
// 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"
)

// TaskRewardDao is the manager for logic model data accessing and custom defined data operations functions management.
type TaskRewardDao 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 TaskRewardColumns // Columns is the short type for Columns, which contains all the column names of Table for convenient usage.
}

// TaskRewardColumns defines and stores column names for table task_reward.
type TaskRewardColumns struct {
	RewardId          string //                           
    IsRewardGoods     string // 是否奖励实物              
    RewardGoodsInfo   string // 实物奖励信息              
    IsPaymentArticle  string // 是否获得稿费              
    PaymentValue      string // 稿费金额描述              
    OtherRewardInfo   string // 其他奖励信息              
    TaskBaseId        string // 关联的task_base_info的id
}

//  taskRewardColumns holds the columns for table task_reward.
var taskRewardColumns = TaskRewardColumns{
	RewardId:         "reward_id",           
            IsRewardGoods:    "is_reward_goods",     
            RewardGoodsInfo:  "reward_goods_info",   
            IsPaymentArticle: "is_payment_article",  
            PaymentValue:     "payment_value",       
            OtherRewardInfo:  "other_reward_info",   
            TaskBaseId:       "task_base_id",
}

// NewTaskRewardDao creates and returns a new DAO object for table data access.
func NewTaskRewardDao() *TaskRewardDao {
	return &TaskRewardDao{
		Group:   "default",
		Table:   "task_reward",
		Columns: taskRewardColumns,
	}
}

// DB retrieves and returns the underlying raw database management object of current DAO.
func (dao *TaskRewardDao) 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 *TaskRewardDao) 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 *TaskRewardDao) Transaction(ctx context.Context, f func(ctx context.Context, tx *gdb.TX) error) (err error) {
	return dao.Ctx(ctx).Transaction(ctx, f)
}