createdomainlogic.go 945 B

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