2023-06-01 03:27:34 +00:00
|
|
|
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"
|
|
|
|
)
|
2023-06-01 03:27:34 +00:00
|
|
|
|
|
|
|
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)
|
2023-06-01 03:27:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|