feat: rbac完善,file接入完成
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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 SetDefaultStorageConfigLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewSetDefaultStorageConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SetDefaultStorageConfigLogic {
|
||||
return &SetDefaultStorageConfigLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
func (l *SetDefaultStorageConfigLogic) SetDefaultStorageConfig(in *file.SetDefaultStorageConfigReq) (*file.CommonResp, error) {
|
||||
tx := l.svcCtx.DB.Begin()
|
||||
if err := tx.Model(&model.StorageConfig{}).Where("1 = 1").Update("is_default", 0).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return nil, err
|
||||
}
|
||||
if err := tx.Model(&model.StorageConfig{}).Where("id = ?", in.Id).Update("is_default", 1).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return nil, err
|
||||
}
|
||||
tx.Commit()
|
||||
|
||||
return &file.CommonResp{Code: 0, Msg: "设置成功"}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user