You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
paopao-ce/internal/dao/sakila/auto/pga/pga.go

71 lines
2.2 KiB

// Code generated by Yesql. DO NOT EDIT.
// versions:
// - Yesql v1.9.0
package pga
import (
"context"
"fmt"
"github.com/alimy/yesql"
"github.com/bitbus/sqlx"
)
var (
_ = fmt.Errorf("error for placeholder")
)
const (
_TopicA_InsertTag = `INSERT INTO @tag (user_id, tag, created_on, modified_on, quote_num) VALUES (?, ?, ?, ?, 1) RETURNING id`
_TopicA_PinTopic = `UPDATE @topic_user SET is_pin=1-is_pin, modified_on=? WHERE user_id=? AND topic_id=? AND is_del=0; RETURNING is_pin`
_TopicA_StickTopic = `UPDATE @topic_user SET is_top=1-is_top, modified_on=? WHERE user_id=? AND topic_id=? AND is_del=0; RETURNING is_top`
)
// PreparexContext enhances the Conn interface with context.
type PreparexContext interface {
// PrepareContext prepares a statement.
// The provided context is used for the preparation of the statement, not for
// the execution of the statement.
PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
// PrepareNamedContext returns an sqlx.NamedStmt
PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
// Rebind rebind query to adapte SQL Driver
Rebind(query string) string
}
// PreparexBuilder preparex builder interface for sqlx
type PreparexBuilder interface {
PreparexContext
QueryHook(query string) string
}
type TopicA struct {
yesql.Namespace `yesql:"topic_a"`
InsertTag *sqlx.Stmt `yesql:"insert_tag"`
PinTopic *sqlx.Stmt `yesql:"pin_topic"`
StickTopic *sqlx.Stmt `yesql:"stick_topic"`
}
func BuildTopicA(p PreparexBuilder, ctx ...context.Context) (obj *TopicA, err error) {
var c context.Context
if len(ctx) > 0 && ctx[0] != nil {
c = ctx[0]
} else {
c = context.Background()
}
obj = &TopicA{}
if obj.InsertTag, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_InsertTag))); err != nil {
return nil, fmt.Errorf("prepare _TopicA_InsertTag error: %w", err)
}
if obj.PinTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_PinTopic))); err != nil {
return nil, fmt.Errorf("prepare _TopicA_PinTopic error: %w", err)
}
if obj.StickTopic, err = p.PreparexContext(c, p.Rebind(p.QueryHook(_TopicA_StickTopic))); err != nil {
return nil, fmt.Errorf("prepare _TopicA_StickTopic error: %w", err)
}
return
}