fusenapi/product/internal/logic/getproductlistlogic.go
laodaming cf4e70b8d1 fix
2023-06-02 12:29:13 +08:00

49 lines
1.2 KiB
Go

package logic
import (
"context"
"fusenapi/model"
"fusenapi/product/internal/svc"
"fusenapi/product/internal/types"
"fusenapi/utils/auth"
"fusenapi/utils/image"
"github.com/zeromicro/go-zero/core/logx"
)
type GetProductListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductListLogic {
return &GetProductListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
// 获取产品列表
func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq, loginInfo auth.UserInfo) (resp *types.Response, err error) {
//校验前台登录情况
if loginInfo.UserId == 0 {
return &types.Response{Code: 402, Message: "please sign in"}, nil
}
//获取合适尺寸
if req.Size > 0 {
req.Size = image.GetCurrentSize(req.Size)
}
//获取是否存在千人千面
userModel := model.NewFsUserModel(l.svcCtx.MysqlConn)
userInfo, err := userModel.FindOne(l.ctx, loginInfo.UserId)
if err != nil {
return nil, err
}
if userInfo.Id == 0 {
return &types.Response{Code: 402, Message: "please sign in"}, nil
}
return
}