fusenapi/model/fsproductmodel3dmodel.go
laodaming 9a2f74fe64 fix
2023-06-06 17:36:11 +08:00

42 lines
1.2 KiB
Go
Executable File

package model
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlx"
"strings"
)
var _ FsProductModel3dModel = (*customFsProductModel3dModel)(nil)
type (
// FsProductModel3dModel is an interface to be customized, add more methods here,
// and implement the added methods in customFsProductModel3dModel.
FsProductModel3dModel interface {
fsProductModel3dModel
ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) (resp []FsProductModel3d, err error)
}
customFsProductModel3dModel struct {
*defaultFsProductModel3dModel
}
)
// NewFsProductModel3dModel returns a model for the database table.
func NewFsProductModel3dModel(conn sqlx.SqlConn) FsProductModel3dModel {
return &customFsProductModel3dModel{
defaultFsProductModel3dModel: newFsProductModel3dModel(conn),
}
}
func (m *defaultFsProductModel3dModel) ListBySizeIdsTag(ctx context.Context, sizeIds []string, tag int) (resp []FsProductModel3d, err error) {
if len(sizeIds) == 0 {
return nil, nil
}
query := fmt.Sprintf("select %s from %s where `size_id` in (?) and `tag` = ?", fsProductModel3dRows, m.table)
err = m.conn.QueryRowsCtx(ctx, &resp, query, strings.Join(sizeIds, ","), tag)
if err != nil {
return nil, err
}
return
}