37 lines
890 B
Go
37 lines
890 B
Go
package model
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
)
|
|
|
|
var _ ProPlanFactoryModel = (*customProPlanFactoryModel)(nil)
|
|
|
|
type (
|
|
ProPlanFactoryModel interface {
|
|
proPlanFactoryModel
|
|
FindByPlanId(ctx context.Context, planId string) ([]*ProPlanFactory, error)
|
|
}
|
|
|
|
customProPlanFactoryModel struct {
|
|
*defaultProPlanFactoryModel
|
|
}
|
|
)
|
|
|
|
func NewProPlanFactoryModel(conn sqlx.SqlConn) ProPlanFactoryModel {
|
|
return &customProPlanFactoryModel{
|
|
defaultProPlanFactoryModel: newProPlanFactoryModel(conn),
|
|
}
|
|
}
|
|
|
|
func (m *customProPlanFactoryModel) FindByPlanId(ctx context.Context, planId string) ([]*ProPlanFactory, error) {
|
|
var list []*ProPlanFactory
|
|
query := fmt.Sprintf("SELECT %s FROM %s WHERE plan_id = ?", proPlanFactoryRows, m.table)
|
|
if err := m.conn.QueryRowsCtx(ctx, &list, query, planId); err != nil {
|
|
return nil, err
|
|
}
|
|
return list, nil
|
|
}
|