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

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

// OrderStatusRecordColumns defines and stores column names for table order_status_record.
type OrderStatusRecordColumns struct {
	OrderStatusId  string // 订单状态记录表id            
    OrderId        string // 对应订单的id                
    AlterBefore    string // 修改订单前状态              
    AlterAfter     string // 修改订单后状态              
    RoleTag        string // 身份标记 1后台管理员 2达人  
    RecordId       string // 操作员工账号                
    RecordName     string // 操作员工姓名                
    CreatedAt      string // 创建时间
}

//  orderStatusRecordColumns holds the columns for table order_status_record.
var orderStatusRecordColumns = OrderStatusRecordColumns{
	OrderStatusId: "order_status_id",  
            OrderId:       "order_id",         
            AlterBefore:   "alter_before",     
            AlterAfter:    "alter_after",      
            RoleTag:       "role_tag",         
            RecordId:      "record_id",        
            RecordName:    "record_name",      
            CreatedAt:     "created_at",
}

// NewOrderStatusRecordDao creates and returns a new DAO object for table data access.
func NewOrderStatusRecordDao() *OrderStatusRecordDao {
	return &OrderStatusRecordDao{
		Group:   "default",
		Table:   "order_status_record",
		Columns: orderStatusRecordColumns,
	}
}

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