1、新增自定义用户私人价格2、优化api服务鉴权缓存3、新增管理员端对公充值
This commit is contained in:
@@ -34,7 +34,11 @@ func (l *CreateUserProductLogic) CreateUserProduct(in *sentinel.CreateUserProduc
|
||||
if isExist {
|
||||
return nil, errors.New("该产品已定阅读,无法重复订阅")
|
||||
}
|
||||
_, err = l.svcCtx.UserProductsModel.Insert(l.ctx, &model.UserProducts{UserId: in.UserId, ProductId: in.ProductId})
|
||||
product, err := l.svcCtx.ProductsModel.FindOne(l.ctx, in.ProductId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, err = l.svcCtx.UserProductsModel.Insert(l.ctx, &model.UserProducts{UserId: in.UserId, ProductId: in.ProductId, ProductPrice: product.ProductPrice})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
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
|
||||
}
|
||||
@@ -25,7 +25,7 @@ func NewGetUserProductPageListLogic(ctx context.Context, svcCtx *svc.ServiceCont
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetUserProductPageListLogic) GetUserProductPageList(in *sentinel.UserProuctPageListRequest) (*sentinel.UserProductResponse, error) {
|
||||
func (l *GetUserProductPageListLogic) GetUserProductPageList(in *sentinel.UserProuctPageListRequest) (*sentinel.UserProductPageListResponse, error) {
|
||||
list, total, err := l.svcCtx.UserProductsModel.FindUserProductsList(l.ctx, in.UserId, in.Page, in.PageSize)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -45,7 +45,7 @@ func (l *GetUserProductPageListLogic) GetUserProductPageList(in *sentinel.UserPr
|
||||
UpdatedAt: up.UpdatedAt.Format("2006-01-02 15:04:05"),
|
||||
})
|
||||
}
|
||||
return &sentinel.UserProductResponse{
|
||||
return &sentinel.UserProductPageListResponse{
|
||||
Total: total,
|
||||
UserProducts: userProducts,
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user