fusenapi/model/fsfontmodel.go

47 lines
1.0 KiB
Go
Raw Normal View History

package model
2023-06-06 09:25:49 +00:00
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
2023-06-06 09:25:49 +00:00
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),
}
}
2023-06-06 09:25:49 +00:00
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
}
}