39 lines
1.2 KiB
Go
Executable File
39 lines
1.2 KiB
Go
Executable File
package model
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/zeromicro/go-zero/core/stores/sqlx"
|
|
)
|
|
|
|
var _ FsCanteenProductModel = (*customFsCanteenProductModel)(nil)
|
|
|
|
type (
|
|
// FsCanteenProductModel is an interface to be customized, add more methods here,
|
|
// and implement the added methods in customFsCanteenProductModel.
|
|
FsCanteenProductModel interface {
|
|
fsCanteenProductModel
|
|
GetAllByCanteenTypeId(ctx context.Context, canteenTypeId int64) (resp []FsCanteenProduct, err error)
|
|
}
|
|
|
|
customFsCanteenProductModel struct {
|
|
*defaultFsCanteenProductModel
|
|
}
|
|
)
|
|
|
|
// NewFsCanteenProductModel returns a model for the database table.
|
|
func NewFsCanteenProductModel(conn sqlx.SqlConn) FsCanteenProductModel {
|
|
return &customFsCanteenProductModel{
|
|
defaultFsCanteenProductModel: newFsCanteenProductModel(conn),
|
|
}
|
|
}
|
|
|
|
func (m *defaultFsCanteenProductModel) GetAllByCanteenTypeId(ctx context.Context, canteenTypeId int64) (resp []FsCanteenProduct, err error) {
|
|
query := fmt.Sprintf("select %s from %s where `canteen_type` = ? and `status` = ?", fsCanteenProductRows, m.table)
|
|
err = m.conn.QueryRowsCtx(ctx, &resp, query, canteenTypeId, 1)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return
|
|
}
|