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 DeleteFilesLogic struct {
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
logx.Logger
|
||||
}
|
||||
|
||||
func NewDeleteFilesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteFilesLogic {
|
||||
return &DeleteFilesLogic{
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
Logger: logx.WithContext(ctx),
|
||||
}
|
||||
}
|
||||
|
||||
// 删除文件记录
|
||||
func (l *DeleteFilesLogic) DeleteFiles(in *file.DeleteFilesReq) (*file.CommonResp, error) {
|
||||
if len(in.Ids) == 0 {
|
||||
return &file.CommonResp{Code: 400, Msg: "ids不能为空"}, nil
|
||||
}
|
||||
|
||||
// 这里的删除只删数据库记录,真实文件的删除由 file-api 在调用这个 RPC 之前处理
|
||||
err := l.svcCtx.DB.Where("id IN ?", in.Ids).Delete(&model.SundynixOss{}).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &file.CommonResp{Code: 0, Msg: "删除成功"}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user