update example doc

This commit is contained in:
kevin
2020-09-04 08:13:22 +08:00
parent b4aa89fc25
commit c0d0e00803
8 changed files with 67 additions and 21 deletions

View File

@@ -5,6 +5,7 @@ import (
"shorturl/api/internal/svc"
"shorturl/api/internal/types"
"shorturl/rpc/transform/transformer"
"github.com/tal-tech/go-zero/core/logx"
)
@@ -24,5 +25,14 @@ func NewExpandLogic(ctx context.Context, svcCtx *svc.ServiceContext) ExpandLogic
}
func (l *ExpandLogic) Expand(req types.ExpandReq) (*types.ExpandResp, error) {
return &types.ExpandResp{}, nil
resp, err := l.svcCtx.Transformer.Expand(l.ctx, &transformer.ExpandReq{
Shorten: req.Shorten,
})
if err != nil {
return nil, err
}
return &types.ExpandResp{
Url: resp.Url,
}, nil
}

View File

@@ -5,6 +5,7 @@ import (
"shorturl/api/internal/svc"
"shorturl/api/internal/types"
"shorturl/rpc/transform/transformer"
"github.com/tal-tech/go-zero/core/logx"
)
@@ -24,5 +25,14 @@ func NewShortenLogic(ctx context.Context, svcCtx *svc.ServiceContext) ShortenLog
}
func (l *ShortenLogic) Shorten(req types.ShortenReq) (*types.ShortenResp, error) {
return &types.ShortenResp{}, nil
resp, err := l.svcCtx.Transformer.Shorten(l.ctx, &transformer.ShortenReq{
Url: req.Url,
})
if err != nil {
return nil, err
}
return &types.ShortenResp{
Shorten: resp.Shorten,
}, nil
}