feat: rbac完善,file接入完成
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
"sundynix-micro-go/app/file/model"
|
||||
"sundynix-micro-go/app/file/rpc/file"
|
||||
"sundynix-micro-go/app/file/rpc/internal/svc"
|
||||
)
|
||||
|
||||
type CreateStorageConfigLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewCreateStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateStorageConfigLogic {
|
||||
return &CreateStorageConfigLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 存储配置 ----------
|
||||
func (l *CreateStorageConfigLogic) CreateStorageConfig(in *file.CreateStorageConfigReq) (*file.CommonResp, error) {
|
||||
conf := &model.StorageConfig{
|
||||
Type: in.Type,
|
||||
Name: in.Name,
|
||||
Endpoint: in.Endpoint,
|
||||
AccessKeyId: in.AccessKeyId,
|
||||
AccessKeySecret: in.AccessKeySecret,
|
||||
BucketName: in.BucketName,
|
||||
BucketUrl: in.BucketUrl,
|
||||
Region: in.Region,
|
||||
IsDefault: 0, // 默认不激活,除非通过 setDefault
|
||||
Status: int(in.Status),
|
||||
Remark: in.Remark,
|
||||
}
|
||||
|
||||
err := l.svcCtx.DB.Create(conf).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &file.CommonResp{Code: 0, Msg: "创建成功"}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user