You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-zero/example/shorturl/rpc/transform/internal/logic/expandlogic.go

36 lines
662 B
Go

package logic
import (
"context"
"shorturl/rpc/transform/internal/svc"
transform "shorturl/rpc/transform/pb"
"github.com/tal-tech/go-zero/core/logx"
)
type ExpandLogic struct {
4 years ago
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewExpandLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExpandLogic {
return &ExpandLogic{
4 years ago
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ExpandLogic) Expand(in *transform.ExpandReq) (*transform.ExpandResp, error) {
res, err := l.svcCtx.Model.FindOne(in.Shorten)
if err != nil {
return nil, err
}
return &transform.ExpandResp{
Url: res.Url,
}, nil
}