fusenapi/home-user-auth/internal/logic/userfontslogic.go
2023-06-06 17:36:10 +08:00

43 lines
959 B
Go

package logic
import (
"context"
"fusenapi/home-user-auth/internal/svc"
"fusenapi/home-user-auth/internal/types"
"fusenapi/model"
"fusenapi/utils/basic"
"github.com/zeromicro/go-zero/core/logx"
)
type UserFontsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewUserFontsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserFontsLogic {
return &UserFontsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *UserFontsLogic) UserFonts(req *types.Request) (resp *types.Response) {
// 必须返回response, 前端需要的是内部约定的Code码, 处理相关的逻辑. 例子(eg): resp.Set(501, "error")
resp = &types.Response{}
data, err := model.NewFsFontModel(l.svcCtx.MysqlConn).FindAllOrderSortByDesc(l.ctx)
if err != nil {
// panic(err)
logx.Error(err)
resp.SetStatus(basic.CodeOK, data)
return resp
}
resp.SetStatus(basic.CodeOK)
return resp
}