createdomainlogic.go 1002 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. package logic
  2. import (
  3. "context"
  4. "strings"
  5. "app.yhyue.com/moapp/jyfs/api/internal/svc"
  6. "app.yhyue.com/moapp/jyfs/api/internal/types"
  7. fsc "app.yhyue.com/moapp/jyfs/rpc/filesystemclient"
  8. "github.com/zeromicro/go-zero/core/logx"
  9. )
  10. type CreateDomainLogic struct {
  11. logx.Logger
  12. ctx context.Context
  13. svcCtx *svc.ServiceContext
  14. }
  15. func NewCreateDomainLogic(ctx context.Context, svcCtx *svc.ServiceContext) CreateDomainLogic {
  16. return CreateDomainLogic{
  17. Logger: logx.WithContext(ctx),
  18. ctx: ctx,
  19. svcCtx: svcCtx,
  20. }
  21. }
  22. func (l *CreateDomainLogic) CreateDomain(req types.CreateDomainReq) (*types.DomainOpResp, error) {
  23. // todo: add your logic here and delete this line
  24. resp, err := l.svcCtx.FileSystem.CreateDomain(l.ctx, &fsc.DomainReq{
  25. Name: req.Name,
  26. MetaFields: strings.Split(req.Meta, ","),
  27. })
  28. if err != nil || (resp != nil && !resp.State) {
  29. return &types.DomainOpResp{State: "创建失败"}, err
  30. } else {
  31. return &types.DomainOpResp{State: "创建成功"}, nil
  32. }
  33. }