39 lines
933 B
Go
39 lines
933 B
Go
package userproductlogic
|
|
|
|
import (
|
|
"context"
|
|
|
|
"tianyuan-api/apps/sentinel/internal/svc"
|
|
"tianyuan-api/apps/sentinel/sentinel"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type GetUserProductLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
}
|
|
|
|
func NewGetUserProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserProductLogic {
|
|
return &GetUserProductLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *GetUserProductLogic) GetUserProduct(in *sentinel.UserProuctRequest) (*sentinel.UserProductResponse, error) {
|
|
userProduct, err := l.svcCtx.UserProductsModel.FindOneUserProduct(l.ctx, in.UserId, in.ProductId)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &sentinel.UserProductResponse{
|
|
Id: userProduct.Id,
|
|
UserId: userProduct.UserId,
|
|
ProductId: userProduct.ProductId,
|
|
ProductPrice: userProduct.ProductPrice,
|
|
}, nil
|
|
}
|