新增后台管理
This commit is contained in:
		
							
								
								
									
										46
									
								
								app/main/api/internal/logic/agent/getlinkdatalogic.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								app/main/api/internal/logic/agent/getlinkdatalogic.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,46 @@ | ||||
| package agent | ||||
|  | ||||
| import ( | ||||
| 	"context" | ||||
| 	"tydata-server/common/xerr" | ||||
|  | ||||
| 	"github.com/jinzhu/copier" | ||||
| 	"github.com/pkg/errors" | ||||
|  | ||||
| 	"tydata-server/app/user/cmd/api/internal/svc" | ||||
| 	"tydata-server/app/user/cmd/api/internal/types" | ||||
|  | ||||
| 	"github.com/zeromicro/go-zero/core/logx" | ||||
| ) | ||||
|  | ||||
| type GetLinkDataLogic struct { | ||||
| 	logx.Logger | ||||
| 	ctx    context.Context | ||||
| 	svcCtx *svc.ServiceContext | ||||
| } | ||||
|  | ||||
| func NewGetLinkDataLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetLinkDataLogic { | ||||
| 	return &GetLinkDataLogic{ | ||||
| 		Logger: logx.WithContext(ctx), | ||||
| 		ctx:    ctx, | ||||
| 		svcCtx: svcCtx, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func (l *GetLinkDataLogic) GetLinkData(req *types.GetLinkDataReq) (resp *types.GetLinkDataResp, err error) { | ||||
| 	agentLinkModel, err := l.svcCtx.AgentLinkModel.FindOneByLinkIdentifier(l.ctx, req.LinkIdentifier) | ||||
| 	if err != nil { | ||||
| 		return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "获取代理链接数据, %v", err) | ||||
| 	} | ||||
|  | ||||
| 	productModel, err := l.svcCtx.ProductModel.FindOne(l.ctx, agentLinkModel.ProductId) | ||||
| 	if err != nil { | ||||
| 		return nil, errors.Wrapf(xerr.NewErrCode(xerr.DB_ERROR), "获取代理链接数据, %v", err) | ||||
| 	} | ||||
| 	var product types.Product | ||||
| 	copier.Copy(&product, productModel) | ||||
| 	product.SellPrice = agentLinkModel.Price | ||||
| 	return &types.GetLinkDataResp{ | ||||
| 		Product: product, | ||||
| 	}, nil | ||||
| } | ||||
		Reference in New Issue
	
	Block a user