createdomainlogic.go 894 B

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