createdomainlogic.go 811 B

12345678910111213141516171819202122232425262728293031323334
  1. package logic
  2. import (
  3. "app.yhyue.com/moapp/jyfs/rpc/filesystem"
  4. "app.yhyue.com/moapp/jyfs/rpc/internal/svc"
  5. "context"
  6. "github.com/tal-tech/go-zero/core/logx"
  7. )
  8. type CreateDomainLogic struct {
  9. ctx context.Context
  10. svcCtx *svc.ServiceContext
  11. logx.Logger
  12. }
  13. func NewCreateDomainLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateDomainLogic {
  14. return &CreateDomainLogic{
  15. ctx: ctx,
  16. svcCtx: svcCtx,
  17. Logger: logx.WithContext(ctx),
  18. }
  19. }
  20. // 创建域
  21. func (l *CreateDomainLogic) CreateDomain(in *filesystem.DomainReq) (*filesystem.DomainResp, error) {
  22. err := l.svcCtx.OssClient.CreateBucket(in.Name)
  23. // todo: 本地存储bucket和meta的对应关系
  24. if err != nil {
  25. return &filesystem.DomainResp{State: false}, nil
  26. } else {
  27. return &filesystem.DomainResp{State: true}, nil
  28. }
  29. }