41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package share
|
|
|
|
import (
|
|
"context"
|
|
|
|
"muyu-apiserver/gateway/internal/svc"
|
|
"muyu-apiserver/gateway/internal/types"
|
|
"muyu-apiserver/pkg/ctxdata"
|
|
"muyu-apiserver/rpc/production/productionservice"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type CreateShareLinkLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewCreateShareLinkLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateShareLinkLogic {
|
|
return &CreateShareLinkLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *CreateShareLinkLogic) CreateShareLink(req *types.GatewayCreateShareLinkReq) (*types.ShareLinkInfoResp, error) {
|
|
resp, err := l.svcCtx.ProductionRpc.CreateShareLink(l.ctx, &productionservice.CreateShareLinkReq{
|
|
PlanId: req.PlanId,
|
|
FactoryType: req.FactoryType,
|
|
HideSensitive: req.HideSensitive,
|
|
ExpiresHours: req.ExpiresHours,
|
|
CreatedBy: ctxdata.GetUserId(l.ctx),
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return shareLinkInfoFromPB(resp), nil
|
|
}
|