Files
novatask/internal/model/nh_castile_token_log_model.go
2025-04-28 19:26:17 +08:00

41 lines
1.2 KiB
Go

package model
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
var _ NhCastileTokenLogModel = (*customNhCastileTokenLogModel)(nil)
type (
// NhCastileTokenLogModel is an interface to be customized, add more methods here,
// and implement the added methods in customNhCastileTokenLogModel.
NhCastileTokenLogModel interface {
nhCastileTokenLogModel
WithSession(session sqlx.Session) NhCastileTokenLogModel
UpdateStatus(ctx context.Context, status uint, id uint) error
}
customNhCastileTokenLogModel struct {
*defaultNhCastileTokenLogModel
}
)
// NewNhCastileTokenLogModel returns a model for the database table.
func NewNhCastileTokenLogModel(conn sqlx.SqlConn) NhCastileTokenLogModel {
return &customNhCastileTokenLogModel{
defaultNhCastileTokenLogModel: newNhCastileTokenLogModel(conn),
}
}
func (m *customNhCastileTokenLogModel) WithSession(session sqlx.Session) NhCastileTokenLogModel {
return NewNhCastileTokenLogModel(sqlx.NewSqlConnFromSession(session))
}
func (m *customNhCastileTokenLogModel) UpdateStatus(ctx context.Context, status uint, id uint) error {
query := fmt.Sprintf("update %s set `callback_status` = ? where `id` = ?", m.table)
_, err := m.conn.ExecCtx(ctx, query, status, id)
return err
}