fusenapi/server/home-user-auth/internal/logic/userfontslogic.go
2023-06-21 14:26:29 +08:00

38 lines
874 B
Go

package logic
import (
"context"
"errors"
"fusenapi/server/home-user-auth/internal/svc"
"fusenapi/server/home-user-auth/internal/types"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/gorm"
)
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, userinfo *auth.UserInfo) (resp *basic.Response) {
data, err := l.svcCtx.AllModels.FsFont.FindAllOrderSortByDesc(l.ctx)
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
logx.Error(err)
return resp.SetStatus(basic.CodeOK)
}
return resp.SetStatus(basic.CodeOK, data)
}