diff --git a/biz/application/service/file.go b/biz/application/service/file.go index d1dd6ca..809d536 100644 --- a/biz/application/service/file.go +++ b/biz/application/service/file.go @@ -406,9 +406,7 @@ func (s *FileService) CompletelyRemoveFile(ctx context.Context, req *gencontent. data, _ := sonic.Marshal(&message.DeleteFileRelationsMessage{ FromType: int64(gencontent.TargetType_UserType), - FromId: req.UserId, - ToType: int64(gencontent.TargetType_FileType), - Files: ids, + FromIds: ids, }) if err2 := s.DeleteFileRelationKq.Push(pconvertor.Bytes2String(data)); err2 != nil { @@ -477,9 +475,7 @@ func (s *FileService) DeleteFile(ctx context.Context, req *gencontent.DeleteFile if req.DeleteType == int64(gencontent.Deletion_Deletion_hardDel) || req.ClearCommunity { data, _ := sonic.Marshal(&message.DeleteFileRelationsMessage{ FromType: int64(gencontent.TargetType_UserType), - FromId: req.UserId, - ToType: int64(gencontent.TargetType_FileType), - Files: ids, + FromIds: ids, }) if err2 := s.DeleteFileRelationKq.Push(pconvertor.Bytes2String(data)); err2 != nil { @@ -537,9 +533,7 @@ func (s *FileService) EmptyRecycleBin(ctx context.Context, req *gencontent.Empty data, _ := sonic.Marshal(&message.DeleteFileRelationsMessage{ FromType: int64(gencontent.TargetType_UserType), - FromId: req.UserId, - ToType: int64(gencontent.TargetType_FileType), - Files: ids, + FromIds: ids, }) if err2 = s.DeleteFileRelationKq.Push(pconvertor.Bytes2String(data)); err2 != nil { @@ -837,25 +831,58 @@ func (s *FileService) AddFileToPublicSpace(ctx context.Context, req *gencontent. func (s *FileService) MakeFilePrivate(ctx context.Context, req *gencontent.MakeFilePrivateReq) (resp *gencontent.MakeFilePrivateResp, err error) { resp = &gencontent.MakeFilePrivateResp{} - data := convertor.FileToFileMapper(&gencontent.File{FileId: req.FileId, AuditStatus: int64(gencontent.AuditStatus_AuditStatus_notStart)}) - update := bson.M{ - consts.Zone: "", - consts.SubZone: "", - consts.Description: "", - consts.Labels: "", - } - if _, err = s.FileMongoMapper.UpdateUnset(ctx, data, update); err != nil { - return resp, err - } - - res, _ := sonic.Marshal(&message.DeleteFileRelationsMessage{ - FromType: int64(gencontent.TargetType_UserType), - FromId: req.UserId, - ToType: int64(gencontent.TargetType_FileType), - }) - if err2 := s.DeleteFileRelationKq.Push(pconvertor.Bytes2String(res)); err2 != nil { - return resp, err2 - } + //data := convertor.FileToFileMapper(&gencontent.File{FileId: req.FileId, AuditStatus: int64(gencontent.AuditStatus_AuditStatus_notStart)}) + //update := bson.M{ + // consts.Zone: "", + // consts.SubZone: "", + // consts.Description: "", + // consts.Labels: "", + //} + + //ids := make([]string, 0, s.Config.InitialSliceLength) + //tx := s.FileMongoMapper.StartClient() + //err = tx.UseSession(ctx, func(sessionContext mongo.SessionContext) error { + // if err = sessionContext.StartTransaction(); err != nil { + // return err + // } + // for _, file := range req.Files { + // ids = append(ids, file.FileId) + // if file.SpaceSize == int64(gencontent.Folder_Folder_Size) { + // var data []*filemapper.File + // filter := bson.M{"path": bson.M{"$regex": "^" + file.Path + "/"}} + // if err = s.FileMongoMapper.GetConn().Find(sessionContext, &data, filter); err != nil { + // return err + // } + // for _, v := range data { + // ids = append(ids, v.ID.Hex()) + // } + // } + // } + // if _, err = s.FileMongoMapper.UpdateMany(sessionContext, ids, update); err != nil { + // if rbErr := sessionContext.AbortTransaction(sessionContext); rbErr != nil { + // log.CtxError(ctx, "删除文件过程中产生错误[%v]: 回滚异常[%v]\n", err, rbErr) + // } + // return err + // } + // if err = sessionContext.CommitTransaction(sessionContext); err != nil { + // log.CtxError(ctx, "删除文件: 提交事务异常[%v]\n", err) + // return err + // } + // return nil + //}) + // + //if _, err = s.FileMongoMapper.UpdateUnset(ctx, data, update); err != nil { + // return resp, err + //} + // + //res, _ := sonic.Marshal(&message.DeleteFileRelationsMessage{ + // FromType: int64(gencontent.TargetType_UserType), + // FromId: req.UserId, + // ToType: int64(gencontent.TargetType_FileType), + //}) + //if err2 := s.DeleteFileRelationKq.Push(pconvertor.Bytes2String(res)); err2 != nil { + // return resp, err2 + //} return resp, nil } diff --git a/go.mod b/go.mod index 3eea1bb..cbf7f19 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module github.com/CloudStriver/cloudmind-content go 1.20 require ( + github.com/CloudStriver/cloudmind-mq v1.0.12-0.20240406143558-b7090c0fbb80 github.com/CloudStriver/go-pkg v0.0.0-20240329084540-20ca37a52fea - github.com/CloudStriver/service-idl-gen-go v0.0.0-20240405111939-0dda8194fc94 + github.com/CloudStriver/service-idl-gen-go v0.0.0-20240406140558-0b39494165c0 github.com/bytedance/sonic v1.10.2 github.com/cloudwego/kitex v0.8.0 github.com/elastic/go-elasticsearch/v8 v8.11.1 @@ -13,6 +14,7 @@ require ( github.com/mitchellh/mapstructure v1.1.2 github.com/pkg/errors v0.9.1 github.com/samber/lo v1.39.0 + github.com/zeromicro/go-queue v1.1.8 github.com/zeromicro/go-zero v1.6.1 go.mongodb.org/mongo-driver v1.13.1 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 @@ -25,7 +27,6 @@ require ( //replace github.com/CloudStriver/cloudmind-mq => ../cloudmind-mq require ( - github.com/CloudStriver/cloudmind-mq v1.0.12-0.20240402110201-7972a2140b4d // indirect github.com/apache/thrift v0.16.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bufbuild/protocompile v0.7.1 // indirect @@ -44,7 +45,6 @@ require ( github.com/cloudwego/netpoll v0.5.1 // indirect github.com/cloudwego/thriftgo v0.3.3 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/elastic/elastic-transport-go/v8 v8.3.0 // indirect github.com/fatih/color v1.16.0 // indirect @@ -65,7 +65,6 @@ require ( github.com/kitex-contrib/monitor-prometheus v0.2.0 // indirect github.com/klauspost/compress v1.16.7 // indirect github.com/klauspost/cpuid/v2 v2.2.4 // indirect - github.com/linvon/cuckoo-filter v0.4.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect @@ -93,7 +92,6 @@ require ( github.com/xdg-go/scram v1.1.2 // indirect github.com/xdg-go/stringprep v1.0.4 // indirect github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect - github.com/zeromicro/go-queue v1.1.8 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect diff --git a/go.sum b/go.sum index d9c35bb..5a18e36 100644 --- a/go.sum +++ b/go.sum @@ -373,18 +373,12 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= github.com/ClickHouse/clickhouse-go/v2 v2.0.14/go.mod h1:iq2DUGgpA4BBki2CVwrF8x43zqBjdgHtbexkFkh5a6M= -github.com/CloudStriver/cloudmind-mq v1.0.11 h1:IeLbEMc8BjfDPh+hWfydOPM3niMHK3NLIUQGTA36xjA= -github.com/CloudStriver/cloudmind-mq v1.0.11/go.mod h1:c5YuPS/PQq2hVnzGXvT/XO4I5GkkkUJFFzkkCwSdQjs= -github.com/CloudStriver/cloudmind-mq v1.0.12-0.20240401060147-a003b51ad6b3 h1:RTjSneAq8oNROMLGG1Iw7r+hztPxwvFtXnRUnkSKlgw= -github.com/CloudStriver/cloudmind-mq v1.0.12-0.20240401060147-a003b51ad6b3/go.mod h1:27iatJiOPboohqXgYguco4ODiOuPWkslTdzhHoBlt+k= -github.com/CloudStriver/cloudmind-mq v1.0.12-0.20240402110201-7972a2140b4d h1:N+UV4VVMZklgme44hJ+FJzlpbBKpcu4ZHfwcjw6IWkg= -github.com/CloudStriver/cloudmind-mq v1.0.12-0.20240402110201-7972a2140b4d/go.mod h1:LnePS+4Vpxp1WzSzXupv2MKdqwwzUEhhWq8gj01VfHI= -github.com/CloudStriver/go-pkg v0.0.0-20231229114943-910edcb8788d h1:c5M3637HJJN+pD3erToZAw0vutEMLmC+5I63szm5PYU= -github.com/CloudStriver/go-pkg v0.0.0-20231229114943-910edcb8788d/go.mod h1:Oj6+J8ixQxqNunSpl9v64q6tAQ83wY/rRFI+3rhHVCk= +github.com/CloudStriver/cloudmind-mq v1.0.12-0.20240406143558-b7090c0fbb80 h1:M0HBRVVZuwJ8XlgcfUnm+9XiwiQbgcoyTgoeqb1vxcU= +github.com/CloudStriver/cloudmind-mq v1.0.12-0.20240406143558-b7090c0fbb80/go.mod h1:LLq2w5YEUj8/wFzOIPz9kC1aBjSQr/dFivi16MBiz5Y= github.com/CloudStriver/go-pkg v0.0.0-20240329084540-20ca37a52fea h1:f+wmV1f8yaOsv9ei83oKG6kr4rbdtv3p0nPMKDZ8hUs= github.com/CloudStriver/go-pkg v0.0.0-20240329084540-20ca37a52fea/go.mod h1:SsAxWs5EIcaDE/0e5buoFOWsM4lTvFZhySkV68+RT3g= -github.com/CloudStriver/service-idl-gen-go v0.0.0-20240405111939-0dda8194fc94 h1:CAl1nQoR9l22BN5VdnOKtaTrLcxo34Q05YCDKAgVDJQ= -github.com/CloudStriver/service-idl-gen-go v0.0.0-20240405111939-0dda8194fc94/go.mod h1:chtR82RvfrjUujTGWROSCNAwF9Lh/U959k34bXIDvBI= +github.com/CloudStriver/service-idl-gen-go v0.0.0-20240406140558-0b39494165c0 h1:y2ABwBsTxL6vmJFe5dbWw+uIsbK3hRXW3rkU14AoAlM= +github.com/CloudStriver/service-idl-gen-go v0.0.0-20240406140558-0b39494165c0/go.mod h1:chtR82RvfrjUujTGWROSCNAwF9Lh/U959k34bXIDvBI= github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -521,8 +515,6 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165 h1:BS21ZUJ/B5X2UVUbczfmdWH7GapPWAhxcMsDnjJTU1E= -github.com/dgryski/go-metro v0.0.0-20200812162917-85c65e2d0165/go.mod h1:c9O8+fpSOX1DM8cPNSkX/qsBWdkD4yd2dpciOWQjpBw= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= @@ -814,8 +806,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/linvon/cuckoo-filter v0.4.0 h1:vNlwcnvLOgmVJrhfE7gE4RYsxhrdW3LzLV7t27YsOuU= -github.com/linvon/cuckoo-filter v0.4.0/go.mod h1:L3YZEEsEkbEEWCA2r4sVk1dkrqz+TZ+uxGihtb6BwwI= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -949,8 +939,6 @@ github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjR github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= -github.com/samber/lo v1.38.1 h1:j2XEAqXKb09Am4ebOg31SpvzUTTs6EN3VfgeLUhPdXM= -github.com/samber/lo v1.38.1/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= github.com/segmentio/kafka-go v0.4.38 h1:iQdOBbUSdfuYlFpvjuALgj7N6DrdPA0HfB4AhREOdtg= @@ -1021,7 +1009,9 @@ github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6 github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8= github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= +github.com/xdg/scram v1.0.5 h1:TuS0RFmt5Is5qm9Tm2SoD89OPqe4IRiFtyFY4iwWXsw= github.com/xdg/scram v1.0.5/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4= github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a h1:fZHgsYlfvtyqToslyjUt3VOPF4J7aK/3MPcK7xp3PDk= @@ -1645,13 +1635,9 @@ google.golang.org/genproto v0.0.0-20221024153911-1573dae28c9c/go.mod h1:9qHF0xnp google.golang.org/genproto v0.0.0-20221024183307-1bc688fe9f3e/go.mod h1:9qHF0xnpdSfF6knlcsnpzUu5y+rpwgbvsyGAZPBMg4s= google.golang.org/genproto v0.0.0-20221027153422-115e99e71e1c/go.mod h1:CGI5F/G+E5bKwmfYo09AXuVN4dD894kIKUFmVbP2/Fo= google.golang.org/genproto v0.0.0-20221111202108-142d8a6fa32e/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= -google.golang.org/genproto v0.0.0-20231016165738-49dd2c1f3d0b h1:+YaDE2r2OG8t/z5qmsh7Y+XXwCbvadxxZ0YY6mTdrVA= -google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b h1:CIC2YMXmIhYw6evmhPxBKJ4fmLbOFtXQN/GV3XOZR8k= -google.golang.org/genproto/googleapis/api v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:IBQ646DjkDkvUIsVq/cc03FUFQ9wbZu7yE396YcL870= +google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 h1:wpZ8pe2x1Q3f2KyT5f8oP/fa9rHAKgFPr/HZdNuS+PQ= google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 h1:JpwMPBpFN3uKhdaekDpiNlImDdkUAyiJ6ez/uxGaUSo= google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b h1:ZlWIi1wSK56/8hn4QcBp/j9M7Gt3U/3hZw3mC7vDICo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b/go.mod h1:swOH3j0KzcDDgGUWr+SNpyTen5YrXjS3eyPzFYKc6lc= google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1691,8 +1677,6 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.60.1 h1:26+wFr+cNqSGFcOXcabYC0lUVJVRa2Sb2ortSK7VrEU= -google.golang.org/grpc v1.60.1/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= google.golang.org/grpc v1.61.0 h1:TOvOcuXn30kRao+gfcvsebNEa5iZIiLkisYEkf7R7o0= google.golang.org/grpc v1.61.0/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw=