// Code scaffolded by goctl. Safe to edit.
// goctl 1.10.1

package file

import (
	"context"

	"github.com/zeromicro/go-zero/core/logx"
	"sundynix-micro-go/app/file/api/internal/svc"
	"sundynix-micro-go/app/file/api/internal/types"
	"sundynix-micro-go/app/file/rpc/fileservice"
)

type CreateStorageConfigLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 创建存储配置
func NewCreateStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateStorageConfigLogic {
	return &CreateStorageConfigLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CreateStorageConfigLogic) CreateStorageConfig(req *types.CreateStorageConfigReq) error {
	_, err := l.svcCtx.FileRpc.CreateStorageConfig(l.ctx, &fileservice.CreateStorageConfigReq{
		Type:            req.Type,
		Name:            req.Name,
		Endpoint:        req.Endpoint,
		AccessKeyId:     req.AccessKeyId,
		AccessKeySecret: req.AccessKeySecret,
		BucketName:      req.BucketName,
		BucketUrl:       req.BucketUrl,
		Region:          req.Region,
		Status:          int32(req.Status),
		Remark:          req.Remark,
	})
	if err != nil {
		return err
	}

	return nil
}
