fusenapi/model/fsfontmodel.go
2023-06-06 17:25:49 +08:00

47 lines
1.0 KiB
Go
Executable File

package model
import (
"context"
"fmt"
"github.com/zeromicro/go-zero/core/stores/sqlc"
"github.com/zeromicro/go-zero/core/stores/sqlx"
)
var _ FsFontModel = (*customFsFontModel)(nil)
type (
// FsFontModel is an interface to be customized, add more methods here,
// and implement the added methods in customFsFontModel.
FsFontModel interface {
fsFontModel
FindAllOrderSortByDesc(ctx context.Context) ([]*FsFont, error)
}
customFsFontModel struct {
*defaultFsFontModel
}
)
// NewFsFontModel returns a model for the database table.
func NewFsFontModel(conn sqlx.SqlConn) FsFontModel {
return &customFsFontModel{
defaultFsFontModel: newFsFontModel(conn),
}
}
func (m *defaultFsFontModel) FindAllOrderSortByDesc(ctx context.Context) ([]*FsFont, error) {
query := fmt.Sprintf("select %s from %s order by sort desc", fsFontRows, m.table)
var resp []*FsFont
err := m.conn.QueryRows(&resp, query)
switch err {
case nil:
return resp, nil
case sqlc.ErrNotFound:
return nil, ErrNotFound
default:
return nil, err
}
}