From 2dfccd2ba7920ea643aa34569d730573eaebf3ff Mon Sep 17 00:00:00 2001 From: Xin ZF <43563921+TremblingV5@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:29:44 +0800 Subject: [PATCH] rollback to previous (#147) --- applications/comment/build.sh | 1 - .../{commentDomain => comment}/dal/gen.go | 8 +- applications/comment/dal/migrate/main.go | 21 + .../dal/model/comment.go | 0 .../dal/model}/comment_hb.go | 2 +- .../dal/model/count.go | 0 .../dal/query/comment_counts.gen.go | 2 +- .../dal/query/comments.gen.go | 2 +- .../dal/query/gen.go | 0 .../dal/query/var.go | 0 applications/comment/errs/errs.go | 27 - .../comment/handler/comment_action.go | 36 + applications/comment/handler/comment_count.go | 23 + applications/comment/handler/comment_list.go | 23 + applications/comment/handler/handler.go | 86 -- applications/comment/handler/var.go | 3 + applications/comment/main.go | 48 +- applications/comment/misc/check_args.go | 11 + applications/comment/misc/config.go | 18 + applications/comment/misc/const.go | 9 + applications/comment/misc/err.go | 33 + applications/comment/misc/row_key.go | 19 + applications/comment/pack/comment_action.go | 38 + applications/comment/pack/comment_count.go | 11 + applications/comment/pack/comment_list.go | 55 + applications/comment/rpc/clients.go | 21 - applications/comment/rpc/init.go | 5 + applications/comment/rpc/user.go | 40 + applications/comment/rpc/var.go | 5 + applications/comment/run.sh | 10 - applications/comment/script/bootstrap.sh | 1 - applications/comment/service/add_comment.go | 106 ++ .../comment/service/add_comment_test.go | 26 + applications/comment/service/count.go | 180 +++ applications/comment/service/count_test.go | 34 + .../service/get_comment_time.go} | 0 .../comment/service/get_comment_time_test.go | 28 + applications/comment/service/init.go | 91 ++ applications/comment/service/init_test.go | 7 + applications/comment/service/list.go | 36 + applications/comment/service/list_test.go | 34 + applications/comment/service/rm_comment.go | 63 + .../comment/service/rm_comment_test.go | 32 + applications/comment/service/timer.go | 70 ++ applications/comment/service/timer_test.go | 15 + applications/comment/service/var.go | 28 + applications/commentDomain/Makefile | 2 - applications/commentDomain/build.sh | 13 - .../cache/commentCntCache/cache.go | 45 - .../cache/commentCntCache/cache_test.go | 57 - .../cache/commentTotalCountCache/cache.go | 35 - .../commentTotalCountCache/cache_test.go | 39 - applications/commentDomain/cmd/server/main.go | 85 -- applications/commentDomain/cmd/server/run.sh | 13 - .../commentDomain/dal/migrate/main.go | 5 - .../comment/mocks/repository_mock.go | 79 -- .../dal/repository/comment/repository.go | 63 - .../commentcnt/mocks/repository_mock.go | 74 -- .../dal/repository/commentcnt/repository.go | 50 - .../commentDomain/handler/add_comment.go | 33 - .../commentDomain/handler/count_comment.go | 31 - .../commentDomain/handler/list_comment.go | 48 - .../handler/mocks/service_mock.go | 101 -- .../commentDomain/handler/rm_comment.go | 22 - applications/commentDomain/handler/typedef.go | 36 - .../commentHBaseRepo/mocks/repository_mock.go | 79 -- .../hb/commentHBaseRepo/repository.go | 84 -- .../hb/commentHBaseRepo/utils.go | 18 - applications/commentDomain/misc/check_args.go | 13 - .../mocks/redis_mock.go | 69 -- .../redis/commentTotalCountRedis/redis.go | 40 - .../commentDomain/script/bootstrap.sh | 22 - .../service/mocks/service_mock.go | 503 -------- applications/commentDomain/service/service.go | 105 -- applications/commentDomain/service/typedef.go | 93 -- .../commentDomain/service/utils_test.go | 24 - applications/favorite/build.sh | 1 - .../{favoriteDomain => favorite}/dal/gen.go | 8 +- applications/favorite/dal/migrate/main.go | 21 + .../dal/model/count.go | 0 .../dal/model/favorite.go | 0 .../dal/query/favorite_counts.gen.go | 2 +- .../dal/query/favorites.gen.go | 2 +- .../dal/query/gen.go | 0 .../dal/query/var.go | 0 applications/favorite/errs/errs.go | 21 - .../favorite/handler/favorite_action.go | 24 + .../favorite/handler/favorite_count.go | 23 + .../favorite/handler/favorite_list.go | 35 + applications/favorite/handler/handler.go | 81 -- applications/favorite/handler/is_favorite.go | 20 + applications/favorite/handler/typedef.go | 3 + applications/favorite/main.go | 49 +- applications/favorite/misc/config.go | 18 + applications/favorite/misc/const.go | 22 + applications/favorite/misc/err.go | 27 + .../{favoriteDomain => favorite}/misc/var.go | 0 applications/favorite/pack/favorite_action.go | 10 + applications/favorite/pack/favorite_count.go | 13 + applications/favorite/pack/favorite_list.go | 29 + applications/favorite/pack/is_favorite.go | 13 + applications/favorite/rpc/clients.go | 21 - applications/favorite/rpc/feed.go | 31 + applications/favorite/rpc/init.go | 5 + applications/favorite/rpc/var.go | 5 + applications/favorite/run.sh | 10 - applications/favorite/script/bootstrap.sh | 1 - .../service/cache_handle.go | 0 .../favorite/service/cache_handle_test.go | 19 + .../service/consumer_fav_req.go | 9 +- .../favorite/service/consumer_fav_req_test.go | 9 + .../service/favorite_action.go | 15 +- .../service/favorite_action_cache.go | 6 +- .../service/favorite_action_cache_test.go | 18 + .../service/favorite_action_rdb.go | 12 +- .../service/favorite_action_rdb_test.go | 19 + .../favorite/service/favorite_action_test.go | 25 + .../service/favorite_count.go | 24 +- .../favorite/service/favorite_count_test.go | 41 + .../service/favorite_list_cache.go | 2 +- .../service/favorite_list_cache_test.go | 32 + .../service/favorite_list_rdb.go | 0 applications/favorite/service/init.go | 97 ++ applications/favorite/service/init_test.go | 7 + .../service/is_favorite.go | 12 +- .../favorite/service/is_favorite_test.go | 17 + .../service/timer.go | 2 +- applications/favorite/service/timer_test.go | 15 + .../service/typedef.go | 0 .../service/var.go | 2 +- applications/favoriteDomain/Makefile | 2 - applications/favoriteDomain/build.sh | 13 - .../cache/favorite_count_cache/cache.go | 34 - .../favoriteDomain/dal/migrate/main.go | 15 - .../dal/repository/favorite/repository.go | 77 -- .../repository/favorite_count/repository.go | 50 - .../favoriteDomain/handler/add_favorite.go | 13 - .../favoriteDomain/handler/count_favorite.go | 21 - .../favoriteDomain/handler/is_favorite.go | 18 - .../favoriteDomain/handler/list_favorite.go | 34 - .../favoriteDomain/handler/rm_favorite.go | 13 - .../favoriteDomain/handler/typedef.go | 3 - applications/favoriteDomain/main.go | 33 - applications/favoriteDomain/misc/const.go | 11 - applications/favoriteDomain/misc/err.go | 27 - .../favoriteDomain/pack/add_favorite.go | 13 - .../favoriteDomain/pack/count_favorite.go | 14 - .../favoriteDomain/pack/is_favorite.go | 14 - .../favoriteDomain/pack/list_favorite.go | 23 - .../favoriteDomain/pack/rm_favorite.go | 13 - .../redis/favorite_count_redis/redis.go | 39 - .../redis/favorite_redis/redis.go | 34 - .../favoriteDomain/script/bootstrap.sh | 22 - applications/favoriteDomain/service/init.go | 108 -- .../favoriteDomain/service/service.go | 56 - applications/feed/build.sh | 1 - applications/{videoDomain => feed}/dal/gen.go | 12 +- .../{videoDomain => feed}/dal/model/video.go | 0 .../{videoDomain => feed}/dal/query/gen.go | 34 +- .../dal/query/typedef.go | 1 - .../dal/query/videos.gen.go | 2 +- applications/feed/handler/get_user_feed.go | 96 +- applications/feed/handler/get_video_by_id.go | 15 +- applications/feed/main.go | 28 +- applications/feed/misc/config.go | 18 + applications/feed/misc/const.go | 6 + .../misc/ensure_id_length.go | 0 applications/feed/misc/string_minus.go | 11 + .../{videoDomain => feed}/misc/timestamp.go | 0 applications/feed/pack/feed_list.go | 138 ++- applications/feed/pack/video_info.go | 40 + applications/feed/rpc/clients.go | 15 - applications/feed/rpc/comment.go | 41 + applications/feed/rpc/favorite.go | 54 + applications/feed/rpc/init.go | 7 + applications/feed/rpc/user.go | 54 + applications/feed/rpc/var.go | 5 + applications/feed/script/bootstrap.sh | 1 - applications/feed/service/cache.go | 56 + applications/feed/service/cache_test.go | 66 + applications/feed/service/hbase.go | 101 ++ applications/feed/service/hbase_test.go | 46 + applications/feed/service/init.go | 79 ++ applications/feed/service/init_test.go | 7 + applications/feed/service/judge.go | 21 + applications/feed/service/judge_test.go | 25 + applications/feed/service/rdb.go | 17 + applications/feed/service/rdb_test.go | 17 + applications/feed/service/serialize.go | 35 + applications/feed/service/serialize_test.go | 29 + .../hbase.go => feed/service/typedef.go} | 10 +- .../{videoDomain => feed}/service/var.go | 14 +- applications/message/build.sh | 1 - applications/message/handler.go | 56 + .../message/handler/message_action.go | 19 - applications/message/handler/message_chat.go | 18 - applications/message/handler/typedef.go | 3 - applications/message/main.go | 57 +- applications/message/pack/message_action.go | 13 - applications/message/pack/message_chat.go | 14 - applications/message/rpc/clients.go | 9 - applications/message/script/bootstrap.sh | 1 - applications/message/service/consume_msg.go | 5 +- .../message/service/consume_msg_test.go | 49 + applications/message/service/init.go | 38 +- applications/message/service/init_test.go | 16 + .../message/service/message_action_test.go | 21 + applications/message/service/message_chat.go | 7 +- .../message/service/message_chat_test.go | 23 + .../message/service/message_friend.go | 18 +- .../message/service/message_friend_test.go | 23 + applications/messageDomain/Makefile | 2 - applications/messageDomain/build.sh | 13 - .../messageDomain/handler/add_message.go | 21 - .../messageDomain/handler/list_message.go | 24 - applications/messageDomain/handler/typedef.go | 3 - applications/messageDomain/main.go | 39 - applications/messageDomain/pack/message.go | 63 - applications/messageDomain/pack/resp.go | 25 - .../messageDomain/script/bootstrap.sh | 22 - .../messageDomain/service/consume_msg.go | 91 -- applications/messageDomain/service/init.go | 61 - .../messageDomain/service/message_action.go | 40 - .../messageDomain/service/message_chat.go | 54 - .../messageDomain/service/message_friend.go | 51 - applications/publish/build.sh | 1 - applications/publish/callback/callback.go | 14 + applications/publish/callback/controller.go | 25 + applications/publish/dal/gen.go | 39 + applications/publish/dal/migrate/main.go | 21 + applications/publish/dal/model/video.go | 17 + applications/publish/dal/query/gen.go | 99 ++ applications/publish/dal/query/typedef.go | 3 + applications/publish/dal/query/videos.gen.go | 416 +++++++ .../publish/handler/publish_action.go | 36 +- applications/publish/handler/publish_list.go | 22 +- applications/publish/main.go | 29 +- applications/publish/misc/config.go | 18 + applications/publish/misc/const.go | 6 + applications/publish/misc/ensure_id_length.go | 7 + applications/publish/misc/timestamp.go | 9 + applications/publish/pack/publish_action.go | 19 +- applications/publish/pack/publish_list.go | 87 +- applications/publish/rpc/clients.go | 13 - applications/publish/rpc/init.go | 5 + applications/publish/rpc/user.go | 40 + applications/publish/rpc/var.go | 5 + applications/publish/script/bootstrap.sh | 1 - applications/publish/service/init.go | 76 ++ applications/publish/service/init_test.go | 7 + .../publish/service/publish_action.go | 112 ++ .../publish/service/publish_action_test.go | 23 + applications/publish/service/publish_list.go | 38 + .../publish/service/publish_list_test.go | 27 + applications/publish/service/var.go | 21 + applications/publish/service/video.go | 29 + applications/publish/service/video_test.go | 32 + applications/publish/typedef/hbase.go | 45 + applications/relation/build.sh | 1 - .../{relationDomain => relation}/dal/gen.go | 24 +- .../dal/migrate/migration.go | 6 +- .../dal/model/count.go | 0 .../dal/model/relation.go | 0 .../dal/query/follow_counts.gen.go | 2 +- .../dal/query/follower_counts.gen.go | 2 +- .../dal/query/gen.go | 0 .../dal/query/relations.gen.go | 2 +- applications/relation/handler.go | 91 ++ applications/relation/handler/handler.go | 181 --- applications/relation/main.go | 54 +- .../pack/relation.go | 0 applications/relation/pack/resp.go | 36 + applications/relation/rpc/clients.go | 24 - applications/relation/rpc/init.go | 12 + applications/relation/rpc/message.go | 66 + applications/relation/rpc/user.go | 65 + applications/relation/script/bootstrap.sh | 1 - applications/relation/service/consume_msg.go | 35 +- .../relation/service/consume_msg_test.go | 31 + applications/relation/service/init.go | 45 +- applications/relation/service/init_test.go | 19 + .../relation/service/relation_action.go | 137 +-- .../relation/service/relation_action_test.go | 20 + .../relation/service/relation_count.go | 64 +- .../relation/service/relation_count_test.go | 28 + .../relation/service/relation_follow_list.go | 63 +- .../service/relation_follow_list_test.go | 50 + .../service/relation_follower_list.go | 40 +- .../service/relation_follower_list_test.go | 46 + .../relation/service/relation_friend_list.go | 73 +- .../service/relation_friend_list_test.go | 62 + applications/relationDomain/Makefile | 2 - applications/relationDomain/build.sh | 13 - .../relationDomain/handler/add_relation.go | 21 - .../relationDomain/handler/count_relation.go | 39 - .../relationDomain/handler/list_relation.go | 47 - .../relationDomain/handler/rm_relation.go | 21 - .../relationDomain/handler/typedef.go | 3 - applications/relationDomain/main.go | 33 - applications/relationDomain/pack/resp.go | 42 - .../relationDomain/script/bootstrap.sh | 22 - .../relationDomain/service/consume_msg.go | 130 -- applications/relationDomain/service/init.go | 89 -- .../relationDomain/service/relation_action.go | 206 ---- .../relationDomain/service/relation_count.go | 234 ---- .../service/relation_follow_list.go | 179 --- .../service/relation_follower_list.go | 121 -- .../service/relation_friend_list.go | 138 --- applications/user/build.sh | 1 - applications/{userDomain => user}/dal/gen.go | 8 +- applications/user/dal/migrate.go | 21 + .../{userDomain => user}/dal/model/user.go | 0 .../{userDomain => user}/dal/query/gen.go | 0 applications/user/dal/query/typedef.go | 3 + .../dal/query/users.gen.go | 2 +- applications/user/errs/errors.go | 13 - applications/user/handler/get_user_by_id.go | 20 + .../user/handler/get_user_list_by_id.go | 26 + applications/user/handler/handler.go | 101 -- applications/user/handler/login.go | 25 + applications/user/handler/register.go | 21 + applications/user/handler/typedef.go | 3 + applications/user/main.go | 46 +- applications/user/misc/config.go | 18 + applications/user/misc/const.go | 6 + applications/user/misc/err.go | 25 + applications/user/misc/get_misc.go | 16 + applications/user/pack/get_user_list_by_id.go | 45 + applications/user/pack/login_register.go | 23 + applications/user/pack/user.go | 43 + applications/user/rpc/clients.go | 22 - applications/user/rpc/init.go | 5 + applications/user/rpc/relation.go | 31 + applications/user/rpc/var.go | 5 + applications/user/run.sh | 10 - applications/user/script/bootstrap.sh | 1 - applications/user/service/encrypt.go | 94 ++ applications/user/service/encrypt_test.go | 16 + applications/user/service/init.go | 43 + applications/user/service/login.go | 22 + applications/user/service/login_test.go | 43 + applications/user/service/register.go | 40 + applications/user/service/register_test.go | 31 + applications/user/service/search.go | 39 + applications/user/service/search_test.go | 36 + applications/user/service/var.go | 10 + applications/userDomain/Makefile | 2 - applications/userDomain/build.sh | 13 - .../dal/repository/user/repository.go | 50 - applications/userDomain/errs/errs.go | 35 - applications/userDomain/handler/handler.go | 74 -- applications/userDomain/handler/pack.go | 35 - applications/userDomain/main.go | 73 -- applications/userDomain/run.sh | 13 - applications/userDomain/script/bootstrap.sh | 22 - applications/userDomain/service/service.go | 84 -- applications/videoDomain/Makefile | 2 - applications/videoDomain/build.sh | 13 - applications/videoDomain/dal/migrate/main.go | 14 - .../videoDomain/dal/model/video_count.go | 11 - .../videoDomain/dal/query/video_counts.gen.go | 392 ------ .../videoDomain/handler/add_publish.go | 21 - .../videoDomain/handler/count_publish.go | 10 - applications/videoDomain/handler/get_feed.go | 86 -- .../videoDomain/handler/get_video_info.go | 24 - .../videoDomain/handler/list_publish.go | 19 - applications/videoDomain/handler/typedef.go | 3 - applications/videoDomain/main.go | 33 - applications/videoDomain/misc/err.go | 17 - applications/videoDomain/pack/add_publish.go | 13 - .../videoDomain/pack/count_publish.go | 1 - applications/videoDomain/pack/get_feed.go | 44 - .../videoDomain/pack/get_video_info.go | 1 - applications/videoDomain/pack/list_publish.go | 30 - applications/videoDomain/script/bootstrap.sh | 22 - .../videoDomain/service/feed_cache.go | 56 - applications/videoDomain/service/hbase.go | 119 -- applications/videoDomain/service/init.go | 104 -- .../videoDomain/service/publish_action.go | 133 --- .../videoDomain/service/publish_list.go | 45 - applications/videoDomain/service/serialize.go | 50 - applications/videoDomain/service/video.go | 50 - config/commentDomain.yaml | 51 - config/configStruct/comment.go | 25 + config/configStruct/favorite.go | 25 + config/configStruct/feed.go | 25 + config/configStruct/hbase.go | 11 - config/configStruct/mysql.go | 31 - config/configStruct/publish.go | 25 + config/configStruct/redis.go | 39 +- config/configStruct/user.go | 25 + config/favoriteDomain.yaml | 54 - config/messageDomain.yaml | 50 - config/relationDomain.yaml | 54 - config/userDomain.yaml | 45 - config/videoDomain.yaml | 66 - kitex_gen/comment/comment.pb.fast.go | 738 ------------ kitex_gen/comment/comment.pb.go | 338 ++++-- kitex_gen/comment/commentservice/client.go | 14 +- .../comment/commentservice/commentservice.go | 206 ++-- kitex_gen/comment/commentservice/invoker.go | 6 +- kitex_gen/comment/commentservice/server.go | 6 +- .../commentDomain/commentDomain.pb.fast.go | 828 ------------- kitex_gen/commentDomain/commentDomain.pb.go | 699 ----------- .../commentdomainservice/client.go | 67 -- .../commentdomainservice.go | 672 ----------- .../commentdomainservice/invoker.go | 24 - .../commentdomainservice/server.go | 20 - kitex_gen/favorite/favorite.pb.fast.go | 907 -------------- kitex_gen/favorite/favorite.pb.go | 207 ++-- kitex_gen/favorite/favoriteservice/client.go | 20 +- .../favoriteservice/favoriteservice.go | 318 +++-- kitex_gen/favorite/favoriteservice/invoker.go | 6 +- kitex_gen/favorite/favoriteservice/server.go | 6 +- .../favoriteDomain/favoriteDomain.pb.fast.go | 1058 ----------------- kitex_gen/favoriteDomain/favoriteDomain.pb.go | 904 -------------- .../favoritedomainservice/client.go | 73 -- .../favoritedomainservice.go | 828 ------------- .../favoritedomainservice/invoker.go | 24 - .../favoritedomainservice/server.go | 20 - kitex_gen/feed/feed.pb.fast.go | 353 ------ kitex_gen/feed/feed.pb.go | 247 +++- kitex_gen/feed/feedservice/client.go | 13 +- kitex_gen/feed/feedservice/feedservice.go | 109 +- kitex_gen/feed/feedservice/invoker.go | 6 +- kitex_gen/feed/feedservice/server.go | 6 +- kitex_gen/message/message.pb.fast.go | 767 ------------ kitex_gen/message/message.pb.go | 342 ++++-- kitex_gen/message/messageservice/client.go | 14 +- kitex_gen/message/messageservice/invoker.go | 6 +- .../message/messageservice/messageservice.go | 210 ++-- kitex_gen/message/messageservice/server.go | 6 +- .../messageDomain/messageDomain.pb.fast.go | 501 -------- kitex_gen/messageDomain/messageDomain.pb.go | 450 ------- .../messagedomainservice/client.go | 55 - .../messagedomainservice/invoker.go | 24 - .../messagedomainservice.go | 360 ------ .../messagedomainservice/server.go | 20 - kitex_gen/publish/publish.pb.fast.go | 443 ------- kitex_gen/publish/publish.pb.go | 113 +- kitex_gen/publish/publishservice/client.go | 8 +- kitex_gen/publish/publishservice/invoker.go | 6 +- .../publish/publishservice/publishservice.go | 96 +- kitex_gen/publish/publishservice/server.go | 6 +- kitex_gen/relation/relation.pb.fast.go | 419 ++++++- kitex_gen/relation/relation.pb.go | 464 +++++--- kitex_gen/relation/relationservice/client.go | 6 + .../relationservice/relationservice.go | 156 +++ .../relationDomain/relationDomain.pb.fast.go | 855 ------------- kitex_gen/relationDomain/relationDomain.pb.go | 755 ------------ .../relationdomainservice/client.go | 67 -- .../relationdomainservice/invoker.go | 24 - .../relationdomainservice.go | 672 ----------- .../relationdomainservice/server.go | 20 - kitex_gen/user/user.pb.fast.go | 356 +++++- kitex_gen/user/user.pb.go | 339 ++++-- kitex_gen/user/userservice/client.go | 6 + kitex_gen/user/userservice/userservice.go | 162 ++- kitex_gen/userDomain/userDomain.pb.fast.go | 671 ----------- kitex_gen/userDomain/userDomain.pb.go | 593 --------- .../userDomain/userdomainservice/client.go | 61 - .../userDomain/userdomainservice/invoker.go | 24 - .../userDomain/userdomainservice/server.go | 20 - .../userdomainservice/userdomainservice.go | 516 -------- kitex_gen/videoDomain/videoDomain.pb.fast.go | 983 --------------- kitex_gen/videoDomain/videoDomain.pb.go | 842 ------------- .../videoDomain/videodomainservice/client.go | 74 -- .../videoDomain/videodomainservice/invoker.go | 24 - .../videoDomain/videodomainservice/server.go | 20 - .../videodomainservice/videodomainservice.go | 829 ------------- pkg/dtviper/config.go | 25 +- pkg/errno/errno.go | 33 +- pkg/hbaseHandle/init.go | 10 + pkg/hbaseHandle/init_test.go | 19 + pkg/hbaseHandle/put.go | 1 + pkg/hbaseHandle/put_test.go | 28 + pkg/hbaseHandle/scan_test.go | 74 ++ pkg/initHelper/comment.go | 2 +- pkg/initHelper/commentDomain.go | 66 - pkg/initHelper/favorite.go | 2 +- pkg/initHelper/favoriteDomain.go | 78 -- pkg/initHelper/feed.go | 6 +- pkg/initHelper/message.go | 2 +- pkg/initHelper/messageDomain.go | 45 - pkg/initHelper/publish.go | 2 +- pkg/initHelper/relation.go | 2 +- pkg/initHelper/relationDomain.go | 67 -- pkg/initHelper/rpc_client.go | 15 +- pkg/initHelper/rpc_server.go | 51 + pkg/initHelper/user.go | 2 +- pkg/initHelper/userDomain.go | 55 - pkg/initHelper/videoDomain.go | 76 -- proto/api.proto | 318 ----- proto/comment.proto | 45 - proto/commentDomain.proto | 51 - proto/favorite.proto | 54 - proto/favoriteDomain.proto | 64 - proto/feed.proto | 30 - proto/hz.proto | 43 - proto/message.proto | 46 - proto/messageDomain.proto | 34 - proto/publish.proto | 32 - proto/relation.proto | 65 - proto/relationDomain.proto | 54 - proto/user.proto | 54 - proto/userDomain.proto | 43 - proto/videoDomain.proto | 61 - 507 files changed, 9020 insertions(+), 27628 deletions(-) rename applications/{commentDomain => comment}/dal/gen.go (83%) create mode 100644 applications/comment/dal/migrate/main.go rename applications/{commentDomain => comment}/dal/model/comment.go (100%) rename applications/{commentDomain/dal/hbModel => comment/dal/model}/comment_hb.go (98%) rename applications/{commentDomain => comment}/dal/model/count.go (100%) rename applications/{commentDomain => comment}/dal/query/comment_counts.gen.go (99%) rename applications/{commentDomain => comment}/dal/query/comments.gen.go (99%) rename applications/{commentDomain => comment}/dal/query/gen.go (100%) rename applications/{commentDomain => comment}/dal/query/var.go (100%) delete mode 100644 applications/comment/errs/errs.go create mode 100644 applications/comment/handler/comment_action.go create mode 100644 applications/comment/handler/comment_count.go create mode 100644 applications/comment/handler/comment_list.go delete mode 100644 applications/comment/handler/handler.go create mode 100644 applications/comment/handler/var.go create mode 100644 applications/comment/misc/check_args.go create mode 100644 applications/comment/misc/config.go create mode 100644 applications/comment/misc/const.go create mode 100644 applications/comment/misc/err.go create mode 100644 applications/comment/misc/row_key.go create mode 100644 applications/comment/pack/comment_action.go create mode 100644 applications/comment/pack/comment_count.go create mode 100644 applications/comment/pack/comment_list.go delete mode 100644 applications/comment/rpc/clients.go create mode 100644 applications/comment/rpc/init.go create mode 100644 applications/comment/rpc/user.go create mode 100644 applications/comment/rpc/var.go delete mode 100644 applications/comment/run.sh create mode 100644 applications/comment/service/add_comment.go create mode 100644 applications/comment/service/add_comment_test.go create mode 100644 applications/comment/service/count.go create mode 100644 applications/comment/service/count_test.go rename applications/{commentDomain/service/utils.go => comment/service/get_comment_time.go} (100%) create mode 100644 applications/comment/service/get_comment_time_test.go create mode 100644 applications/comment/service/init.go create mode 100644 applications/comment/service/init_test.go create mode 100644 applications/comment/service/list.go create mode 100644 applications/comment/service/list_test.go create mode 100644 applications/comment/service/rm_comment.go create mode 100644 applications/comment/service/rm_comment_test.go create mode 100644 applications/comment/service/timer.go create mode 100644 applications/comment/service/timer_test.go create mode 100644 applications/comment/service/var.go delete mode 100644 applications/commentDomain/Makefile delete mode 100644 applications/commentDomain/build.sh delete mode 100644 applications/commentDomain/cache/commentCntCache/cache.go delete mode 100644 applications/commentDomain/cache/commentCntCache/cache_test.go delete mode 100644 applications/commentDomain/cache/commentTotalCountCache/cache.go delete mode 100644 applications/commentDomain/cache/commentTotalCountCache/cache_test.go delete mode 100644 applications/commentDomain/cmd/server/main.go delete mode 100644 applications/commentDomain/cmd/server/run.sh delete mode 100644 applications/commentDomain/dal/migrate/main.go delete mode 100644 applications/commentDomain/dal/repository/comment/mocks/repository_mock.go delete mode 100644 applications/commentDomain/dal/repository/comment/repository.go delete mode 100644 applications/commentDomain/dal/repository/commentcnt/mocks/repository_mock.go delete mode 100644 applications/commentDomain/dal/repository/commentcnt/repository.go delete mode 100644 applications/commentDomain/handler/add_comment.go delete mode 100644 applications/commentDomain/handler/count_comment.go delete mode 100644 applications/commentDomain/handler/list_comment.go delete mode 100644 applications/commentDomain/handler/mocks/service_mock.go delete mode 100644 applications/commentDomain/handler/rm_comment.go delete mode 100644 applications/commentDomain/handler/typedef.go delete mode 100644 applications/commentDomain/hb/commentHBaseRepo/mocks/repository_mock.go delete mode 100644 applications/commentDomain/hb/commentHBaseRepo/repository.go delete mode 100644 applications/commentDomain/hb/commentHBaseRepo/utils.go delete mode 100644 applications/commentDomain/misc/check_args.go delete mode 100644 applications/commentDomain/redis/commentTotalCountRedis/mocks/redis_mock.go delete mode 100644 applications/commentDomain/redis/commentTotalCountRedis/redis.go delete mode 100644 applications/commentDomain/script/bootstrap.sh delete mode 100644 applications/commentDomain/service/mocks/service_mock.go delete mode 100644 applications/commentDomain/service/service.go delete mode 100644 applications/commentDomain/service/typedef.go delete mode 100644 applications/commentDomain/service/utils_test.go rename applications/{favoriteDomain => favorite}/dal/gen.go (83%) create mode 100644 applications/favorite/dal/migrate/main.go rename applications/{favoriteDomain => favorite}/dal/model/count.go (100%) rename applications/{favoriteDomain => favorite}/dal/model/favorite.go (100%) rename applications/{favoriteDomain => favorite}/dal/query/favorite_counts.gen.go (99%) rename applications/{favoriteDomain => favorite}/dal/query/favorites.gen.go (99%) rename applications/{favoriteDomain => favorite}/dal/query/gen.go (100%) rename applications/{favoriteDomain => favorite}/dal/query/var.go (100%) delete mode 100644 applications/favorite/errs/errs.go create mode 100644 applications/favorite/handler/favorite_action.go create mode 100644 applications/favorite/handler/favorite_count.go create mode 100644 applications/favorite/handler/favorite_list.go delete mode 100644 applications/favorite/handler/handler.go create mode 100644 applications/favorite/handler/is_favorite.go create mode 100644 applications/favorite/handler/typedef.go create mode 100644 applications/favorite/misc/config.go create mode 100644 applications/favorite/misc/const.go create mode 100644 applications/favorite/misc/err.go rename applications/{favoriteDomain => favorite}/misc/var.go (100%) create mode 100644 applications/favorite/pack/favorite_action.go create mode 100644 applications/favorite/pack/favorite_count.go create mode 100644 applications/favorite/pack/favorite_list.go create mode 100644 applications/favorite/pack/is_favorite.go delete mode 100644 applications/favorite/rpc/clients.go create mode 100644 applications/favorite/rpc/feed.go create mode 100644 applications/favorite/rpc/init.go create mode 100644 applications/favorite/rpc/var.go delete mode 100644 applications/favorite/run.sh rename applications/{favoriteDomain => favorite}/service/cache_handle.go (100%) create mode 100644 applications/favorite/service/cache_handle_test.go rename applications/{favoriteDomain => favorite}/service/consumer_fav_req.go (83%) create mode 100644 applications/favorite/service/consumer_fav_req_test.go rename applications/{favoriteDomain => favorite}/service/favorite_action.go (79%) rename applications/{favoriteDomain => favorite}/service/favorite_action_cache.go (79%) create mode 100644 applications/favorite/service/favorite_action_cache_test.go rename applications/{favoriteDomain => favorite}/service/favorite_action_rdb.go (84%) create mode 100644 applications/favorite/service/favorite_action_rdb_test.go create mode 100644 applications/favorite/service/favorite_action_test.go rename applications/{favoriteDomain => favorite}/service/favorite_count.go (83%) create mode 100644 applications/favorite/service/favorite_count_test.go rename applications/{favoriteDomain => favorite}/service/favorite_list_cache.go (91%) create mode 100644 applications/favorite/service/favorite_list_cache_test.go rename applications/{favoriteDomain => favorite}/service/favorite_list_rdb.go (100%) create mode 100644 applications/favorite/service/init.go create mode 100644 applications/favorite/service/init_test.go rename applications/{favoriteDomain => favorite}/service/is_favorite.go (69%) create mode 100644 applications/favorite/service/is_favorite_test.go rename applications/{favoriteDomain => favorite}/service/timer.go (95%) create mode 100644 applications/favorite/service/timer_test.go rename applications/{favoriteDomain => favorite}/service/typedef.go (100%) rename applications/{favoriteDomain => favorite}/service/var.go (91%) delete mode 100644 applications/favoriteDomain/Makefile delete mode 100644 applications/favoriteDomain/build.sh delete mode 100644 applications/favoriteDomain/cache/favorite_count_cache/cache.go delete mode 100644 applications/favoriteDomain/dal/migrate/main.go delete mode 100644 applications/favoriteDomain/dal/repository/favorite/repository.go delete mode 100644 applications/favoriteDomain/dal/repository/favorite_count/repository.go delete mode 100644 applications/favoriteDomain/handler/add_favorite.go delete mode 100644 applications/favoriteDomain/handler/count_favorite.go delete mode 100644 applications/favoriteDomain/handler/is_favorite.go delete mode 100644 applications/favoriteDomain/handler/list_favorite.go delete mode 100644 applications/favoriteDomain/handler/rm_favorite.go delete mode 100644 applications/favoriteDomain/handler/typedef.go delete mode 100644 applications/favoriteDomain/main.go delete mode 100644 applications/favoriteDomain/misc/const.go delete mode 100644 applications/favoriteDomain/misc/err.go delete mode 100644 applications/favoriteDomain/pack/add_favorite.go delete mode 100644 applications/favoriteDomain/pack/count_favorite.go delete mode 100644 applications/favoriteDomain/pack/is_favorite.go delete mode 100644 applications/favoriteDomain/pack/list_favorite.go delete mode 100644 applications/favoriteDomain/pack/rm_favorite.go delete mode 100644 applications/favoriteDomain/redis/favorite_count_redis/redis.go delete mode 100644 applications/favoriteDomain/redis/favorite_redis/redis.go delete mode 100644 applications/favoriteDomain/script/bootstrap.sh delete mode 100644 applications/favoriteDomain/service/init.go delete mode 100644 applications/favoriteDomain/service/service.go rename applications/{videoDomain => feed}/dal/gen.go (70%) rename applications/{videoDomain => feed}/dal/model/video.go (100%) rename applications/{videoDomain => feed}/dal/query/gen.go (69%) rename applications/{videoDomain => feed}/dal/query/typedef.go (53%) rename applications/{videoDomain => feed}/dal/query/videos.gen.go (99%) create mode 100644 applications/feed/misc/config.go create mode 100644 applications/feed/misc/const.go rename applications/{videoDomain => feed}/misc/ensure_id_length.go (100%) create mode 100644 applications/feed/misc/string_minus.go rename applications/{videoDomain => feed}/misc/timestamp.go (100%) create mode 100644 applications/feed/pack/video_info.go delete mode 100644 applications/feed/rpc/clients.go create mode 100644 applications/feed/rpc/comment.go create mode 100644 applications/feed/rpc/favorite.go create mode 100644 applications/feed/rpc/init.go create mode 100644 applications/feed/rpc/user.go create mode 100644 applications/feed/rpc/var.go create mode 100644 applications/feed/service/cache.go create mode 100644 applications/feed/service/cache_test.go create mode 100644 applications/feed/service/hbase.go create mode 100644 applications/feed/service/hbase_test.go create mode 100644 applications/feed/service/init.go create mode 100644 applications/feed/service/init_test.go create mode 100644 applications/feed/service/judge.go create mode 100644 applications/feed/service/judge_test.go create mode 100644 applications/feed/service/rdb.go create mode 100644 applications/feed/service/rdb_test.go create mode 100644 applications/feed/service/serialize.go create mode 100644 applications/feed/service/serialize_test.go rename applications/{videoDomain/typedef/hbase.go => feed/service/typedef.go} (84%) rename applications/{videoDomain => feed}/service/var.go (50%) create mode 100644 applications/message/handler.go delete mode 100644 applications/message/handler/message_action.go delete mode 100644 applications/message/handler/message_chat.go delete mode 100644 applications/message/handler/typedef.go delete mode 100644 applications/message/pack/message_action.go delete mode 100644 applications/message/pack/message_chat.go delete mode 100644 applications/message/rpc/clients.go create mode 100644 applications/message/service/consume_msg_test.go create mode 100644 applications/message/service/init_test.go create mode 100644 applications/message/service/message_action_test.go create mode 100644 applications/message/service/message_chat_test.go create mode 100644 applications/message/service/message_friend_test.go delete mode 100644 applications/messageDomain/Makefile delete mode 100644 applications/messageDomain/build.sh delete mode 100644 applications/messageDomain/handler/add_message.go delete mode 100644 applications/messageDomain/handler/list_message.go delete mode 100644 applications/messageDomain/handler/typedef.go delete mode 100644 applications/messageDomain/main.go delete mode 100644 applications/messageDomain/pack/message.go delete mode 100644 applications/messageDomain/pack/resp.go delete mode 100644 applications/messageDomain/script/bootstrap.sh delete mode 100644 applications/messageDomain/service/consume_msg.go delete mode 100644 applications/messageDomain/service/init.go delete mode 100644 applications/messageDomain/service/message_action.go delete mode 100644 applications/messageDomain/service/message_chat.go delete mode 100644 applications/messageDomain/service/message_friend.go create mode 100644 applications/publish/callback/callback.go create mode 100644 applications/publish/callback/controller.go create mode 100644 applications/publish/dal/gen.go create mode 100644 applications/publish/dal/migrate/main.go create mode 100644 applications/publish/dal/model/video.go create mode 100644 applications/publish/dal/query/gen.go create mode 100644 applications/publish/dal/query/typedef.go create mode 100644 applications/publish/dal/query/videos.gen.go create mode 100644 applications/publish/misc/config.go create mode 100644 applications/publish/misc/const.go create mode 100644 applications/publish/misc/ensure_id_length.go create mode 100644 applications/publish/misc/timestamp.go delete mode 100644 applications/publish/rpc/clients.go create mode 100644 applications/publish/rpc/init.go create mode 100644 applications/publish/rpc/user.go create mode 100644 applications/publish/rpc/var.go create mode 100644 applications/publish/service/init.go create mode 100644 applications/publish/service/init_test.go create mode 100644 applications/publish/service/publish_action.go create mode 100644 applications/publish/service/publish_action_test.go create mode 100644 applications/publish/service/publish_list.go create mode 100644 applications/publish/service/publish_list_test.go create mode 100644 applications/publish/service/var.go create mode 100644 applications/publish/service/video.go create mode 100644 applications/publish/service/video_test.go create mode 100644 applications/publish/typedef/hbase.go rename applications/{relationDomain => relation}/dal/gen.go (54%) rename applications/{relationDomain => relation}/dal/migrate/migration.go (69%) rename applications/{relationDomain => relation}/dal/model/count.go (100%) rename applications/{relationDomain => relation}/dal/model/relation.go (100%) rename applications/{relationDomain => relation}/dal/query/follow_counts.gen.go (99%) rename applications/{relationDomain => relation}/dal/query/follower_counts.gen.go (99%) rename applications/{relationDomain => relation}/dal/query/gen.go (100%) rename applications/{relationDomain => relation}/dal/query/relations.gen.go (99%) create mode 100644 applications/relation/handler.go delete mode 100644 applications/relation/handler/handler.go rename applications/{relationDomain => relation}/pack/relation.go (100%) create mode 100644 applications/relation/pack/resp.go delete mode 100644 applications/relation/rpc/clients.go create mode 100644 applications/relation/rpc/init.go create mode 100644 applications/relation/rpc/message.go create mode 100644 applications/relation/rpc/user.go create mode 100644 applications/relation/service/consume_msg_test.go create mode 100644 applications/relation/service/init_test.go create mode 100644 applications/relation/service/relation_action_test.go create mode 100644 applications/relation/service/relation_count_test.go create mode 100644 applications/relation/service/relation_follow_list_test.go create mode 100644 applications/relation/service/relation_follower_list_test.go create mode 100644 applications/relation/service/relation_friend_list_test.go delete mode 100644 applications/relationDomain/Makefile delete mode 100644 applications/relationDomain/build.sh delete mode 100644 applications/relationDomain/handler/add_relation.go delete mode 100644 applications/relationDomain/handler/count_relation.go delete mode 100644 applications/relationDomain/handler/list_relation.go delete mode 100644 applications/relationDomain/handler/rm_relation.go delete mode 100644 applications/relationDomain/handler/typedef.go delete mode 100644 applications/relationDomain/main.go delete mode 100644 applications/relationDomain/pack/resp.go delete mode 100644 applications/relationDomain/script/bootstrap.sh delete mode 100644 applications/relationDomain/service/consume_msg.go delete mode 100644 applications/relationDomain/service/init.go delete mode 100644 applications/relationDomain/service/relation_action.go delete mode 100644 applications/relationDomain/service/relation_count.go delete mode 100644 applications/relationDomain/service/relation_follow_list.go delete mode 100644 applications/relationDomain/service/relation_follower_list.go delete mode 100644 applications/relationDomain/service/relation_friend_list.go rename applications/{userDomain => user}/dal/gen.go (83%) create mode 100644 applications/user/dal/migrate.go rename applications/{userDomain => user}/dal/model/user.go (100%) rename applications/{userDomain => user}/dal/query/gen.go (100%) create mode 100644 applications/user/dal/query/typedef.go rename applications/{userDomain => user}/dal/query/users.gen.go (99%) delete mode 100644 applications/user/errs/errors.go create mode 100644 applications/user/handler/get_user_by_id.go create mode 100644 applications/user/handler/get_user_list_by_id.go delete mode 100644 applications/user/handler/handler.go create mode 100644 applications/user/handler/login.go create mode 100644 applications/user/handler/register.go create mode 100644 applications/user/handler/typedef.go create mode 100644 applications/user/misc/config.go create mode 100644 applications/user/misc/const.go create mode 100644 applications/user/misc/err.go create mode 100644 applications/user/misc/get_misc.go create mode 100644 applications/user/pack/get_user_list_by_id.go create mode 100644 applications/user/pack/login_register.go create mode 100644 applications/user/pack/user.go delete mode 100644 applications/user/rpc/clients.go create mode 100644 applications/user/rpc/init.go create mode 100644 applications/user/rpc/relation.go create mode 100644 applications/user/rpc/var.go delete mode 100644 applications/user/run.sh create mode 100644 applications/user/service/encrypt.go create mode 100644 applications/user/service/encrypt_test.go create mode 100644 applications/user/service/init.go create mode 100644 applications/user/service/login.go create mode 100644 applications/user/service/login_test.go create mode 100644 applications/user/service/register.go create mode 100644 applications/user/service/register_test.go create mode 100644 applications/user/service/search.go create mode 100644 applications/user/service/search_test.go create mode 100644 applications/user/service/var.go delete mode 100644 applications/userDomain/Makefile delete mode 100644 applications/userDomain/build.sh delete mode 100644 applications/userDomain/dal/repository/user/repository.go delete mode 100644 applications/userDomain/errs/errs.go delete mode 100644 applications/userDomain/handler/handler.go delete mode 100644 applications/userDomain/handler/pack.go delete mode 100644 applications/userDomain/main.go delete mode 100644 applications/userDomain/run.sh delete mode 100644 applications/userDomain/script/bootstrap.sh delete mode 100644 applications/userDomain/service/service.go delete mode 100644 applications/videoDomain/Makefile delete mode 100644 applications/videoDomain/build.sh delete mode 100644 applications/videoDomain/dal/migrate/main.go delete mode 100644 applications/videoDomain/dal/model/video_count.go delete mode 100644 applications/videoDomain/dal/query/video_counts.gen.go delete mode 100644 applications/videoDomain/handler/add_publish.go delete mode 100644 applications/videoDomain/handler/count_publish.go delete mode 100644 applications/videoDomain/handler/get_feed.go delete mode 100644 applications/videoDomain/handler/get_video_info.go delete mode 100644 applications/videoDomain/handler/list_publish.go delete mode 100644 applications/videoDomain/handler/typedef.go delete mode 100644 applications/videoDomain/main.go delete mode 100644 applications/videoDomain/misc/err.go delete mode 100644 applications/videoDomain/pack/add_publish.go delete mode 100644 applications/videoDomain/pack/count_publish.go delete mode 100644 applications/videoDomain/pack/get_feed.go delete mode 100644 applications/videoDomain/pack/get_video_info.go delete mode 100644 applications/videoDomain/pack/list_publish.go delete mode 100644 applications/videoDomain/script/bootstrap.sh delete mode 100644 applications/videoDomain/service/feed_cache.go delete mode 100644 applications/videoDomain/service/hbase.go delete mode 100644 applications/videoDomain/service/init.go delete mode 100644 applications/videoDomain/service/publish_action.go delete mode 100644 applications/videoDomain/service/publish_list.go delete mode 100644 applications/videoDomain/service/serialize.go delete mode 100644 applications/videoDomain/service/video.go delete mode 100644 config/commentDomain.yaml create mode 100644 config/configStruct/comment.go create mode 100644 config/configStruct/favorite.go create mode 100644 config/configStruct/feed.go create mode 100644 config/configStruct/publish.go create mode 100644 config/configStruct/user.go delete mode 100644 config/favoriteDomain.yaml delete mode 100644 config/messageDomain.yaml delete mode 100644 config/relationDomain.yaml delete mode 100644 config/userDomain.yaml delete mode 100644 config/videoDomain.yaml delete mode 100644 kitex_gen/comment/comment.pb.fast.go delete mode 100644 kitex_gen/commentDomain/commentDomain.pb.fast.go delete mode 100644 kitex_gen/commentDomain/commentDomain.pb.go delete mode 100644 kitex_gen/commentDomain/commentdomainservice/client.go delete mode 100644 kitex_gen/commentDomain/commentdomainservice/commentdomainservice.go delete mode 100644 kitex_gen/commentDomain/commentdomainservice/invoker.go delete mode 100644 kitex_gen/commentDomain/commentdomainservice/server.go delete mode 100644 kitex_gen/favorite/favorite.pb.fast.go delete mode 100644 kitex_gen/favoriteDomain/favoriteDomain.pb.fast.go delete mode 100644 kitex_gen/favoriteDomain/favoriteDomain.pb.go delete mode 100644 kitex_gen/favoriteDomain/favoritedomainservice/client.go delete mode 100644 kitex_gen/favoriteDomain/favoritedomainservice/favoritedomainservice.go delete mode 100644 kitex_gen/favoriteDomain/favoritedomainservice/invoker.go delete mode 100644 kitex_gen/favoriteDomain/favoritedomainservice/server.go delete mode 100644 kitex_gen/feed/feed.pb.fast.go delete mode 100644 kitex_gen/message/message.pb.fast.go delete mode 100644 kitex_gen/messageDomain/messageDomain.pb.fast.go delete mode 100644 kitex_gen/messageDomain/messageDomain.pb.go delete mode 100644 kitex_gen/messageDomain/messagedomainservice/client.go delete mode 100644 kitex_gen/messageDomain/messagedomainservice/invoker.go delete mode 100644 kitex_gen/messageDomain/messagedomainservice/messagedomainservice.go delete mode 100644 kitex_gen/messageDomain/messagedomainservice/server.go delete mode 100644 kitex_gen/publish/publish.pb.fast.go delete mode 100644 kitex_gen/relationDomain/relationDomain.pb.fast.go delete mode 100644 kitex_gen/relationDomain/relationDomain.pb.go delete mode 100644 kitex_gen/relationDomain/relationdomainservice/client.go delete mode 100644 kitex_gen/relationDomain/relationdomainservice/invoker.go delete mode 100644 kitex_gen/relationDomain/relationdomainservice/relationdomainservice.go delete mode 100644 kitex_gen/relationDomain/relationdomainservice/server.go delete mode 100644 kitex_gen/userDomain/userDomain.pb.fast.go delete mode 100644 kitex_gen/userDomain/userDomain.pb.go delete mode 100644 kitex_gen/userDomain/userdomainservice/client.go delete mode 100644 kitex_gen/userDomain/userdomainservice/invoker.go delete mode 100644 kitex_gen/userDomain/userdomainservice/server.go delete mode 100644 kitex_gen/userDomain/userdomainservice/userdomainservice.go delete mode 100644 kitex_gen/videoDomain/videoDomain.pb.fast.go delete mode 100644 kitex_gen/videoDomain/videoDomain.pb.go delete mode 100644 kitex_gen/videoDomain/videodomainservice/client.go delete mode 100644 kitex_gen/videoDomain/videodomainservice/invoker.go delete mode 100644 kitex_gen/videoDomain/videodomainservice/server.go delete mode 100644 kitex_gen/videoDomain/videodomainservice/videodomainservice.go create mode 100644 pkg/hbaseHandle/init.go create mode 100644 pkg/hbaseHandle/init_test.go create mode 100644 pkg/hbaseHandle/put_test.go create mode 100644 pkg/hbaseHandle/scan_test.go delete mode 100644 pkg/initHelper/commentDomain.go delete mode 100644 pkg/initHelper/favoriteDomain.go delete mode 100644 pkg/initHelper/messageDomain.go delete mode 100644 pkg/initHelper/relationDomain.go create mode 100644 pkg/initHelper/rpc_server.go delete mode 100644 pkg/initHelper/userDomain.go delete mode 100644 pkg/initHelper/videoDomain.go delete mode 100644 proto/api.proto delete mode 100644 proto/comment.proto delete mode 100644 proto/commentDomain.proto delete mode 100644 proto/favorite.proto delete mode 100644 proto/favoriteDomain.proto delete mode 100644 proto/feed.proto delete mode 100644 proto/hz.proto delete mode 100644 proto/message.proto delete mode 100644 proto/messageDomain.proto delete mode 100644 proto/publish.proto delete mode 100644 proto/relation.proto delete mode 100644 proto/relationDomain.proto delete mode 100644 proto/user.proto delete mode 100644 proto/userDomain.proto delete mode 100644 proto/videoDomain.proto diff --git a/applications/comment/build.sh b/applications/comment/build.sh index da7bb5f9..6a8940db 100644 --- a/applications/comment/build.sh +++ b/applications/comment/build.sh @@ -10,4 +10,3 @@ if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then else go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... fi - diff --git a/applications/commentDomain/dal/gen.go b/applications/comment/dal/gen.go similarity index 83% rename from applications/commentDomain/dal/gen.go rename to applications/comment/dal/gen.go index 355acde5..466ea246 100644 --- a/applications/commentDomain/dal/gen.go +++ b/applications/comment/dal/gen.go @@ -1,7 +1,7 @@ package main import ( - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/comment/dal/model" "github.com/TremblingV5/DouTok/config/configStruct" "github.com/TremblingV5/DouTok/pkg/configurator" "github.com/TremblingV5/DouTok/pkg/mysqlIniter" @@ -15,11 +15,9 @@ func main() { }) var config configStruct.MySQLConfig - if err := configurator.InitConfig( + configurator.InitConfig( &config, "mysql.yaml", - ); err != nil { - panic(err) - } + ) db, err := mysqlIniter.InitDb( config.Username, diff --git a/applications/comment/dal/migrate/main.go b/applications/comment/dal/migrate/main.go new file mode 100644 index 00000000..633b2301 --- /dev/null +++ b/applications/comment/dal/migrate/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "github.com/TremblingV5/DouTok/applications/comment/dal/model" + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/applications/comment/service" +) + +func main() { + misc.InitViperConfig() + + service.InitDb( + misc.GetConfig("MySQL.Username"), + misc.GetConfig("MySQL.Password"), + misc.GetConfig("MySQL.Host"), + misc.GetConfig("MySQL.Port"), + misc.GetConfig("MySQL.Database"), + ) + + service.DB.AutoMigrate(&model.Comment{}, &model.CommentCount{}) +} diff --git a/applications/commentDomain/dal/model/comment.go b/applications/comment/dal/model/comment.go similarity index 100% rename from applications/commentDomain/dal/model/comment.go rename to applications/comment/dal/model/comment.go diff --git a/applications/commentDomain/dal/hbModel/comment_hb.go b/applications/comment/dal/model/comment_hb.go similarity index 98% rename from applications/commentDomain/dal/hbModel/comment_hb.go rename to applications/comment/dal/model/comment_hb.go index e974934d..673421f0 100644 --- a/applications/commentDomain/dal/hbModel/comment_hb.go +++ b/applications/comment/dal/model/comment_hb.go @@ -1,4 +1,4 @@ -package hbModel +package model import ( "encoding/binary" diff --git a/applications/commentDomain/dal/model/count.go b/applications/comment/dal/model/count.go similarity index 100% rename from applications/commentDomain/dal/model/count.go rename to applications/comment/dal/model/count.go diff --git a/applications/commentDomain/dal/query/comment_counts.gen.go b/applications/comment/dal/query/comment_counts.gen.go similarity index 99% rename from applications/commentDomain/dal/query/comment_counts.gen.go rename to applications/comment/dal/query/comment_counts.gen.go index 0416d810..17dc24f4 100644 --- a/applications/commentDomain/dal/query/comment_counts.gen.go +++ b/applications/comment/dal/query/comment_counts.gen.go @@ -16,7 +16,7 @@ import ( "gorm.io/plugin/dbresolver" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/comment/dal/model" ) func newCommentCount(db *gorm.DB, opts ...gen.DOOption) commentCount { diff --git a/applications/commentDomain/dal/query/comments.gen.go b/applications/comment/dal/query/comments.gen.go similarity index 99% rename from applications/commentDomain/dal/query/comments.gen.go rename to applications/comment/dal/query/comments.gen.go index dc99b437..f1e95b71 100644 --- a/applications/commentDomain/dal/query/comments.gen.go +++ b/applications/comment/dal/query/comments.gen.go @@ -16,7 +16,7 @@ import ( "gorm.io/plugin/dbresolver" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/comment/dal/model" ) func newComment(db *gorm.DB, opts ...gen.DOOption) comment { diff --git a/applications/commentDomain/dal/query/gen.go b/applications/comment/dal/query/gen.go similarity index 100% rename from applications/commentDomain/dal/query/gen.go rename to applications/comment/dal/query/gen.go diff --git a/applications/commentDomain/dal/query/var.go b/applications/comment/dal/query/var.go similarity index 100% rename from applications/commentDomain/dal/query/var.go rename to applications/comment/dal/query/var.go diff --git a/applications/comment/errs/errs.go b/applications/comment/errs/errs.go deleted file mode 100644 index 876532a9..00000000 --- a/applications/comment/errs/errs.go +++ /dev/null @@ -1,27 +0,0 @@ -package errs - -import "github.com/TremblingV5/DouTok/pkg/response" - -const ( - ParamsError = "params error" - ParamsErrorCode = 101 - BindingError = "binding error" - BindingErrorCode = 102 -) - -var ( - Success *response.Response - ParamsErr *response.Response - BindingErr *response.Response -) - -func Init(config response.Config) { - Success = response.Success(config) - - ParamsErr = Success.Copy().Update( - response.Message(ParamsError), response.Code(ParamsErrorCode), - ) - BindingErr = Success.Copy().Update( - response.Message(BindingError), response.Code(BindingErrorCode), - ) -} diff --git a/applications/comment/handler/comment_action.go b/applications/comment/handler/comment_action.go new file mode 100644 index 00000000..ed0a6ed6 --- /dev/null +++ b/applications/comment/handler/comment_action.go @@ -0,0 +1,36 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/applications/comment/pack" + "github.com/TremblingV5/DouTok/applications/comment/service" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/TremblingV5/DouTok/pkg/utils" +) + +func (s *CommentServiceImpl) CommentAction(ctx context.Context, req *comment.DouyinCommentActionRequest) (resp *comment.DouyinCommentActionResponse, err error) { + if result := misc.CheckCommentActionArgs(req); !result { + return pack.PackCommentActionResp(int32(misc.ParamsErr.ErrCode), misc.ParamsErr.ErrMsg, nil, req.UserId) + } + + // 判断请求的动作,1为新加评论,2为删除评论 + if req.ActionType == 1 { + result, err := service.AddComment( + req.VideoId, req.UserId, utils.GetSnowFlakeId().Int64(), 0, 0, req.CommentText, + ) + if err != nil { + return pack.PackCommentActionResp(int32(misc.SystemErr.ErrCode), misc.SystemErr.ErrMsg, nil, req.UserId) + } + return pack.PackCommentActionResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, result, req.UserId) + } else if req.ActionType == 2 { + errNo, err := service.RmComment(req.UserId, req.CommentId) + if err != nil { + return pack.PackCommentActionResp(int32(errNo.ErrCode), errNo.ErrMsg, nil, req.UserId) + } + return pack.PackCommentActionResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, nil, req.UserId) + } else { + return pack.PackCommentActionResp(int32(misc.BindingErr.ErrCode), misc.BindingErr.ErrMsg, nil, req.UserId) + } +} diff --git a/applications/comment/handler/comment_count.go b/applications/comment/handler/comment_count.go new file mode 100644 index 00000000..f1496bca --- /dev/null +++ b/applications/comment/handler/comment_count.go @@ -0,0 +1,23 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/applications/comment/pack" + "github.com/TremblingV5/DouTok/applications/comment/service" + "github.com/TremblingV5/DouTok/kitex_gen/comment" +) + +func (s *CommentServiceImpl) CommentCount(ctx context.Context, req *comment.DouyinCommentCountRequest) (resp *comment.DouyinCommentCountResponse, err error) { + if len(req.VideoIdList) == 0 { + return pack.PackCommentCountResp(int32(misc.ListEmptyErr.ErrCode), misc.ListEmptyErr.ErrMsg, nil) + } + + res, errNo, err := service.CountComment(req.VideoIdList...) + if err != nil { + return pack.PackCommentCountResp(int32(errNo.ErrCode), errNo.ErrMsg, nil) + } + + return pack.PackCommentCountResp(int32(errNo.ErrCode), errNo.ErrMsg, res) +} diff --git a/applications/comment/handler/comment_list.go b/applications/comment/handler/comment_list.go new file mode 100644 index 00000000..68c8be44 --- /dev/null +++ b/applications/comment/handler/comment_list.go @@ -0,0 +1,23 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/applications/comment/pack" + "github.com/TremblingV5/DouTok/applications/comment/service" + "github.com/TremblingV5/DouTok/kitex_gen/comment" +) + +func (s *CommentServiceImpl) CommentList(ctx context.Context, req *comment.DouyinCommentListRequest) (resp *comment.DouyinCommentListResponse, err error) { + if !misc.CheckCommentListArgs(req) { + return pack.PackCommentListResp(int32(misc.VideoIdErr.ErrCode), misc.VideoIdErr.ErrMsg, nil) + } + + res, errNo, err := service.ListComment(req.VideoId) + if err != nil { + return pack.PackCommentListResp(int32(errNo.ErrCode), errNo.ErrMsg, nil) + } + + return pack.PackCommentListResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, res) +} diff --git a/applications/comment/handler/handler.go b/applications/comment/handler/handler.go deleted file mode 100644 index 28ec07cc..00000000 --- a/applications/comment/handler/handler.go +++ /dev/null @@ -1,86 +0,0 @@ -package handler - -import ( - "context" - - "github.com/TremblingV5/DouTok/applications/comment/errs" - "github.com/TremblingV5/DouTok/applications/comment/rpc" - "github.com/TremblingV5/DouTok/kitex_gen/comment" - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" -) - -type Handler struct { - clients *rpc.Clients -} - -func New(clients *rpc.Clients) *Handler { - return &Handler{clients: clients} -} - -func (h *Handler) CommentAction(ctx context.Context, req *comment.DouyinCommentActionRequest) (resp *comment.DouyinCommentActionResponse, err error) { - if req.CommentText != "" { - return &comment.DouyinCommentActionResponse{ - StatusCode: errs.ParamsErr.Code(), - StatusMsg: errs.ParamsErr.Message(), - }, nil - } - - // add comments - if req.ActionType == 1 { - result, err := h.clients.Comment.Client.AddComment(ctx, &commentDomain.DoutokAddCommentReq{ - VideoId: req.VideoId, - UserId: req.UserId, - CommentText: req.CommentText, - }) - return &comment.DouyinCommentActionResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - }, err - } - - // remove comments - if req.ActionType == 2 { - result, err := h.clients.Comment.Client.RmComment(ctx, &commentDomain.DoutokRmCommentReq{ - VideoId: req.VideoId, - UserId: req.UserId, - CommentId: req.CommentId, - }) - return &comment.DouyinCommentActionResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - }, err - } - - return &comment.DouyinCommentActionResponse{ - StatusCode: errs.BindingErr.Code(), - StatusMsg: errs.BindingErr.Message(), - }, nil -} - -func (h *Handler) CommentCount(ctx context.Context, req *comment.DouyinCommentCountRequest) (resp *comment.DouyinCommentCountResponse, err error) { - result, err := h.clients.Comment.Client.CountComment(ctx, &commentDomain.DoutokCountCommentReq{ - VideoIdList: req.VideoIdList, - }) - - if err != nil { - return nil, err - } - - return &comment.DouyinCommentCountResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - Result: result.CommentCount, - }, nil -} - -func (h *Handler) CommentList(ctx context.Context, req *comment.DouyinCommentListRequest) (resp *comment.DouyinCommentListResponse, err error) { - result, err := h.clients.Comment.Client.ListComment(ctx, &commentDomain.DoutokListCommentReq{ - VideoId: req.VideoId, - }) - - return &comment.DouyinCommentListResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - CommentList: result.CommentList, - }, err -} diff --git a/applications/comment/handler/var.go b/applications/comment/handler/var.go new file mode 100644 index 00000000..5dffe72e --- /dev/null +++ b/applications/comment/handler/var.go @@ -0,0 +1,3 @@ +package handler + +type CommentServiceImpl struct{} diff --git a/applications/comment/main.go b/applications/comment/main.go index ecb11481..47e637d0 100644 --- a/applications/comment/main.go +++ b/applications/comment/main.go @@ -1,52 +1,42 @@ package main import ( - "context" "github.com/TremblingV5/DouTok/applications/comment/handler" + "github.com/TremblingV5/DouTok/applications/comment/misc" "github.com/TremblingV5/DouTok/applications/comment/rpc" - "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/applications/comment/service" "github.com/TremblingV5/DouTok/kitex_gen/comment/commentservice" - "github.com/TremblingV5/DouTok/pkg/DouTokContext" - "github.com/TremblingV5/DouTok/pkg/DouTokLogger" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/services" - "go.uber.org/zap" + "github.com/TremblingV5/DouTok/pkg/dlog" + "github.com/TremblingV5/DouTok/pkg/initHelper" ) -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_COMMENT_"` - Jwt configStruct.Jwt `envPrefix:"DOUTOK_COMMENT_"` - Logger configStruct.Logger `envPrefix:"DOUTOK_COMMENT_"` -} - var ( - logger *zap.Logger - config = &Config{} + Logger = dlog.InitLog(3) ) -func init() { +func Init() { + misc.InitViperConfig() - ctx := context.Background() - _, err := configurator.Load(config, "DOUTOK_COMMENT", "comment") - logger = DouTokLogger.InitLogger(config.Logger) - DouTokContext.DefaultLogger = logger - DouTokContext.AddLoggerToContext(ctx, logger) - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", config)) - } + service.Init() + + rpc.InitPRCClient() + + go service.UpdateComCountMap() + go service.UpdateComTotalCntMap() } func main() { - options, shutdown := services.InitRPCServerArgs(constants.COMMENT_SERVER_NAME, config.BaseConfig) + Init() + + options, shutdown := initHelper.InitRPCServerArgs(misc.Config) defer shutdown() svr := commentservice.NewServer( - handler.New(rpc.New(services.InitRPCClientArgs(constants.COMMENT_SERVER_NAME, config.Etcd))), - options..., + new(handler.CommentServiceImpl), + options... ) if err := svr.Run(); err != nil { - logger.Fatal("run server err", zap.Error(err)) + Logger.Fatal(err) } } diff --git a/applications/comment/misc/check_args.go b/applications/comment/misc/check_args.go new file mode 100644 index 00000000..b59882ed --- /dev/null +++ b/applications/comment/misc/check_args.go @@ -0,0 +1,11 @@ +package misc + +import "github.com/TremblingV5/DouTok/kitex_gen/comment" + +func CheckCommentActionArgs(req *comment.DouyinCommentActionRequest) bool { + return req.CommentText != "" +} + +func CheckCommentListArgs(req *comment.DouyinCommentListRequest) bool { + return req.VideoId >= 0 +} diff --git a/applications/comment/misc/config.go b/applications/comment/misc/config.go new file mode 100644 index 00000000..c51050fa --- /dev/null +++ b/applications/comment/misc/config.go @@ -0,0 +1,18 @@ +package misc + +import "github.com/TremblingV5/DouTok/pkg/dtviper" + +var Config *dtviper.Config + +func InitViperConfig() { + config := dtviper.ConfigInit(ViperConfigEnvPrefix, ViperConfigEnvFilename) + Config = config +} + +func GetConfig(key string) string { + return Config.Viper.GetString(key) +} + +func GetConfigNum(key string) int64 { + return Config.Viper.GetInt64(key) +} diff --git a/applications/comment/misc/const.go b/applications/comment/misc/const.go new file mode 100644 index 00000000..510b9b3e --- /dev/null +++ b/applications/comment/misc/const.go @@ -0,0 +1,9 @@ +package misc + +const ( + ViperConfigEnvPrefix = "DOUTOK_COMMENT" + ViperConfigEnvFilename = "comment" + + ComCntCache = "comcntcache" + ComTotalCntCache = "comtotalcntcache" +) diff --git a/applications/comment/misc/err.go b/applications/comment/misc/err.go new file mode 100644 index 00000000..1491736a --- /dev/null +++ b/applications/comment/misc/err.go @@ -0,0 +1,33 @@ +package misc + +import "github.com/TremblingV5/DouTok/pkg/errno" + +var ( + NilErrCode = -1 + SuccessCode = 0 + ParamsErrCode = 26001 + SystemErrCode = 26002 + BindingErrCode = 26003 + ListEmptyErrCode = 26004 + VideoIdErrCode = 26005 + QueryCommentCountErrCode = 26006 + QueryCommentListInHBErrCode = 26007 + CommentNotBelongToUserErrCode = 26008 + RmDataFromHBErrCode = 26009 + HBDataNotFoundErrCode = 26010 +) + +var ( + NilErr = errno.NewErrNo(NilErrCode, "Don't care") + Success = errno.NewErrNo(SuccessCode, "Success") + ParamsErr = errno.NewErrNo(ParamsErrCode, "Invalid parameters") + SystemErr = errno.NewErrNo(SystemErrCode, "System error") + BindingErr = errno.NewErrNo(BindingErrCode, "Action type invalid") + ListEmptyErr = errno.NewErrNo(ListEmptyErrCode, "List is empty") + VideoIdErr = errno.NewErrNo(VideoIdErrCode, "Video id invalid") + QueryCommentCountErr = errno.NewErrNo(QueryCommentCountErrCode, "Query comment count error") + QueryCommentListInHBErr = errno.NewErrNo(QueryCommentListInHBErrCode, "Query comment list in HBase error") + CommentNotBelongToUserErr = errno.NewErrNo(CommentNotBelongToUserErrCode, "This comment not belong to the user") + RmDataFromHBErr = errno.NewErrNo(RmDataFromHBErrCode, "Deleta data in HBase error") + HBDataNotFoundErr = errno.NewErrNo(HBDataNotFoundErrCode, "HBase comment data not found") +) diff --git a/applications/comment/misc/row_key.go b/applications/comment/misc/row_key.go new file mode 100644 index 00000000..8266eced --- /dev/null +++ b/applications/comment/misc/row_key.go @@ -0,0 +1,19 @@ +package misc + +import ( + "fmt" + + globalMisc "github.com/TremblingV5/DouTok/pkg/misc" +) + +func EnsureIdLength(id int64) string { + return globalMisc.LFill(fmt.Sprint(id), 20) +} + +func GetCommentRowKey(video_id int64, is_deleted string, conversation_id int64, timestamp string) string { + return EnsureIdLength(video_id) + is_deleted + EnsureIdLength(conversation_id) + timestamp +} + +func GetCommentQueryPrefix(video_id int64) string { + return EnsureIdLength(video_id) + "0" +} diff --git a/applications/comment/pack/comment_action.go b/applications/comment/pack/comment_action.go new file mode 100644 index 00000000..72737ae5 --- /dev/null +++ b/applications/comment/pack/comment_action.go @@ -0,0 +1,38 @@ +package pack + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/applications/comment/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/TremblingV5/DouTok/kitex_gen/user" +) + +func PackCommentActionResp(code int32, msg string, cmt *comment.Comment, user_id int64) (resp *comment.DouyinCommentActionResponse, err error) { + if code == int32(misc.Success.ErrCode) { + reqUser, err := rpc.GetUserById(context.Background(), &user.DouyinUserRequest{ + UserId: user_id, + }) + if err != nil { + return nil, err + } + + user := user.User{ + Id: reqUser.User.Id, + Name: reqUser.User.Name, + Avatar: reqUser.User.Avatar, + BackgroundImage: reqUser.User.BackgroundImage, + Signature: reqUser.User.Signature, + FollowCount: reqUser.User.FollowCount, + FollowerCount: reqUser.User.FollowerCount, + } + + cmt.User = &user + } + + return &comment.DouyinCommentActionResponse{ + StatusCode: code, + StatusMsg: msg, + Comment: cmt, + }, nil +} diff --git a/applications/comment/pack/comment_count.go b/applications/comment/pack/comment_count.go new file mode 100644 index 00000000..a77b1950 --- /dev/null +++ b/applications/comment/pack/comment_count.go @@ -0,0 +1,11 @@ +package pack + +import "github.com/TremblingV5/DouTok/kitex_gen/comment" + +func PackCommentCountResp(code int32, msg string, countList map[int64]int64) (*comment.DouyinCommentCountResponse, error) { + return &comment.DouyinCommentCountResponse{ + StatusCode: code, + StatusMsg: msg, + Result: countList, + }, nil +} diff --git a/applications/comment/pack/comment_list.go b/applications/comment/pack/comment_list.go new file mode 100644 index 00000000..7f3af286 --- /dev/null +++ b/applications/comment/pack/comment_list.go @@ -0,0 +1,55 @@ +package pack + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/comment/service" + "time" + + "github.com/TremblingV5/DouTok/applications/comment/dal/model" + "github.com/TremblingV5/DouTok/applications/comment/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/TremblingV5/DouTok/kitex_gen/user" +) + +func PackCommentListResp(code int32, msg string, comments []*model.CommentInHB) (resp *comment.DouyinCommentListResponse, err error) { + resp = &comment.DouyinCommentListResponse{ + StatusCode: code, + StatusMsg: msg, + } + + comment_list := []*comment.Comment{} + + currentTime := time.Now().Unix() + + for _, v := range comments { + temp := comment.Comment{ + Id: v.GetId(), + Content: v.GetContent(), + CreateDate: service.GetTimeRecall(v.GetTimestamp(), currentTime), + } + + reqUser, err := rpc.GetUserById(context.Background(), &user.DouyinUserRequest{ + UserId: v.GetUserId(), + }) + if err != nil { + continue + } + + tempUser := user.User{ + Id: reqUser.User.Id, + Name: reqUser.User.Name, + FollowCount: reqUser.User.FollowCount, + FollowerCount: reqUser.User.FollowerCount, + Avatar: reqUser.User.Avatar, + BackgroundImage: reqUser.User.BackgroundImage, + Signature: reqUser.User.Signature, + } + + temp.User = &tempUser + comment_list = append(comment_list, &temp) + } + + resp.CommentList = comment_list + + return resp, nil +} diff --git a/applications/comment/rpc/clients.go b/applications/comment/rpc/clients.go deleted file mode 100644 index c4e6a66d..00000000 --- a/applications/comment/rpc/clients.go +++ /dev/null @@ -1,21 +0,0 @@ -package rpc - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain/commentdomainservice" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain/userdomainservice" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/services" - "github.com/cloudwego/kitex/client" -) - -type Clients struct { - User *services.Service[userdomainservice.Client] - Comment *services.Service[commentdomainservice.Client] -} - -func New(options []client.Option) *Clients { - return &Clients{ - User: services.New[userdomainservice.Client](constants.USER_DOMAIN_SERVER_NAME, userdomainservice.NewClient, options), - Comment: services.New[commentdomainservice.Client](constants.COMMENT_DOMAIN_SERVER_NAME, commentdomainservice.NewClient, options), - } -} diff --git a/applications/comment/rpc/init.go b/applications/comment/rpc/init.go new file mode 100644 index 00000000..f80989ed --- /dev/null +++ b/applications/comment/rpc/init.go @@ -0,0 +1,5 @@ +package rpc + +func InitPRCClient() { + InitUserRpc() +} diff --git a/applications/comment/rpc/user.go b/applications/comment/rpc/user.go new file mode 100644 index 00000000..4e5973a2 --- /dev/null +++ b/applications/comment/rpc/user.go @@ -0,0 +1,40 @@ +package rpc + +import ( + "context" + "errors" + "github.com/TremblingV5/DouTok/kitex_gen/user" + "github.com/TremblingV5/DouTok/kitex_gen/user/userservice" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/initHelper" +) + +var userClient userservice.Client + +func InitUserRpc() { + config := dtviper.ConfigInit("DOUTOK_USER", "user") + + c, err := userservice.NewClient( + config.Viper.GetString("Server.Name"), + initHelper.InitRPCClientArgs(config)..., + ) + + if err != nil { + panic(err) + } + + userClient = c +} + +func GetUserById(ctx context.Context, req *user.DouyinUserRequest) (resp *user.DouyinUserResponse, err error) { + resp, err = userClient.GetUserById(ctx, req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 0 { + return nil, errors.New(resp.StatusMsg) + } + + return resp, nil +} diff --git a/applications/comment/rpc/var.go b/applications/comment/rpc/var.go new file mode 100644 index 00000000..db1c698a --- /dev/null +++ b/applications/comment/rpc/var.go @@ -0,0 +1,5 @@ +package rpc + +import "github.com/TremblingV5/DouTok/config/configStruct" + +var ClientConfig *configStruct.CommentConfig diff --git a/applications/comment/run.sh b/applications/comment/run.sh deleted file mode 100644 index 6306bccd..00000000 --- a/applications/comment/run.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# 设置环境变量 -export DOUTOK_COMMENT_SERVER_NAME=DouTokCommentServer -export DOUTOK_COMMENT_SERVER_PORT=8081 -export DOUTOK_COMMENT_ETCD_ADDRESS=localhost -export DOUTOK_COMMENT_ETCD_PORT=2379 - -# 运行 Go 项目 -go run main.go diff --git a/applications/comment/script/bootstrap.sh b/applications/comment/script/bootstrap.sh index e940a23d..294cb6e7 100644 --- a/applications/comment/script/bootstrap.sh +++ b/applications/comment/script/bootstrap.sh @@ -19,4 +19,3 @@ if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then fi exec "$CURDIR/bin/comment" - diff --git a/applications/comment/service/add_comment.go b/applications/comment/service/add_comment.go new file mode 100644 index 00000000..50399dee --- /dev/null +++ b/applications/comment/service/add_comment.go @@ -0,0 +1,106 @@ +package service + +import ( + "fmt" + "time" + + "github.com/TremblingV5/DouTok/applications/comment/dal/model" + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/TremblingV5/DouTok/pkg/utils" +) + +/* + 添加评论 +*/ +func AddComment(video_id int64, user_id int64, con_id int64, last_id int64, to_user_id int64, content string) (*comment.Comment, error) { + timestamp := fmt.Sprint(time.Now().Unix()) + + id := utils.GetSnowFlakeId() + + result := comment.Comment{ + Id: int64(id), + Content: content, + CreateDate: "刚刚", + } + + if err := SaveComment2RDB(int64(id), video_id, user_id, con_id, last_id, to_user_id, content, timestamp); err != nil { + return nil, err + } + + if err := SaveComment2HB(int64(id), video_id, user_id, con_id, last_id, to_user_id, content, timestamp); err != nil { + return nil, err + } + + UpdateCacheComCount(video_id, true) + + //reqUser, err := rpc.GetUserById(context.Background(), &user.DouyinUserRequest{ + // UserId: user_id, + //}) + //if err != nil { + // return nil, err + //} + // + //user := user.User{ + // Id: reqUser.User.Id, + // Name: reqUser.User.Name, + // Avatar: reqUser.User.Avatar, + // FollowCount: reqUser.User.FollowCount, + // FollowerCount: reqUser.User.FollowerCount, + //} + // + //result.User = &user + + return &result, nil +} + +/* + 在MySQL中存储评论信息 +*/ +func SaveComment2RDB(id int64, video_id int64, user_id int64, con_id int64, last_id int64, to_user_id int64, content string, timestamp string) error { + err := DoComment.Create( + &model.Comment{ + Id: id, + VideoId: video_id, + UserId: user_id, + ConversationId: con_id, + LastId: last_id, + ToUserId: to_user_id, + Content: content, + Status: true, + Timestamp: timestamp, + }, + ) + + if err != nil { + return err + } + + return nil +} + +/* + 在HBase中存储评论信息 +*/ +func SaveComment2HB(id int64, video_id int64, user_id int64, con_id int64, last_id int64, to_user_id int64, content string, timestamp string) error { + hbData := map[string]map[string][]byte{ + "data": { + "id": []byte(fmt.Sprint(id)), + "video_id": []byte(fmt.Sprint(video_id)), + "user_id": []byte(fmt.Sprint(user_id)), + "conversation_id": []byte(fmt.Sprint(con_id)), + "last_id": []byte(fmt.Sprint(last_id)), + "to_user_id": []byte(fmt.Sprint(to_user_id)), + "content": []byte(content), + "timestamp": []byte(timestamp), + }, + } + + if err := HBClient.Put( + "comment", misc.GetCommentRowKey(video_id, "0", con_id, timestamp), hbData, + ); err != nil { + return err + } + + return nil +} diff --git a/applications/comment/service/add_comment_test.go b/applications/comment/service/add_comment_test.go new file mode 100644 index 00000000..1eddbe5f --- /dev/null +++ b/applications/comment/service/add_comment_test.go @@ -0,0 +1,26 @@ +package service + +import ( + "log" + "testing" +) + +func TestAddComment(t *testing.T) { + Init() + + videoId := int64(1111111111111111111) + userId := int64(1111111111111111111) + conId := int64(1111111111111111111) + lastId := int64(0) + toUserId := int64(2222222222222222) + content := "Unit test comment content" + + res, err := AddComment( + videoId, userId, conId, lastId, toUserId, content, + ) + if err != nil { + log.Panicln(err) + } + + log.Println(res) +} diff --git a/applications/comment/service/count.go b/applications/comment/service/count.go new file mode 100644 index 00000000..a7d02267 --- /dev/null +++ b/applications/comment/service/count.go @@ -0,0 +1,180 @@ +package service + +import ( + "context" + "fmt" + "github.com/TremblingV5/DouTok/applications/comment/dal/model" + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/pkg/errno" + "github.com/go-redis/redis/v8" + "strconv" +) + +/* + 返回一个由video_id组成的列表的评论数统计 +*/ +func CountComment(video_id ...int64) (map[int64]int64, *errno.ErrNo, error) { + resMap := make(map[int64]int64) + + // 1. 从内存中查找喜欢数 + findAgain := []int64{} + for _, v := range video_id { + cnt, ok, _ := ReadComTotalCount(fmt.Sprint(v)) + + if !ok { + findAgain = append(findAgain, v) + } else { + resMap[v] = cnt + } + + } + + // 2. 从Redis中查找喜欢数 + findAgainAgain := []int64{} + for _, v := range findAgain { + cnt, ok, _ := ReadComTotalCountFromCache(fmt.Sprint(v)) + + if !ok { + findAgainAgain = append(findAgainAgain, v) + } else { + resMap[v] = cnt + ComTotalCount.Set(fmt.Sprint(v), cnt) + } + } + + // 3. 从MySQL中查找喜欢数 + res, err := DoCommentCnt.Where( + CommentCnt.Id.In(findAgainAgain...), + ).Find() + + if err != nil { + return nil, &misc.QueryCommentCountErr, err + } + + for _, v := range res { + resMap[v.Id] = v.Number + } + + // 4. 如果仍然没有查找到该记录,则置0 + for _, v := range video_id { + if _, ok := resMap[v]; !ok { + resMap[v] = 0 + } + } + + return resMap, &misc.Success, nil +} + +//func AddCount(video_id int64) error { +// _, err := DoCommentCnt.Where( +// CommentCnt.Id.Eq(video_id), +// ).Update(CommentCnt.Number, CommentCnt.Number.Add(1)) +// +// if err != nil { +// return err +// } +// +// return nil +//} +// +//func ReduceCount(video_id int64) error { +// _, err := DoCommentCnt.Where( +// CommentCnt.Id.Eq(video_id), +// ).Update(CommentCnt.Number, CommentCnt.Number.Add(-1)) +// +// if err != nil { +// return err +// } +// +// return nil +//} + +/* + 从内存中读取完整的视频评论条数 +*/ +func ReadComTotalCount(videoId string) (int64, bool, error) { + data, ok := ComTotalCount.Get(videoId) + if !ok { + return 0, false, nil + } + + return int64(data.(int)), true, nil +} + +/* + 从Redis中读取完整的视频评论条数 +*/ +func ReadComTotalCountFromCache(videoId string) (int64, bool, error) { + data, err := RedisClients[misc.ComTotalCntCache].Get(context.Background(), videoId) + if err == redis.Nil { + return 0, false, nil + } else if err != nil { + return 0, false, err + } + + num, _ := strconv.ParseInt(data, 10, 64) + + return num, true, nil +} + +/* + 更新内存中的局部评论计数器 +*/ +func UpdateCacheComCount(videoId int64, is_add bool) { + data, ok := ComCount.Get(fmt.Sprint(videoId)) + + if ok { + // 已经存在videoId对应的局部评论数 + if is_add { + ComCount.Set(fmt.Sprint(videoId), data.(int)+1) + } else { + ComCount.Set(fmt.Sprint(videoId), data.(int)-1) + } + } else { + // 尚不存在videoId对应的局部评论数 + if is_add { + ComCount.Set(fmt.Sprint(videoId), 1) + } else { + ComCount.Set(fmt.Sprint(videoId), -1) + } + } +} + +/* + 更新MySQL中的视频评论条数 +*/ +func UpdateCount(videoId int64, cnt int64) error { + data, _ := DoCommentCnt.Where( + CommentCnt.Id.Eq(videoId), + ).First() + + if data != nil { + // 已经存在该videoId的计数数据 + _, err := DoCommentCnt.Where( + CommentCnt.Id.Eq(videoId), + ).Update(CommentCnt.Number, CommentCnt.Number.Add(cnt)) + + if err != nil { + return err + } + } else { + // 新建该videoId的计数数据 + err := DoCommentCnt.Create( + &model.CommentCount{ + Id: videoId, + Number: cnt, + }, + ) + if err != nil { + return err + } + } + return nil +} + +/* + 删除Redis中存储的视频的完整的评论数量 +*/ +func DelCount2Cache(videoId string) error { + return RedisClients[misc.ComTotalCntCache].Del(context.Background(), videoId) +} diff --git a/applications/comment/service/count_test.go b/applications/comment/service/count_test.go new file mode 100644 index 00000000..f54fa1fc --- /dev/null +++ b/applications/comment/service/count_test.go @@ -0,0 +1,34 @@ +package service + +import ( + "log" + "testing" +) + +func TestCountComment(t *testing.T) { + Init() + + videoId := int64(1111111111111111111) + userId := int64(1111111111111111111) + conId := int64(1111111111111111111) + lastId := int64(0) + toUserId := int64(2222222222222222) + content := "Unit test comment content" + + res, err := AddComment( + videoId, userId, conId, lastId, toUserId, content, + ) + if err != nil { + log.Panicln(err) + } + + log.Println(res) + + cntRes, errNo, err := CountComment(videoId) + if err != nil { + log.Panicln(err) + } + + log.Println(errNo) + log.Println(cntRes) +} diff --git a/applications/commentDomain/service/utils.go b/applications/comment/service/get_comment_time.go similarity index 100% rename from applications/commentDomain/service/utils.go rename to applications/comment/service/get_comment_time.go diff --git a/applications/comment/service/get_comment_time_test.go b/applications/comment/service/get_comment_time_test.go new file mode 100644 index 00000000..7f552a5a --- /dev/null +++ b/applications/comment/service/get_comment_time_test.go @@ -0,0 +1,28 @@ +package service + +import ( + "fmt" + "log" + "testing" + "time" +) + +func TestGetCommentRecall(t *testing.T) { + timeNow := time.Now().Unix() + + // 1小时内的时间戳,返回 x分钟前 + time1 := fmt.Sprint(timeNow - 60*12) + log.Println(GetTimeRecall(time1, timeNow)) + + // 1天内的时间戳,返回 x小时前 + time2 := fmt.Sprint(timeNow - 60*60*5) + log.Println(GetTimeRecall(time2, timeNow)) + + // 14天内的时间戳,返回 x天前 + time3 := fmt.Sprint(timeNow - 60*60*24*4) + log.Println(GetTimeRecall(time3, timeNow)) + + // 14天外的时间戳,返回具体日期 + time4 := fmt.Sprint(timeNow - 60*60*24*18) + log.Println(GetTimeRecall(time4, timeNow)) +} diff --git a/applications/comment/service/init.go b/applications/comment/service/init.go new file mode 100644 index 00000000..4a6bd9f3 --- /dev/null +++ b/applications/comment/service/init.go @@ -0,0 +1,91 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/comment/dal/query" + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/pkg/hbaseHandle" + "github.com/TremblingV5/DouTok/pkg/mysqlIniter" + redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" + "github.com/TremblingV5/DouTok/pkg/safeMap" + "github.com/TremblingV5/DouTok/pkg/utils" +) + +func Init() { + misc.InitViperConfig() + + InitDb( + misc.GetConfig("MySQL.Username"), + misc.GetConfig("MySQL.Password"), + misc.GetConfig("MySQL.Host"), + misc.GetConfig("MySQL.Port"), + misc.GetConfig("MySQL.Database"), + ) + + redisMap := map[string]int{ + misc.ComCntCache: int(misc.GetConfigNum("Redis.ComCntCache.Num")), + misc.ComTotalCntCache: int(misc.GetConfigNum("Redis.ComTotalCntCache.Num")), + } + InitRedis( + misc.GetConfig("Redis.Dest"), + misc.GetConfig("Redis.Password"), + redisMap, + ) + + InitHB(misc.GetConfig("HBase.Host")) + + InitMemoryMap() + + utils.InitSnowFlake(misc.GetConfigNum("Snowflake.Node")) +} + +func InitRedis(dest string, password string, dbs map[string]int) error { + redisCaches, _ := redishandle.InitRedis( + dest, password, dbs, + ) + + RedisClients = redisCaches + + return nil +} + +func InitMemoryMap() { + comCount := safeMap.New() + comTotalCount := safeMap.New() + + ComCount = comCount + ComTotalCount = comTotalCount +} + +func InitHB(host string) error { + client := hbaseHandle.InitHB(host) + HBClient = &client + + return nil +} + +func InitDb(username string, password string, host string, port string, database string) error { + db, err := mysqlIniter.InitDb( + username, + password, + host, + port, + database, + ) + + if err != nil { + return err + } + + DB = db + + query.SetDefault(DB) + + Comment = query.Comment + CommentCnt = query.CommentCount + + DoComment = Comment.WithContext(context.Background()) + DoCommentCnt = CommentCnt.WithContext(context.Background()) + + return nil +} diff --git a/applications/comment/service/init_test.go b/applications/comment/service/init_test.go new file mode 100644 index 00000000..8ef9d018 --- /dev/null +++ b/applications/comment/service/init_test.go @@ -0,0 +1,7 @@ +package service + +import "testing" + +func TestInit(t *testing.T) { + Init() +} diff --git a/applications/comment/service/list.go b/applications/comment/service/list.go new file mode 100644 index 00000000..030988e6 --- /dev/null +++ b/applications/comment/service/list.go @@ -0,0 +1,36 @@ +package service + +import ( + "github.com/TremblingV5/DouTok/applications/comment/dal/model" + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/pkg/errno" + "github.com/TremblingV5/DouTok/pkg/hbaseHandle" + tools "github.com/TremblingV5/DouTok/pkg/misc" +) + +/* + 根据video_id列出评论列表 +*/ +func ListComment(video_id int64) ([]*model.CommentInHB, errno.ErrNo, error) { + res, err := HBClient.Scan( + "comment", + hbaseHandle.GetFilterByRowKeyPrefix(misc.GetCommentQueryPrefix(video_id))..., + ) + + if err != nil { + return nil, misc.QueryCommentListInHBErr, err + } + + comment_list := []*model.CommentInHB{} + + for _, v := range res { + temp := model.CommentInHB{} + err := tools.Map2Struct4HB(v, &temp) + if err != nil { + continue + } + comment_list = append(comment_list, &temp) + } + + return comment_list, misc.Success, nil +} diff --git a/applications/comment/service/list_test.go b/applications/comment/service/list_test.go new file mode 100644 index 00000000..d0b5c135 --- /dev/null +++ b/applications/comment/service/list_test.go @@ -0,0 +1,34 @@ +package service + +import ( + "log" + "testing" +) + +func TestListComment(t *testing.T) { + Init() + + videoId := int64(1111111111111111111) + userId := int64(1111111111111111111) + conId := int64(1111111111111111111) + lastId := int64(0) + toUserId := int64(2222222222222222) + content := "Unit test comment content" + + res, err := AddComment( + videoId, userId, conId, lastId, toUserId, content, + ) + if err != nil { + log.Panicln(err) + } + + log.Println(res) + + videoList, errNo, err := ListComment(videoId) + if err != nil { + log.Panicln(err) + } + + log.Println(errNo) + log.Println(videoList) +} diff --git a/applications/comment/service/rm_comment.go b/applications/comment/service/rm_comment.go new file mode 100644 index 00000000..ac12a2e6 --- /dev/null +++ b/applications/comment/service/rm_comment.go @@ -0,0 +1,63 @@ +package service + +import ( + "github.com/TremblingV5/DouTok/applications/comment/dal/model" + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/pkg/errno" +) + +/* + 删除评论 +*/ +func RmComment(user_id int64, comment_id int64) (errno.ErrNo, error) { + comment, isBelong, err := IsCommentFromUser(user_id, comment_id) + if err != nil { + return misc.SystemErr, err + } + if !isBelong { + return misc.CommentNotBelongToUserErr, nil + } + + rowKey := misc.GetCommentRowKey(comment.VideoId, "0", comment.ConversationId, comment.Timestamp) + + err = RmCommentInRDB(comment_id) + if err != nil { + return misc.RmDataFromHBErr, err + } + + err = HBClient.RmByRowKey("comment", rowKey) + if err != nil { + return misc.RmDataFromHBErr, err + } + + UpdateCacheComCount(comment.VideoId, false) + + return misc.Success, nil +} + +/* + 判断一条评论是否属于某用户 +*/ +func IsCommentFromUser(user_id int64, comment_id int64) (*model.Comment, bool, error) { + res, err := DoComment.Where( + Comment.Id.Eq(comment_id), + ).First() + + if err != nil { + return nil, false, err + } + + if res.UserId != user_id { + return nil, false, nil + } + + return res, true, nil +} + +func RmCommentInRDB(comment_id int64) error { + _, err := DoComment.Where( + Comment.Id.Eq(comment_id), + ).Update(Comment.Status, false) + + return err +} diff --git a/applications/comment/service/rm_comment_test.go b/applications/comment/service/rm_comment_test.go new file mode 100644 index 00000000..6f039e11 --- /dev/null +++ b/applications/comment/service/rm_comment_test.go @@ -0,0 +1,32 @@ +package service + +import ( + "log" + "testing" +) + +func TestRmComment(t *testing.T) { + Init() + + videoId := int64(1111111111111111111) + userId := int64(1111111111111111111) + conId := int64(1111111111111111111) + lastId := int64(0) + toUserId := int64(2222222222222222) + content := "Unit test comment content" + + res, err := AddComment( + videoId, userId, conId, lastId, toUserId, content, + ) + if err != nil { + log.Panicln(err) + } + + log.Println(res) + + rmRes, err := RmComment(userId, res.Id) + if err != nil { + log.Panicln(err) + } + log.Println(rmRes) +} diff --git a/applications/comment/service/timer.go b/applications/comment/service/timer.go new file mode 100644 index 00000000..8532cb31 --- /dev/null +++ b/applications/comment/service/timer.go @@ -0,0 +1,70 @@ +package service + +import ( + "context" + "fmt" + "github.com/TremblingV5/DouTok/applications/comment/misc" + "github.com/TremblingV5/DouTok/pkg/dlog" + "strconv" + "time" +) + +var logger = dlog.InitLog(3) + +/* + 定时将内存中的局部评论数更新到数据库中,并删除Redis中的评论总数 +*/ +func UpdateComCountMap() { + for { + time.Sleep(time.Duration(5) * time.Second) + logger.Info("Start iter comment cnt map and update on " + fmt.Sprint(time.Now().Unix())) + + keyList := []string{} + + ComCount.Iter(func(key string, v interface{}) { + keyList = append(keyList, key) + + keyI64, _ := strconv.ParseInt(key, 10, 64) + err := UpdateCount(keyI64, int64(v.(int))) + if err != nil { + dlog.Warn("Write comment count to RDB defeat: " + key + " with count: " + fmt.Sprint(v.(int))) + } + + err = DelCount2Cache(key) + if err != nil { + dlog.Warn("Delete comment count from third party cache defeat: " + key) + } + }) + + for _, v := range keyList { + ComCount.Set(v, 0) + } + } +} + +/* + 定时将Redis中每个Video的Comment总数更新到内存中的Map + Redis不存在的视频评论数由单独查询时再添加到Redis中 +*/ +func UpdateComTotalCntMap() { + for { + time.Sleep(time.Duration(5) * time.Second) + logger.Info("Start iter comment total cnt map and update on " + fmt.Sprint(time.Now().Unix())) + + keyList := []string{} + + ComTotalCount.Iter(func(key string, v interface{}) { + keyList = append(keyList, key) + }) + + for _, v := range keyList { + res, err := RedisClients[misc.ComTotalCntCache].Get(context.Background(), fmt.Sprint(v)) + if err != nil { + continue + } + + i, _ := strconv.ParseInt(res, 10, 64) + ComTotalCount.Set(v, i) + } + } +} diff --git a/applications/comment/service/timer_test.go b/applications/comment/service/timer_test.go new file mode 100644 index 00000000..22e16dfa --- /dev/null +++ b/applications/comment/service/timer_test.go @@ -0,0 +1,15 @@ +package service + +import "testing" + +func TestUpdateComCountMap(t *testing.T) { + Init() + ComCount.Set("1111111111111111112", 22) + UpdateComCountMap() +} + +func TestUpdateComTotalCntMap(t *testing.T) { + Init() + ComTotalCount.Set("1111111111111111111", 22) + UpdateComTotalCntMap() +} diff --git a/applications/comment/service/var.go b/applications/comment/service/var.go new file mode 100644 index 00000000..eaa33367 --- /dev/null +++ b/applications/comment/service/var.go @@ -0,0 +1,28 @@ +package service + +import ( + "github.com/TremblingV5/DouTok/applications/comment/dal/query" + "github.com/TremblingV5/DouTok/pkg/hbaseHandle" + redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" + "github.com/TremblingV5/DouTok/pkg/safeMap" + "gorm.io/gorm" +) + +var DB *gorm.DB + +var DoComment query.ICommentDo +var DoCommentCnt query.ICommentCountDo + +var Comment = query.CommentStruct +var CommentCnt = query.CommentCountStruct + +var HBClient *hbaseHandle.HBaseClient + +var RedisClients map[string]*redishandle.RedisClient + +// ComCount 在内存中创建一个map用于存储视频的评论数 +var ComCount *safeMap.SafeMap +var ComTotalCount *safeMap.SafeMap + +// ComContent 达到一定评论数的视频的评论被存储在内存中 +var ComContent *safeMap.SafeMap diff --git a/applications/commentDomain/Makefile b/applications/commentDomain/Makefile deleted file mode 100644 index e292a0ed..00000000 --- a/applications/commentDomain/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -server: - kitex -module github.com/TremblingV5/DouTok -type protobuf -I ../../proto/ -service commentDomain ../../proto/commentDomain.proto \ No newline at end of file diff --git a/applications/commentDomain/build.sh b/applications/commentDomain/build.sh deleted file mode 100644 index 91955901..00000000 --- a/applications/commentDomain/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -RUN_NAME="commentDomain" - -mkdir -p output/bin -cp script/* output/ -chmod +x output/bootstrap.sh - -if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then - go build -o output/bin/${RUN_NAME} -else - go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... -fi - diff --git a/applications/commentDomain/cache/commentCntCache/cache.go b/applications/commentDomain/cache/commentCntCache/cache.go deleted file mode 100644 index a97acdd9..00000000 --- a/applications/commentDomain/cache/commentCntCache/cache.go +++ /dev/null @@ -1,45 +0,0 @@ -package commentCntCache - -import ( - "fmt" - "github.com/TremblingV5/DouTok/pkg/cache" - "strconv" -) - -type Cache struct { - cache *cache.MapCache[int64] -} - -func NewCache() *Cache { - mapCache := cache.NewMapCache[int64]() - return &Cache{ - cache: mapCache, - } -} - -func (c *Cache) Add(videoId int64, modification int64) { - c.cache.Update(fmt.Sprint(videoId), modification, func(exist bool, valueInMap int64, newValue int64) int64 { - if exist { - return valueInMap + modification - } else { - return modification - } - }) -} - -func (c *Cache) Get(videoId int64) (int64, bool) { - return c.cache.Get(fmt.Sprint(videoId)) -} - -func (c *Cache) GetAll() map[int64]int64 { - result := make(map[int64]int64) - c.cache.Iter(func(key string, v int64) { - i64, _ := strconv.ParseInt(key, 10, 64) - result[i64] = v - }) - return result -} - -func (c *Cache) Clear() { - c.cache.Clear() -} diff --git a/applications/commentDomain/cache/commentCntCache/cache_test.go b/applications/commentDomain/cache/commentCntCache/cache_test.go deleted file mode 100644 index 326ba400..00000000 --- a/applications/commentDomain/cache/commentCntCache/cache_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package commentCntCache - -import ( - "github.com/stretchr/testify/require" - "sync" - "testing" -) - -func assertEqual(t *testing.T, expect int, actual int64) { - require.Equal(t, int64(expect), actual) -} - -func TestCache(t *testing.T) { - cache := NewCache() - - cache.Add(1, 1) - v1, ok := cache.Get(1) - assertEqual(t, 1, v1) - require.Equal(t, true, ok) - _, ok = cache.Get(2) - require.Equal(t, false, ok) - - cache.Add(1, 5) - v1, ok = cache.Get(1) - assertEqual(t, 6, v1) - require.Equal(t, true, ok) - - cache.Add(1, -13) - v1, ok = cache.Get(1) - assertEqual(t, -7, v1) - require.Equal(t, true, ok) - - cache.Clear() - _, ok = cache.Get(1) - require.Equal(t, false, ok) -} - -func TestCacheMultiThread(t *testing.T) { - cache := NewCache() - var wg sync.WaitGroup - wg.Add(100) - - for i := 0; i < 100; i++ { - go func() { - defer wg.Done() - cache.Add(1, 1) - - cache.Get(1) - }() - } - - wg.Wait() - - value, ok := cache.Get(1) - require.Equal(t, int64(100), value) - require.Equal(t, true, ok) -} diff --git a/applications/commentDomain/cache/commentTotalCountCache/cache.go b/applications/commentDomain/cache/commentTotalCountCache/cache.go deleted file mode 100644 index d0a222d3..00000000 --- a/applications/commentDomain/cache/commentTotalCountCache/cache.go +++ /dev/null @@ -1,35 +0,0 @@ -package commentTotalCountCache - -import ( - "fmt" - "github.com/TremblingV5/DouTok/pkg/cache" -) - -type Cache struct { - cache *cache.MapCache[int64] -} - -func NewCache() *Cache { - mapCache := cache.NewMapCache[int64]() - return &Cache{ - cache: mapCache, - } -} - -func (c *Cache) Get(videoId int64) (int64, bool) { - return c.cache.Get(fmt.Sprint(videoId)) -} - -func (c *Cache) Set(videoId, count int64) { - c.cache.Set(fmt.Sprint(videoId), count) -} - -func (c *Cache) SetBatch(batch map[int64]int64) { - for k, v := range batch { - c.cache.Set(fmt.Sprint(k), v) - } -} - -func (c *Cache) Clear() { - c.cache.Clear() -} diff --git a/applications/commentDomain/cache/commentTotalCountCache/cache_test.go b/applications/commentDomain/cache/commentTotalCountCache/cache_test.go deleted file mode 100644 index ecad489a..00000000 --- a/applications/commentDomain/cache/commentTotalCountCache/cache_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package commentTotalCountCache - -import ( - "github.com/stretchr/testify/require" - "testing" -) - -func assertEqual(t *testing.T, expect int, actual int64) { - require.Equal(t, int64(expect), actual) -} - -func TestCache(t *testing.T) { - cache := NewCache() - - cache.Set(1, 1) - v1, ok := cache.Get(1) - assertEqual(t, 1, v1) - require.Equal(t, true, ok) - - cache.Set(1, 5) - v1, ok = cache.Get(1) - assertEqual(t, 5, v1) - require.Equal(t, true, ok) - - batchData := make(map[int64]int64) - batchData[1] = 1 - batchData[2] = 2 - cache.SetBatch(batchData) - v1, ok = cache.Get(1) - assertEqual(t, 1, v1) - require.Equal(t, true, ok) - v2, ok := cache.Get(2) - assertEqual(t, 2, v2) - require.Equal(t, true, ok) - - cache.Clear() - _, ok = cache.Get(1) - require.Equal(t, false, ok) -} diff --git a/applications/commentDomain/cmd/server/main.go b/applications/commentDomain/cmd/server/main.go deleted file mode 100644 index 253914fd..00000000 --- a/applications/commentDomain/cmd/server/main.go +++ /dev/null @@ -1,85 +0,0 @@ -package main - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/commentDomain/handler" - "github.com/TremblingV5/DouTok/applications/commentDomain/redis/commentTotalCountRedis" - "github.com/TremblingV5/DouTok/applications/commentDomain/service" - "github.com/TremblingV5/DouTok/config/configStruct" - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain/commentdomainservice" - "github.com/TremblingV5/DouTok/pkg/DouTokContext" - "github.com/TremblingV5/DouTok/pkg/DouTokLogger" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/hbaseHandle" - redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" - "github.com/TremblingV5/DouTok/pkg/services" - "github.com/TremblingV5/DouTok/pkg/utils" - "go.uber.org/zap" -) - -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_COMMENT_DOMAIN_"` - - MySQL configStruct.MySQL `envPrefix:"DOUTOK_COMMENT_DOMAIN_"` - Snowflake configStruct.Snowflake `envPrefix:"DOUTOK_COMMENT_DOMAIN_"` - HBase configStruct.HBase `envPrefix:"DOUTOK_COMMENT_DOMAIN_"` - Redis configStruct.Redis `envPrefix:"DOUTOK_COMMENT_DOMAIN_"` - - Logger configStruct.Logger `envPrefix:"DOUTOK_COMMENT_DOMAIN_"` -} - -var ( - logger *zap.Logger - handle = &handler.CommentDomainHandler{} - config = &Config{} -) - -func init() { - ctx := context.Background() - - _, err := configurator.Load(config, "DOUTOK_COMMENT_DOMAIN", "commentDomain") - - logger = DouTokLogger.InitLogger(config.Logger) - DouTokContext.DefaultLogger = logger - DouTokContext.AddLoggerToContext(ctx, logger) - - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", config)) - } - - logger = DouTokContext.Extract(ctx) - - db, err := config.MySQL.InitDB() - if err != nil { - panic(err) - } - - hb := hbaseHandle.HBaseClient{ - Client: *config.HBase.InitHB(), - } - redisClient := redishandle.RedisClient{ - Client: config.Redis.InitRedisClient(1), - } - commentTotalCountRedisClient := commentTotalCountRedis.NewClient(&redisClient) - commentDomainService := service.NewCommentDomainService( - db, &hb, commentTotalCountRedisClient, config.Snowflake.Node, - ) - - utils.InitSnowFlake(config.Snowflake.Node) - - handle = handler.NewCommentDomainHandler(commentDomainService) -} - -func main() { - - options, shutdown := services.InitRPCServerArgs(constants.COMMENT_DOMAIN_SERVER_NAME, config.BaseConfig) - defer shutdown() - - svr := commentdomainservice.NewServer( - handle, options..., - ) - if err := svr.Run(); err != nil { - logger.Fatal("start server defeat", zap.Error(err)) - } -} diff --git a/applications/commentDomain/cmd/server/run.sh b/applications/commentDomain/cmd/server/run.sh deleted file mode 100644 index af1ec900..00000000 --- a/applications/commentDomain/cmd/server/run.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# 设置环境变量 -export DOUTOK_COMMENT_DOMAIN_SERVER_NAME=DouTokCommentDomainServer -export DOUTOK_COMMENT_DOMAIN_SERVER_PORT=8083 -export DOUTOK_COMMENT_DOMAIN_ETCD_ADDRESS=localhost -export DOUTOK_COMMENT_DOMAIN_ETCD_PORT=2379 -export DOUTOK_COMMENT_DOMAIN_MYSQL_USERNAME=admin -export DOUTOK_COMMENT_DOMAIN_MYSQL_PASSWORD=root -export DOUTOK_COMMENT_DOMAIN_MYSQL_DATABASE=DouTok - -# 运行 Go 项目 -go run main.go diff --git a/applications/commentDomain/dal/migrate/main.go b/applications/commentDomain/dal/migrate/main.go deleted file mode 100644 index 79058077..00000000 --- a/applications/commentDomain/dal/migrate/main.go +++ /dev/null @@ -1,5 +0,0 @@ -package main - -func main() { - -} diff --git a/applications/commentDomain/dal/repository/comment/mocks/repository_mock.go b/applications/commentDomain/dal/repository/comment/mocks/repository_mock.go deleted file mode 100644 index 4d58ddd7..00000000 --- a/applications/commentDomain/dal/repository/comment/mocks/repository_mock.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: repository.go - -// Package CommentRepositoryMocks is a generated GoMock package. -package CommentRepositoryMocks - -import ( - context "context" - reflect "reflect" - - model "github.com/TremblingV5/DouTok/applications/commentDomain/dal/model" - gomock "github.com/golang/mock/gomock" -) - -// MockIRepository is a mock of IRepository interface. -type MockIRepository struct { - ctrl *gomock.Controller - recorder *MockIRepositoryMockRecorder -} - -// MockIRepositoryMockRecorder is the mock recorder for MockIRepository. -type MockIRepositoryMockRecorder struct { - mock *MockIRepository -} - -// NewMockIRepository creates a new mock instance. -func NewMockIRepository(ctrl *gomock.Controller) *MockIRepository { - mock := &MockIRepository{ctrl: ctrl} - mock.recorder = &MockIRepositoryMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockIRepository) EXPECT() *MockIRepositoryMockRecorder { - return m.recorder -} - -// IsCommentFromUser mocks base method. -func (m *MockIRepository) IsCommentFromUser(ctx context.Context, userId, commentId int64) (*model.Comment, bool) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsCommentFromUser", ctx, userId, commentId) - ret0, _ := ret[0].(*model.Comment) - ret1, _ := ret[1].(bool) - return ret0, ret1 -} - -// IsCommentFromUser indicates an expected call of IsCommentFromUser. -func (mr *MockIRepositoryMockRecorder) IsCommentFromUser(ctx, userId, commentId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsCommentFromUser", reflect.TypeOf((*MockIRepository)(nil).IsCommentFromUser), ctx, userId, commentId) -} - -// Remove mocks base method. -func (m *MockIRepository) Remove(ctx context.Context, commentId int64) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Remove", ctx, commentId) - ret0, _ := ret[0].(error) - return ret0 -} - -// Remove indicates an expected call of Remove. -func (mr *MockIRepositoryMockRecorder) Remove(ctx, commentId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockIRepository)(nil).Remove), ctx, commentId) -} - -// Save mocks base method. -func (m *MockIRepository) Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content, timestamp string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Save", ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp) - ret0, _ := ret[0].(error) - return ret0 -} - -// Save indicates an expected call of Save. -func (mr *MockIRepositoryMockRecorder) Save(ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIRepository)(nil).Save), ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp) -} diff --git a/applications/commentDomain/dal/repository/comment/repository.go b/applications/commentDomain/dal/repository/comment/repository.go deleted file mode 100644 index 04433b02..00000000 --- a/applications/commentDomain/dal/repository/comment/repository.go +++ /dev/null @@ -1,63 +0,0 @@ -package comment - -import ( - "context" - "gorm.io/gorm" - - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/query" -) - -type Repository struct { - commentTable query.ICommentDo -} - -//go:generate mockgen -source=repository.go -destination=./mocks/repository_mock.go -package CommentRepositoryMocks -type IRepository interface { - Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content string, timestamp string) error - IsCommentFromUser(ctx context.Context, userId, commentId int64) (*model.Comment, bool) - Remove(ctx context.Context, commentId int64) error -} - -func NewRepository(db *gorm.DB) *Repository { - return &Repository{ - commentTable: query.Comment.WithContext(db.Statement.Context), - } -} - -func (r *Repository) Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content string, timestamp string) error { - return r.commentTable.Create( - &model.Comment{ - Id: commentId, - VideoId: videoId, - UserId: userId, - ConversationId: conversationId, - LastId: lastId, - ToUserId: toUserId, - Content: content, - Status: true, - Timestamp: timestamp, - }) -} - -func (r *Repository) IsCommentFromUser(ctx context.Context, userId, commentId int64) (*model.Comment, bool) { - comment, err := r.commentTable.Where( - query.Comment.Id.Eq(commentId), - ).First() - if err != nil { - return nil, false - } - - if comment.UserId == userId { - return nil, true - } - - return comment, false -} - -func (r *Repository) Remove(ctx context.Context, commentId int64) error { - _, err := r.commentTable.Where(query.Comment.Id.Eq(commentId)).Update(query.Comment.Status, false) - return err -} - -var _ IRepository = (*Repository)(nil) diff --git a/applications/commentDomain/dal/repository/commentcnt/mocks/repository_mock.go b/applications/commentDomain/dal/repository/commentcnt/mocks/repository_mock.go deleted file mode 100644 index 05b6acc6..00000000 --- a/applications/commentDomain/dal/repository/commentcnt/mocks/repository_mock.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: repository.go - -// Package CommentCountRepositoryMocks is a generated GoMock package. -package CommentCountRepositoryMocks - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" -) - -// MockIRepository is a mock of IRepository interface. -type MockIRepository struct { - ctrl *gomock.Controller - recorder *MockIRepositoryMockRecorder -} - -// MockIRepositoryMockRecorder is the mock recorder for MockIRepository. -type MockIRepositoryMockRecorder struct { - mock *MockIRepository -} - -// NewMockIRepository creates a new mock instance. -func NewMockIRepository(ctrl *gomock.Controller) *MockIRepository { - mock := &MockIRepository{ctrl: ctrl} - mock.recorder = &MockIRepositoryMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockIRepository) EXPECT() *MockIRepositoryMockRecorder { - return m.recorder -} - -// GetCommentsCount mocks base method. -func (m *MockIRepository) GetCommentsCount(ctx context.Context, videoIdList ...int64) (map[int64]int64, error) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range videoIdList { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetCommentsCount", varargs...) - ret0, _ := ret[0].(map[int64]int64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetCommentsCount indicates an expected call of GetCommentsCount. -func (mr *MockIRepositoryMockRecorder) GetCommentsCount(ctx interface{}, videoIdList ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, videoIdList...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCommentsCount", reflect.TypeOf((*MockIRepository)(nil).GetCommentsCount), varargs...) -} - -// UpdateCommentsCount mocks base method. -func (m *MockIRepository) UpdateCommentsCount(ctx context.Context, videoIdList ...int64) error { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range videoIdList { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "UpdateCommentsCount", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// UpdateCommentsCount indicates an expected call of UpdateCommentsCount. -func (mr *MockIRepositoryMockRecorder) UpdateCommentsCount(ctx interface{}, videoIdList ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, videoIdList...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateCommentsCount", reflect.TypeOf((*MockIRepository)(nil).UpdateCommentsCount), varargs...) -} diff --git a/applications/commentDomain/dal/repository/commentcnt/repository.go b/applications/commentDomain/dal/repository/commentcnt/repository.go deleted file mode 100644 index f8a22646..00000000 --- a/applications/commentDomain/dal/repository/commentcnt/repository.go +++ /dev/null @@ -1,50 +0,0 @@ -package commentcnt - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/query" - "gorm.io/gorm" -) - -type Repository struct { - commentCountTable query.ICommentCountDo -} - -//go:generate mockgen -source=repository.go -destination=./mocks/repository_mock.go -package CommentCountRepositoryMocks -type IRepository interface { - GetCommentsCount(ctx context.Context, videoIdList ...int64) (map[int64]int64, error) - UpdateCommentsCount(ctx context.Context, videoIdList ...int64) error -} - -func NewRepository(db *gorm.DB) *Repository { - return &Repository{ - commentCountTable: query.CommentCount.WithContext(db.Statement.Context), - } -} - -func (r *Repository) GetCommentsCount(ctx context.Context, videoIdList ...int64) (map[int64]int64, error) { - results, err := r.commentCountTable.Where(query.CommentCount.Id.In(videoIdList...)).Find() - if err != nil { - return nil, err - } - - resultMap := make(map[int64]int64) - for _, result := range results { - resultMap[result.Id] = result.Number - } - - // Set comments count to 0 if not exist - for _, videoId := range videoIdList { - if _, ok := resultMap[videoId]; !ok { - resultMap[videoId] = 0 - } - } - - return resultMap, nil -} - -func (r *Repository) UpdateCommentsCount(ctx context.Context, videoIdList ...int64) error { - return nil -} - -var _ IRepository = (*Repository)(nil) diff --git a/applications/commentDomain/handler/add_comment.go b/applications/commentDomain/handler/add_comment.go deleted file mode 100644 index 737482cd..00000000 --- a/applications/commentDomain/handler/add_comment.go +++ /dev/null @@ -1,33 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/commentDomain/misc" - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" - "github.com/TremblingV5/DouTok/pkg/utils" -) - -func (s *CommentDomainHandler) AddComment(ctx context.Context, req *commentDomain.DoutokAddCommentReq) (resp *commentDomain.DoutokAddCommentResp, err error) { - if ok := misc.CheckCommentActionArgs(req); !ok { - return &commentDomain.DoutokAddCommentResp{ - StatusCode: 1, - StatusMsg: ParametersError.Error(), - Comment: nil, - }, ParametersError - } - - result, err := s.service.AddComment(ctx, req.VideoId, req.UserId, utils.GetSnowFlakeId().Int64(), 0, 0, req.CommentText) - if err != nil { - return &commentDomain.DoutokAddCommentResp{ - StatusCode: 1, - StatusMsg: err.Error(), - Comment: nil, - }, err - } - - return &commentDomain.DoutokAddCommentResp{ - StatusCode: 0, - StatusMsg: Success, - Comment: result, - }, nil -} diff --git a/applications/commentDomain/handler/count_comment.go b/applications/commentDomain/handler/count_comment.go deleted file mode 100644 index 08b5a902..00000000 --- a/applications/commentDomain/handler/count_comment.go +++ /dev/null @@ -1,31 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" -) - -func (s *CommentDomainHandler) CountComment(ctx context.Context, req *commentDomain.DoutokCountCommentReq) (resp *commentDomain.DoutokCountCommentResp, err error) { - if len(req.VideoIdList) <= 0 { - return &commentDomain.DoutokCountCommentResp{ - StatusCode: 1, - StatusMsg: ParametersError.Error(), - CommentCount: nil, - }, ParametersError - } - - result, err := s.service.CountComments(ctx, req.VideoIdList...) - if err != nil { - return &commentDomain.DoutokCountCommentResp{ - StatusCode: 1, - StatusMsg: err.Error(), - CommentCount: nil, - }, err - } - - return &commentDomain.DoutokCountCommentResp{ - StatusCode: 0, - StatusMsg: Success, - CommentCount: result, - }, nil -} diff --git a/applications/commentDomain/handler/list_comment.go b/applications/commentDomain/handler/list_comment.go deleted file mode 100644 index a14a2bc6..00000000 --- a/applications/commentDomain/handler/list_comment.go +++ /dev/null @@ -1,48 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/commentDomain/misc" - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" - "github.com/TremblingV5/DouTok/kitex_gen/entity" -) - -func (s *CommentDomainHandler) ListComment(ctx context.Context, req *commentDomain.DoutokListCommentReq) (resp *commentDomain.DoutokListCommentResp, err error) { - if !misc.CheckCommentListArgs(req) { - return &commentDomain.DoutokListCommentResp{ - StatusCode: 1, - StatusMsg: ParametersError.Error(), - CommentList: nil, - }, ParametersError - } - - list, err := s.service.ListComment(ctx, req.VideoId) - if err != nil { - return &commentDomain.DoutokListCommentResp{ - StatusCode: 1, - StatusMsg: err.Error(), - CommentList: nil, - }, err - } - - result := func() []*entity.Comment { - var r []*entity.Comment - for _, v := range list { - r = append(r, &entity.Comment{ - Id: v.GetId(), - User: &entity.User{ - Id: v.GetUserId(), - }, - Content: v.GetContent(), - CreateDate: v.GetTimestamp(), - }) - } - return r - }() - - return &commentDomain.DoutokListCommentResp{ - StatusCode: 0, - StatusMsg: Success, - CommentList: result, - }, nil -} diff --git a/applications/commentDomain/handler/mocks/service_mock.go b/applications/commentDomain/handler/mocks/service_mock.go deleted file mode 100644 index 0b1b9c27..00000000 --- a/applications/commentDomain/handler/mocks/service_mock.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: typedef.go - -// Package HandlerServiceMocks is a generated GoMock package. -package HandlerServiceMocks - -import ( - context "context" - model "github.com/TremblingV5/DouTok/applications/commentDomain/dal/hbModel" - reflect "reflect" - - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - gomock "github.com/golang/mock/gomock" -) - -// MockCommentDomainService is a mock of CommentDomainService interface. -type MockCommentDomainService struct { - ctrl *gomock.Controller - recorder *MockCommentDomainServiceMockRecorder -} - -// MockCommentDomainServiceMockRecorder is the mock recorder for MockCommentDomainService. -type MockCommentDomainServiceMockRecorder struct { - mock *MockCommentDomainService -} - -// NewMockCommentDomainService creates a new mock instance. -func NewMockCommentDomainService(ctrl *gomock.Controller) *MockCommentDomainService { - mock := &MockCommentDomainService{ctrl: ctrl} - mock.recorder = &MockCommentDomainServiceMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockCommentDomainService) EXPECT() *MockCommentDomainServiceMockRecorder { - return m.recorder -} - -// AddComment mocks base method. -func (m *MockCommentDomainService) AddComment(ctx context.Context, videoId, userId, conversationId, lastId, toUserId int64, content string) (*entity.Comment, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddComment", ctx, videoId, userId, conversationId, lastId, toUserId, content) - ret0, _ := ret[0].(*entity.Comment) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// AddComment indicates an expected call of AddComment. -func (mr *MockCommentDomainServiceMockRecorder) AddComment(ctx, videoId, userId, conversationId, lastId, toUserId, content interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddComment", reflect.TypeOf((*MockCommentDomainService)(nil).AddComment), ctx, videoId, userId, conversationId, lastId, toUserId, content) -} - -// CountComments mocks base method. -func (m *MockCommentDomainService) CountComments(ctx context.Context, videoId ...int64) (map[int64]int64, error) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range videoId { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "CountComments", varargs...) - ret0, _ := ret[0].(map[int64]int64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CountComments indicates an expected call of CountComments. -func (mr *MockCommentDomainServiceMockRecorder) CountComments(ctx interface{}, videoId ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, videoId...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountComments", reflect.TypeOf((*MockCommentDomainService)(nil).CountComments), varargs...) -} - -// ListComment mocks base method. -func (m *MockCommentDomainService) ListComment(ctx context.Context, videoId int64) ([]*model.CommentInHB, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListComment", ctx, videoId) - ret0, _ := ret[0].([]*model.CommentInHB) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ListComment indicates an expected call of ListComment. -func (mr *MockCommentDomainServiceMockRecorder) ListComment(ctx, videoId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListComment", reflect.TypeOf((*MockCommentDomainService)(nil).ListComment), ctx, videoId) -} - -// RemoveComment mocks base method. -func (m *MockCommentDomainService) RemoveComment(ctx context.Context, userId, commentId int64) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RemoveComment", ctx, userId, commentId) - ret0, _ := ret[0].(error) - return ret0 -} - -// RemoveComment indicates an expected call of RemoveComment. -func (mr *MockCommentDomainServiceMockRecorder) RemoveComment(ctx, userId, commentId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveComment", reflect.TypeOf((*MockCommentDomainService)(nil).RemoveComment), ctx, userId, commentId) -} diff --git a/applications/commentDomain/handler/rm_comment.go b/applications/commentDomain/handler/rm_comment.go deleted file mode 100644 index 80c7388e..00000000 --- a/applications/commentDomain/handler/rm_comment.go +++ /dev/null @@ -1,22 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" -) - -func (s *CommentDomainHandler) RmComment(ctx context.Context, req *commentDomain.DoutokRmCommentReq) (resp *commentDomain.DoutokAddCommentResp, err error) { - if err := s.service.RemoveComment(ctx, req.UserId, req.CommentId); err != nil { - return &commentDomain.DoutokAddCommentResp{ - StatusCode: 1, - StatusMsg: err.Error(), - Comment: nil, - }, err - } - - return &commentDomain.DoutokAddCommentResp{ - StatusCode: 0, - StatusMsg: Success, - Comment: nil, - }, nil -} diff --git a/applications/commentDomain/handler/typedef.go b/applications/commentDomain/handler/typedef.go deleted file mode 100644 index 20c44b4c..00000000 --- a/applications/commentDomain/handler/typedef.go +++ /dev/null @@ -1,36 +0,0 @@ -package handler - -import ( - "context" - "errors" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/hbModel" - "github.com/TremblingV5/DouTok/applications/commentDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/entity" -) - -var ( - Success = "success" - ParametersError = errors.New("parameters error") -) - -type CommentDomainHandler struct { - service CommentDomainService -} - -func NewCommentDomainHandler(service CommentDomainService) *CommentDomainHandler { - return &CommentDomainHandler{ - service: service, - } -} - -//go:generate mockgen -source=typedef.go -destination=./mocks/service_mock.go -package HandlerServiceMocks -type CommentDomainService interface { - AddComment(ctx context.Context, videoId, userId, conversationId, lastId, toUserId int64, content string) (*entity.Comment, error) - CountComments(ctx context.Context, videoId ...int64) (map[int64]int64, error) - ListComment(ctx context.Context, videoId int64) ([]*hbModel.CommentInHB, error) - RemoveComment(ctx context.Context, userId, commentId int64) error -} - -var ( - _ CommentDomainService = (*service.CommentDomainService)(nil) -) diff --git a/applications/commentDomain/hb/commentHBaseRepo/mocks/repository_mock.go b/applications/commentDomain/hb/commentHBaseRepo/mocks/repository_mock.go deleted file mode 100644 index e9657d30..00000000 --- a/applications/commentDomain/hb/commentHBaseRepo/mocks/repository_mock.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: repository.go - -// Package CommentHBRepositoryMocks is a generated GoMock package. -package CommentHBRepositoryMocks - -import ( - context "context" - model "github.com/TremblingV5/DouTok/applications/commentDomain/dal/hbModel" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" -) - -// MockIRepository is a mock of IRepository interface. -type MockIRepository struct { - ctrl *gomock.Controller - recorder *MockIRepositoryMockRecorder -} - -// MockIRepositoryMockRecorder is the mock recorder for MockIRepository. -type MockIRepositoryMockRecorder struct { - mock *MockIRepository -} - -// NewMockIRepository creates a new mock instance. -func NewMockIRepository(ctrl *gomock.Controller) *MockIRepository { - mock := &MockIRepository{ctrl: ctrl} - mock.recorder = &MockIRepositoryMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockIRepository) EXPECT() *MockIRepositoryMockRecorder { - return m.recorder -} - -// List mocks base method. -func (m *MockIRepository) List(ctx context.Context, videoId int64) ([]*model.CommentInHB, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "List", ctx, videoId) - ret0, _ := ret[0].([]*model.CommentInHB) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// List indicates an expected call of List. -func (mr *MockIRepositoryMockRecorder) List(ctx, videoId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockIRepository)(nil).List), ctx, videoId) -} - -// Remove mocks base method. -func (m *MockIRepository) Remove(ctx context.Context, videoId, conversationId int64, timestamp string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Remove", ctx, videoId, conversationId, timestamp) - ret0, _ := ret[0].(error) - return ret0 -} - -// Remove indicates an expected call of Remove. -func (mr *MockIRepositoryMockRecorder) Remove(ctx, videoId, conversationId, timestamp interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockIRepository)(nil).Remove), ctx, videoId, conversationId, timestamp) -} - -// Save mocks base method. -func (m *MockIRepository) Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content, timestamp string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Save", ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp) - ret0, _ := ret[0].(error) - return ret0 -} - -// Save indicates an expected call of Save. -func (mr *MockIRepositoryMockRecorder) Save(ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockIRepository)(nil).Save), ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp) -} diff --git a/applications/commentDomain/hb/commentHBaseRepo/repository.go b/applications/commentDomain/hb/commentHBaseRepo/repository.go deleted file mode 100644 index 1bddb487..00000000 --- a/applications/commentDomain/hb/commentHBaseRepo/repository.go +++ /dev/null @@ -1,84 +0,0 @@ -package commentHBaseRepo - -import ( - "context" - "errors" - "fmt" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/hbModel" - - "github.com/TremblingV5/DouTok/pkg/hbaseHandle" - tools "github.com/TremblingV5/DouTok/pkg/misc" -) - -var ( - CommentsNotFoundByVideoId = errors.New("comments not found by video id") -) - -type Repository struct { - name string - client *hbaseHandle.HBaseClient -} - -//go:generate mockgen -source=repository.go -destination=./mocks/repository_mock.go -package CommentHBRepositoryMocks -type IRepository interface { - Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content string, timestamp string) error - List(ctx context.Context, videoId int64) ([]*hbModel.CommentInHB, error) - Remove(ctx context.Context, videoId, conversationId int64, timestamp string) error -} - -func NewRepository(client *hbaseHandle.HBaseClient) *Repository { - return &Repository{ - name: "comment", - client: client, - } -} - -func (r *Repository) Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content string, timestamp string) error { - hbData := map[string]map[string][]byte{ - "data": { - "id": []byte(fmt.Sprint(commentId)), - "video_id": []byte(fmt.Sprint(videoId)), - "user_id": []byte(fmt.Sprint(userId)), - "conversation_id": []byte(fmt.Sprint(conversationId)), - "last_id": []byte(fmt.Sprint(lastId)), - "to_user_id": []byte(fmt.Sprint(toUserId)), - "content": []byte(content), - "timestamp": []byte(timestamp), - }, - } - - if err := r.client.Put( - r.name, getCommentRowKey(videoId, conversationId, "0", timestamp), hbData, - ); err != nil { - return err - } - - return nil -} - -func (r *Repository) List(ctx context.Context, videoId int64) ([]*hbModel.CommentInHB, error) { - res, err := r.client.Scan( - r.name, hbaseHandle.GetFilterByRowKeyPrefix(getCommentQueryPrefix(videoId))..., - ) - - if err != nil { - return nil, CommentsNotFoundByVideoId - } - - var commentList []*hbModel.CommentInHB - - for _, v := range res { - temp := hbModel.CommentInHB{} - err := tools.Map2Struct4HB(v, &temp) - if err != nil { - continue - } - commentList = append(commentList, &temp) - } - - return commentList, nil -} - -func (r *Repository) Remove(ctx context.Context, videoId, conversationId int64, timestamp string) error { - return r.client.RmByRowKey(r.name, getCommentRowKey(videoId, conversationId, "0", timestamp)) -} diff --git a/applications/commentDomain/hb/commentHBaseRepo/utils.go b/applications/commentDomain/hb/commentHBaseRepo/utils.go deleted file mode 100644 index 1875f84e..00000000 --- a/applications/commentDomain/hb/commentHBaseRepo/utils.go +++ /dev/null @@ -1,18 +0,0 @@ -package commentHBaseRepo - -import ( - "fmt" - globalMisc "github.com/TremblingV5/DouTok/pkg/misc" -) - -func ensureIdLength(id int64) string { - return globalMisc.LFill(fmt.Sprint(id), 20) -} - -func getCommentRowKey(videoId, conversationId int64, isDeleted, timestamp string) string { - return ensureIdLength(videoId) + isDeleted + ensureIdLength(conversationId) + timestamp -} - -func getCommentQueryPrefix(video_id int64) string { - return ensureIdLength(video_id) + "0" -} diff --git a/applications/commentDomain/misc/check_args.go b/applications/commentDomain/misc/check_args.go deleted file mode 100644 index 1d7e86a6..00000000 --- a/applications/commentDomain/misc/check_args.go +++ /dev/null @@ -1,13 +0,0 @@ -package misc - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" -) - -func CheckCommentActionArgs(req *commentDomain.DoutokAddCommentReq) bool { - return req.CommentText != "" -} - -func CheckCommentListArgs(req *commentDomain.DoutokListCommentReq) bool { - return req.VideoId >= 0 -} diff --git a/applications/commentDomain/redis/commentTotalCountRedis/mocks/redis_mock.go b/applications/commentDomain/redis/commentTotalCountRedis/mocks/redis_mock.go deleted file mode 100644 index 6acadac4..00000000 --- a/applications/commentDomain/redis/commentTotalCountRedis/mocks/redis_mock.go +++ /dev/null @@ -1,69 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: redis.go - -// Package ComentTotalCountRedisRepositoryMocks is a generated GoMock package. -package ComentTotalCountRedisRepositoryMocks - -import ( - context "context" - reflect "reflect" - - gomock "github.com/golang/mock/gomock" -) - -// MockIClient is a mock of IClient interface. -type MockIClient struct { - ctrl *gomock.Controller - recorder *MockIClientMockRecorder -} - -// MockIClientMockRecorder is the mock recorder for MockIClient. -type MockIClientMockRecorder struct { - mock *MockIClient -} - -// NewMockIClient creates a new mock instance. -func NewMockIClient(ctrl *gomock.Controller) *MockIClient { - mock := &MockIClient{ctrl: ctrl} - mock.recorder = &MockIClientMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockIClient) EXPECT() *MockIClientMockRecorder { - return m.recorder -} - -// Delete mocks base method. -func (m *MockIClient) Delete(ctx context.Context, videoId ...int64) error { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range videoId { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Delete", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// Delete indicates an expected call of Delete. -func (mr *MockIClientMockRecorder) Delete(ctx interface{}, videoId ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, videoId...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockIClient)(nil).Delete), varargs...) -} - -// Get mocks base method. -func (m *MockIClient) Get(ctx context.Context, videoId int64) (int64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, videoId) - ret0, _ := ret[0].(int64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockIClientMockRecorder) Get(ctx, videoId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockIClient)(nil).Get), ctx, videoId) -} diff --git a/applications/commentDomain/redis/commentTotalCountRedis/redis.go b/applications/commentDomain/redis/commentTotalCountRedis/redis.go deleted file mode 100644 index c1b694bb..00000000 --- a/applications/commentDomain/redis/commentTotalCountRedis/redis.go +++ /dev/null @@ -1,40 +0,0 @@ -package commentTotalCountRedis - -import ( - "context" - "fmt" - redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" -) - -type Client struct { - client *redishandle.RedisClient -} - -//go:generate mockgen -source=redis.go -destination=./mocks/redis_mock.go -package ComentTotalCountRedisRepositoryMocks -type IClient interface { - Get(ctx context.Context, videoId int64) (int64, error) - Delete(ctx context.Context, videoId ...int64) error -} - -func NewClient(client *redishandle.RedisClient) *Client { - return &Client{ - client: client, - } -} - -func getRedisKeyByVideoId(videoId int64) string { - return fmt.Sprint("comment_total_count_", videoId) -} - -func (c *Client) Get(ctx context.Context, videoId int64) (int64, error) { - key := getRedisKeyByVideoId(videoId) - return c.client.GetI64(ctx, key) -} - -func (c *Client) Delete(ctx context.Context, videoId ...int64) error { - videoIdList := make([]string, len(videoId)) - for i, id := range videoId { - videoIdList[i] = getRedisKeyByVideoId(id) - } - return c.client.DelBatch(ctx, videoIdList...) -} diff --git a/applications/commentDomain/script/bootstrap.sh b/applications/commentDomain/script/bootstrap.sh deleted file mode 100644 index 561b733c..00000000 --- a/applications/commentDomain/script/bootstrap.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env bash -CURDIR=$(cd $(dirname $0); pwd) - -if [ "X$1" != "X" ]; then - RUNTIME_ROOT=$1 -else - RUNTIME_ROOT=${CURDIR} -fi - -export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT -export KITEX_LOG_DIR="$RUNTIME_ROOT/log" - -if [ ! -d "$KITEX_LOG_DIR/app" ]; then - mkdir -p "$KITEX_LOG_DIR/app" -fi - -if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then - mkdir -p "$KITEX_LOG_DIR/rpc" -fi - -exec "$CURDIR/bin/commentDomain" - diff --git a/applications/commentDomain/service/mocks/service_mock.go b/applications/commentDomain/service/mocks/service_mock.go deleted file mode 100644 index b990ab5f..00000000 --- a/applications/commentDomain/service/mocks/service_mock.go +++ /dev/null @@ -1,503 +0,0 @@ -// Code generated by MockGen. DO NOT EDIT. -// Source: typedef.go - -// Package CommentServiceMocks is a generated GoMock package. -package CommentServiceMocks - -import ( - context "context" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/hbModel" - reflect "reflect" - - model "github.com/TremblingV5/DouTok/applications/commentDomain/dal/model" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - gomock "github.com/golang/mock/gomock" -) - -// MockcommentRepository is a mock of commentRepository interface. -type MockcommentRepository struct { - ctrl *gomock.Controller - recorder *MockcommentRepositoryMockRecorder -} - -// MockcommentRepositoryMockRecorder is the mock recorder for MockcommentRepository. -type MockcommentRepositoryMockRecorder struct { - mock *MockcommentRepository -} - -// NewMockcommentRepository creates a new mock instance. -func NewMockcommentRepository(ctrl *gomock.Controller) *MockcommentRepository { - mock := &MockcommentRepository{ctrl: ctrl} - mock.recorder = &MockcommentRepositoryMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockcommentRepository) EXPECT() *MockcommentRepositoryMockRecorder { - return m.recorder -} - -// IsCommentFromUser mocks base method. -func (m *MockcommentRepository) IsCommentFromUser(ctx context.Context, userId, commentId int64) (*model.Comment, bool) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "IsCommentFromUser", ctx, userId, commentId) - ret0, _ := ret[0].(*model.Comment) - ret1, _ := ret[1].(bool) - return ret0, ret1 -} - -// IsCommentFromUser indicates an expected call of IsCommentFromUser. -func (mr *MockcommentRepositoryMockRecorder) IsCommentFromUser(ctx, userId, commentId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsCommentFromUser", reflect.TypeOf((*MockcommentRepository)(nil).IsCommentFromUser), ctx, userId, commentId) -} - -// Remove mocks base method. -func (m *MockcommentRepository) Remove(ctx context.Context, commentId int64) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Remove", ctx, commentId) - ret0, _ := ret[0].(error) - return ret0 -} - -// Remove indicates an expected call of Remove. -func (mr *MockcommentRepositoryMockRecorder) Remove(ctx, commentId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockcommentRepository)(nil).Remove), ctx, commentId) -} - -// Save mocks base method. -func (m *MockcommentRepository) Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content, timestamp string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Save", ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp) - ret0, _ := ret[0].(error) - return ret0 -} - -// Save indicates an expected call of Save. -func (mr *MockcommentRepositoryMockRecorder) Save(ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockcommentRepository)(nil).Save), ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp) -} - -// MockcommentHBaseRepository is a mock of commentHBaseRepository interface. -type MockcommentHBaseRepository struct { - ctrl *gomock.Controller - recorder *MockcommentHBaseRepositoryMockRecorder -} - -// MockcommentHBaseRepositoryMockRecorder is the mock recorder for MockcommentHBaseRepository. -type MockcommentHBaseRepositoryMockRecorder struct { - mock *MockcommentHBaseRepository -} - -// NewMockcommentHBaseRepository creates a new mock instance. -func NewMockcommentHBaseRepository(ctrl *gomock.Controller) *MockcommentHBaseRepository { - mock := &MockcommentHBaseRepository{ctrl: ctrl} - mock.recorder = &MockcommentHBaseRepositoryMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockcommentHBaseRepository) EXPECT() *MockcommentHBaseRepositoryMockRecorder { - return m.recorder -} - -// List mocks base method. -func (m *MockcommentHBaseRepository) List(ctx context.Context, videoId int64) ([]*hbModel.CommentInHB, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "List", ctx, videoId) - ret0, _ := ret[0].([]*hbModel.CommentInHB) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// List indicates an expected call of List. -func (mr *MockcommentHBaseRepositoryMockRecorder) List(ctx, videoId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "List", reflect.TypeOf((*MockcommentHBaseRepository)(nil).List), ctx, videoId) -} - -// Remove mocks base method. -func (m *MockcommentHBaseRepository) Remove(ctx context.Context, videoId, conversationId int64, timestamp string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Remove", ctx, videoId, conversationId, timestamp) - ret0, _ := ret[0].(error) - return ret0 -} - -// Remove indicates an expected call of Remove. -func (mr *MockcommentHBaseRepositoryMockRecorder) Remove(ctx, videoId, conversationId, timestamp interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Remove", reflect.TypeOf((*MockcommentHBaseRepository)(nil).Remove), ctx, videoId, conversationId, timestamp) -} - -// Save mocks base method. -func (m *MockcommentHBaseRepository) Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content, timestamp string) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Save", ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp) - ret0, _ := ret[0].(error) - return ret0 -} - -// Save indicates an expected call of Save. -func (mr *MockcommentHBaseRepositoryMockRecorder) Save(ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Save", reflect.TypeOf((*MockcommentHBaseRepository)(nil).Save), ctx, commentId, videoId, userId, conversationId, lastId, toUserId, content, timestamp) -} - -// MockcommentCntRepository is a mock of commentCntRepository interface. -type MockcommentCntRepository struct { - ctrl *gomock.Controller - recorder *MockcommentCntRepositoryMockRecorder -} - -// MockcommentCntRepositoryMockRecorder is the mock recorder for MockcommentCntRepository. -type MockcommentCntRepositoryMockRecorder struct { - mock *MockcommentCntRepository -} - -// NewMockcommentCntRepository creates a new mock instance. -func NewMockcommentCntRepository(ctrl *gomock.Controller) *MockcommentCntRepository { - mock := &MockcommentCntRepository{ctrl: ctrl} - mock.recorder = &MockcommentCntRepositoryMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockcommentCntRepository) EXPECT() *MockcommentCntRepositoryMockRecorder { - return m.recorder -} - -// GetCommentsCount mocks base method. -func (m *MockcommentCntRepository) GetCommentsCount(ctx context.Context, videoIdList ...int64) (map[int64]int64, error) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range videoIdList { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetCommentsCount", varargs...) - ret0, _ := ret[0].(map[int64]int64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetCommentsCount indicates an expected call of GetCommentsCount. -func (mr *MockcommentCntRepositoryMockRecorder) GetCommentsCount(ctx interface{}, videoIdList ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, videoIdList...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetCommentsCount", reflect.TypeOf((*MockcommentCntRepository)(nil).GetCommentsCount), varargs...) -} - -// UpdateCommentsCount mocks base method. -func (m *MockcommentCntRepository) UpdateCommentsCount(ctx context.Context, videoIdList ...int64) error { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range videoIdList { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "UpdateCommentsCount", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// UpdateCommentsCount indicates an expected call of UpdateCommentsCount. -func (mr *MockcommentCntRepositoryMockRecorder) UpdateCommentsCount(ctx interface{}, videoIdList ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, videoIdList...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateCommentsCount", reflect.TypeOf((*MockcommentCntRepository)(nil).UpdateCommentsCount), varargs...) -} - -// MockCommentCntCache is a mock of CommentCntCache interface. -type MockCommentCntCache struct { - ctrl *gomock.Controller - recorder *MockCommentCntCacheMockRecorder -} - -// MockCommentCntCacheMockRecorder is the mock recorder for MockCommentCntCache. -type MockCommentCntCacheMockRecorder struct { - mock *MockCommentCntCache -} - -// NewMockCommentCntCache creates a new mock instance. -func NewMockCommentCntCache(ctrl *gomock.Controller) *MockCommentCntCache { - mock := &MockCommentCntCache{ctrl: ctrl} - mock.recorder = &MockCommentCntCacheMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockCommentCntCache) EXPECT() *MockCommentCntCacheMockRecorder { - return m.recorder -} - -// Add mocks base method. -func (m *MockCommentCntCache) Add(videoId, modification int64) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Add", videoId, modification) -} - -// Add indicates an expected call of Add. -func (mr *MockCommentCntCacheMockRecorder) Add(videoId, modification interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Add", reflect.TypeOf((*MockCommentCntCache)(nil).Add), videoId, modification) -} - -// Clear mocks base method. -func (m *MockCommentCntCache) Clear() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Clear") -} - -// Clear indicates an expected call of Clear. -func (mr *MockCommentCntCacheMockRecorder) Clear() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Clear", reflect.TypeOf((*MockCommentCntCache)(nil).Clear)) -} - -// Get mocks base method. -func (m *MockCommentCntCache) Get(videoId int64) (int64, bool) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", videoId) - ret0, _ := ret[0].(int64) - ret1, _ := ret[1].(bool) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockCommentCntCacheMockRecorder) Get(videoId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockCommentCntCache)(nil).Get), videoId) -} - -// GetAll mocks base method. -func (m *MockCommentCntCache) GetAll() map[int64]int64 { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetAll") - ret0, _ := ret[0].(map[int64]int64) - return ret0 -} - -// GetAll indicates an expected call of GetAll. -func (mr *MockCommentCntCacheMockRecorder) GetAll() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAll", reflect.TypeOf((*MockCommentCntCache)(nil).GetAll)) -} - -// MockCommentTotalCountCache is a mock of CommentTotalCountCache interface. -type MockCommentTotalCountCache struct { - ctrl *gomock.Controller - recorder *MockCommentTotalCountCacheMockRecorder -} - -// MockCommentTotalCountCacheMockRecorder is the mock recorder for MockCommentTotalCountCache. -type MockCommentTotalCountCacheMockRecorder struct { - mock *MockCommentTotalCountCache -} - -// NewMockCommentTotalCountCache creates a new mock instance. -func NewMockCommentTotalCountCache(ctrl *gomock.Controller) *MockCommentTotalCountCache { - mock := &MockCommentTotalCountCache{ctrl: ctrl} - mock.recorder = &MockCommentTotalCountCacheMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockCommentTotalCountCache) EXPECT() *MockCommentTotalCountCacheMockRecorder { - return m.recorder -} - -// Clear mocks base method. -func (m *MockCommentTotalCountCache) Clear() { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Clear") -} - -// Clear indicates an expected call of Clear. -func (mr *MockCommentTotalCountCacheMockRecorder) Clear() *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Clear", reflect.TypeOf((*MockCommentTotalCountCache)(nil).Clear)) -} - -// Get mocks base method. -func (m *MockCommentTotalCountCache) Get(videoId int64) (int64, bool) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", videoId) - ret0, _ := ret[0].(int64) - ret1, _ := ret[1].(bool) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockCommentTotalCountCacheMockRecorder) Get(videoId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockCommentTotalCountCache)(nil).Get), videoId) -} - -// Set mocks base method. -func (m *MockCommentTotalCountCache) Set(videoId, count int64) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "Set", videoId, count) -} - -// Set indicates an expected call of Set. -func (mr *MockCommentTotalCountCacheMockRecorder) Set(videoId, count interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Set", reflect.TypeOf((*MockCommentTotalCountCache)(nil).Set), videoId, count) -} - -// SetBatch mocks base method. -func (m *MockCommentTotalCountCache) SetBatch(batch map[int64]int64) { - m.ctrl.T.Helper() - m.ctrl.Call(m, "SetBatch", batch) -} - -// SetBatch indicates an expected call of SetBatch. -func (mr *MockCommentTotalCountCacheMockRecorder) SetBatch(batch interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBatch", reflect.TypeOf((*MockCommentTotalCountCache)(nil).SetBatch), batch) -} - -// MockCommentTotalCountRedis is a mock of CommentTotalCountRedis interface. -type MockCommentTotalCountRedis struct { - ctrl *gomock.Controller - recorder *MockCommentTotalCountRedisMockRecorder -} - -// MockCommentTotalCountRedisMockRecorder is the mock recorder for MockCommentTotalCountRedis. -type MockCommentTotalCountRedisMockRecorder struct { - mock *MockCommentTotalCountRedis -} - -// NewMockCommentTotalCountRedis creates a new mock instance. -func NewMockCommentTotalCountRedis(ctrl *gomock.Controller) *MockCommentTotalCountRedis { - mock := &MockCommentTotalCountRedis{ctrl: ctrl} - mock.recorder = &MockCommentTotalCountRedisMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockCommentTotalCountRedis) EXPECT() *MockCommentTotalCountRedisMockRecorder { - return m.recorder -} - -// Delete mocks base method. -func (m *MockCommentTotalCountRedis) Delete(ctx context.Context, videoId ...int64) error { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range videoId { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "Delete", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// Delete indicates an expected call of Delete. -func (mr *MockCommentTotalCountRedisMockRecorder) Delete(ctx interface{}, videoId ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, videoId...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockCommentTotalCountRedis)(nil).Delete), varargs...) -} - -// Get mocks base method. -func (m *MockCommentTotalCountRedis) Get(ctx context.Context, videoId int64) (int64, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "Get", ctx, videoId) - ret0, _ := ret[0].(int64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// Get indicates an expected call of Get. -func (mr *MockCommentTotalCountRedisMockRecorder) Get(ctx, videoId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Get", reflect.TypeOf((*MockCommentTotalCountRedis)(nil).Get), ctx, videoId) -} - -// MockIService is a mock of IService interface. -type MockIService struct { - ctrl *gomock.Controller - recorder *MockIServiceMockRecorder -} - -// MockIServiceMockRecorder is the mock recorder for MockIService. -type MockIServiceMockRecorder struct { - mock *MockIService -} - -// NewMockIService creates a new mock instance. -func NewMockIService(ctrl *gomock.Controller) *MockIService { - mock := &MockIService{ctrl: ctrl} - mock.recorder = &MockIServiceMockRecorder{mock} - return mock -} - -// EXPECT returns an object that allows the caller to indicate expected use. -func (m *MockIService) EXPECT() *MockIServiceMockRecorder { - return m.recorder -} - -// AddComment mocks base method. -func (m *MockIService) AddComment(ctx context.Context, videoId, userId, conversationId, lastId, toUserId int64, content string) (*entity.Comment, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "AddComment", ctx, videoId, userId, conversationId, lastId, toUserId, content) - ret0, _ := ret[0].(*entity.Comment) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// AddComment indicates an expected call of AddComment. -func (mr *MockIServiceMockRecorder) AddComment(ctx, videoId, userId, conversationId, lastId, toUserId, content interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddComment", reflect.TypeOf((*MockIService)(nil).AddComment), ctx, videoId, userId, conversationId, lastId, toUserId, content) -} - -// CountComments mocks base method. -func (m *MockIService) CountComments(ctx context.Context, videoId ...int64) (map[int64]int64, error) { - m.ctrl.T.Helper() - varargs := []interface{}{ctx} - for _, a := range videoId { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "CountComments", varargs...) - ret0, _ := ret[0].(map[int64]int64) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// CountComments indicates an expected call of CountComments. -func (mr *MockIServiceMockRecorder) CountComments(ctx interface{}, videoId ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx}, videoId...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CountComments", reflect.TypeOf((*MockIService)(nil).CountComments), varargs...) -} - -// ListComment mocks base method. -func (m *MockIService) ListComment(ctx context.Context, videoId int64) ([]*hbModel.CommentInHB, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "ListComment", ctx, videoId) - ret0, _ := ret[0].([]*hbModel.CommentInHB) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// ListComment indicates an expected call of ListComment. -func (mr *MockIServiceMockRecorder) ListComment(ctx, videoId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListComment", reflect.TypeOf((*MockIService)(nil).ListComment), ctx, videoId) -} - -// RemoveComment mocks base method. -func (m *MockIService) RemoveComment(ctx context.Context, userId, commentId int64) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "RemoveComment", ctx, userId, commentId) - ret0, _ := ret[0].(error) - return ret0 -} - -// RemoveComment indicates an expected call of RemoveComment. -func (mr *MockIServiceMockRecorder) RemoveComment(ctx, userId, commentId interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveComment", reflect.TypeOf((*MockIService)(nil).RemoveComment), ctx, userId, commentId) -} diff --git a/applications/commentDomain/service/service.go b/applications/commentDomain/service/service.go deleted file mode 100644 index 161aad41..00000000 --- a/applications/commentDomain/service/service.go +++ /dev/null @@ -1,105 +0,0 @@ -package service - -import ( - "context" - "errors" - "fmt" - "time" - - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/hbModel" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/go-redis/redis/v8" - "golang.org/x/exp/maps" -) - -var ( - CommentNotBelongToUser = errors.New("comment not belong to user") -) - -func (s *CommentDomainService) AddComment( - ctx context.Context, - videoId, userId, conversationId, lastId, toUserId int64, - content string, -) (*entity.Comment, error) { - timestamp := fmt.Sprint(time.Now().Unix()) - id := s.snowflakeHandle.GetId() - - result := entity.Comment{ - Id: int64(id), - Content: content, - CreateDate: "刚刚", - } - - if err := s.commentRepository.Save(ctx, id.Int64(), videoId, userId, conversationId, lastId, toUserId, content, timestamp); err != nil { - return nil, err - } - - if err := s.commentHBaseRepository.Save(ctx, id.Int64(), videoId, userId, conversationId, lastId, toUserId, content, timestamp); err != nil { - return nil, err - } - - s.commentCountCache.Add(videoId, 1) - - return &result, nil -} - -func (s *CommentDomainService) CountComments(ctx context.Context, videoId ...int64) (map[int64]int64, error) { - resultMap := make(map[int64]int64) - - // Query comments count from cache - queryAgain := []int64{} - for _, v := range videoId { - cnt, ok := s.commentCountCache.Get(v) - if !ok { - queryAgain = append(queryAgain, v) - } else { - resultMap[v] = cnt - } - } - - // Query comments count from redis - query3times := []int64{} - for _, v := range queryAgain { - cnt, err := s.commentTotalCountRedis.Get(ctx, v) - if err != nil && err != redis.Nil { - return nil, err - } else if err == redis.Nil { - query3times = append(query3times, v) - } else { - resultMap[v] = cnt - s.commentCountCache.Add(v, cnt) - } - } - - // Query comments count from mysql - results, err := s.commentCntRepository.GetCommentsCount(ctx, query3times...) - if err != nil { - return resultMap, err - } - - maps.Copy(resultMap, results) - return resultMap, nil -} - -func (s *CommentDomainService) ListComment(ctx context.Context, videoId int64) ([]*hbModel.CommentInHB, error) { - return s.commentHBaseRepository.List(ctx, videoId) -} - -func (s *CommentDomainService) RemoveComment(ctx context.Context, userId, commentId int64) error { - comment, ok := s.commentRepository.IsCommentFromUser(ctx, userId, commentId) - if !ok { - return CommentNotBelongToUser - } - - if err := s.commentRepository.Remove(ctx, commentId); err != nil { - return err - } - - if err := s.commentHBaseRepository.Remove(ctx, comment.VideoId, comment.ConversationId, comment.Timestamp); err != nil { - return err - } - - s.commentCountCache.Add(commentId, -1) - - return nil -} diff --git a/applications/commentDomain/service/typedef.go b/applications/commentDomain/service/typedef.go deleted file mode 100644 index 3b4886f6..00000000 --- a/applications/commentDomain/service/typedef.go +++ /dev/null @@ -1,93 +0,0 @@ -package service - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/hbModel" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/repository/comment" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/repository/commentcnt" - "github.com/TremblingV5/DouTok/applications/commentDomain/hb/commentHBaseRepo" - "github.com/TremblingV5/DouTok/applications/commentDomain/redis/commentTotalCountRedis" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "gorm.io/gorm" - - "github.com/TremblingV5/DouTok/applications/commentDomain/cache/commentCntCache" - "github.com/TremblingV5/DouTok/applications/commentDomain/cache/commentTotalCountCache" - "github.com/TremblingV5/DouTok/applications/commentDomain/dal/query" - "github.com/TremblingV5/DouTok/pkg/hbaseHandle" - "github.com/TremblingV5/DouTok/pkg/utils" -) - -type commentRepository interface { - Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content string, timestamp string) error - IsCommentFromUser(ctx context.Context, userId, commentId int64) (*model.Comment, bool) - Remove(ctx context.Context, commentId int64) error -} - -type commentHBaseRepository interface { - Save(ctx context.Context, commentId, videoId, userId, conversationId, lastId, toUserId int64, content string, timestamp string) error - List(ctx context.Context, videoId int64) ([]*hbModel.CommentInHB, error) - Remove(ctx context.Context, videoId, conversationId int64, timestamp string) error -} - -type commentCntRepository interface { - GetCommentsCount(ctx context.Context, videoIdList ...int64) (map[int64]int64, error) - UpdateCommentsCount(ctx context.Context, videoIdList ...int64) error -} - -type CommentCntCache interface { - Add(videoId int64, modification int64) - Get(videoId int64) (int64, bool) - GetAll() map[int64]int64 - Clear() -} - -type CommentTotalCountCache interface { - Get(videoId int64) (int64, bool) - Set(videoId, count int64) - SetBatch(batch map[int64]int64) - Clear() -} - -type CommentTotalCountRedis interface { - Get(ctx context.Context, videoId int64) (int64, error) - Delete(ctx context.Context, videoId ...int64) error -} - -type CommentDomainService struct { - commentRepository commentRepository - commentCntRepository commentCntRepository - commentHBaseRepository commentHBaseRepository - commentTotalCountRedis CommentTotalCountRedis - commentCountCache CommentCntCache // key: video id, value: modification if count of comments for a video - commentTotalCountCache CommentTotalCountCache // key: video id, value: count of comments for a video - snowflakeHandle *utils.SnowflakeHandle -} - -//go:generate mockgen -source=typedef.go -destinDBation=./mocks/service_mock.go -package CommentServiceMocks -type IService interface { - AddComment(ctx context.Context, videoId, userId, conversationId, lastId, toUserId int64, content string) (*entity.Comment, error) - CountComments(ctx context.Context, videoId ...int64) (map[int64]int64, error) - ListComment(ctx context.Context, videoId int64) ([]*hbModel.CommentInHB, error) - RemoveComment(ctx context.Context, userId, commentId int64) error -} - -func NewCommentDomainService( - db *gorm.DB, - hb *hbaseHandle.HBaseClient, - commentTotalCountRedis *commentTotalCountRedis.Client, - snowflakeNode int64, -) *CommentDomainService { - query.SetDefault(db) - return &CommentDomainService{ - commentRepository: comment.NewRepository(db), - commentCntRepository: commentcnt.NewRepository(db), - commentHBaseRepository: commentHBaseRepo.NewRepository(hb), - commentTotalCountRedis: commentTotalCountRedis, - commentCountCache: commentCntCache.NewCache(), - commentTotalCountCache: commentTotalCountCache.NewCache(), - snowflakeHandle: utils.NewSnowflakeHandle(snowflakeNode), - } -} - -var _ IService = (*CommentDomainService)(nil) diff --git a/applications/commentDomain/service/utils_test.go b/applications/commentDomain/service/utils_test.go deleted file mode 100644 index 89853237..00000000 --- a/applications/commentDomain/service/utils_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package service - -import ( - "fmt" - "github.com/stretchr/testify/require" - "testing" - "time" -) - -func TestGetCommentRecall(t *testing.T) { - timeNow := time.Now().Unix() - - time1 := fmt.Sprint(timeNow - 60*12) - require.Equal(t, "12分钟前", GetTimeRecall(time1, timeNow)) - - time2 := fmt.Sprint(timeNow - 60*60*5) - require.Equal(t, "5小时前", GetTimeRecall(time2, timeNow)) - - time3 := fmt.Sprint(timeNow - 60*60*24*4) - require.Equal(t, "4天前", GetTimeRecall(time3, timeNow)) - - time4 := fmt.Sprint(timeNow - 60*60*24*18) - require.Equal(t, time.Unix(timeNow-60*60*24*18, 0).Format("2006/01/02"), GetTimeRecall(time4, timeNow)) -} diff --git a/applications/favorite/build.sh b/applications/favorite/build.sh index fe400170..c4cd2b98 100644 --- a/applications/favorite/build.sh +++ b/applications/favorite/build.sh @@ -10,4 +10,3 @@ if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then else go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... fi - diff --git a/applications/favoriteDomain/dal/gen.go b/applications/favorite/dal/gen.go similarity index 83% rename from applications/favoriteDomain/dal/gen.go rename to applications/favorite/dal/gen.go index 40a8a775..48c49277 100644 --- a/applications/favoriteDomain/dal/gen.go +++ b/applications/favorite/dal/gen.go @@ -1,7 +1,7 @@ package main import ( - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/favorite/dal/model" "github.com/TremblingV5/DouTok/config/configStruct" "github.com/TremblingV5/DouTok/pkg/configurator" "github.com/TremblingV5/DouTok/pkg/mysqlIniter" @@ -15,11 +15,9 @@ func main() { }) var config configStruct.MySQLConfig - if err := configurator.InitConfig( + configurator.InitConfig( &config, "mysql.yaml", - ); err != nil { - panic(err) - } + ) db, err := mysqlIniter.InitDb( config.Username, diff --git a/applications/favorite/dal/migrate/main.go b/applications/favorite/dal/migrate/main.go new file mode 100644 index 00000000..4546f283 --- /dev/null +++ b/applications/favorite/dal/migrate/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "github.com/TremblingV5/DouTok/applications/favorite/dal/model" + "github.com/TremblingV5/DouTok/applications/favorite/misc" + "github.com/TremblingV5/DouTok/applications/favorite/service" +) + +func main() { + misc.InitViperConfig() + + service.InitDb( + misc.GetConfig("MySQL.Username"), + misc.GetConfig("MySQL.Password"), + misc.GetConfig("MySQL.Host"), + misc.GetConfig("MySQL.Port"), + misc.GetConfig("MySQL.Database"), + ) + + service.DB.AutoMigrate(&model.Favorite{}, &model.FavoriteCount{}) +} diff --git a/applications/favoriteDomain/dal/model/count.go b/applications/favorite/dal/model/count.go similarity index 100% rename from applications/favoriteDomain/dal/model/count.go rename to applications/favorite/dal/model/count.go diff --git a/applications/favoriteDomain/dal/model/favorite.go b/applications/favorite/dal/model/favorite.go similarity index 100% rename from applications/favoriteDomain/dal/model/favorite.go rename to applications/favorite/dal/model/favorite.go diff --git a/applications/favoriteDomain/dal/query/favorite_counts.gen.go b/applications/favorite/dal/query/favorite_counts.gen.go similarity index 99% rename from applications/favoriteDomain/dal/query/favorite_counts.gen.go rename to applications/favorite/dal/query/favorite_counts.gen.go index a7dc51b6..848b3b34 100644 --- a/applications/favoriteDomain/dal/query/favorite_counts.gen.go +++ b/applications/favorite/dal/query/favorite_counts.gen.go @@ -16,7 +16,7 @@ import ( "gorm.io/plugin/dbresolver" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/favorite/dal/model" ) func newFavoriteCount(db *gorm.DB, opts ...gen.DOOption) favoriteCount { diff --git a/applications/favoriteDomain/dal/query/favorites.gen.go b/applications/favorite/dal/query/favorites.gen.go similarity index 99% rename from applications/favoriteDomain/dal/query/favorites.gen.go rename to applications/favorite/dal/query/favorites.gen.go index 0f261f24..f19f1dd7 100644 --- a/applications/favoriteDomain/dal/query/favorites.gen.go +++ b/applications/favorite/dal/query/favorites.gen.go @@ -16,7 +16,7 @@ import ( "gorm.io/plugin/dbresolver" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/favorite/dal/model" ) func newFavorite(db *gorm.DB, opts ...gen.DOOption) favorite { diff --git a/applications/favoriteDomain/dal/query/gen.go b/applications/favorite/dal/query/gen.go similarity index 100% rename from applications/favoriteDomain/dal/query/gen.go rename to applications/favorite/dal/query/gen.go diff --git a/applications/favoriteDomain/dal/query/var.go b/applications/favorite/dal/query/var.go similarity index 100% rename from applications/favoriteDomain/dal/query/var.go rename to applications/favorite/dal/query/var.go diff --git a/applications/favorite/errs/errs.go b/applications/favorite/errs/errs.go deleted file mode 100644 index 2429ee3e..00000000 --- a/applications/favorite/errs/errs.go +++ /dev/null @@ -1,21 +0,0 @@ -package errs - -import "github.com/TremblingV5/DouTok/pkg/response" - -const ( - bindingError = "binding error" - bindingErrorCode = 101 -) - -var ( - Success *response.Response - BindingErr *response.Response -) - -func Init(config response.Config) { - Success = response.Success(config) - - BindingErr = Success.Copy().Update( - response.Message(bindingError), response.Code(bindingErrorCode), - ) -} diff --git a/applications/favorite/handler/favorite_action.go b/applications/favorite/handler/favorite_action.go new file mode 100644 index 00000000..3e967975 --- /dev/null +++ b/applications/favorite/handler/favorite_action.go @@ -0,0 +1,24 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/favorite/misc" + "github.com/TremblingV5/DouTok/applications/favorite/pack" + "github.com/TremblingV5/DouTok/applications/favorite/service" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" +) + +func (s *FavoriteServiceImpl) FavoriteAction(ctx context.Context, req *favorite.DouyinFavoriteActionRequest) (resp *favorite.DouyinFavoriteActionResponse, err error) { + if req.ActionType == 1 { + // 点赞 + errNo, _ := service.ActionFavorite(req.UserId, req.VideoId, true) + return pack.PackFavoriteActionResp(int32(errNo.ErrCode), errNo.ErrMsg) + } else if req.ActionType == 2 { + // 取消点赞 + errNo, _ := service.ActionFavorite(req.UserId, req.VideoId, false) + return pack.PackFavoriteActionResp(int32(errNo.ErrCode), errNo.ErrMsg) + } else { + return pack.PackFavoriteActionResp(int32(misc.BindingInvalidErr.ErrCode), misc.BindingInvalidErr.ErrMsg) + } +} diff --git a/applications/favorite/handler/favorite_count.go b/applications/favorite/handler/favorite_count.go new file mode 100644 index 00000000..22f74235 --- /dev/null +++ b/applications/favorite/handler/favorite_count.go @@ -0,0 +1,23 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/favorite/misc" + "github.com/TremblingV5/DouTok/applications/favorite/pack" + "github.com/TremblingV5/DouTok/applications/favorite/service" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" +) + +func (s *FavoriteServiceImpl) FavoriteCount(ctx context.Context, req *favorite.DouyinFavoriteCountRequest) (resp *favorite.DouyinFavoriteCountResponse, err error) { + if len(req.VideoIdList) == 0 { + return pack.PackFavoriteCountResp(int32(misc.EmptyVideoIdListErr.ErrCode), misc.EmptyVideoIdListErr.ErrMsg, nil) + } + + res, err := service.QueryFavoriteCount(req.VideoIdList) + if err != nil { + return pack.PackFavoriteCountResp(int32(misc.SystemErr.ErrCode), misc.SystemErr.ErrMsg, nil) + } + + return pack.PackFavoriteCountResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, res) +} diff --git a/applications/favorite/handler/favorite_list.go b/applications/favorite/handler/favorite_list.go new file mode 100644 index 00000000..56603342 --- /dev/null +++ b/applications/favorite/handler/favorite_list.go @@ -0,0 +1,35 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/favorite/misc" + "github.com/TremblingV5/DouTok/applications/favorite/pack" + "github.com/TremblingV5/DouTok/applications/favorite/service" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" +) + +func (s *FavoriteServiceImpl) FavoriteList(ctx context.Context, req *favorite.DouyinFavoriteListRequest) (resp *favorite.DouyinFavoriteListResponse, err error) { + // 1. 查缓存 + res, _ := service.QueryFavListInCache(req.UserId) + + // 2. 如果缓存有则直接返回 + if len(res) > 0 { + return pack.PackFavoriteListResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, res) + } + + // 3. 如果缓存没有则查库 + res, err = service.QueryFavListInRDB(req.UserId) + // 4. 将从RDB查询到的数据读入缓存 + for _, v := range res { + if err := service.WriteFavoriteInCache(req.UserId, v, true); err != nil { + continue + } + } + + if err != nil { + pack.PackFavoriteListResp(int32(misc.SystemErr.ErrCode), misc.SystemErr.ErrMsg, nil) + } + + return pack.PackFavoriteListResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, res) +} diff --git a/applications/favorite/handler/handler.go b/applications/favorite/handler/handler.go deleted file mode 100644 index f7e71591..00000000 --- a/applications/favorite/handler/handler.go +++ /dev/null @@ -1,81 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/comment/errs" - "github.com/TremblingV5/DouTok/applications/favorite/rpc" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/favorite" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" -) - -type Handler struct { - client *rpc.Clients -} - -func New(client *rpc.Clients) *Handler { - return &Handler{ - client: client, - } -} - -func (h *Handler) FavoriteAction(ctx context.Context, req *favorite.DouyinFavoriteActionRequest) (resp *favorite.DouyinFavoriteActionResponse, err error) { - if req.ActionType == 1 { - // 点赞 - result, err := h.client.Favorite.Client.AddFavorite(ctx, &favoriteDomain.DoutokAddFavRequest{ - UserId: req.UserId, - VideoId: req.VideoId, - }) - return &favorite.DouyinFavoriteActionResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - }, err - } - - if req.ActionType == 2 { - // 取消点赞 - result, _ := h.client.Favorite.Client.RmFavorite(ctx, &favoriteDomain.DoutokRmFavRequest{ - UserId: req.UserId, - VideoId: req.VideoId, - }) - return &favorite.DouyinFavoriteActionResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - }, err - } - - return &favorite.DouyinFavoriteActionResponse{ - StatusCode: errs.BindingErr.Code(), - StatusMsg: errs.BindingErr.Message(), - }, err -} - -func (h *Handler) FavoriteList(ctx context.Context, req *favorite.DouyinFavoriteListRequest) (resp *favorite.DouyinFavoriteListResponse, err error) { - result, err := h.client.Favorite.Client.ListFavorite(ctx, &favoriteDomain.DoutokListFavRequest{ - UserId: req.UserId, - }) - if err != nil { - return &favorite.DouyinFavoriteListResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - }, err - } - - var videoIdList []*entity.Video - for _, v := range result.VideoList { - videoInfo, e := h.client.Video.Client.GetVideoInfo(ctx, &videoDomain.DoutokGetVideoInfoRequest{ - VideoId: v.Id, - }) - if e != nil { - continue - } - videoIdList = append(videoIdList, videoInfo) - } - - return &favorite.DouyinFavoriteListResponse{ - StatusCode: errs.Success.Code(), - StatusMsg: errs.Success.Message(), - VideoList: videoIdList, - }, nil -} diff --git a/applications/favorite/handler/is_favorite.go b/applications/favorite/handler/is_favorite.go new file mode 100644 index 00000000..e882b5db --- /dev/null +++ b/applications/favorite/handler/is_favorite.go @@ -0,0 +1,20 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/favorite/misc" + "github.com/TremblingV5/DouTok/applications/favorite/pack" + "github.com/TremblingV5/DouTok/applications/favorite/service" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" +) + +func (s *FavoriteServiceImpl) IsFavorite(ctx context.Context, req *favorite.DouyinIsFavoriteRequest) (resp *favorite.DouyinIsFavoriteResponse, err error) { + res, err := service.QueryIsFavorite(req.UserId, req.VideoIdList) + + if err != nil { + return pack.PackIsFavoriteResp(int32(misc.SystemErr.ErrCode), misc.SystemErr.ErrMsg, nil) + } + + return pack.PackIsFavoriteResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, res) +} diff --git a/applications/favorite/handler/typedef.go b/applications/favorite/handler/typedef.go new file mode 100644 index 00000000..ca849f58 --- /dev/null +++ b/applications/favorite/handler/typedef.go @@ -0,0 +1,3 @@ +package handler + +type FavoriteServiceImpl struct{} diff --git a/applications/favorite/main.go b/applications/favorite/main.go index 47a1ab46..15146337 100644 --- a/applications/favorite/main.go +++ b/applications/favorite/main.go @@ -1,52 +1,43 @@ package main import ( - "context" - "github.com/TremblingV5/DouTok/applications/favorite/handler" + "github.com/TremblingV5/DouTok/applications/favorite/misc" "github.com/TremblingV5/DouTok/applications/favorite/rpc" - "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/applications/favorite/service" "github.com/TremblingV5/DouTok/kitex_gen/favorite/favoriteservice" - "github.com/TremblingV5/DouTok/pkg/DouTokContext" - "github.com/TremblingV5/DouTok/pkg/DouTokLogger" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/services" - "go.uber.org/zap" + "github.com/TremblingV5/DouTok/pkg/dlog" + "github.com/TremblingV5/DouTok/pkg/initHelper" ) -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_FAVORITE_"` - Jwt configStruct.Jwt `envPrefix:"DOUTOK_FAVORITE_"` - Logger configStruct.Logger `envPrefix:"DOUTOK_FAVORITE_"` -} - var ( - logger *zap.Logger - config = &Config{} + Logger = dlog.InitLog(3) ) -func init() { - ctx := context.Background() - _, err := configurator.Load(config, "DOUTOK_FAVORITE", "favorite") - logger = DouTokLogger.InitLogger(config.Logger) - DouTokContext.DefaultLogger = logger - DouTokContext.AddLoggerToContext(ctx, logger) - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", config)) - } +func Init() { + misc.InitViperConfig() + + service.Init() + + rpc.InitPRCClient() + + go service.UpdateFavMap() + go service.UpdateFavCntMap() + go service.Consumer4UpdateCount() } func main() { - options, shutdown := services.InitRPCServerArgs(constants.FAVORITE_SERVER_NAME, config.BaseConfig) + Init() + + options, shutdown := initHelper.InitRPCServerArgs(misc.Config) defer shutdown() svr := favoriteservice.NewServer( - handler.New(rpc.New(services.InitRPCClientArgs(constants.FAVORITE_SERVER_NAME, config.Etcd))), + new(handler.FavoriteServiceImpl), options..., ) if err := svr.Run(); err != nil { - logger.Fatal("run server err", zap.Error(err)) + Logger.Fatal(err) } } diff --git a/applications/favorite/misc/config.go b/applications/favorite/misc/config.go new file mode 100644 index 00000000..c51050fa --- /dev/null +++ b/applications/favorite/misc/config.go @@ -0,0 +1,18 @@ +package misc + +import "github.com/TremblingV5/DouTok/pkg/dtviper" + +var Config *dtviper.Config + +func InitViperConfig() { + config := dtviper.ConfigInit(ViperConfigEnvPrefix, ViperConfigEnvFilename) + Config = config +} + +func GetConfig(key string) string { + return Config.Viper.GetString(key) +} + +func GetConfigNum(key string) int64 { + return Config.Viper.GetInt64(key) +} diff --git a/applications/favorite/misc/const.go b/applications/favorite/misc/const.go new file mode 100644 index 00000000..56f0a254 --- /dev/null +++ b/applications/favorite/misc/const.go @@ -0,0 +1,22 @@ +package misc + +var ( + FavCountTopicName = "fav_count" + FavCountGroupName = "fav_count01" + + ViperConfigEnvPrefix = "DOUTOK_FAVORITE" + ViperConfigEnvFilename = "favorite" + + ConfigIndex_MySQLUsername = "MySQL.Username" + ConfigIndex_MySQLPassword = "MySQL.Password" + ConfigIndex_MySQLHost = "MySQL.Host" + ConfigIndex_MySQLPort = "MySQL.Port" + ConfigIndex_MySQLDb = "MySQL.Database" + + ConfigIndex_RedisDest = "Redis.Dest" + ConfigIndex_RedisPassword = "Redis.Password" + ConfigIndex_RedisFavCacheDbNum = "Redis.FavCache.Num" + ConfigIndex_RedisFavCntCacheDbNum = "Redis.FavCntCache.Num" + + ConfigIndex_SnowFlake = "Snowflake.Node" +) diff --git a/applications/favorite/misc/err.go b/applications/favorite/misc/err.go new file mode 100644 index 00000000..7b33ce55 --- /dev/null +++ b/applications/favorite/misc/err.go @@ -0,0 +1,27 @@ +package misc + +import "github.com/TremblingV5/DouTok/pkg/errno" + +var ( + NilErrCode = -1 + SuccessCode = 0 + ParamsErrCode = 27001 + SystemErrCode = 27002 + EmptyVideoIdListErrCode = 27003 + BindingInvalidErrCode = 27004 + QueryCacheErrCode = 27005 + CreateFavoriteInRDBErrCode = 27006 + WriteRDBErrCode = 27007 +) + +var ( + NilErr = errno.NewErrNo(NilErrCode, "Don't care") + Success = errno.NewErrNo(SuccessCode, "Success") + ParamsErr = errno.NewErrNo(ParamsErrCode, "Invalid parameters") + SystemErr = errno.NewErrNo(SystemErrCode, "System error") + EmptyVideoIdListErr = errno.NewErrNo(EmptyVideoIdListErrCode, "Empty video id list") + BindingInvalidErr = errno.NewErrNo(BindingInvalidErrCode, "Action type is invalid") + QueryCacheErr = errno.NewErrNo(QueryCacheErrCode, "Query cache defeat") + CreateFavoriteInRDBErr = errno.NewErrNo(CreateFavoriteInRDBErrCode, "Create new favorite relation in rdb defeat") + WriteRDBErr = errno.NewErrNo(WriteRDBErrCode, "Write rdb defeat") +) diff --git a/applications/favoriteDomain/misc/var.go b/applications/favorite/misc/var.go similarity index 100% rename from applications/favoriteDomain/misc/var.go rename to applications/favorite/misc/var.go diff --git a/applications/favorite/pack/favorite_action.go b/applications/favorite/pack/favorite_action.go new file mode 100644 index 00000000..90237b4e --- /dev/null +++ b/applications/favorite/pack/favorite_action.go @@ -0,0 +1,10 @@ +package pack + +import "github.com/TremblingV5/DouTok/kitex_gen/favorite" + +func PackFavoriteActionResp(code int32, msg string) (resp *favorite.DouyinFavoriteActionResponse, err error) { + return &favorite.DouyinFavoriteActionResponse{ + StatusCode: code, + StatusMsg: msg, + }, nil +} diff --git a/applications/favorite/pack/favorite_count.go b/applications/favorite/pack/favorite_count.go new file mode 100644 index 00000000..092beb80 --- /dev/null +++ b/applications/favorite/pack/favorite_count.go @@ -0,0 +1,13 @@ +package pack + +import "github.com/TremblingV5/DouTok/kitex_gen/favorite" + +func PackFavoriteCountResp(code int32, msg string, list map[int64]int64) (resp *favorite.DouyinFavoriteCountResponse, err error) { + resp = &favorite.DouyinFavoriteCountResponse{ + StatusCode: code, + StatusMsg: msg, + Result: list, + } + + return resp, nil +} diff --git a/applications/favorite/pack/favorite_list.go b/applications/favorite/pack/favorite_list.go new file mode 100644 index 00000000..4e223dc1 --- /dev/null +++ b/applications/favorite/pack/favorite_list.go @@ -0,0 +1,29 @@ +package pack + +import ( + "github.com/TremblingV5/DouTok/applications/favorite/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" + "github.com/TremblingV5/DouTok/kitex_gen/feed" + "golang.org/x/net/context" +) + +func PackFavoriteListResp(code int32, msg string, list []int64) (resp *favorite.DouyinFavoriteListResponse, err error) { + var resList []*feed.Video + for _, i := range list { + res, err := rpc.GetVideoById(context.Background(), &feed.VideoIdRequest{ + VideoId: i, + SearchId: 0, + }) + if err != nil { + continue + } + + resList = append(resList, res) + } + + return &favorite.DouyinFavoriteListResponse{ + StatusCode: code, + StatusMsg: msg, + VideoList: resList, + }, nil +} diff --git a/applications/favorite/pack/is_favorite.go b/applications/favorite/pack/is_favorite.go new file mode 100644 index 00000000..b41c174b --- /dev/null +++ b/applications/favorite/pack/is_favorite.go @@ -0,0 +1,13 @@ +package pack + +import "github.com/TremblingV5/DouTok/kitex_gen/favorite" + +func PackIsFavoriteResp(code int32, msg string, list map[int64]bool) (resp *favorite.DouyinIsFavoriteResponse, err error) { + resp = &favorite.DouyinIsFavoriteResponse{ + StatusCode: code, + StatusMsg: msg, + Result: list, + } + + return resp, nil +} diff --git a/applications/favorite/rpc/clients.go b/applications/favorite/rpc/clients.go deleted file mode 100644 index 5b65924d..00000000 --- a/applications/favorite/rpc/clients.go +++ /dev/null @@ -1,21 +0,0 @@ -package rpc - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain/favoritedomainservice" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain/videodomainservice" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/services" - "github.com/cloudwego/kitex/client" -) - -type Clients struct { - Favorite *services.Service[favoritedomainservice.Client] - Video *services.Service[videodomainservice.Client] -} - -func New(options []client.Option) *Clients { - return &Clients{ - Favorite: services.New[favoritedomainservice.Client](constants.FAVORITE_DOMAIN_SERVER_NAME, favoritedomainservice.NewClient, options), - Video: services.New[videodomainservice.Client](constants.VIDEO_DOMAIN_SERVER_NAME, videodomainservice.NewClient, options), - } -} diff --git a/applications/favorite/rpc/feed.go b/applications/favorite/rpc/feed.go new file mode 100644 index 00000000..460206a9 --- /dev/null +++ b/applications/favorite/rpc/feed.go @@ -0,0 +1,31 @@ +package rpc + +import ( + "context" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/initHelper" + + "github.com/TremblingV5/DouTok/kitex_gen/feed" + "github.com/TremblingV5/DouTok/kitex_gen/feed/feedservice" +) + +var feedClient feedservice.Client + +func InitRelationRpc() { + config := dtviper.ConfigInit("DOUTOK_FEED", "feed") + + c, err := feedservice.NewClient( + config.Viper.GetString("Server.Name"), + initHelper.InitRPCClientArgs(config)..., + ) + + if err != nil { + panic(err) + } + + feedClient = c +} + +func GetVideoById(ctx context.Context, req *feed.VideoIdRequest) (resp *feed.Video, err error) { + return feedClient.GetVideoById(ctx, req) +} diff --git a/applications/favorite/rpc/init.go b/applications/favorite/rpc/init.go new file mode 100644 index 00000000..67e0d682 --- /dev/null +++ b/applications/favorite/rpc/init.go @@ -0,0 +1,5 @@ +package rpc + +func InitPRCClient() { + InitRelationRpc() +} diff --git a/applications/favorite/rpc/var.go b/applications/favorite/rpc/var.go new file mode 100644 index 00000000..fcc1e6f8 --- /dev/null +++ b/applications/favorite/rpc/var.go @@ -0,0 +1,5 @@ +package rpc + +import "github.com/TremblingV5/DouTok/config/configStruct" + +var ClientConfig *configStruct.FavoriteConfig diff --git a/applications/favorite/run.sh b/applications/favorite/run.sh deleted file mode 100644 index 3f7baf19..00000000 --- a/applications/favorite/run.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# 设置环境变量 -export DOUTOK_FAVORITE_SERVER_NAME=DouTokFavoriteServer -export DOUTOK_FAVORITE_SERVER_PORT=8082 -export DOUTOK_FAVORITE_ETCD_ADDRESS=localhost -export DOUTOK_FAVORITE_ETCD_PORT=2379 - -# 运行 Go 项目 -go run main.go diff --git a/applications/favorite/script/bootstrap.sh b/applications/favorite/script/bootstrap.sh index 45b3d69a..023030b2 100644 --- a/applications/favorite/script/bootstrap.sh +++ b/applications/favorite/script/bootstrap.sh @@ -19,4 +19,3 @@ if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then fi exec "$CURDIR/bin/favorite" - diff --git a/applications/favoriteDomain/service/cache_handle.go b/applications/favorite/service/cache_handle.go similarity index 100% rename from applications/favoriteDomain/service/cache_handle.go rename to applications/favorite/service/cache_handle.go diff --git a/applications/favorite/service/cache_handle_test.go b/applications/favorite/service/cache_handle_test.go new file mode 100644 index 00000000..7edff3e9 --- /dev/null +++ b/applications/favorite/service/cache_handle_test.go @@ -0,0 +1,19 @@ +package service + +import ( + "log" + "testing" +) + +func TestUpdateCacheFavCount(t *testing.T) { + Init() + + video_id := int64(2222222222222222222) + + err1 := UpdateCacheFavCount(video_id, true) + err2 := UpdateCacheFavCount(video_id, false) + + if err1 != nil || err2 != nil { + log.Panicln(err1, err2) + } +} diff --git a/applications/favoriteDomain/service/consumer_fav_req.go b/applications/favorite/service/consumer_fav_req.go similarity index 83% rename from applications/favoriteDomain/service/consumer_fav_req.go rename to applications/favorite/service/consumer_fav_req.go index a64953a5..627df5f8 100644 --- a/applications/favoriteDomain/service/consumer_fav_req.go +++ b/applications/favorite/service/consumer_fav_req.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" + "github.com/TremblingV5/DouTok/applications/favorite/misc" ) type favCountConsumerGroup struct{} @@ -18,12 +18,9 @@ func (m favCountConsumerGroup) ConsumeClaim(sess sarama.ConsumerGroupSession, cl fmt.Printf("Message topic:%q partition:%d offset:%d value:%s\n", msg.Topic, msg.Partition, msg.Offset, string(msg.Value)) req := FavReqInKafka{} - err := json.Unmarshal(msg.Value, &req) - if err != nil { - return err - } + json.Unmarshal(msg.Value, &req) - err = CreateFavoriteInRDB(req.UserId, req.VideoId, req.Op) + err := CreateFavoriteInRDB(req.UserId, req.VideoId, req.Op) if err != nil { // TODO: 写日志 diff --git a/applications/favorite/service/consumer_fav_req_test.go b/applications/favorite/service/consumer_fav_req_test.go new file mode 100644 index 00000000..9a191f00 --- /dev/null +++ b/applications/favorite/service/consumer_fav_req_test.go @@ -0,0 +1,9 @@ +package service + +import "testing" + +func TestConsumer4UpdateCount(t *testing.T) { + Init() + + go Consumer4UpdateCount() +} diff --git a/applications/favoriteDomain/service/favorite_action.go b/applications/favorite/service/favorite_action.go similarity index 79% rename from applications/favoriteDomain/service/favorite_action.go rename to applications/favorite/service/favorite_action.go index 10a18509..17f4c917 100644 --- a/applications/favoriteDomain/service/favorite_action.go +++ b/applications/favorite/service/favorite_action.go @@ -4,23 +4,14 @@ import ( "context" "encoding/json" "fmt" - "github.com/go-redis/redis/v8" "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" + "github.com/TremblingV5/DouTok/applications/favorite/misc" "github.com/TremblingV5/DouTok/pkg/errno" ) -type ActionFavoriteService struct { - ctx context.Context -} - -func NewActionFavoriteService(ctx context.Context) *ActionFavoriteService { - return &ActionFavoriteService{ctx: ctx} -} - -func (s *ActionFavoriteService) ActionFavorite(user_id int64, video_id int64, op bool) (*errno.ErrNo, error) { +func ActionFavorite(user_id int64, video_id int64, op bool) (*errno.ErrNo, error) { // 1. 在Redis中查找是否已经存在点赞关系的缓存 _, err := RedisClients[misc.FavCache].HGetAll(context.Background(), fmt.Sprint(user_id)) @@ -53,7 +44,7 @@ func (s *ActionFavoriteService) ActionFavorite(user_id int64, video_id int64, op } // 3. 更新内存中的计数Map - if (existed == "1" && !op) || (existed == "2" && op) { + if (existed == "1" && op == false) || (existed == "2" && op == true) { err = UpdateCacheFavCount(video_id, op) if err != nil { return &misc.QueryCacheErr, err diff --git a/applications/favoriteDomain/service/favorite_action_cache.go b/applications/favorite/service/favorite_action_cache.go similarity index 79% rename from applications/favoriteDomain/service/favorite_action_cache.go rename to applications/favorite/service/favorite_action_cache.go index 9fdaa300..df891b53 100644 --- a/applications/favoriteDomain/service/favorite_action_cache.go +++ b/applications/favorite/service/favorite_action_cache.go @@ -3,10 +3,8 @@ package service import ( "context" "fmt" -) -const ( - favCache = "favcache" + "github.com/TremblingV5/DouTok/applications/favorite/misc" ) /* @@ -19,7 +17,7 @@ func WriteFavoriteInCache(user_id int64, video_id int64, is_fav bool) error { } else { op = "2" } - return RedisClients[favCache].HSet( + return RedisClients[misc.FavCache].HSet( context.Background(), fmt.Sprint(user_id), fmt.Sprint(video_id), op, ) } diff --git a/applications/favorite/service/favorite_action_cache_test.go b/applications/favorite/service/favorite_action_cache_test.go new file mode 100644 index 00000000..04eec9e4 --- /dev/null +++ b/applications/favorite/service/favorite_action_cache_test.go @@ -0,0 +1,18 @@ +package service + +import ( + "log" + "testing" +) + +func TestWriteFavoriteInCache(t *testing.T) { + Init() + + userId := int64(1111111111111111111) + videoId := int64(2222222222222222222) + + err := WriteFavoriteInCache(userId, videoId, true) + if err != nil { + log.Panicln(err) + } +} diff --git a/applications/favoriteDomain/service/favorite_action_rdb.go b/applications/favorite/service/favorite_action_rdb.go similarity index 84% rename from applications/favoriteDomain/service/favorite_action_rdb.go rename to applications/favorite/service/favorite_action_rdb.go index 6c7ed0fe..da681a75 100644 --- a/applications/favoriteDomain/service/favorite_action_rdb.go +++ b/applications/favorite/service/favorite_action_rdb.go @@ -1,7 +1,7 @@ package service import ( - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/favorite/dal/model" "github.com/TremblingV5/DouTok/pkg/utils" "github.com/go-redis/redis/v8" ) @@ -39,12 +39,12 @@ func CreateFavoriteInRDB(user_id int64, video_id int64, is_fav bool) error { } if is_fav { - err = AddCount(video_id) + AddCount(video_id) } else { - err = ReduceCount(video_id) + ReduceCount(video_id) } - return err + return nil } else { // 尚未存在用户与视频之间的关系记录 id := utils.GetSnowFlakeId() @@ -62,9 +62,9 @@ func CreateFavoriteInRDB(user_id int64, video_id int64, is_fav bool) error { } if is_fav { - err = AddCount(video_id) + AddCount(video_id) } - return err + return nil } } diff --git a/applications/favorite/service/favorite_action_rdb_test.go b/applications/favorite/service/favorite_action_rdb_test.go new file mode 100644 index 00000000..92aadab0 --- /dev/null +++ b/applications/favorite/service/favorite_action_rdb_test.go @@ -0,0 +1,19 @@ +package service + +import ( + "log" + "testing" +) + +func TestCreateFavoriteInRDB(t *testing.T) { + Init() + + userId := int64(1111111111111111111) + videoId := int64(2222222222222222222) + op := true + + err := CreateFavoriteInRDB(userId, videoId, op) + if err != nil { + log.Panicln(err) + } +} diff --git a/applications/favorite/service/favorite_action_test.go b/applications/favorite/service/favorite_action_test.go new file mode 100644 index 00000000..fa4bf386 --- /dev/null +++ b/applications/favorite/service/favorite_action_test.go @@ -0,0 +1,25 @@ +package service + +import ( + "log" + "testing" +) + +func TestActionFavorite(t *testing.T) { + Init() + + userId := int64(1111111111111111111) + videoId := int64(2222222222222222222) + + errNo, err := ActionFavorite(userId, videoId, true) + if err != nil { + log.Panicln(err) + } + log.Println(errNo) + + errNo, err = ActionFavorite(userId, videoId, false) + if err != nil { + log.Panicln(err) + } + log.Println(errNo) +} diff --git a/applications/favoriteDomain/service/favorite_count.go b/applications/favorite/service/favorite_count.go similarity index 83% rename from applications/favoriteDomain/service/favorite_count.go rename to applications/favorite/service/favorite_count.go index cc78aa71..5b700cb4 100644 --- a/applications/favoriteDomain/service/favorite_count.go +++ b/applications/favorite/service/favorite_count.go @@ -3,24 +3,15 @@ package service import ( "context" "fmt" + "github.com/TremblingV5/DouTok/applications/favorite/dal/model" "strconv" "time" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/model" - - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" + "github.com/TremblingV5/DouTok/applications/favorite/misc" "github.com/go-redis/redis/v8" ) -type QueryFavoriteCountService struct { - ctx context.Context -} - -func NewQueryFavoriteCountService(ctx context.Context) *QueryFavoriteCountService { - return &QueryFavoriteCountService{ctx: ctx} -} - -func (s *QueryFavoriteCountService) QueryFavoriteCount(video_id []int64) (map[int64]int64, error) { +func QueryFavoriteCount(video_id []int64) (map[int64]int64, error) { resMap := make(map[int64]int64) // 1. 从内存中查找喜欢数 @@ -67,10 +58,7 @@ func (s *QueryFavoriteCountService) QueryFavoriteCount(video_id []int64) (map[in for _, v := range res { resMap[v.VideoId] = v.Number - if err := WriteCount2Cache(v.VideoId, v.Number); err != nil { - return nil, err - } - + WriteCount2Cache(v.VideoId, v.Number) } // 4. 如果仍然没有查找到该记录,则置0 @@ -83,8 +71,8 @@ func (s *QueryFavoriteCountService) QueryFavoriteCount(video_id []int64) (map[in return resMap, nil } -func ReadCountFromCache(videoId int64) (int64, bool, error) { - data, err := RedisClients[misc.FavTotalCntCache].Get(context.Background(), fmt.Sprint(videoId)) +func ReadCountFromCache(video_id int64) (int64, bool, error) { + data, err := RedisClients[misc.FavTotalCntCache].Get(context.Background(), fmt.Sprint(video_id)) if err == redis.Nil { return -1, false, nil diff --git a/applications/favorite/service/favorite_count_test.go b/applications/favorite/service/favorite_count_test.go new file mode 100644 index 00000000..e9f11d9b --- /dev/null +++ b/applications/favorite/service/favorite_count_test.go @@ -0,0 +1,41 @@ +package service + +import ( + "github.com/go-redis/redis/v8" + "log" + "testing" +) + +func TestQueryFavoriteCount(t *testing.T) { + Init() + + video_id := int64(2222222222222222222) + list := []int64{video_id} + + res, err := QueryFavoriteCount(list) + if err != nil && err != redis.Nil { + log.Panicln(err) + } + + log.Println(res) +} + +func TestReadCountFromCache(t *testing.T) { + Init() + video_id := int64(1111111111111111111) + num, ok, err := ReadCountFromCache(video_id) + if err != nil { + log.Panicln(err) + } + log.Println(num, ok) +} + +func TestReadFavTotalCount(t *testing.T) { + Init() + video_id := int64(1111111111111111111) + num, ok, err := ReadFavTotalCount(video_id) + if err != nil { + log.Panicln(err) + } + log.Println(num, ok) +} diff --git a/applications/favoriteDomain/service/favorite_list_cache.go b/applications/favorite/service/favorite_list_cache.go similarity index 91% rename from applications/favoriteDomain/service/favorite_list_cache.go rename to applications/favorite/service/favorite_list_cache.go index c23bd9e2..b86074f6 100644 --- a/applications/favoriteDomain/service/favorite_list_cache.go +++ b/applications/favorite/service/favorite_list_cache.go @@ -5,7 +5,7 @@ import ( "fmt" "strconv" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" + "github.com/TremblingV5/DouTok/applications/favorite/misc" ) func QueryFavListInCache(user_id int64) ([]int64, error) { diff --git a/applications/favorite/service/favorite_list_cache_test.go b/applications/favorite/service/favorite_list_cache_test.go new file mode 100644 index 00000000..ed097d0d --- /dev/null +++ b/applications/favorite/service/favorite_list_cache_test.go @@ -0,0 +1,32 @@ +package service + +import ( + "log" + "testing" +) + +func TestQueryFavListInCache(t *testing.T) { + Init() + + userId := int64(1111111111111111111) + res, err := QueryFavListInCache(userId) + if err != nil { + log.Panicln(err) + } + + log.Println(res) +} + +func TestWriteFavListInCache(t *testing.T) { + Init() + + userId := int64(1111111111111111111) + list := []int64{ + int64(2222222222222222222), int64(2222222222222222223), + } + err := WriteFavListInCache(userId, list) + + if err != nil { + log.Panicln(err) + } +} diff --git a/applications/favoriteDomain/service/favorite_list_rdb.go b/applications/favorite/service/favorite_list_rdb.go similarity index 100% rename from applications/favoriteDomain/service/favorite_list_rdb.go rename to applications/favorite/service/favorite_list_rdb.go diff --git a/applications/favorite/service/init.go b/applications/favorite/service/init.go new file mode 100644 index 00000000..9d5db112 --- /dev/null +++ b/applications/favorite/service/init.go @@ -0,0 +1,97 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/favorite/dal/query" + "github.com/TremblingV5/DouTok/applications/favorite/misc" + "github.com/TremblingV5/DouTok/pkg/kafka" + "github.com/TremblingV5/DouTok/pkg/mysqlIniter" + redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" + "github.com/TremblingV5/DouTok/pkg/safeMap" + "github.com/TremblingV5/DouTok/pkg/utils" +) + +func Init() { + misc.InitViperConfig() + + InitDb( + misc.GetConfig(misc.ConfigIndex_MySQLUsername), + misc.GetConfig(misc.ConfigIndex_MySQLPassword), + misc.GetConfig(misc.ConfigIndex_MySQLHost), + misc.GetConfig(misc.ConfigIndex_MySQLPort), + misc.GetConfig(misc.ConfigIndex_MySQLDb), + ) + + redisMap := map[string]int{ + misc.FavCache: int(misc.GetConfigNum(misc.ConfigIndex_RedisFavCacheDbNum)), + misc.FavCntCache: int(misc.GetConfigNum(misc.ConfigIndex_RedisFavCntCacheDbNum)), + misc.FavTotalCntCache: int(misc.GetConfigNum("Redis.FavTotalCountCache.Num")), + } + InitRedis( + misc.GetConfig(misc.ConfigIndex_RedisDest), + misc.GetConfig(misc.ConfigIndex_RedisPassword), + redisMap, + ) + InitMemoryMap() + + kafkaBrokers := []string{ + misc.GetConfig("Kafka.Broker"), + } + InitKafka(kafkaBrokers) + + utils.InitSnowFlake( + misc.GetConfigNum(misc.ConfigIndex_SnowFlake), + ) +} + +func InitDb(username string, password string, host string, port string, database string) error { + db, err := mysqlIniter.InitDb( + username, password, host, port, database, + ) + + if err != nil { + return err + } + + DB = db + + query.SetDefault(DB) + + Favorite = query.Favorite + FavoriteCnt = query.FavoriteCount + + DoFavorite = Favorite.WithContext(context.Background()) + DoFavoriteCnt = FavoriteCnt.WithContext(context.Background()) + + return nil +} + +func InitRedis(dest string, password string, dbs map[string]int) error { + redisCaches, _ := redishandle.InitRedis( + dest, password, dbs, + ) + + RedisClients = redisCaches + + return nil +} + +func InitMemoryMap() { + favCount := safeMap.New() + favTotalCount := safeMap.New() + favRelationU2V := safeMap.New() + favRelationV2U := safeMap.New() + + FavCount = favCount + FavTotalCount = favTotalCount + FavRelationU2V = favRelationU2V + FavRelationV2U = favRelationV2U +} + +func InitKafka(brokers []string) { + fav_count_kafka_producer := kafka.InitSynProducer(brokers) + fav_count_kafka_consumer := kafka.InitConsumerGroup(brokers, misc.FavCountGroupName) + + FavCountKafkaProducer = fav_count_kafka_producer + FavCountKafkaConsumer = fav_count_kafka_consumer +} diff --git a/applications/favorite/service/init_test.go b/applications/favorite/service/init_test.go new file mode 100644 index 00000000..8ef9d018 --- /dev/null +++ b/applications/favorite/service/init_test.go @@ -0,0 +1,7 @@ +package service + +import "testing" + +func TestInit(t *testing.T) { + Init() +} diff --git a/applications/favoriteDomain/service/is_favorite.go b/applications/favorite/service/is_favorite.go similarity index 69% rename from applications/favoriteDomain/service/is_favorite.go rename to applications/favorite/service/is_favorite.go index 3b25b6cc..a65d12fe 100644 --- a/applications/favoriteDomain/service/is_favorite.go +++ b/applications/favorite/service/is_favorite.go @@ -3,18 +3,10 @@ package service import ( "context" "fmt" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" + "github.com/TremblingV5/DouTok/applications/favorite/misc" ) -type QueryIsFavoriteService struct { - ctx context.Context -} - -func NewQueryIsFavoriteService(ctx context.Context) *QueryIsFavoriteService { - return &QueryIsFavoriteService{ctx: ctx} -} - -func (s *QueryIsFavoriteService) QueryIsFavorite(user_id int64, videoIdList []int64) (map[int64]bool, error) { +func QueryIsFavorite(user_id int64, videoIdList []int64) (map[int64]bool, error) { resMap := make(map[int64]bool) userIdFavoritedInCache, err := RedisClients[misc.FavCache].HGetAll(context.Background(), fmt.Sprint(user_id)) diff --git a/applications/favorite/service/is_favorite_test.go b/applications/favorite/service/is_favorite_test.go new file mode 100644 index 00000000..65a8e7a4 --- /dev/null +++ b/applications/favorite/service/is_favorite_test.go @@ -0,0 +1,17 @@ +package service + +import ( + "log" + "testing" +) + +func TestQueryIsFavorite(t *testing.T) { + Init() + + res, err := QueryIsFavorite(int64(1111111111111111111), []int64{int64(2222222222222222222)}) + if err != nil { + log.Panicln(err) + } + + log.Println(res) +} diff --git a/applications/favoriteDomain/service/timer.go b/applications/favorite/service/timer.go similarity index 95% rename from applications/favoriteDomain/service/timer.go rename to applications/favorite/service/timer.go index 34a463c7..5a329b78 100644 --- a/applications/favoriteDomain/service/timer.go +++ b/applications/favorite/service/timer.go @@ -3,7 +3,7 @@ package service import ( "context" "fmt" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" + "github.com/TremblingV5/DouTok/applications/favorite/misc" "strconv" "time" diff --git a/applications/favorite/service/timer_test.go b/applications/favorite/service/timer_test.go new file mode 100644 index 00000000..7cebee51 --- /dev/null +++ b/applications/favorite/service/timer_test.go @@ -0,0 +1,15 @@ +package service + +import "testing" + +func TestUpdateFavMap(t *testing.T) { + Init() + FavCount.Set("111111111111111111", 22) + UpdateFavMap() +} + +func TestUpdateFavCntMap(t *testing.T) { + Init() + FavTotalCount.Set("111111111111111111", 22) + UpdateFavMap() +} diff --git a/applications/favoriteDomain/service/typedef.go b/applications/favorite/service/typedef.go similarity index 100% rename from applications/favoriteDomain/service/typedef.go rename to applications/favorite/service/typedef.go diff --git a/applications/favoriteDomain/service/var.go b/applications/favorite/service/var.go similarity index 91% rename from applications/favoriteDomain/service/var.go rename to applications/favorite/service/var.go index ae50cdd9..dc3f5437 100644 --- a/applications/favoriteDomain/service/var.go +++ b/applications/favorite/service/var.go @@ -2,7 +2,7 @@ package service import ( "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/query" + "github.com/TremblingV5/DouTok/applications/favorite/dal/query" redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" "github.com/TremblingV5/DouTok/pkg/safeMap" "gorm.io/gorm" diff --git a/applications/favoriteDomain/Makefile b/applications/favoriteDomain/Makefile deleted file mode 100644 index a3fd85b6..00000000 --- a/applications/favoriteDomain/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -server: - kitex -module github.com/TremblingV5/DouTok -type protobuf -I ../../proto/ -service favoriteDomain ../../proto/favoriteDomain.proto \ No newline at end of file diff --git a/applications/favoriteDomain/build.sh b/applications/favoriteDomain/build.sh deleted file mode 100644 index 2ed3ad7a..00000000 --- a/applications/favoriteDomain/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -RUN_NAME="favoriteDomain" - -mkdir -p output/bin -cp script/* output/ -chmod +x output/bootstrap.sh - -if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then - go build -o output/bin/${RUN_NAME} -else - go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... -fi - diff --git a/applications/favoriteDomain/cache/favorite_count_cache/cache.go b/applications/favoriteDomain/cache/favorite_count_cache/cache.go deleted file mode 100644 index 768b286a..00000000 --- a/applications/favoriteDomain/cache/favorite_count_cache/cache.go +++ /dev/null @@ -1,34 +0,0 @@ -package favorite_count_cache - -import ( - "fmt" - "github.com/TremblingV5/DouTok/pkg/cache" -) - -type Cache struct { - cache *cache.MapCache[int64] -} - -func New() *Cache { - return &Cache{ - cache: cache.NewMapCache[int64](), - } -} - -func (c *Cache) Get(videoId int64) (int64, bool) { - return c.cache.Get(fmt.Sprint(videoId)) -} - -func (c *Cache) Set(videoId, count int64) { - c.cache.Set(fmt.Sprint(videoId), count) -} - -func (c *Cache) SetBatch(bacth map[int64]int64) { - for k, v := range bacth { - c.cache.Set(fmt.Sprint(k), v) - } -} - -func (c *Cache) Clear() { - c.cache.Clear() -} diff --git a/applications/favoriteDomain/dal/migrate/main.go b/applications/favoriteDomain/dal/migrate/main.go deleted file mode 100644 index 8cfc13e9..00000000 --- a/applications/favoriteDomain/dal/migrate/main.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import ( - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/service" -) - -func main() { - - service.Init() - - if err := service.DB.AutoMigrate(&model.Favorite{}, &model.FavoriteCount{}); err != nil { - panic(err) - } -} diff --git a/applications/favoriteDomain/dal/repository/favorite/repository.go b/applications/favoriteDomain/dal/repository/favorite/repository.go deleted file mode 100644 index cd856d6b..00000000 --- a/applications/favoriteDomain/dal/repository/favorite/repository.go +++ /dev/null @@ -1,77 +0,0 @@ -package favorite - -import ( - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/query" - "github.com/TremblingV5/DouTok/pkg/utils" -) - -type Repository interface { - Load(userId, videoId int64) (bool, error) - DoFavorite(userId, videoId int64) error - UndoFavorite(userId, videoId int64) error - CountFavoriteForUserId(userId int64) (int64, error) - CountFavoriteForVideoId(videoId int64) (int64, error) - LoadFavoriteListByUserId(userId int64) ([]int64, error) -} - -type PersistRepository struct { - favorite query.IFavoriteDo - snowflakeHandle *utils.SnowflakeHandle -} - -func (r *PersistRepository) Load(userId, videoId int64) (*model.Favorite, error) { - record, err := r.favorite.Where(query.Favorite.UserId.Eq(userId), query.Favorite.VideoId.Eq(videoId)).First() - if err != nil { - return nil, err - } - - return record, nil -} - -func (r *PersistRepository) DoFavorite(userId, videoId int64) error { - return query.Q.Transaction(func(tx *query.Query) error { - favorite, err := r.Load(userId, videoId) - if err != nil { - e := tx.Favorite.Create(&model.Favorite{ID: r.snowflakeHandle.GetId().Int64(), UserId: userId, VideoId: videoId, Status: 1}) - if err != nil { - return e - } - return nil - } - _, err = tx.Favorite.Updates(&model.Favorite{ID: favorite.ID, Status: 1}) - return err - }) -} - -func (r *PersistRepository) UndoFavorite(userId, videoId int64) error { - return query.Q.Transaction(func(tx *query.Query) error { - favorite, err := r.Load(userId, videoId) - if err != nil { - e := tx.Favorite.Create(&model.Favorite{UserId: userId, VideoId: videoId, Status: 0}) - if err != nil { - return e - } - return nil - } - _, err = tx.Favorite.Updates(&model.Favorite{ID: favorite.ID, Status: 0}) - return err - }) -} - -func (r *PersistRepository) CountFavoriteForUserId(userId int64) (int64, error) { - return r.favorite.Where(query.Favorite.UserId.Eq(userId)).Count() -} - -func (r *PersistRepository) CountFavoriteForVideoId(videoId int64) (int64, error) { - return r.favorite.Where(query.Favorite.VideoId.Eq(videoId)).Count() -} - -func (r *PersistRepository) LoadFavoriteListByUserId(userId int64) ([]int64, error) { - var list []int64 - err := r.favorite.Select(query.Favorite.ID).Where(query.Favorite.UserId.Eq(userId)).Scan(&list) - if err != nil { - return nil, err - } - return list, nil -} diff --git a/applications/favoriteDomain/dal/repository/favorite_count/repository.go b/applications/favoriteDomain/dal/repository/favorite_count/repository.go deleted file mode 100644 index 72a019af..00000000 --- a/applications/favoriteDomain/dal/repository/favorite_count/repository.go +++ /dev/null @@ -1,50 +0,0 @@ -package favorite_count - -import ( - "errors" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/query" - "gorm.io/gorm" -) - -type Repository interface { - Load(videoId int64) (int64, error) - Update(videoId, count int64) error -} - -type PersistRepository struct { - FavoriteCount query.IFavoriteCountDo -} - -func (r *PersistRepository) Load(videoId int64) (int64, error) { - count, err := r.FavoriteCount.Where(query.FavoriteCount.VideoId.Eq(videoId)).First() - if err != nil { - return 0, err - } - - return count.Number, nil -} - -func (r *PersistRepository) Update(videoId, count int64) error { - return query.Q.Transaction(func(tx *query.Query) error { - number, err := tx.FavoriteCount.Where(query.FavoriteCount.VideoId.Eq(videoId)).First() - if !errors.Is(err, gorm.ErrRecordNotFound) { - return err - } - - if errors.Is(err, gorm.ErrRecordNotFound) { - if err := tx.FavoriteCount.Create(&model.FavoriteCount{ - VideoId: videoId, - Number: count, - }); err != nil { - return err - } - } - - _, err = tx.FavoriteCount.Updates(&model.FavoriteCount{ - VideoId: videoId, - Number: number.Number + count, - }) - return err - }) -} diff --git a/applications/favoriteDomain/handler/add_favorite.go b/applications/favoriteDomain/handler/add_favorite.go deleted file mode 100644 index 7ae940a9..00000000 --- a/applications/favoriteDomain/handler/add_favorite.go +++ /dev/null @@ -1,13 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/pack" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" -) - -func (s *FavoriteDomainServiceImpl) AddFavorite(ctx context.Context, req *favoriteDomain.DoutokAddFavRequest) (resp *favoriteDomain.DoutokAddFavResponse, err error) { - errNo, _ := service.NewActionFavoriteService(ctx).ActionFavorite(req.UserId, req.VideoId, true) - return pack.PackageAddFavoriteResp(errNo) -} diff --git a/applications/favoriteDomain/handler/count_favorite.go b/applications/favoriteDomain/handler/count_favorite.go deleted file mode 100644 index 50a10d97..00000000 --- a/applications/favoriteDomain/handler/count_favorite.go +++ /dev/null @@ -1,21 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/pack" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" -) - -func (s *FavoriteDomainServiceImpl) CountFavorite(ctx context.Context, req *favoriteDomain.DoutokCountFavRequest) (resp *favoriteDomain.DoutokCountFavResponse, err error) { - if len(req.UserIdList) <= 0 { - return pack.PackageCountFavoriteResp(&misc.EmptyVideoIdListErr, nil) - } - - res, err := service.NewQueryFavoriteCountService(ctx).QueryFavoriteCount(req.UserIdList) - if err != nil { - return pack.PackageCountFavoriteResp(&misc.SystemErr, nil) - } - return pack.PackageCountFavoriteResp(&misc.Success, res) -} diff --git a/applications/favoriteDomain/handler/is_favorite.go b/applications/favoriteDomain/handler/is_favorite.go deleted file mode 100644 index bbe9863b..00000000 --- a/applications/favoriteDomain/handler/is_favorite.go +++ /dev/null @@ -1,18 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/pack" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" -) - -func (s *FavoriteDomainServiceImpl) IsFavorite(ctx context.Context, req *favoriteDomain.DoutokIsFavRequest) (resp *favoriteDomain.DoutokIsFavResponse, err error) { - res, err := service.NewQueryIsFavoriteService(ctx).QueryIsFavorite(req.UserId, req.VideoId) - if err != nil { - return pack.PackageIsFavoriteResp(&misc.SystemErr, nil) - } - - return pack.PackageIsFavoriteResp(&misc.Success, res) -} diff --git a/applications/favoriteDomain/handler/list_favorite.go b/applications/favoriteDomain/handler/list_favorite.go deleted file mode 100644 index daf82531..00000000 --- a/applications/favoriteDomain/handler/list_favorite.go +++ /dev/null @@ -1,34 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/pack" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" -) - -func (s *FavoriteDomainServiceImpl) ListFavorite(ctx context.Context, req *favoriteDomain.DoutokListFavRequest) (resp *favoriteDomain.DoutokListFavResponse, err error) { - // 1. 查缓存 - res, _ := service.QueryFavListInCache(req.UserId) - - // 2. 如果缓存有则直接返回 - if len(res) > 0 { - return pack.PackageListFavoriteResp(&misc.Success, res) - } - - // 3. 如果缓存没有则查库 - res, err = service.QueryFavListInRDB(req.UserId) - // 4. 将从RDB查询到的数据读入缓存 - for _, v := range res { - if err := service.WriteFavoriteInCache(req.UserId, v, true); err != nil { - continue - } - } - - if err != nil { - return pack.PackageListFavoriteResp(&misc.SystemErr, nil) - } - - return pack.PackageListFavoriteResp(&misc.Success, res) -} diff --git a/applications/favoriteDomain/handler/rm_favorite.go b/applications/favoriteDomain/handler/rm_favorite.go deleted file mode 100644 index d6c21372..00000000 --- a/applications/favoriteDomain/handler/rm_favorite.go +++ /dev/null @@ -1,13 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/pack" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" -) - -func (s *FavoriteDomainServiceImpl) RmFavorite(ctx context.Context, req *favoriteDomain.DoutokRmFavRequest) (resp *favoriteDomain.DoutokRmFavResponse, err error) { - errNo, _ := service.NewActionFavoriteService(ctx).ActionFavorite(req.UserId, req.VideoId, false) - return pack.PackageRmFavoriteResp(errNo) -} diff --git a/applications/favoriteDomain/handler/typedef.go b/applications/favoriteDomain/handler/typedef.go deleted file mode 100644 index 4cd37c61..00000000 --- a/applications/favoriteDomain/handler/typedef.go +++ /dev/null @@ -1,3 +0,0 @@ -package handler - -type FavoriteDomainServiceImpl struct{} diff --git a/applications/favoriteDomain/main.go b/applications/favoriteDomain/main.go deleted file mode 100644 index dd5c4812..00000000 --- a/applications/favoriteDomain/main.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "github.com/TremblingV5/DouTok/applications/favoriteDomain/handler" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain/favoritedomainservice" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/dlog" - "github.com/TremblingV5/DouTok/pkg/services" -) - -var ( - Logger = dlog.InitLog(3) -) - -func init() { - service.Init() -} - -func main() { - - options, shutdown := services.InitRPCServerArgs(constants.FAVORITE_DOMAIN_SERVER_NAME, service.DomainConfig.BaseConfig) - defer shutdown() - - svr := favoritedomainservice.NewServer( - new(handler.FavoriteDomainServiceImpl), - options..., - ) - - if err := svr.Run(); err != nil { - Logger.Fatal(err) - } -} diff --git a/applications/favoriteDomain/misc/const.go b/applications/favoriteDomain/misc/const.go deleted file mode 100644 index 98f8d3c9..00000000 --- a/applications/favoriteDomain/misc/const.go +++ /dev/null @@ -1,11 +0,0 @@ -package misc - -var ( - FavCountTopicName = "fav_count" - FavCountGroupName = "fav_count01" - - ConfigIndex_RedisFavCacheDbNum = "Redis.FavCache.Num" - ConfigIndex_RedisFavCntCacheDbNum = "Redis.FavCntCache.Num" - - ConfigIndex_SnowFlake = "Snowflake.Node" -) diff --git a/applications/favoriteDomain/misc/err.go b/applications/favoriteDomain/misc/err.go deleted file mode 100644 index d2261261..00000000 --- a/applications/favoriteDomain/misc/err.go +++ /dev/null @@ -1,27 +0,0 @@ -package misc - -import "github.com/TremblingV5/DouTok/pkg/errno" - -var ( - NilErrCode = -1 - SuccessCode = 0 - ParamsErrCode = 27001 - SystemErrCode = 27002 - EmptyVideoIdListErrCode = 27003 - BindingInvalidErrCode = 27004 - QueryCacheErrCode = 27005 - CreateFavoriteInRDBErrCode = 27006 - WriteRDBErrCode = 27007 -) - -var ( - NilErr = errno.New(NilErrCode, "Don't care") - Success = errno.New(SuccessCode, "Success") - ParamsErr = errno.New(ParamsErrCode, "Invalid parameters") - SystemErr = errno.New(SystemErrCode, "System error") - EmptyVideoIdListErr = errno.New(EmptyVideoIdListErrCode, "Empty video id list") - BindingInvalidErr = errno.New(BindingInvalidErrCode, "Action type is invalid") - QueryCacheErr = errno.New(QueryCacheErrCode, "Query cache defeat") - CreateFavoriteInRDBErr = errno.New(CreateFavoriteInRDBErrCode, "Create new favorite relation in rdb defeat") - WriteRDBErr = errno.New(WriteRDBErrCode, "Write rdb defeat") -) diff --git a/applications/favoriteDomain/pack/add_favorite.go b/applications/favoriteDomain/pack/add_favorite.go deleted file mode 100644 index bd3f2caa..00000000 --- a/applications/favoriteDomain/pack/add_favorite.go +++ /dev/null @@ -1,13 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func PackageAddFavoriteResp(errNo *errno.ErrNo) (resp *favoriteDomain.DoutokAddFavResponse, err error) { - return &favoriteDomain.DoutokAddFavResponse{ - StatusCode: int32(errNo.ErrCode), - StatusMsg: errNo.ErrMsg, - }, nil -} diff --git a/applications/favoriteDomain/pack/count_favorite.go b/applications/favoriteDomain/pack/count_favorite.go deleted file mode 100644 index 6633def3..00000000 --- a/applications/favoriteDomain/pack/count_favorite.go +++ /dev/null @@ -1,14 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func PackageCountFavoriteResp(errNo *errno.ErrNo, data map[int64]int64) (resp *favoriteDomain.DoutokCountFavResponse, err error) { - return &favoriteDomain.DoutokCountFavResponse{ - StatusCode: int32(errNo.ErrCode), - StatusMsg: errNo.ErrMsg, - CountFav: data, - }, nil -} diff --git a/applications/favoriteDomain/pack/is_favorite.go b/applications/favoriteDomain/pack/is_favorite.go deleted file mode 100644 index 48cdec1d..00000000 --- a/applications/favoriteDomain/pack/is_favorite.go +++ /dev/null @@ -1,14 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func PackageIsFavoriteResp(errNo *errno.ErrNo, data map[int64]bool) (resp *favoriteDomain.DoutokIsFavResponse, err error) { - return &favoriteDomain.DoutokIsFavResponse{ - StatusCode: int32(errNo.ErrCode), - StatusMsg: errNo.ErrMsg, - IsFav: data, - }, nil -} diff --git a/applications/favoriteDomain/pack/list_favorite.go b/applications/favoriteDomain/pack/list_favorite.go deleted file mode 100644 index 9b9abaa5..00000000 --- a/applications/favoriteDomain/pack/list_favorite.go +++ /dev/null @@ -1,23 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func PackageListFavoriteResp(errNo *errno.ErrNo, data []int64) (resp *favoriteDomain.DoutokListFavResponse, err error) { - var result []*entity.Video - - for _, v := range data { - result = append(result, &entity.Video{ - Id: v, - }) - } - - return &favoriteDomain.DoutokListFavResponse{ - StatusCode: int32(errNo.ErrCode), - StatusMsg: errNo.ErrMsg, - VideoList: result, - }, nil -} diff --git a/applications/favoriteDomain/pack/rm_favorite.go b/applications/favoriteDomain/pack/rm_favorite.go deleted file mode 100644 index 191e25b3..00000000 --- a/applications/favoriteDomain/pack/rm_favorite.go +++ /dev/null @@ -1,13 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func PackageRmFavoriteResp(errNo *errno.ErrNo) (resp *favoriteDomain.DoutokRmFavResponse, err error) { - return &favoriteDomain.DoutokRmFavResponse{ - StatusCode: int32(errNo.ErrCode), - StatusMsg: errNo.ErrMsg, - }, nil -} diff --git a/applications/favoriteDomain/redis/favorite_count_redis/redis.go b/applications/favoriteDomain/redis/favorite_count_redis/redis.go deleted file mode 100644 index fd3d65f6..00000000 --- a/applications/favoriteDomain/redis/favorite_count_redis/redis.go +++ /dev/null @@ -1,39 +0,0 @@ -package favorite_count_redis - -import ( - "context" - "fmt" - "github.com/go-redis/redis/v8" - "time" -) - -type Redis struct { - client *redis.Client -} - -func New(client *redis.Client) *Redis { - return &Redis{ - client: client, - } -} - -func getRedisKey(videoId int64) string { - return fmt.Sprint("favorite_count_", videoId) -} - -func (r *Redis) Get(ctx context.Context, videoId int64) (int64, bool) { - value, err := r.client.Get(ctx, getRedisKey(videoId)).Int64() - if err != nil { - return 0, false - } - - return value, true -} - -func (r *Redis) Set(ctx context.Context, videoId, count int64, ttl time.Duration) error { - return r.client.Set(ctx, getRedisKey(videoId), count, ttl).Err() -} - -func (r *Redis) Clear(ctx context.Context) error { - return r.client.FlushAll(ctx).Err() -} diff --git a/applications/favoriteDomain/redis/favorite_redis/redis.go b/applications/favoriteDomain/redis/favorite_redis/redis.go deleted file mode 100644 index 58ed69a6..00000000 --- a/applications/favoriteDomain/redis/favorite_redis/redis.go +++ /dev/null @@ -1,34 +0,0 @@ -package favorite_redis - -import ( - "context" - "fmt" - "github.com/go-redis/redis/v8" - "time" -) - -type Redis struct { - client *redis.Client -} - -func New(client *redis.Client) *Redis { - return &Redis{ - client: client, - } -} - -func getKey(userId, videoId int64) string { - return fmt.Sprint("favorite_userId_", userId, "_videoId_", videoId) -} - -func (r *Redis) Load(ctx context.Context, userId, videoId int64) (bool, error) { - return r.client.Get(ctx, getKey(userId, videoId)).Bool() -} - -func (r *Redis) Put(ctx context.Context, userId, videoId int64, ttl time.Duration) error { - return r.client.Set(ctx, getKey(userId, videoId), 1, ttl).Err() -} - -func (r *Redis) Remove(ctx context.Context, userId, videoId int64, ttl time.Duration) error { - return r.client.Set(ctx, getKey(userId, videoId), 0, ttl).Err() -} diff --git a/applications/favoriteDomain/script/bootstrap.sh b/applications/favoriteDomain/script/bootstrap.sh deleted file mode 100644 index cdfbff51..00000000 --- a/applications/favoriteDomain/script/bootstrap.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env bash -CURDIR=$(cd $(dirname $0); pwd) - -if [ "X$1" != "X" ]; then - RUNTIME_ROOT=$1 -else - RUNTIME_ROOT=${CURDIR} -fi - -export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT -export KITEX_LOG_DIR="$RUNTIME_ROOT/log" - -if [ ! -d "$KITEX_LOG_DIR/app" ]; then - mkdir -p "$KITEX_LOG_DIR/app" -fi - -if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then - mkdir -p "$KITEX_LOG_DIR/rpc" -fi - -exec "$CURDIR/bin/favoriteDomain" - diff --git a/applications/favoriteDomain/service/init.go b/applications/favoriteDomain/service/init.go deleted file mode 100644 index 896ffb1b..00000000 --- a/applications/favoriteDomain/service/init.go +++ /dev/null @@ -1,108 +0,0 @@ -package service - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/query" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/misc" - "github.com/TremblingV5/DouTok/config/configStruct" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/TremblingV5/DouTok/pkg/dtviper" - "github.com/TremblingV5/DouTok/pkg/kafka" - redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" - "github.com/TremblingV5/DouTok/pkg/safeMap" - "github.com/TremblingV5/DouTok/pkg/utils" - "go.uber.org/zap" -) - -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_FAVORITEDOMAIN_"` - Redis configStruct.Redis `envPrefix:"DOUTOK_FAVORITEDOMAIN_"` - MySQL configStruct.MySQL `envPrefix:"DOUTOK_FAVORITEDOMAIN_"` - HBase configStruct.HBase `envPrefix:"DOUTOK_FAVORITEDOMAIN_"` -} - -var ( - ViperConfig *dtviper.Config - DomainConfig = &Config{} -) - -func Init() { - - v, err := configurator.Load(DomainConfig, "DOUTOK_FAVORITEDOMAIN", "favoriteDomain") - ViperConfig = v - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", DomainConfig)) - } - - if err := InitDb(); err != nil { - panic(err) - } - - redisMap := map[string]int{ - misc.FavCache: ViperConfig.Viper.GetInt(misc.ConfigIndex_RedisFavCacheDbNum), - misc.FavCntCache: ViperConfig.Viper.GetInt(misc.ConfigIndex_RedisFavCntCacheDbNum), - misc.FavTotalCntCache: ViperConfig.Viper.GetInt("Redis.FavTotalCountCache.Num"), - } - - InitRedis(redisMap) - - InitMemoryMap() - - kafkaBrokers := []string{ - ViperConfig.Viper.GetString("Kafka.Broker"), - } - InitKafka(kafkaBrokers) - - utils.InitSnowFlake( - ViperConfig.Viper.GetInt64(misc.ConfigIndex_SnowFlake), - ) -} - -func InitDb() error { - db, err := DomainConfig.MySQL.InitDB() - - if err != nil { - return err - } - - DB = db - - query.SetDefault(DB) - - Favorite = query.Favorite - FavoriteCnt = query.FavoriteCount - - DoFavorite = Favorite.WithContext(context.Background()) - DoFavoriteCnt = FavoriteCnt.WithContext(context.Background()) - - return nil -} - -func InitRedis(dbs map[string]int) { - RedisClients = make(map[string]*redishandle.RedisClient) - for k, v := range dbs { - RedisClients[k] = &redishandle.RedisClient{ - Client: DomainConfig.Redis.InitRedisClient(v), - } - } -} - -func InitMemoryMap() { - favCount := safeMap.New() - favTotalCount := safeMap.New() - favRelationU2V := safeMap.New() - favRelationV2U := safeMap.New() - - FavCount = favCount - FavTotalCount = favTotalCount - FavRelationU2V = favRelationU2V - FavRelationV2U = favRelationV2U -} - -func InitKafka(brokers []string) { - fav_count_kafka_producer := kafka.InitSynProducer(brokers) - fav_count_kafka_consumer := kafka.InitConsumerGroup(brokers, misc.FavCountGroupName) - - FavCountKafkaProducer = fav_count_kafka_producer - FavCountKafkaConsumer = fav_count_kafka_consumer -} diff --git a/applications/favoriteDomain/service/service.go b/applications/favoriteDomain/service/service.go deleted file mode 100644 index 48484eab..00000000 --- a/applications/favoriteDomain/service/service.go +++ /dev/null @@ -1,56 +0,0 @@ -package service - -import ( - "context" - - "github.com/TremblingV5/DouTok/applications/favoriteDomain/cache/favorite_count_cache" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/repository/favorite" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/dal/repository/favorite_count" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/redis/favorite_count_redis" - "github.com/TremblingV5/DouTok/applications/favoriteDomain/redis/favorite_redis" -) - -type Service struct { - favorite favorite.Repository - favoriteCount favorite_count.Repository //nolint - favoriteCountCache *favorite_count_cache.Cache //nolint - favoriteRedis *favorite_redis.Redis - favoriteCountRedis *favorite_count_redis.Redis //nolint -} - -type IService interface { - CreateFavorite(ctx context.Context, userId, videoId int64) error - RemoveFavorite(ctx context.Context, userId, videoId int64) error - CountFavorite(ctx context.Context, videoId []int64) (map[int64]int64, error) - ListFavorite(ctx context.Context, userId int64) ([]int64, error) - IsFavorite(ctx context.Context, userId, videoId int64) (bool, error) -} - -func New() *Service { - return &Service{} -} - -func (s *Service) CreateFavorite(ctx context.Context, userId, videoId int64) error { - return nil -} - -func (s *Service) RemoveFavorite(ctx context.Context, userId, videoId int64) error { - return nil -} - -func (s *Service) CountFavorite(ctx context.Context, videoId []int64) (map[int64]int64, error) { - return nil, nil -} - -func (s *Service) ListFavorite(ctx context.Context, userId int64) ([]int64, error) { - return nil, nil -} - -func (s *Service) IsFavorite(ctx context.Context, userId, videoId int64) (bool, error) { - cached, err := s.favoriteRedis.Load(ctx, userId, videoId) - if err == nil && cached { - return true, nil - } - - return s.favorite.Load(userId, videoId) -} diff --git a/applications/feed/build.sh b/applications/feed/build.sh index 0f4843a1..61170524 100644 --- a/applications/feed/build.sh +++ b/applications/feed/build.sh @@ -10,4 +10,3 @@ if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then else go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... fi - diff --git a/applications/videoDomain/dal/gen.go b/applications/feed/dal/gen.go similarity index 70% rename from applications/videoDomain/dal/gen.go rename to applications/feed/dal/gen.go index 311e0ecd..afc16f95 100644 --- a/applications/videoDomain/dal/gen.go +++ b/applications/feed/dal/gen.go @@ -1,7 +1,7 @@ package main import ( - "github.com/TremblingV5/DouTok/applications/videoDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/feed/dal/model" "github.com/TremblingV5/DouTok/config/configStruct" "github.com/TremblingV5/DouTok/pkg/configurator" "github.com/TremblingV5/DouTok/pkg/mysqlIniter" @@ -15,11 +15,9 @@ func main() { }) var config configStruct.MySQLConfig - if err := configurator.InitConfig( + configurator.InitConfig( &config, "mysql.yaml", - ); err != nil { - panic(err) - } + ) db, err := mysqlIniter.InitDb( config.Username, @@ -34,8 +32,8 @@ func main() { } g.UseDB(db) - g.ApplyBasic(model.Video{}, model.VideoCount{}) - g.ApplyInterface(func() {}, model.Video{}, model.VideoCount{}) + g.ApplyBasic(model.Video{}) + g.ApplyInterface(func() {}, model.Video{}) g.Execute() } diff --git a/applications/videoDomain/dal/model/video.go b/applications/feed/dal/model/video.go similarity index 100% rename from applications/videoDomain/dal/model/video.go rename to applications/feed/dal/model/video.go diff --git a/applications/videoDomain/dal/query/gen.go b/applications/feed/dal/query/gen.go similarity index 69% rename from applications/videoDomain/dal/query/gen.go rename to applications/feed/dal/query/gen.go index 7da9ff43..cc7ae460 100644 --- a/applications/videoDomain/dal/query/gen.go +++ b/applications/feed/dal/query/gen.go @@ -16,67 +16,59 @@ import ( ) var ( - Q = new(Query) - Video *video - VideoCount *videoCount + Q = new(Query) + Video *video ) func SetDefault(db *gorm.DB, opts ...gen.DOOption) { *Q = *Use(db, opts...) Video = &Q.Video - VideoCount = &Q.VideoCount } func Use(db *gorm.DB, opts ...gen.DOOption) *Query { return &Query{ - db: db, - Video: newVideo(db, opts...), - VideoCount: newVideoCount(db, opts...), + db: db, + Video: newVideo(db, opts...), } } type Query struct { db *gorm.DB - Video video - VideoCount videoCount + Video video } func (q *Query) Available() bool { return q.db != nil } func (q *Query) clone(db *gorm.DB) *Query { return &Query{ - db: db, - Video: q.Video.clone(db), - VideoCount: q.VideoCount.clone(db), + db: db, + Video: q.Video.clone(db), } } func (q *Query) ReadDB() *Query { - return q.ReplaceDB(q.db.Clauses(dbresolver.Read)) + return q.clone(q.db.Clauses(dbresolver.Read)) } func (q *Query) WriteDB() *Query { - return q.ReplaceDB(q.db.Clauses(dbresolver.Write)) + return q.clone(q.db.Clauses(dbresolver.Write)) } func (q *Query) ReplaceDB(db *gorm.DB) *Query { return &Query{ - db: db, - Video: q.Video.replaceDB(db), - VideoCount: q.VideoCount.replaceDB(db), + db: db, + Video: q.Video.replaceDB(db), } } type queryCtx struct { - Video IVideoDo - VideoCount IVideoCountDo + Video IVideoDo } func (q *Query) WithContext(ctx context.Context) *queryCtx { return &queryCtx{ - Video: q.Video.WithContext(ctx), - VideoCount: q.VideoCount.WithContext(ctx), + Video: q.Video.WithContext(ctx), } } diff --git a/applications/videoDomain/dal/query/typedef.go b/applications/feed/dal/query/typedef.go similarity index 53% rename from applications/videoDomain/dal/query/typedef.go rename to applications/feed/dal/query/typedef.go index 50a5d331..77547dba 100644 --- a/applications/videoDomain/dal/query/typedef.go +++ b/applications/feed/dal/query/typedef.go @@ -1,4 +1,3 @@ package query var VideoStruct = &video{} -var VideoCountStruct = &videoCount{} diff --git a/applications/videoDomain/dal/query/videos.gen.go b/applications/feed/dal/query/videos.gen.go similarity index 99% rename from applications/videoDomain/dal/query/videos.gen.go rename to applications/feed/dal/query/videos.gen.go index e120c90e..ac580544 100644 --- a/applications/videoDomain/dal/query/videos.gen.go +++ b/applications/feed/dal/query/videos.gen.go @@ -16,7 +16,7 @@ import ( "gorm.io/plugin/dbresolver" - "github.com/TremblingV5/DouTok/applications/videoDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/feed/dal/model" ) func newVideo(db *gorm.DB, opts ...gen.DOOption) video { diff --git a/applications/feed/handler/get_user_feed.go b/applications/feed/handler/get_user_feed.go index 465dea97..6c5ee10f 100644 --- a/applications/feed/handler/get_user_feed.go +++ b/applications/feed/handler/get_user_feed.go @@ -2,16 +2,98 @@ package handler import ( "context" + "fmt" + "time" + "github.com/TremblingV5/DouTok/applications/feed/pack" - "github.com/TremblingV5/DouTok/applications/feed/rpc" + + "github.com/TremblingV5/DouTok/applications/feed/misc" + "github.com/TremblingV5/DouTok/applications/feed/service" "github.com/TremblingV5/DouTok/kitex_gen/feed" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" ) func (s *FeedServiceImpl) GetUserFeed(ctx context.Context, req *feed.DouyinFeedRequest) (res *feed.DouyinFeedResponse, err error) { - result, err := rpc.VideoDomainClient.GetFeed(ctx, &videoDomain.DoutokGetFeedRequest{ - LatestTime: req.LatestTime, - UserId: req.UserId, - }) - return pack.PackageFeedListResp(ctx, result, req.UserId, err) + log_list := []string{} + + if req.LatestTime == 0 { + req.LatestTime = time.Now().Unix() + } + + user_id_string := misc.FillUserId(fmt.Sprint(req.UserId)) + + // 1. 从Redis中获取Feed列表(通过LPop) + var list []service.VideoInHB + var ok bool + list, ok = service.GetFeedCache(ctx, user_id_string, 10) + + // 2. 【视频条数不足】从hbase中从latest_time开始,以24h的周期向前查询,直至条数满足或超过current_time - 14 * 24h + if !ok { + listFromHB, err := service.SearchFeedEarlierInHB(req.LatestTime, req.LatestTime-7*86400) + if err != nil { + return pack.PackFeedListResp([]service.VideoInHB{}, 1, "search hbase defeat", req.UserId) + } + + // 3. 取前10条视频作为本次feed的数据,其余的通过RPush进入投递箱 + err = service.SetFeedCache(ctx, "r", user_id_string, listFromHB...) + if err != nil { + return pack.PackFeedListResp([]service.VideoInHB{}, 1, "set send box defeat", req.UserId) + } + + var newListNum int64 + if len(listFromHB) >= 10 { + newListNum = 10 + } else { + newListNum = int64(len(listFromHB)) + } + list, ok = service.GetFeedCache(ctx, user_id_string, newListNum) + + if !ok { + return pack.PackFeedListResp([]service.VideoInHB{}, 1, "get send box defeat", req.UserId) + } + } + + // 4. 计算current_time与marked_time的差值是否超过6个小时,如是则进行查询 + current_time := time.Now().Unix() + marked_time, err := service.GetMarkedTime(ctx, user_id_string) + if err != nil { + marked_time = fmt.Sprint(current_time) + } + + if err != nil { + marked_time = fmt.Sprint(current_time) + if err := service.SetMarkedTime(ctx, user_id_string, marked_time); err != nil { + // TODO: 此处只进行日志记录,并向返回信息中说明 + log_list = append(log_list, "user_id为"+user_id_string+"的用户设置新的marked_time失败") + } + } + + if service.JudgeTimeDiff(current_time, marked_time, 60*60*6) { + // 时间差值已经超过了6个小时 + laterVideoListInHB, new_marked_time, err := service.SearchFeedLaterInHB(marked_time, fmt.Sprint(current_time)) + + if err != nil { + // TODO: 此处只进行日志记录,并向返回信息中说明 + log_list = append(log_list, "user_id为"+user_id_string+"的用户SearchFeedlaterInHB失败") + } + + if err := service.SetMarkedTime(ctx, user_id_string, new_marked_time); err != nil { + // TODO: 此处只进行日志记录,并向返回信息中说明 + log_list = append(log_list, "user_id为"+user_id_string+"的用户SetMarkedTime失败") + } + + // 5. 若存在新更新的内容,将结果存入投递箱,根据比例选择RPush或LPush + if err := service.SetFeedCache(ctx, "r", user_id_string, laterVideoListInHB...); err != nil { + // TODO: 此处只进行日志记录,并向返回信息中说明 + log_list = append(log_list, "user_id为"+user_id_string+"的用户SetFeedCache失败") + } + } + + //log_string := "" + //for _, v := range log_list { + // log_string += v + // log_string += ";" + //} + //dlog.Warn(log_string) + + return pack.PackFeedListResp(list, 0, "Success", req.UserId) } diff --git a/applications/feed/handler/get_video_by_id.go b/applications/feed/handler/get_video_by_id.go index 632d5894..16e6017a 100644 --- a/applications/feed/handler/get_video_by_id.go +++ b/applications/feed/handler/get_video_by_id.go @@ -2,15 +2,16 @@ package handler import ( "context" - "github.com/TremblingV5/DouTok/applications/feed/rpc" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" + "github.com/TremblingV5/DouTok/applications/feed/pack" - "github.com/TremblingV5/DouTok/kitex_gen/entity" + "github.com/TremblingV5/DouTok/applications/feed/service" "github.com/TremblingV5/DouTok/kitex_gen/feed" ) -func (s *FeedServiceImpl) GetVideoById(ctx context.Context, req *feed.VideoIdRequest) (resp *entity.Video, err error) { - return rpc.VideoDomainClient.GetVideoInfo(ctx, &videoDomain.DoutokGetVideoInfoRequest{ - VideoId: req.VideoId, - }) +func (s *FeedServiceImpl) GetVideoById(ctx context.Context, req *feed.VideoIdRequest) (resp *feed.Video, err error) { + data, err := service.GetVideoByIdInRDB(uint64(req.VideoId)) + if err != nil { + return &feed.Video{}, err + } + return pack.PackVideoInfoResp(data) } diff --git a/applications/feed/main.go b/applications/feed/main.go index 873c4d02..3f0d6f71 100644 --- a/applications/feed/main.go +++ b/applications/feed/main.go @@ -2,38 +2,30 @@ package main import ( "github.com/TremblingV5/DouTok/applications/feed/handler" + "github.com/TremblingV5/DouTok/applications/feed/misc" "github.com/TremblingV5/DouTok/applications/feed/rpc" - "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/applications/feed/service" "github.com/TremblingV5/DouTok/kitex_gen/feed/feedservice" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/TremblingV5/DouTok/pkg/constants" "github.com/TremblingV5/DouTok/pkg/dlog" - "github.com/TremblingV5/DouTok/pkg/services" - "github.com/bytedance/gopkg/util/logger" - "go.uber.org/zap" + "github.com/TremblingV5/DouTok/pkg/initHelper" ) -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_FEED_"` -} - var ( Logger = dlog.InitLog(3) - config = &Config{} ) -func init() { +func Init() { + misc.InitViperConfig() - _, err := configurator.Load(config, "DOUTOK_FEED", "feed") - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", config)) - } - rpc.Init() + service.Init() + + rpc.InitPRCClient() } func main() { + Init() - options, shutdown := services.InitRPCServerArgs(constants.FEED_SERVER_NAME, config.BaseConfig) + options, shutdown := initHelper.InitRPCServerArgs(misc.Config) defer shutdown() svr := feedservice.NewServer( diff --git a/applications/feed/misc/config.go b/applications/feed/misc/config.go new file mode 100644 index 00000000..c51050fa --- /dev/null +++ b/applications/feed/misc/config.go @@ -0,0 +1,18 @@ +package misc + +import "github.com/TremblingV5/DouTok/pkg/dtviper" + +var Config *dtviper.Config + +func InitViperConfig() { + config := dtviper.ConfigInit(ViperConfigEnvPrefix, ViperConfigEnvFilename) + Config = config +} + +func GetConfig(key string) string { + return Config.Viper.GetString(key) +} + +func GetConfigNum(key string) int64 { + return Config.Viper.GetInt64(key) +} diff --git a/applications/feed/misc/const.go b/applications/feed/misc/const.go new file mode 100644 index 00000000..c56f01a9 --- /dev/null +++ b/applications/feed/misc/const.go @@ -0,0 +1,6 @@ +package misc + +const ( + ViperConfigEnvPrefix = "DOUTOK_FEED" + ViperConfigEnvFilename = "feed" +) diff --git a/applications/videoDomain/misc/ensure_id_length.go b/applications/feed/misc/ensure_id_length.go similarity index 100% rename from applications/videoDomain/misc/ensure_id_length.go rename to applications/feed/misc/ensure_id_length.go diff --git a/applications/feed/misc/string_minus.go b/applications/feed/misc/string_minus.go new file mode 100644 index 00000000..6bfddd88 --- /dev/null +++ b/applications/feed/misc/string_minus.go @@ -0,0 +1,11 @@ +package misc + +import ( + "fmt" + "strconv" +) + +func TimestampMinus(curr string, m int) string { + curr_time, _ := strconv.Atoi(curr) + return fmt.Sprint(curr_time - int(m)) +} diff --git a/applications/videoDomain/misc/timestamp.go b/applications/feed/misc/timestamp.go similarity index 100% rename from applications/videoDomain/misc/timestamp.go rename to applications/feed/misc/timestamp.go diff --git a/applications/feed/pack/feed_list.go b/applications/feed/pack/feed_list.go index a445d53a..41f67cb5 100644 --- a/applications/feed/pack/feed_list.go +++ b/applications/feed/pack/feed_list.go @@ -3,103 +3,121 @@ package pack import ( "context" "github.com/TremblingV5/DouTok/applications/feed/rpc" - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" + "github.com/TremblingV5/DouTok/applications/feed/service" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" "github.com/TremblingV5/DouTok/kitex_gen/feed" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" + "github.com/TremblingV5/DouTok/kitex_gen/user" + "strconv" ) -func PackageFeedListResp(ctx context.Context, result *videoDomain.DoutokGetFeedResponse, userId int64, err error) (*feed.DouyinFeedResponse, error) { - if err != nil { - return nil, err +func PackFeedListResp(list []service.VideoInHB, code int32, msg string, user_id int64) (*feed.DouyinFeedResponse, error) { + res := feed.DouyinFeedResponse{ + StatusCode: code, + StatusMsg: msg, } - var videoIdList []int64 + next_time := "9999999999" + var video_list []*feed.Video + + var video_id_list []int64 + validateMap := make(map[int64]bool) var userIdList []int64 - for _, v := range result.VideoList { - videoIdList = append(videoIdList, v.Id) - userIdList = append(userIdList, v.Author.Id) + validateUserIdMap := make(map[int64]bool) + for _, v := range list { + videoId := v.GetId() + if _, ok := validateMap[videoId]; !ok { + video_id_list = append(video_id_list, v.GetId()) + validateMap[videoId] = true + } + userId := v.GetAuthorId() + if _, ok := validateUserIdMap[userId]; !ok { + userIdList = append(userIdList, userId) + validateUserIdMap[userId] = true + } + if v.GetTimestamp() < next_time { + next_time = v.GetTimestamp() + } } - userInfo, err := rpc.UserDomainClient.GetUserInfo(ctx, &userDomain.DoutokGetUserInfoRequest{ - UserId: userIdList, + userInfoResp, err := rpc.GetUserListByIds(context.Background(), &user.DouyinUserListRequest{ + UserList: userIdList, }) if err != nil { - return nil, err + return nil, nil + } + userInfo := userInfoResp.UserList + userMap := make(map[int64]*user.User) + for _, v := range userInfo { + userMap[v.Id] = v } - isFavInfo, err := rpc.FavoriteDomainClient.IsFavorite(ctx, &favoriteDomain.DoutokIsFavRequest{ - UserId: userId, - VideoId: videoIdList, + isFavoriteResp, err := rpc.IsFavorite(context.Background(), &favorite.DouyinIsFavoriteRequest{ + UserId: user_id, + VideoIdList: video_id_list, }) if err != nil { - return nil, err + return nil, nil } + isFavorite := isFavoriteResp.Result - favCount, err := rpc.FavoriteDomainClient.CountFavorite(ctx, &favoriteDomain.DoutokCountFavRequest{ - UserIdList: videoIdList, + favoriteCountResp, err := rpc.FavoriteCount(context.Background(), &favorite.DouyinFavoriteCountRequest{ + VideoIdList: video_id_list, }) if err != nil { return nil, err } + favoriteCount := favoriteCountResp.Result - commentCount, err := rpc.CommentDomainClient.CountComment(ctx, &commentDomain.DoutokCountCommentReq{ - VideoIdList: videoIdList, + commentCountResp, err := rpc.CommentCount(context.Background(), &comment.DouyinCommentCountRequest{ + VideoIdList: video_id_list, }) if err != nil { - return nil, err + return nil, nil } + commentCount := commentCountResp.Result - var videoList []*entity.Video - for _, v := range result.VideoList { - temp := &entity.Video{ - Id: v.GetId(), - PlayUrl: v.GetPlayUrl(), - CoverUrl: v.GetCoverUrl(), - Title: v.GetTitle(), + for _, v := range list { + var temp feed.Video + + temp.Id = v.GetId() + temp.PlayUrl = v.GetVideoUrl() + temp.CoverUrl = v.GetCoverUrl() + temp.Title = v.GetTitle() + + value, ok := favoriteCount[v.GetId()] + if ok { + temp.FavoriteCount = value + } else { + temp.FavoriteCount = 0 } - if u, ok := userInfo.UserList[v.GetId()]; ok { - temp.Author = &entity.User{ - Id: u.Id, - Name: u.Name, - Avatar: u.Avatar, - BackgroundImage: u.BackgroundImage, - Signature: u.Signature, - } + commentCnt, ok := commentCount[v.GetId()] + if ok { + temp.CommentCount = commentCnt } else { - temp.Author = &entity.User{ - Id: v.Author.Id, - } + temp.CommentCount = 0 } - if isFav, ok := isFavInfo.IsFav[v.GetId()]; ok { + isFav, ok := isFavorite[v.GetId()] + if ok { temp.IsFavorite = isFav } else { temp.IsFavorite = false } - if favCnt, ok := favCount.CountFav[v.GetId()]; ok { - temp.FavoriteCount = favCnt - } else { - temp.FavoriteCount = 0 - } + temp.Author = userMap[v.GetAuthorId()] - if commentCnt, ok := commentCount.CommentCount[v.GetId()]; ok { - temp.CommentCount = commentCnt - } else { - temp.CommentCount = 0 - } + video_list = append(video_list, &temp) - videoList = append(videoList, temp) + if v.GetTimestamp() < next_time { + next_time = v.GetTimestamp() + } } - return &feed.DouyinFeedResponse{ - StatusCode: 0, - StatusMsg: "Success", - VideoList: videoList, - NextTime: result.NextTime, - }, nil + res.VideoList = video_list + next_time_int64, _ := strconv.Atoi(next_time) + res.NextTime = int64(next_time_int64) + + return &res, nil } diff --git a/applications/feed/pack/video_info.go b/applications/feed/pack/video_info.go new file mode 100644 index 00000000..09709d2c --- /dev/null +++ b/applications/feed/pack/video_info.go @@ -0,0 +1,40 @@ +package pack + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/feed/dal/model" + "github.com/TremblingV5/DouTok/applications/feed/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" + "github.com/TremblingV5/DouTok/kitex_gen/feed" +) + +func PackVideoInfoResp(video *model.Video) (*feed.Video, error) { + v := feed.Video{} + + v.Id = int64(video.ID) + v.PlayUrl = video.VideoUrl + v.CoverUrl = video.CoverUrl + v.Title = video.Title + + id_list := []int64{int64(video.ID)} + favCountResp, err := rpc.FavoriteCount(context.Background(), &favorite.DouyinFavoriteCountRequest{ + VideoIdList: id_list, + }) + if err != nil { + v.FavoriteCount = 0 + } + + comCountResp, err := rpc.CommentCount(context.Background(), &comment.DouyinCommentCountRequest{ + VideoIdList: id_list, + }) + if err != nil { + v.CommentCount = 0 + } + + v.FavoriteCount = favCountResp.Result[int64(video.ID)] + v.CommentCount = comCountResp.Result[int64(video.ID)] + v.IsFavorite = true + + return &v, nil +} diff --git a/applications/feed/rpc/clients.go b/applications/feed/rpc/clients.go deleted file mode 100644 index e29b878e..00000000 --- a/applications/feed/rpc/clients.go +++ /dev/null @@ -1,15 +0,0 @@ -package rpc - -import "github.com/TremblingV5/DouTok/pkg/initHelper" - -var CommentDomainClient *initHelper.CommentDomainClient -var FavoriteDomainClient *initHelper.FavoriteDomainClient -var UserDomainClient *initHelper.UserDomainClient -var VideoDomainClient *initHelper.VideoDomainClient - -func Init() { - CommentDomainClient = initHelper.InitCommentDomainRPCClient() - FavoriteDomainClient = initHelper.InitFavoriteDomainRPCClient() - UserDomainClient = initHelper.InitUserDomainRPCClient() - VideoDomainClient = initHelper.InitVideoDomainRPCClient() -} diff --git a/applications/feed/rpc/comment.go b/applications/feed/rpc/comment.go new file mode 100644 index 00000000..88cfd3fd --- /dev/null +++ b/applications/feed/rpc/comment.go @@ -0,0 +1,41 @@ +package rpc + +import ( + "context" + "errors" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/initHelper" + + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/TremblingV5/DouTok/kitex_gen/comment/commentservice" +) + +var commentClient commentservice.Client + +func InitCommentRpc() { + config := dtviper.ConfigInit("DOUTOK_COMMENT", "comment") + + c, err := commentservice.NewClient( + config.Viper.GetString("Server.Name"), + initHelper.InitRPCClientArgs(config)..., + ) + + if err != nil { + panic(err) + } + + commentClient = c +} + +func CommentCount(ctx context.Context, req *comment.DouyinCommentCountRequest) (resp *comment.DouyinCommentCountResponse, err error) { + resp, err = commentClient.CommentCount(ctx, req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 0 { + return nil, errors.New(resp.StatusMsg) + } + + return resp, nil +} diff --git a/applications/feed/rpc/favorite.go b/applications/feed/rpc/favorite.go new file mode 100644 index 00000000..80e076e1 --- /dev/null +++ b/applications/feed/rpc/favorite.go @@ -0,0 +1,54 @@ +package rpc + +import ( + "context" + "errors" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/initHelper" + + "github.com/TremblingV5/DouTok/kitex_gen/favorite" + "github.com/TremblingV5/DouTok/kitex_gen/favorite/favoriteservice" +) + +var favoriteClient favoriteservice.Client + +func InitFavoriteRpc() { + config := dtviper.ConfigInit("DOUTOK_FAVORITE", "favorite") + + c, err := favoriteservice.NewClient( + config.Viper.GetString("Server.Name"), + initHelper.InitRPCClientArgs(config)..., + ) + + if err != nil { + panic(err) + } + + favoriteClient = c +} + +func IsFavorite(ctx context.Context, req *favorite.DouyinIsFavoriteRequest) (resp *favorite.DouyinIsFavoriteResponse, err error) { + resp, err = favoriteClient.IsFavorite(ctx, req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 0 { + return nil, errors.New(resp.StatusMsg) + } + + return resp, nil +} + +func FavoriteCount(ctx context.Context, req *favorite.DouyinFavoriteCountRequest) (resp *favorite.DouyinFavoriteCountResponse, err error) { + resp, err = favoriteClient.FavoriteCount(ctx, req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 0 { + return nil, errors.New(resp.StatusMsg) + } + + return resp, nil +} diff --git a/applications/feed/rpc/init.go b/applications/feed/rpc/init.go new file mode 100644 index 00000000..d19e0396 --- /dev/null +++ b/applications/feed/rpc/init.go @@ -0,0 +1,7 @@ +package rpc + +func InitPRCClient() { + InitCommentRpc() + InitFavoriteRpc() + InitUserRpc() +} diff --git a/applications/feed/rpc/user.go b/applications/feed/rpc/user.go new file mode 100644 index 00000000..2c65d4f1 --- /dev/null +++ b/applications/feed/rpc/user.go @@ -0,0 +1,54 @@ +package rpc + +import ( + "context" + "errors" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/initHelper" + + "github.com/TremblingV5/DouTok/kitex_gen/user" + "github.com/TremblingV5/DouTok/kitex_gen/user/userservice" +) + +var userClient userservice.Client + +func InitUserRpc() { + config := dtviper.ConfigInit("DOUTOK_USER", "user") + + c, err := userservice.NewClient( + config.Viper.GetString("Server.Name"), + initHelper.InitRPCClientArgs(config)..., + ) + + if err != nil { + panic(err) + } + + userClient = c +} + +func GetUserById(ctx context.Context, req *user.DouyinUserRequest) (resp *user.DouyinUserResponse, err error) { + resp, err = userClient.GetUserById(ctx, req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 0 { + return nil, errors.New(resp.StatusMsg) + } + + return resp, nil +} + +func GetUserListByIds(ctx context.Context, req *user.DouyinUserListRequest) (resp *user.DouyinUserListResponse, err error) { + resp, err = userClient.GetUserListByIds(ctx, req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 0 { + return nil, errors.New(resp.StatusMsg) + } + + return resp, nil +} diff --git a/applications/feed/rpc/var.go b/applications/feed/rpc/var.go new file mode 100644 index 00000000..8cf985dd --- /dev/null +++ b/applications/feed/rpc/var.go @@ -0,0 +1,5 @@ +package rpc + +import "github.com/TremblingV5/DouTok/config/configStruct" + +var ClientConfig *configStruct.FeedConfig diff --git a/applications/feed/script/bootstrap.sh b/applications/feed/script/bootstrap.sh index 62a1b6eb..dca10984 100644 --- a/applications/feed/script/bootstrap.sh +++ b/applications/feed/script/bootstrap.sh @@ -19,4 +19,3 @@ if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then fi exec "$CURDIR/bin/feed" - diff --git a/applications/feed/service/cache.go b/applications/feed/service/cache.go new file mode 100644 index 00000000..feca31c1 --- /dev/null +++ b/applications/feed/service/cache.go @@ -0,0 +1,56 @@ +package service + +import ( + "context" + "errors" + "time" + + "github.com/TremblingV5/DouTok/pkg/constants" +) + +/* + 从Redis中获取缓存的feed列表,通过Redis事务执行若干次feed操作,从而获得足够的feed list +*/ +func GetFeedCache(ctx context.Context, user_id string, num int64) ([]VideoInHB, bool) { + res, err := RedisClients[constants.FeedSendBox].LPops(ctx, user_id, int(num)) + if err != nil { + return []VideoInHB{}, false + } + + video_list := String2VideoList(res) + + if err != nil { + return []VideoInHB{}, false + } + + return video_list, true +} + +/* + 将新的feed列表存储到Redis中,method参数只允许l或r,代表选择不同的方法Push到Redis +*/ +func SetFeedCache(ctx context.Context, method string, userId string, values ...VideoInHB) error { + videoList := VideoList2String(values) + switch method { + case "l": + return RedisClients[constants.FeedSendBox].LPush(ctx, userId, videoList...) + case "r": + return RedisClients[constants.FeedSendBox].RPush(ctx, userId, videoList...) + default: + return errors.New("unknown method, only accept 'l' or 'r'") + } +} + +/* + 获取某个user_id在系统中的marked_time +*/ +func GetMarkedTime(ctx context.Context, user_id string) (string, error) { + return RedisClients[constants.TimeCache].Get(ctx, user_id) +} + +/* + 为某个user_id设置新的marked_time +*/ +func SetMarkedTime(ctx context.Context, user_id string, marked_time string) error { + return RedisClients[constants.TimeCache].Set(ctx, user_id, marked_time, 24*time.Hour) +} diff --git a/applications/feed/service/cache_test.go b/applications/feed/service/cache_test.go new file mode 100644 index 00000000..f0567c17 --- /dev/null +++ b/applications/feed/service/cache_test.go @@ -0,0 +1,66 @@ +package service + +import ( + "context" + "fmt" + "github.com/go-redis/redis/v8" + "log" + "testing" + "time" +) + +func TestGetFeedCache(t *testing.T) { + Init() + + userId := int64(2222222222222222222) + num := int64(1) + + res, ok := GetFeedCache(context.Background(), fmt.Sprint(userId), num) + + log.Println(ok) + log.Println(res) +} + +func TestSetFeedCache(t *testing.T) { + Init() + + userId := int64(2222222222222222222) + method := "l" + + video := VideoInHB{ + Id: []byte("3333333333333333333"), + AuthorId: []byte("2222222222222222222"), + AuthorName: []byte("Unit testing author name"), + Title: []byte("Unit testing title"), + VideoUrl: []byte("Unit testing video url"), + CoverUrl: []byte("Unit testing cover url"), + Timestamp: []byte(fmt.Sprint(time.Now().Unix())), + } + + err := SetFeedCache(context.Background(), method, fmt.Sprint(userId), video) + if err != nil { + log.Panicln(err) + } +} + +func TestGetMarkedTime(t *testing.T) { + Init() + + userId := int64(2222222222222222222) + res, err := GetMarkedTime(context.Background(), fmt.Sprint(userId)) + if err != nil && err != redis.Nil { + panic(err) + } + log.Println(res) +} + +func TestSetMarkedTime(t *testing.T) { + Init() + + userId := int64(2222222222222222222) + err := SetMarkedTime(context.Background(), fmt.Sprint(userId), fmt.Sprint(time.Now().Unix())) + + if err != nil { + log.Panicln(err) + } +} diff --git a/applications/feed/service/hbase.go b/applications/feed/service/hbase.go new file mode 100644 index 00000000..ab3fd436 --- /dev/null +++ b/applications/feed/service/hbase.go @@ -0,0 +1,101 @@ +package service + +import ( + "fmt" + "strconv" + + "github.com/TremblingV5/DouTok/applications/publish/misc" + tools "github.com/TremblingV5/DouTok/pkg/misc" +) + +/* + 在HBase中搜索start_time < time <= end_time的视频,作为feed使用 + 函数中从HBase中获取了Map结构的数据,并打包成结构体列表 +*/ +func FindFeedInHB(start_time string, end_time string) ([]VideoInHB, error) { + start_time_int, _ := strconv.Atoi(start_time) + end_time_int, _ := strconv.Atoi(end_time) + + res, err := HBClient.ScanRange("feed", misc.GetTimeRebound(int64(end_time_int)), misc.GetTimeRebound(int64(start_time_int))) + if err != nil { + return []VideoInHB{}, err + } + + video_list := []VideoInHB{} + for _, v := range res { + temp := VideoInHB{} + err := tools.Map2Struct4HB(v, &temp) + if err != nil { + continue + } + video_list = append(video_list, temp) + } + + return video_list, nil +} + +/* + 向前搜索Feed List,前为更早的时间点 +*/ +func SearchFeedEarlierInHB(latest_time int64, stop_time int64) ([]VideoInHB, error) { + next_time := latest_time - 86400 + + video_list := []VideoInHB{} + + for { + temp, err := FindFeedInHB(fmt.Sprint(next_time), fmt.Sprint(latest_time)) + + if err != nil { + return video_list, err + } + + video_list = append(video_list, temp...) + + // 终止条件1:视频列表长度已经大于30;长度列表已经至少满足3次feed的数量,且为一个feed list的最大允许长度 + // 故可以以此为停止条件,以减少资源的使用 + // 终止条件2:next_time少于stop_time,stop_time设置为了14天前,不断搜索14天前的视频作为feed不符合产品定义, + // 故作为终止条件 + if len(video_list) > 30 || next_time < stop_time { + break + } + + latest_time = next_time + next_time -= 86400 + } + + return video_list, nil +} + +/* + 向后搜索Feed List,后为更接近当前时间的时间点 +*/ +func SearchFeedLaterInHB(marked_time string, current_time string) (res []VideoInHB, new_marked_time string, err error) { + marked_time_int, _ := strconv.Atoi(marked_time) + current_time_int, _ := strconv.Atoi(current_time) + + next_marked_time_int := int64(marked_time_int) + 6*60*60 + + video_list := []VideoInHB{} + + for { + temp, err := FindFeedInHB(fmt.Sprint(marked_time_int), fmt.Sprint(next_marked_time_int)) + + if err != nil { + return video_list, marked_time, err + } + + video_list = append(video_list, temp...) + + // 终止条件1:视频列表长度已经大于30;长度列表已经至少满足3次feed的数量,且为一个feed list的最大允许长度 + // 故可以以此为停止条件,以减少资源的使用 + // 终止条件2:时间差小于6个小时 + if len(video_list) > 30 || JudgeTimeDiff(next_marked_time_int, fmt.Sprint(current_time_int), 6*60*60) { + break + } + + marked_time_int = int(next_marked_time_int) + next_marked_time_int += 6 * 60 * 60 + } + + return video_list, fmt.Sprint(next_marked_time_int), nil +} diff --git a/applications/feed/service/hbase_test.go b/applications/feed/service/hbase_test.go new file mode 100644 index 00000000..fc2fcd80 --- /dev/null +++ b/applications/feed/service/hbase_test.go @@ -0,0 +1,46 @@ +package service + +import ( + "fmt" + "log" + "testing" + "time" +) + +func TestFindFeedInHB(t *testing.T) { + Init() + + res, err := FindFeedInHB("1627500000", fmt.Sprint(time.Now().Unix())) + if err != nil { + log.Panicln(err) + } + + log.Println(len(res)) +} + +func TestSearchFeedEarlierInHB(t *testing.T) { + Init() + + curr := time.Now().Unix() + + res, err := SearchFeedEarlierInHB(curr, curr-86400*7) + if err != nil { + log.Panicln(err) + } + + log.Println(len(res)) +} + +func TestSearchFeedLaterInHB(t *testing.T) { + Init() + + curr := time.Now().Unix() + + res, newMarkedTime, err := SearchFeedLaterInHB(fmt.Sprint(curr-86400), fmt.Sprint(curr)) + if err != nil { + log.Panicln(err) + } + + log.Println(len(res)) + log.Println(newMarkedTime) +} diff --git a/applications/feed/service/init.go b/applications/feed/service/init.go new file mode 100644 index 00000000..a484fd75 --- /dev/null +++ b/applications/feed/service/init.go @@ -0,0 +1,79 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/feed/misc" + "github.com/TremblingV5/DouTok/pkg/constants" + "github.com/TremblingV5/DouTok/pkg/utils" + + "github.com/TremblingV5/DouTok/applications/feed/dal/query" + "github.com/TremblingV5/DouTok/pkg/hbaseHandle" + "github.com/TremblingV5/DouTok/pkg/mysqlIniter" + redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" +) + +func Init() { + misc.InitViperConfig() + + InitDb( + misc.GetConfig("MySQL.Username"), + misc.GetConfig("MySQL.Password"), + misc.GetConfig("MySQL.Host"), + misc.GetConfig("MySQL.Port"), + misc.GetConfig("MySQL.Database"), + ) + + InitHB( + misc.GetConfig("HBase.Host"), + ) + + redisMap := map[string]int{ + constants.FeedSendBox: int(misc.GetConfigNum("Redis.SendBox.Num")), + constants.TimeCache: int(misc.GetConfigNum("Redis.MarkdedTime.Num")), + } + InitRedis( + misc.GetConfig("Redis.Dest"), + misc.GetConfig("Redis.Password"), + redisMap, + ) + utils.InitSnowFlake(misc.GetConfigNum("Snowflake.Node")) +} + +func InitDb(username string, password string, host string, port string, database string) error { + db, err := mysqlIniter.InitDb( + username, + password, + host, + port, + database, + ) + + if err != nil { + return err + } + + DB = db + + query.SetDefault(DB) + Video = query.Video + Do = Video.WithContext(context.Background()) + + return nil +} + +func InitHB(host string) error { + client := hbaseHandle.InitHB(host) + HBClient = &client + + return nil +} + +func InitRedis(dest string, password string, dbs map[string]int) error { + redisCaches, _ := redishandle.InitRedis( + dest, password, dbs, + ) + + RedisClients = redisCaches + + return nil +} diff --git a/applications/feed/service/init_test.go b/applications/feed/service/init_test.go new file mode 100644 index 00000000..8ef9d018 --- /dev/null +++ b/applications/feed/service/init_test.go @@ -0,0 +1,7 @@ +package service + +import "testing" + +func TestInit(t *testing.T) { + Init() +} diff --git a/applications/feed/service/judge.go b/applications/feed/service/judge.go new file mode 100644 index 00000000..61bdd13e --- /dev/null +++ b/applications/feed/service/judge.go @@ -0,0 +1,21 @@ +package service + +import "strconv" + +/* + 以下不等式是否成立: + t1 - t2 >= diff +*/ +func JudgeTimeDiff(t1 int64, t2 string, diff int64) bool { + t2_i, _ := strconv.Atoi(t2) + t2_i64 := int64(t2_i) + return t1-t2_i64 >= diff +} + +/* + 以下不等式是否成立: + q1 / q2 >= ratio +*/ +func JudgeQuantityRatio(q1 float64, q2 float64, ratio float64) bool { + return q1/q2 >= ratio +} diff --git a/applications/feed/service/judge_test.go b/applications/feed/service/judge_test.go new file mode 100644 index 00000000..5c6415c9 --- /dev/null +++ b/applications/feed/service/judge_test.go @@ -0,0 +1,25 @@ +package service + +import ( + "fmt" + "log" + "testing" + "time" +) + +func TestJudgeTimeDiff(t *testing.T) { + curr := time.Now().Unix() + ok := JudgeTimeDiff(curr-86400, fmt.Sprint(curr), 8000) + + if ok { + log.Panicln(ok) + } +} + +func TestJudgeQuantityRatio(t *testing.T) { + ok := JudgeQuantityRatio(2, 3, 0.5) + + if !ok { + log.Panicln(ok) + } +} diff --git a/applications/feed/service/rdb.go b/applications/feed/service/rdb.go new file mode 100644 index 00000000..46c4ad46 --- /dev/null +++ b/applications/feed/service/rdb.go @@ -0,0 +1,17 @@ +package service + +import ( + "github.com/TremblingV5/DouTok/applications/feed/dal/model" +) + +func GetVideoByIdInRDB(user_id uint64) (*model.Video, error) { + v, err := Do.Where( + Video.ID.Eq(user_id), + ).First() + + if err != nil { + return v, err + } + + return v, nil +} diff --git a/applications/feed/service/rdb_test.go b/applications/feed/service/rdb_test.go new file mode 100644 index 00000000..d2088654 --- /dev/null +++ b/applications/feed/service/rdb_test.go @@ -0,0 +1,17 @@ +package service + +import ( + "log" + "testing" +) + +func TestGetVideoByIdInRDB(t *testing.T) { + Init() + + res, err := GetVideoByIdInRDB(uint64(1627183461678981120)) + if err != nil { + log.Panicln(err) + } + + log.Println(res) +} diff --git a/applications/feed/service/serialize.go b/applications/feed/service/serialize.go new file mode 100644 index 00000000..011b30c1 --- /dev/null +++ b/applications/feed/service/serialize.go @@ -0,0 +1,35 @@ +package service + +import ( + "encoding/json" + "fmt" +) + +func VideoList2String(list []VideoInHB) []string { + res := []string{} + + for _, v := range list { + r, err := json.Marshal(v) + if err != nil { + continue + } + res = append(res, string(r)) + } + + return res +} + +func String2VideoList(list []string) []VideoInHB { + res := []VideoInHB{} + + for _, v := range list { + temp := VideoInHB{} + err := json.Unmarshal([]byte(v), &temp) + if err != nil { + fmt.Println(err) + } + res = append(res, temp) + } + + return res +} diff --git a/applications/feed/service/serialize_test.go b/applications/feed/service/serialize_test.go new file mode 100644 index 00000000..ec2563b9 --- /dev/null +++ b/applications/feed/service/serialize_test.go @@ -0,0 +1,29 @@ +package service + +import ( + "fmt" + "testing" +) + +func TestVideoList2String(t *testing.T) { + video := VideoInHB{ + Id: []byte("1"), + AuthorId: []byte("1"), + AuthorName: []byte("Tom"), + } + list := []VideoInHB{ + video, + } + res := VideoList2String(list) + + fmt.Println(res) +} + +func TestString2VideoList(t *testing.T) { + str := "{\"id\":\"1\",\"author_id\":\"2\",\"author_name\":\"Tom\",\"title\":\"\",\"video_url\":\"\",\"cover_url\":\"\",\"timestamp\":\"\"}" + list := []string{str} + + res := String2VideoList(list) + + fmt.Println(res) +} diff --git a/applications/videoDomain/typedef/hbase.go b/applications/feed/service/typedef.go similarity index 84% rename from applications/videoDomain/typedef/hbase.go rename to applications/feed/service/typedef.go index 9f12d36f..ea34c16f 100644 --- a/applications/videoDomain/typedef/hbase.go +++ b/applications/feed/service/typedef.go @@ -1,4 +1,4 @@ -package typedef +package service import ( "encoding/binary" @@ -20,14 +20,14 @@ func ToInt64(data []byte) int64 { } func (v *VideoInHB) GetId() int64 { - str := string(v.Id) - i, _ := strconv.ParseInt(str, 10, 64) + id_string := string(v.Id) + i, _ := strconv.ParseInt(id_string, 10, 64) return i } func (v *VideoInHB) GetAuthorId() int64 { - str := string(v.AuthorId) - i, _ := strconv.ParseInt(str, 10, 64) + id_string := string(v.AuthorId) + i, _ := strconv.ParseInt(id_string, 10, 64) return i } diff --git a/applications/videoDomain/service/var.go b/applications/feed/service/var.go similarity index 50% rename from applications/videoDomain/service/var.go rename to applications/feed/service/var.go index 2989ca2a..49404a49 100644 --- a/applications/videoDomain/service/var.go +++ b/applications/feed/service/var.go @@ -1,11 +1,9 @@ package service import ( - "github.com/TremblingV5/DouTok/applications/videoDomain/dal/query" + "github.com/TremblingV5/DouTok/applications/feed/dal/query" "github.com/TremblingV5/DouTok/pkg/hbaseHandle" - "github.com/TremblingV5/DouTok/pkg/minioHandle" redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" - minio "github.com/minio/minio-go/v6" "gorm.io/gorm" ) @@ -13,13 +11,5 @@ var DB *gorm.DB var Do query.IVideoDo var Video = query.VideoStruct -var VideoCount = query.VideoCountStruct -var VideoCountDo query.IVideoCountDo - -var HBClient *hbaseHandle.HBaseClient - -var MinioClient = &minioHandle.MinioClient{ - Client: &minio.Client{}, -} - var RedisClients map[string]*redishandle.RedisClient +var HBClient *hbaseHandle.HBaseClient diff --git a/applications/message/build.sh b/applications/message/build.sh index a6f77e14..2e28b6ae 100644 --- a/applications/message/build.sh +++ b/applications/message/build.sh @@ -10,4 +10,3 @@ if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then else go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... fi - diff --git a/applications/message/handler.go b/applications/message/handler.go new file mode 100644 index 00000000..d0910e20 --- /dev/null +++ b/applications/message/handler.go @@ -0,0 +1,56 @@ +package main + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/message/pack" + "github.com/TremblingV5/DouTok/applications/message/service" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/TremblingV5/DouTok/pkg/errno" +) + +// MessageServiceImpl implements the last service interface defined in the IDL. +type MessageServiceImpl struct{} + +// MessageChat implements the MessageServiceImpl interface. +func (s *MessageServiceImpl) MessageChat(ctx context.Context, req *message.DouyinMessageChatRequest) (resp *message.DouyinMessageChatResponse, err error) { + // 从 hbase 返回历史消息列表(会话id的概念) + resp = new(message.DouyinMessageChatResponse) + + err, messageList := service.NewMessageChatService(ctx).MessageChat(req) + if err != nil { + pack.BuildMessageChatResp(err, resp) + return resp, nil + } + resp.MessageList = messageList + + pack.BuildMessageChatResp(errno.Success, resp) + return resp, nil +} + +// MessageAction implements the MessageServiceImpl interface. +func (s *MessageServiceImpl) MessageAction(ctx context.Context, req *message.DouyinMessageActionRequest) (resp *message.DouyinMessageActionResponse, err error) { + resp = new(message.DouyinMessageActionResponse) + + err = service.NewMessageActionService(ctx).MessageAction(req) + if err != nil { + pack.BuildMessageActionResp(err, resp) + return resp, nil + } + pack.BuildMessageActionResp(errno.Success, resp) + return resp, nil +} + +// MessageFriendList implements the MessageServiceImpl interface. +func (s *MessageServiceImpl) MessageFriendList(ctx context.Context, req *message.DouyinFriendListMessageRequest) (resp *message.DouyinFriendListMessageResponse, err error) { + resp = new(message.DouyinFriendListMessageResponse) + + err, result := service.NewMessageFriendService(ctx).MessageFriendList(req) + if err != nil { + pack.BuildMessageFriendResp(err, resp) + return resp, nil + } + resp.Result = result + + pack.BuildMessageFriendResp(errno.Success, resp) + return resp, nil +} diff --git a/applications/message/handler/message_action.go b/applications/message/handler/message_action.go deleted file mode 100644 index d9901b5c..00000000 --- a/applications/message/handler/message_action.go +++ /dev/null @@ -1,19 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/message/pack" - "github.com/TremblingV5/DouTok/applications/message/rpc" - "github.com/TremblingV5/DouTok/kitex_gen/message" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" -) - -func (s *MessageServiceImpl) MessageAction(ctx context.Context, req *message.DouyinMessageActionRequest) (*message.DouyinMessageActionResponse, error) { - result, err := rpc.MessageDomainClient.AddMessage(ctx, &messageDomain.DoutokAddMessageRequest{ - ToUserId: req.ToUserId, - UserId: req.UserId, - ActionType: req.ActionType, - Content: req.Content, - }) - return pack.PackageMessageActionResponse(result, err) -} diff --git a/applications/message/handler/message_chat.go b/applications/message/handler/message_chat.go deleted file mode 100644 index 2394ca66..00000000 --- a/applications/message/handler/message_chat.go +++ /dev/null @@ -1,18 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/message/pack" - "github.com/TremblingV5/DouTok/applications/message/rpc" - "github.com/TremblingV5/DouTok/kitex_gen/message" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" -) - -func (s *MessageServiceImpl) MessageChat(ctx context.Context, req *message.DouyinMessageChatRequest) (*message.DouyinMessageChatResponse, error) { - result, err := rpc.MessageDomainClient.ListMessage(ctx, &messageDomain.DoutokListMessageRequest{ - ToUserId: req.ToUserId, - UserId: req.UserId, - PreMsgTime: req.PreMsgTime, - }) - return pack.PackageMessageChatResponse(result, err) -} diff --git a/applications/message/handler/typedef.go b/applications/message/handler/typedef.go deleted file mode 100644 index c38506b9..00000000 --- a/applications/message/handler/typedef.go +++ /dev/null @@ -1,3 +0,0 @@ -package handler - -type MessageServiceImpl struct{} diff --git a/applications/message/main.go b/applications/message/main.go index d46f80cd..8309ae66 100644 --- a/applications/message/main.go +++ b/applications/message/main.go @@ -1,51 +1,80 @@ package main import ( - "github.com/TremblingV5/DouTok/applications/message/rpc" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/services" - "go.uber.org/zap" - - "github.com/TremblingV5/DouTok/applications/message/handler" + "context" + "fmt" "github.com/TremblingV5/DouTok/applications/message/service" "github.com/TremblingV5/DouTok/kitex_gen/message/messageservice" "github.com/TremblingV5/DouTok/pkg/dlog" + "github.com/TremblingV5/DouTok/pkg/middleware" "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/limit" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" + "net" ) -func init() { +func Init() { service.InitViper() service.InitHB() service.InitRedisClient() service.InitSyncProducer() service.InitConsumerGroup() service.InitId() - rpc.Init() } func main() { - + Init() defer func() { _ = service.SyncProducer.Close() }() // 启动 kafka 消费者协程,消费 IM 消息 go service.ConsumeMsg() + //go service.TT() var logger = dlog.InitLog(3) defer logger.Sync() klog.SetLogger(logger) - options, shutdown := services.InitRPCServerArgs(constants.MESSAGE_SERVER_NAME, service.DomainConfig.BaseConfig) - defer shutdown() + ServiceName := service.ViperConfig.Viper.GetString("Server.Name") + ServiceAddr := fmt.Sprintf("%s:%d", service.ViperConfig.Viper.GetString("Server.Address"), service.ViperConfig.Viper.GetInt("Server.Port")) + EtcdAddress := fmt.Sprintf("%s:%d", service.ViperConfig.Viper.GetString("Etcd.Address"), service.ViperConfig.Viper.GetInt("Etcd.Port")) + + r, err := etcd.NewEtcdRegistry([]string{EtcdAddress}) + if err != nil { + klog.Fatal(err) + } + addr, err := net.ResolveTCPAddr("tcp", ServiceAddr) + if err != nil { + klog.Fatal(err) + } + + p := provider.NewOpenTelemetryProvider( + provider.WithServiceName(ServiceName), + provider.WithExportEndpoint(fmt.Sprintf("%s:%s", service.ViperConfig.Viper.GetString("Otel.Host"), service.ViperConfig.Viper.GetString("Otel.Port"))), + provider.WithInsecure(), + ) + defer p.Shutdown(context.Background()) svr := messageservice.NewServer( - new(handler.MessageServiceImpl), - options..., + new(MessageServiceImpl), + server.WithServiceAddr(addr), // address + server.WithMiddleware(middleware.CommonMiddleware), // middleware + server.WithMiddleware(middleware.ServerMiddleware), // middleware + server.WithRegistry(r), // registry + server.WithLimit(&limit.Option{MaxConnections: 1000, MaxQPS: 100}), // limit + server.WithMuxTransport(), // Multiplex + server.WithSuite(tracing.NewServerSuite()), // trace + // Please keep the same as provider.WithServiceName + server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: ServiceName}), ) if err := svr.Run(); err != nil { - logger.Fatal("run server err", zap.Error(err)) + klog.Fatalf("%s stopped with error:", ServiceName, err) } } diff --git a/applications/message/pack/message_action.go b/applications/message/pack/message_action.go deleted file mode 100644 index f944bdda..00000000 --- a/applications/message/pack/message_action.go +++ /dev/null @@ -1,13 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/message" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" -) - -func PackageMessageActionResponse(result *messageDomain.DoutokAddMessageResponse, err error) (*message.DouyinMessageActionResponse, error) { - return &message.DouyinMessageActionResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - }, err -} diff --git a/applications/message/pack/message_chat.go b/applications/message/pack/message_chat.go deleted file mode 100644 index c600924e..00000000 --- a/applications/message/pack/message_chat.go +++ /dev/null @@ -1,14 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/message" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" -) - -func PackageMessageChatResponse(result *messageDomain.DoutokListMessageResponse, err error) (*message.DouyinMessageChatResponse, error) { - return &message.DouyinMessageChatResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - MessageList: result.Message, - }, err -} diff --git a/applications/message/rpc/clients.go b/applications/message/rpc/clients.go deleted file mode 100644 index f75b6755..00000000 --- a/applications/message/rpc/clients.go +++ /dev/null @@ -1,9 +0,0 @@ -package rpc - -import "github.com/TremblingV5/DouTok/pkg/initHelper" - -var MessageDomainClient *initHelper.MessageDomainClient - -func Init() { - MessageDomainClient = initHelper.InitMessageDomainRPCClient() -} diff --git a/applications/message/script/bootstrap.sh b/applications/message/script/bootstrap.sh index 93a55ff0..3f8be4c1 100644 --- a/applications/message/script/bootstrap.sh +++ b/applications/message/script/bootstrap.sh @@ -19,4 +19,3 @@ if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then fi exec "$CURDIR/bin/message" - diff --git a/applications/message/service/consume_msg.go b/applications/message/service/consume_msg.go index aad4f05d..e7002dab 100644 --- a/applications/message/service/consume_msg.go +++ b/applications/message/service/consume_msg.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "github.com/Shopify/sarama" "github.com/TremblingV5/DouTok/applications/message/pack" "github.com/TremblingV5/DouTok/pkg/misc" @@ -21,9 +20,7 @@ func (m msgConsumerGroup) ConsumeClaim(sess sarama.ConsumerGroupSession, claim s fmt.Printf("Message topic:%q partition:%d offset:%d value:%s\n", msg.Topic, msg.Partition, msg.Offset, string(msg.Value)) message := pack.Message{} - if err := json.Unmarshal(msg.Value, &message); err != nil { - return err - } + json.Unmarshal(msg.Value, &message) mp, err := misc.Struct2Map(message) if err != nil { return err diff --git a/applications/message/service/consume_msg_test.go b/applications/message/service/consume_msg_test.go new file mode 100644 index 00000000..9fa9e060 --- /dev/null +++ b/applications/message/service/consume_msg_test.go @@ -0,0 +1,49 @@ +package service + +import ( + "context" + "fmt" + "github.com/TremblingV5/DouTok/applications/message/pack" + "github.com/TremblingV5/DouTok/pkg/misc" + "github.com/TremblingV5/DouTok/pkg/utils" + "github.com/cloudwego/hertz/pkg/common/test/assert" + "log" + "math" + "testing" + "time" +) + +func TestConsumeMsg(t *testing.T) { + Init() + + // 消费4个消息 + go ConsumeMsg() + + time.Sleep(3 * time.Second) + + // 查看 hbase 数据 + sessionId := utils.GenerateSessionId(10001000, 10002000) + start := fmt.Sprintf("%s%d", sessionId, 0) + end := fmt.Sprintf("%s%d", sessionId, math.MaxInt) + res, err := HBClient.ScanRange(ViperConfig.Viper.GetString("Hbase.Table"), start, end) + if err != nil { + log.Fatal(err) + } + for _, v := range res { + hbMsg := pack.HBMessage{} + err := misc.Map2Struct4HB(v, &hbMsg) + if err != nil { + fmt.Println(err) + } + assert.DeepEqual(t, "10001000", string(hbMsg.FromUserId)) + assert.DeepEqual(t, "10002000", string(hbMsg.ToUserId)) + fmt.Printf("id = %s, content = %s, createTime = %s\n", string(hbMsg.Id), string(hbMsg.Content), string(hbMsg.CreateTime)) + } + + // 查看 redis 数据 + val, err := RedisClient.HGet(context.Background(), sessionId, "content").Result() + if err != nil { + log.Fatal(err) + } + assert.DeepEqual(t, "test msg", val) +} diff --git a/applications/message/service/init.go b/applications/message/service/init.go index 46f501f4..104a5fd2 100644 --- a/applications/message/service/init.go +++ b/applications/message/service/init.go @@ -1,44 +1,33 @@ package service import ( - "github.com/TremblingV5/DouTok/config/configStruct" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/bytedance/gopkg/util/logger" - "go.uber.org/zap" - + "fmt" "github.com/Shopify/sarama" "github.com/TremblingV5/DouTok/pkg/dtviper" "github.com/TremblingV5/DouTok/pkg/hbaseHandle" "github.com/TremblingV5/DouTok/pkg/kafka" + redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" "github.com/TremblingV5/DouTok/pkg/utils" "github.com/go-redis/redis/v8" ) -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_MESSAGE_"` - Redis configStruct.Redis `envPrefix:"DOUTOK_MESSAGE_"` - HBase configStruct.HBase `envPrefix:"DOUTOK_MESSAGE_"` -} - var ( HBClient *hbaseHandle.HBaseClient RedisClient *redis.Client SyncProducer sarama.SyncProducer - ViperConfig *dtviper.Config + ViperConfig dtviper.Config ConsumerGroup sarama.ConsumerGroup - DomainConfig = &Config{} ) func InitViper() { - v, err := configurator.Load(DomainConfig, "DOUTOK_MESSAGE", "message") - ViperConfig = v - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", DomainConfig)) - } + ViperConfig = dtviper.ConfigInit("DOUTOK_MESSAGE", "message") } func InitHB() { - HBClient = &hbaseHandle.HBaseClient{Client: *DomainConfig.HBase.InitHB()} + + client := hbaseHandle.InitHB(ViperConfig.Viper.GetString("Hbase.Host")) + + HBClient = &client } func InitSyncProducer() { @@ -52,7 +41,16 @@ func InitConsumerGroup() { } func InitRedisClient() { - RedisClient = DomainConfig.Redis.InitRedisClient(configStruct.DEFAULT_DATABASE) + + Client, err := redishandle.InitRedisClient( + fmt.Sprintf("%s:%d", ViperConfig.Viper.GetString("Redis.Host"), ViperConfig.Viper.GetInt("Redis.Port")), + ViperConfig.Viper.GetString("Redis.Password"), + ViperConfig.Viper.GetInt("Redis.Databases.Default"), + ) + if err != nil { + panic(err) + } + RedisClient = Client } func InitId() { diff --git a/applications/message/service/init_test.go b/applications/message/service/init_test.go new file mode 100644 index 00000000..76188ae5 --- /dev/null +++ b/applications/message/service/init_test.go @@ -0,0 +1,16 @@ +package service + +import "testing" + +func Init() { + InitViper() + InitHB() + InitRedisClient() + InitSyncProducer() + InitConsumerGroup() + InitId() +} + +func TestInit(t *testing.T) { + Init() +} diff --git a/applications/message/service/message_action_test.go b/applications/message/service/message_action_test.go new file mode 100644 index 00000000..ab97b6fa --- /dev/null +++ b/applications/message/service/message_action_test.go @@ -0,0 +1,21 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/cloudwego/hertz/pkg/common/test/assert" + "testing" +) + +func TestMessageActionService(t *testing.T) { + Init() + msgService := NewMessageActionService(context.Background()) + req := &message.DouyinMessageActionRequest{ + UserId: 10001000, + ToUserId: 10002000, + ActionType: 1, + Content: "test msg", + } + err := msgService.MessageAction(req) + assert.Nil(t, err) +} diff --git a/applications/message/service/message_chat.go b/applications/message/service/message_chat.go index cfdc2461..8afe2ba4 100644 --- a/applications/message/service/message_chat.go +++ b/applications/message/service/message_chat.go @@ -7,7 +7,6 @@ import ( "sort" "github.com/TremblingV5/DouTok/applications/message/pack" - "github.com/TremblingV5/DouTok/kitex_gen/entity" "github.com/TremblingV5/DouTok/kitex_gen/message" "github.com/TremblingV5/DouTok/pkg/misc" "github.com/TremblingV5/DouTok/pkg/utils" @@ -21,9 +20,9 @@ func NewMessageChatService(ctx context.Context) *MessageChatService { return &MessageChatService{ctx: ctx} } -func (s *MessageChatService) MessageChat(req *message.DouyinMessageChatRequest) (error, []*entity.Message) { +func (s *MessageChatService) MessageChat(req *message.DouyinMessageChatRequest) (error, []*message.Message) { // 从 hbase 获取聊天记录 - messageList := make([]*entity.Message, 0) + messageList := make([]*message.Message, 0) sessionId := utils.GenerateSessionId(req.UserId, req.ToUserId) start := fmt.Sprintf("%s%d", sessionId, req.PreMsgTime) end := fmt.Sprintf("%s%d", sessionId, math.MaxInt) @@ -38,7 +37,7 @@ func (s *MessageChatService) MessageChat(req *message.DouyinMessageChatRequest) continue } packMsg := pack.HBMsg2Msg(&hbMsg) - message := entity.Message{ + message := message.Message{ Id: packMsg.Id, ToUserId: packMsg.ToUserId, FromUserId: packMsg.FromUserId, diff --git a/applications/message/service/message_chat_test.go b/applications/message/service/message_chat_test.go new file mode 100644 index 00000000..b6c3fda7 --- /dev/null +++ b/applications/message/service/message_chat_test.go @@ -0,0 +1,23 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/cloudwego/hertz/pkg/common/test/assert" + "testing" +) + +func TestMessageChatService(t *testing.T) { + Init() + msgService := NewMessageChatService(context.Background()) + req := &message.DouyinMessageChatRequest{ + ToUserId: 10002000, + UserId: 10001000, + PreMsgTime: 0, + } + err, ret := msgService.MessageChat(req) + assert.Nil(t, err) + for _, msg := range ret { + assert.DeepEqual(t, "test msg", msg.Content) + } +} diff --git a/applications/message/service/message_friend.go b/applications/message/service/message_friend.go index c49154bd..e6e6258f 100644 --- a/applications/message/service/message_friend.go +++ b/applications/message/service/message_friend.go @@ -2,8 +2,6 @@ package service import ( "context" - - "github.com/TremblingV5/DouTok/kitex_gen/entity" "github.com/TremblingV5/DouTok/kitex_gen/message" "github.com/TremblingV5/DouTok/pkg/utils" "github.com/cloudwego/kitex/pkg/klog" @@ -17,30 +15,20 @@ func NewMessageFriendService(ctx context.Context) *MessageFriendService { return &MessageFriendService{ctx: ctx} } -func (s *MessageFriendService) MessageFriendList(req *message.DouyinFriendListMessageRequest) (error, map[int64]*entity.Message) { +func (s *MessageFriendService) MessageFriendList(req *message.DouyinFriendListMessageRequest) (error, map[int64]*message.Message) { // 从 redis 缓存读 key:会话id value: 消息内容 - result := make(map[int64]*entity.Message) + result := make(map[int64]*message.Message) for _, friendId := range req.GetFriendIdList() { sessionId := utils.GenerateSessionId(req.UserId, friendId) content, err := RedisClient.HGet(context.Background(), sessionId, "content").Result() - if err != nil { - klog.Errorf("get friend list message error, sessionId = %s, err = %s", sessionId, err) - // TODO 从 hbase获取最新一条聊天记录(慢)应该使用基于 redis 的存储(集群确保可用性) - } - fromUserId, err := RedisClient.HGet(context.Background(), sessionId, "from_user_id").Float64() - if err != nil { - klog.Errorf("get friend list message error, sessionId = %s, err = %s", sessionId, err) - // TODO 从 hbase获取最新一条聊天记录(慢)应该使用基于 redis 的存储(集群确保可用性) - } - toUserId, err := RedisClient.HGet(context.Background(), sessionId, "to_user_id").Float64() if err != nil { klog.Errorf("get friend list message error, sessionId = %s, err = %s", sessionId, err) // TODO 从 hbase获取最新一条聊天记录(慢)应该使用基于 redis 的存储(集群确保可用性) } - message := entity.Message{ + message := message.Message{ Content: content, FromUserId: int64(fromUserId), ToUserId: int64(toUserId), diff --git a/applications/message/service/message_friend_test.go b/applications/message/service/message_friend_test.go new file mode 100644 index 00000000..92446f7b --- /dev/null +++ b/applications/message/service/message_friend_test.go @@ -0,0 +1,23 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/cloudwego/hertz/pkg/common/test/assert" + "testing" +) + +func TestMessageFriendService(t *testing.T) { + Init() + msgService := NewMessageFriendService(context.Background()) + req := &message.DouyinFriendListMessageRequest{ + UserId: 10001000, + FriendIdList: []int64{10002000}, + } + err, ret := msgService.MessageFriendList(req) + assert.Nil(t, err) + for k, v := range ret { + assert.DeepEqual(t, int64(10002000), k) + assert.DeepEqual(t, "test msg", v.Content) + } +} diff --git a/applications/messageDomain/Makefile b/applications/messageDomain/Makefile deleted file mode 100644 index 111cc7e3..00000000 --- a/applications/messageDomain/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -server: - kitex -module github.com/TremblingV5/DouTok -type protobuf -I ../../proto/ -service messageDomain ../../proto/messageDomain.proto \ No newline at end of file diff --git a/applications/messageDomain/build.sh b/applications/messageDomain/build.sh deleted file mode 100644 index 2c30c259..00000000 --- a/applications/messageDomain/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -RUN_NAME="messageDomain" - -mkdir -p output/bin -cp script/* output/ -chmod +x output/bootstrap.sh - -if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then - go build -o output/bin/${RUN_NAME} -else - go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... -fi - diff --git a/applications/messageDomain/handler/add_message.go b/applications/messageDomain/handler/add_message.go deleted file mode 100644 index 97b2c7cd..00000000 --- a/applications/messageDomain/handler/add_message.go +++ /dev/null @@ -1,21 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/messageDomain/pack" - "github.com/TremblingV5/DouTok/applications/messageDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func (s *MessageDomainServiceImpl) AddMessage(ctx context.Context, req *messageDomain.DoutokAddMessageRequest) (resp *messageDomain.DoutokAddMessageResponse, err error) { - resp = new(messageDomain.DoutokAddMessageResponse) - - err = service.NewMessageActionService(ctx).MessageAction(req) - if err != nil { - pack.BuildMessageActionResp(err, resp) - return resp, nil - } - pack.BuildMessageActionResp(errno.Success, resp) - return resp, nil -} diff --git a/applications/messageDomain/handler/list_message.go b/applications/messageDomain/handler/list_message.go deleted file mode 100644 index b3a8b928..00000000 --- a/applications/messageDomain/handler/list_message.go +++ /dev/null @@ -1,24 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/messageDomain/pack" - "github.com/TremblingV5/DouTok/applications/messageDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func (s *MessageDomainServiceImpl) ListMessage(ctx context.Context, req *messageDomain.DoutokListMessageRequest) (resp *messageDomain.DoutokListMessageResponse, err error) { - // 从 hbase 返回历史消息列表(会话id的概念) - resp = new(messageDomain.DoutokListMessageResponse) - - err, messageList := service.NewMessageChatService(ctx).MessageChat(req) - if err != nil { - pack.BuildMessageChatResp(err, resp) - return resp, nil - } - resp.Message = messageList - - pack.BuildMessageChatResp(errno.Success, resp) - return resp, nil -} diff --git a/applications/messageDomain/handler/typedef.go b/applications/messageDomain/handler/typedef.go deleted file mode 100644 index 305dbb92..00000000 --- a/applications/messageDomain/handler/typedef.go +++ /dev/null @@ -1,3 +0,0 @@ -package handler - -type MessageDomainServiceImpl struct{} diff --git a/applications/messageDomain/main.go b/applications/messageDomain/main.go deleted file mode 100644 index a1530d90..00000000 --- a/applications/messageDomain/main.go +++ /dev/null @@ -1,39 +0,0 @@ -package main - -import ( - "github.com/TremblingV5/DouTok/applications/messageDomain/handler" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain/messagedomainservice" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/services" - - "github.com/TremblingV5/DouTok/applications/messageDomain/service" - "github.com/TremblingV5/DouTok/pkg/dlog" -) - -var ( - Logger = dlog.InitLog(3) -) - -func init() { - service.InitViper() - service.InitHB() - service.InitRedisClient() - service.InitSyncProducer() - service.InitConsumerGroup() - service.InitId() -} - -func main() { - - options, shutdown := services.InitRPCServerArgs(constants.MESSAGE_DOMAIN_SERVER_NAME, service.DomainConfig.BaseConfig) - defer shutdown() - - svr := messagedomainservice.NewServer( - new(handler.MessageDomainServiceImpl), - options..., - ) - - if err := svr.Run(); err != nil { - Logger.Fatal(err) - } -} diff --git a/applications/messageDomain/pack/message.go b/applications/messageDomain/pack/message.go deleted file mode 100644 index 924443fa..00000000 --- a/applications/messageDomain/pack/message.go +++ /dev/null @@ -1,63 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - "github.com/TremblingV5/DouTok/pkg/utils" - "github.com/cloudwego/kitex/pkg/klog" - "strconv" - "time" -) - -type Message struct { - Id int64 `json:"id"` - FromUserId int64 `json:"from_user_id"` - ToUserId int64 `json:"to_user_id"` - Content string `json:"content"` - CreateTime int64 `json:"create_time"` -} - -type HBMessage struct { - Id []byte `json:"id"` - FromUserId []byte `json:"from_user_id"` - ToUserId []byte `json:"to_user_id"` - Content []byte `json:"content"` - CreateTime []byte `json:"create_time"` -} - -func NewMessage(req *messageDomain.DoutokAddMessageRequest) *entity.Message { - message := entity.Message{ - Id: int64(utils.GetSnowFlakeId()), - FromUserId: req.UserId, - ToUserId: req.ToUserId, - Content: req.Content, - CreateTime: time.Now().Unix(), - } - return &message -} - -func HBMsg2Msg(msg *HBMessage) *entity.Message { - id, err := strconv.ParseInt(string(msg.Id), 10, 64) - if err != nil { - klog.Errorf("hbmsg to msg error, err = %s", err) - } - fromUserId, err := strconv.ParseInt(string(msg.FromUserId), 10, 64) - if err != nil { - klog.Errorf("hbmsg to msg error, err = %s", err) - } - toUserId, err := strconv.ParseInt(string(msg.ToUserId), 10, 64) - if err != nil { - klog.Errorf("hbmsg to msg error, err = %s", err) - } - createTime, err := strconv.ParseInt(string(msg.CreateTime), 10, 64) - if err != nil { - klog.Errorf("hbmsg to msg error, err = %s", err) - } - return &entity.Message{ - Id: id, - FromUserId: fromUserId, - ToUserId: toUserId, - CreateTime: createTime, - Content: string(msg.Content), - } -} diff --git a/applications/messageDomain/pack/resp.go b/applications/messageDomain/pack/resp.go deleted file mode 100644 index 7b233f88..00000000 --- a/applications/messageDomain/pack/resp.go +++ /dev/null @@ -1,25 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/message" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func BuildMessageActionResp(err error, resp *messageDomain.DoutokAddMessageResponse) { - e := errno.ConvertErr(err) - resp.StatusMsg = e.ErrMsg - resp.StatusCode = int32(e.ErrCode) -} - -func BuildMessageChatResp(err error, resp *messageDomain.DoutokListMessageResponse) { - e := errno.ConvertErr(err) - resp.StatusMsg = e.ErrMsg - resp.StatusCode = int32(e.ErrCode) -} - -func BuildMessageFriendResp(err error, resp *message.DouyinFriendListMessageResponse) { - e := errno.ConvertErr(err) - resp.StatusMsg = e.ErrMsg - resp.StatusCode = int32(e.ErrCode) -} diff --git a/applications/messageDomain/script/bootstrap.sh b/applications/messageDomain/script/bootstrap.sh deleted file mode 100644 index 34e126cb..00000000 --- a/applications/messageDomain/script/bootstrap.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env bash -CURDIR=$(cd $(dirname $0); pwd) - -if [ "X$1" != "X" ]; then - RUNTIME_ROOT=$1 -else - RUNTIME_ROOT=${CURDIR} -fi - -export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT -export KITEX_LOG_DIR="$RUNTIME_ROOT/log" - -if [ ! -d "$KITEX_LOG_DIR/app" ]; then - mkdir -p "$KITEX_LOG_DIR/app" -fi - -if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then - mkdir -p "$KITEX_LOG_DIR/rpc" -fi - -exec "$CURDIR/bin/messageDomain" - diff --git a/applications/messageDomain/service/consume_msg.go b/applications/messageDomain/service/consume_msg.go deleted file mode 100644 index c848c661..00000000 --- a/applications/messageDomain/service/consume_msg.go +++ /dev/null @@ -1,91 +0,0 @@ -package service - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/applications/messageDomain/pack" - "github.com/TremblingV5/DouTok/pkg/misc" - "github.com/TremblingV5/DouTok/pkg/utils" - "github.com/cloudwego/kitex/pkg/klog" -) - -type msgConsumerGroup struct{} - -func (m msgConsumerGroup) Setup(_ sarama.ConsumerGroupSession) error { return nil } -func (m msgConsumerGroup) Cleanup(_ sarama.ConsumerGroupSession) error { return nil } -func (m msgConsumerGroup) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { - for msg := range claim.Messages() { - fmt.Printf("Message topic:%q partition:%d offset:%d value:%s\n", msg.Topic, msg.Partition, msg.Offset, string(msg.Value)) - - message := pack.Message{} - if err := json.Unmarshal(msg.Value, &message); err != nil { - return err - } - mp, err := misc.Struct2Map(message) - if err != nil { - return err - } - // Struct2Map 有bug,会转float64 - klog.Infof("messages to map, msg content = %s from %d to %d\n", mp["content"], int64(mp["from_user_id"].(float64)), int64(mp["to_user_id"].(float64))) - sessionId := utils.GenerateSessionId(message.FromUserId, message.ToUserId) - - // 更新 redis 的最新消息 - err = RedisClient.HMSet(context.Background(), sessionId, mp).Err() - if err != nil { - return err - } - - content, err := RedisClient.HGet(context.Background(), sessionId, "content").Result() - if err != nil { - klog.Errorf("get friend list message error, err = %s", err) - } - klog.Infof("content = %s\n", content) - - // 将消息存入 hbase - // 生成 rowkey - rowKey := fmt.Sprintf("%s%d", sessionId, message.CreateTime) - - println("consume msg form kafka, generate rowKey = ", rowKey) - - // 构造 hbase 一条数据 - hbData := map[string]map[string][]byte{ - "data": { - "id": []byte(fmt.Sprintf("%d", message.Id)), - "from_user_id": []byte(fmt.Sprintf("%d", message.FromUserId)), - "to_user_id": []byte(fmt.Sprintf("%d", message.ToUserId)), - "content": []byte(message.Content), - "create_time": []byte(fmt.Sprintf("%d", message.CreateTime)), - }, - } - - err = HBClient.Put(ViperConfig.Viper.GetString("Hbase.Table"), rowKey, hbData) - if err != nil { - return err - } - - // TODO 1、解决消息重复消费 2、分布式事务一致性(redis 与 hbase 同时成功或失败、重试策略) - - // 标记,sarama会自动进行提交,默认间隔1秒 - sess.MarkMessage(msg, "") - - } - return nil -} - -var consumerGroup msgConsumerGroup - -func ConsumeMsg() { - - for { - err := ConsumerGroup.Consume(context.Background(), ViperConfig.Viper.GetStringSlice("Kafka.Topics"), consumerGroup) - if err != nil { - fmt.Println(err.Error()) - break - } - } - - _ = ConsumerGroup.Close() -} diff --git a/applications/messageDomain/service/init.go b/applications/messageDomain/service/init.go deleted file mode 100644 index 702e83e2..00000000 --- a/applications/messageDomain/service/init.go +++ /dev/null @@ -1,61 +0,0 @@ -package service - -import ( - "github.com/TremblingV5/DouTok/config/configStruct" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/bytedance/gopkg/util/logger" - "go.uber.org/zap" - - "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/pkg/dtviper" - "github.com/TremblingV5/DouTok/pkg/hbaseHandle" - "github.com/TremblingV5/DouTok/pkg/kafka" - "github.com/TremblingV5/DouTok/pkg/utils" - "github.com/go-redis/redis/v8" -) - -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_MESSAGEDOMAIN_"` - Redis configStruct.Redis `envPrefix:"DOUTOK_MESSAGEDOMAIN_"` - HBase configStruct.HBase `envPrefix:"DOUTOK_MESSAGEDOMAIN_"` -} - -var ( - HBClient *hbaseHandle.HBaseClient - RedisClient *redis.Client - SyncProducer sarama.SyncProducer - ViperConfig *dtviper.Config - ConsumerGroup sarama.ConsumerGroup - DomainConfig = &Config{} -) - -func InitViper() { - v, err := configurator.Load(DomainConfig, "DOUTOK_MESSAGEDOMAIN", "messageDomain") - ViperConfig = v - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", DomainConfig)) - } -} - -func InitHB() { - HBClient = &hbaseHandle.HBaseClient{Client: *DomainConfig.HBase.InitHB()} -} - -func InitSyncProducer() { - producer := kafka.InitSynProducer(ViperConfig.Viper.GetStringSlice("Kafka.Brokers")) - SyncProducer = producer -} - -func InitConsumerGroup() { - cGroup := kafka.InitConsumerGroup(ViperConfig.Viper.GetStringSlice("Kafka.Brokers"), ViperConfig.Viper.GetStringSlice("Kafka.GroupIds")[0]) - ConsumerGroup = cGroup -} - -func InitRedisClient() { - RedisClient = DomainConfig.Redis.InitRedisClient(configStruct.DEFAULT_DATABASE) -} - -func InitId() { - node := ViperConfig.Viper.GetInt64("Snowflake.Node") - utils.InitSnowFlake(node) -} diff --git a/applications/messageDomain/service/message_action.go b/applications/messageDomain/service/message_action.go deleted file mode 100644 index 524e0020..00000000 --- a/applications/messageDomain/service/message_action.go +++ /dev/null @@ -1,40 +0,0 @@ -package service - -import ( - "context" - "encoding/json" - "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/applications/messageDomain/pack" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - "github.com/cloudwego/kitex/pkg/klog" -) - -type MessageActionService struct { - ctx context.Context -} - -func NewMessageActionService(ctx context.Context) *MessageActionService { - return &MessageActionService{ctx: ctx} -} - -func (s *MessageActionService) MessageAction(req *messageDomain.DoutokAddMessageRequest) error { - // 使用同步producer,将消息存入 kafka - // 构建消息 - val, err := json.Marshal(pack.NewMessage(req)) - if err != nil { - return err - } - msg := &sarama.ProducerMessage{ - Topic: ViperConfig.Viper.GetStringSlice("Kafka.Topics")[0], - Value: sarama.StringEncoder(val), - } - partition, offset, err := SyncProducer.SendMessage(msg) - - if err == nil { - klog.Infof("produce success, partition: %d, offset: %d\n", partition, offset) - } else { - return err - } - - return nil -} diff --git a/applications/messageDomain/service/message_chat.go b/applications/messageDomain/service/message_chat.go deleted file mode 100644 index 11913450..00000000 --- a/applications/messageDomain/service/message_chat.go +++ /dev/null @@ -1,54 +0,0 @@ -package service - -import ( - "context" - "fmt" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - "math" - "sort" - - "github.com/TremblingV5/DouTok/applications/messageDomain/pack" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/pkg/misc" - "github.com/TremblingV5/DouTok/pkg/utils" -) - -type MessageChatService struct { - ctx context.Context -} - -func NewMessageChatService(ctx context.Context) *MessageChatService { - return &MessageChatService{ctx: ctx} -} - -func (s *MessageChatService) MessageChat(req *messageDomain.DoutokListMessageRequest) (error, []*entity.Message) { - // 从 hbase 获取聊天记录 - messageList := make([]*entity.Message, 0) - sessionId := utils.GenerateSessionId(req.UserId, req.ToUserId) - start := fmt.Sprintf("%s%d", sessionId, req.PreMsgTime) - end := fmt.Sprintf("%s%d", sessionId, math.MaxInt) - res, err := HBClient.ScanRange(ViperConfig.Viper.GetString("Hbase.Table"), start, end) - if err != nil { - return err, nil - } - for _, v := range res { - hbMsg := pack.HBMessage{} - err := misc.Map2Struct4HB(v, &hbMsg) - if err != nil { - continue - } - packMsg := pack.HBMsg2Msg(&hbMsg) - message := entity.Message{ - Id: packMsg.Id, - ToUserId: packMsg.ToUserId, - FromUserId: packMsg.FromUserId, - Content: packMsg.Content, - CreateTime: packMsg.CreateTime, - } - messageList = append(messageList, &message) - } - sort.SliceStable(messageList, func(i, j int) bool { - return messageList[i].CreateTime < messageList[j].CreateTime - }) - return nil, messageList -} diff --git a/applications/messageDomain/service/message_friend.go b/applications/messageDomain/service/message_friend.go deleted file mode 100644 index c49154bd..00000000 --- a/applications/messageDomain/service/message_friend.go +++ /dev/null @@ -1,51 +0,0 @@ -package service - -import ( - "context" - - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/message" - "github.com/TremblingV5/DouTok/pkg/utils" - "github.com/cloudwego/kitex/pkg/klog" -) - -type MessageFriendService struct { - ctx context.Context -} - -func NewMessageFriendService(ctx context.Context) *MessageFriendService { - return &MessageFriendService{ctx: ctx} -} - -func (s *MessageFriendService) MessageFriendList(req *message.DouyinFriendListMessageRequest) (error, map[int64]*entity.Message) { - // 从 redis 缓存读 key:会话id value: 消息内容 - result := make(map[int64]*entity.Message) - for _, friendId := range req.GetFriendIdList() { - sessionId := utils.GenerateSessionId(req.UserId, friendId) - content, err := RedisClient.HGet(context.Background(), sessionId, "content").Result() - if err != nil { - klog.Errorf("get friend list message error, sessionId = %s, err = %s", sessionId, err) - // TODO 从 hbase获取最新一条聊天记录(慢)应该使用基于 redis 的存储(集群确保可用性) - } - - fromUserId, err := RedisClient.HGet(context.Background(), sessionId, "from_user_id").Float64() - if err != nil { - klog.Errorf("get friend list message error, sessionId = %s, err = %s", sessionId, err) - // TODO 从 hbase获取最新一条聊天记录(慢)应该使用基于 redis 的存储(集群确保可用性) - } - - toUserId, err := RedisClient.HGet(context.Background(), sessionId, "to_user_id").Float64() - if err != nil { - klog.Errorf("get friend list message error, sessionId = %s, err = %s", sessionId, err) - // TODO 从 hbase获取最新一条聊天记录(慢)应该使用基于 redis 的存储(集群确保可用性) - } - - message := entity.Message{ - Content: content, - FromUserId: int64(fromUserId), - ToUserId: int64(toUserId), - } - result[friendId] = &message - } - return nil, result -} diff --git a/applications/publish/build.sh b/applications/publish/build.sh index db120940..1c389225 100644 --- a/applications/publish/build.sh +++ b/applications/publish/build.sh @@ -10,4 +10,3 @@ if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then else go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... fi - diff --git a/applications/publish/callback/callback.go b/applications/publish/callback/callback.go new file mode 100644 index 00000000..e60fb7f9 --- /dev/null +++ b/applications/publish/callback/callback.go @@ -0,0 +1,14 @@ +package callback + +import ( + "github.com/gin-gonic/gin" +) + +func InitCallbackServer() { + server := gin.Default() + + router := server.Group("/callback") + router.POST("/handle", CallbackAction) + + server.Run(":8888") +} diff --git a/applications/publish/callback/controller.go b/applications/publish/callback/controller.go new file mode 100644 index 00000000..18f5af02 --- /dev/null +++ b/applications/publish/callback/controller.go @@ -0,0 +1,25 @@ +package callback + +import ( + "fmt" + "net/http" + + "github.com/gin-gonic/gin" +) + +type CallbackDto struct { + Filename string `json:"filename"` + Size string `json:"size"` +} + +func CallbackAction(c *gin.Context) { + var in CallbackDto + if err := c.Bind(&in); err != nil { + fmt.Println(err) + } + fmt.Println(in) + + c.JSON(http.StatusOK, gin.H{ + "Status": "OK", + }) +} diff --git a/applications/publish/dal/gen.go b/applications/publish/dal/gen.go new file mode 100644 index 00000000..afc16f95 --- /dev/null +++ b/applications/publish/dal/gen.go @@ -0,0 +1,39 @@ +package main + +import ( + "github.com/TremblingV5/DouTok/applications/feed/dal/model" + "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/pkg/configurator" + "github.com/TremblingV5/DouTok/pkg/mysqlIniter" + "gorm.io/gen" +) + +func main() { + g := gen.NewGenerator(gen.Config{ + OutPath: "../query", + Mode: gen.WithoutContext | gen.WithDefaultQuery | gen.WithQueryInterface, + }) + + var config configStruct.MySQLConfig + configurator.InitConfig( + &config, "mysql.yaml", + ) + + db, err := mysqlIniter.InitDb( + config.Username, + config.Password, + config.Host, + config.Port, + config.Database, + ) + + if err != nil { + panic(err) + } + + g.UseDB(db) + g.ApplyBasic(model.Video{}) + g.ApplyInterface(func() {}, model.Video{}) + + g.Execute() +} diff --git a/applications/publish/dal/migrate/main.go b/applications/publish/dal/migrate/main.go new file mode 100644 index 00000000..467e76f4 --- /dev/null +++ b/applications/publish/dal/migrate/main.go @@ -0,0 +1,21 @@ +package main + +import ( + "github.com/TremblingV5/DouTok/applications/publish/dal/model" + "github.com/TremblingV5/DouTok/applications/publish/misc" + "github.com/TremblingV5/DouTok/applications/publish/service" +) + +func main() { + misc.InitViperConfig() + + service.InitDb( + misc.GetConfig("MySQL.Username"), + misc.GetConfig("MySQL.Password"), + misc.GetConfig("MySQL.Host"), + misc.GetConfig("MySQL.Port"), + misc.GetConfig("MySQL.Database"), + ) + + service.DB.AutoMigrate(&model.Video{}) +} diff --git a/applications/publish/dal/model/video.go b/applications/publish/dal/model/video.go new file mode 100644 index 00000000..341d8704 --- /dev/null +++ b/applications/publish/dal/model/video.go @@ -0,0 +1,17 @@ +package model + +import ( + "time" +) + +type Video struct { + ID uint64 `gorm:"primarykey"` + AuthorID uint64 `gorm:"index:author_id"` + Title string + VideoUrl string + CoverUrl string + FavCount uint64 // 点赞数 + ComCount uint64 // 评论数 + CreatedAt time.Time `gorm:"type:TIMESTAMP;default:CURRENT_TIMESTAMP"` + UpdatedAt time.Time `gorm:"type:TIMESTAMP;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP"` +} diff --git a/applications/publish/dal/query/gen.go b/applications/publish/dal/query/gen.go new file mode 100644 index 00000000..cc7ae460 --- /dev/null +++ b/applications/publish/dal/query/gen.go @@ -0,0 +1,99 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package query + +import ( + "context" + "database/sql" + + "gorm.io/gorm" + + "gorm.io/gen" + + "gorm.io/plugin/dbresolver" +) + +var ( + Q = new(Query) + Video *video +) + +func SetDefault(db *gorm.DB, opts ...gen.DOOption) { + *Q = *Use(db, opts...) + Video = &Q.Video +} + +func Use(db *gorm.DB, opts ...gen.DOOption) *Query { + return &Query{ + db: db, + Video: newVideo(db, opts...), + } +} + +type Query struct { + db *gorm.DB + + Video video +} + +func (q *Query) Available() bool { return q.db != nil } + +func (q *Query) clone(db *gorm.DB) *Query { + return &Query{ + db: db, + Video: q.Video.clone(db), + } +} + +func (q *Query) ReadDB() *Query { + return q.clone(q.db.Clauses(dbresolver.Read)) +} + +func (q *Query) WriteDB() *Query { + return q.clone(q.db.Clauses(dbresolver.Write)) +} + +func (q *Query) ReplaceDB(db *gorm.DB) *Query { + return &Query{ + db: db, + Video: q.Video.replaceDB(db), + } +} + +type queryCtx struct { + Video IVideoDo +} + +func (q *Query) WithContext(ctx context.Context) *queryCtx { + return &queryCtx{ + Video: q.Video.WithContext(ctx), + } +} + +func (q *Query) Transaction(fc func(tx *Query) error, opts ...*sql.TxOptions) error { + return q.db.Transaction(func(tx *gorm.DB) error { return fc(q.clone(tx)) }, opts...) +} + +func (q *Query) Begin(opts ...*sql.TxOptions) *QueryTx { + return &QueryTx{q.clone(q.db.Begin(opts...))} +} + +type QueryTx struct{ *Query } + +func (q *QueryTx) Commit() error { + return q.db.Commit().Error +} + +func (q *QueryTx) Rollback() error { + return q.db.Rollback().Error +} + +func (q *QueryTx) SavePoint(name string) error { + return q.db.SavePoint(name).Error +} + +func (q *QueryTx) RollbackTo(name string) error { + return q.db.RollbackTo(name).Error +} diff --git a/applications/publish/dal/query/typedef.go b/applications/publish/dal/query/typedef.go new file mode 100644 index 00000000..77547dba --- /dev/null +++ b/applications/publish/dal/query/typedef.go @@ -0,0 +1,3 @@ +package query + +var VideoStruct = &video{} diff --git a/applications/publish/dal/query/videos.gen.go b/applications/publish/dal/query/videos.gen.go new file mode 100644 index 00000000..a80d0c5d --- /dev/null +++ b/applications/publish/dal/query/videos.gen.go @@ -0,0 +1,416 @@ +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. +// Code generated by gorm.io/gen. DO NOT EDIT. + +package query + +import ( + "context" + + "gorm.io/gorm" + "gorm.io/gorm/clause" + "gorm.io/gorm/schema" + + "gorm.io/gen" + "gorm.io/gen/field" + + "gorm.io/plugin/dbresolver" + + "github.com/TremblingV5/DouTok/applications/publish/dal/model" +) + +func newVideo(db *gorm.DB, opts ...gen.DOOption) video { + _video := video{} + + _video.videoDo.UseDB(db, opts...) + _video.videoDo.UseModel(&model.Video{}) + + tableName := _video.videoDo.TableName() + _video.ALL = field.NewAsterisk(tableName) + _video.ID = field.NewUint64(tableName, "id") + _video.AuthorID = field.NewUint64(tableName, "author_id") + _video.Title = field.NewString(tableName, "title") + _video.VideoUrl = field.NewString(tableName, "video_url") + _video.CoverUrl = field.NewString(tableName, "cover_url") + _video.FavCount = field.NewUint64(tableName, "fav_count") + _video.ComCount = field.NewUint64(tableName, "com_count") + _video.CreatedAt = field.NewTime(tableName, "created_at") + _video.UpdatedAt = field.NewTime(tableName, "updated_at") + + _video.fillFieldMap() + + return _video +} + +type video struct { + videoDo + + ALL field.Asterisk + ID field.Uint64 + AuthorID field.Uint64 + Title field.String + VideoUrl field.String + CoverUrl field.String + FavCount field.Uint64 + ComCount field.Uint64 + CreatedAt field.Time + UpdatedAt field.Time + + fieldMap map[string]field.Expr +} + +func (v video) Table(newTableName string) *video { + v.videoDo.UseTable(newTableName) + return v.updateTableName(newTableName) +} + +func (v video) As(alias string) *video { + v.videoDo.DO = *(v.videoDo.As(alias).(*gen.DO)) + return v.updateTableName(alias) +} + +func (v *video) updateTableName(table string) *video { + v.ALL = field.NewAsterisk(table) + v.ID = field.NewUint64(table, "id") + v.AuthorID = field.NewUint64(table, "author_id") + v.Title = field.NewString(table, "title") + v.VideoUrl = field.NewString(table, "video_url") + v.CoverUrl = field.NewString(table, "cover_url") + v.FavCount = field.NewUint64(table, "fav_count") + v.ComCount = field.NewUint64(table, "com_count") + v.CreatedAt = field.NewTime(table, "created_at") + v.UpdatedAt = field.NewTime(table, "updated_at") + + v.fillFieldMap() + + return v +} + +func (v *video) GetFieldByName(fieldName string) (field.OrderExpr, bool) { + _f, ok := v.fieldMap[fieldName] + if !ok || _f == nil { + return nil, false + } + _oe, ok := _f.(field.OrderExpr) + return _oe, ok +} + +func (v *video) fillFieldMap() { + v.fieldMap = make(map[string]field.Expr, 9) + v.fieldMap["id"] = v.ID + v.fieldMap["author_id"] = v.AuthorID + v.fieldMap["title"] = v.Title + v.fieldMap["video_url"] = v.VideoUrl + v.fieldMap["cover_url"] = v.CoverUrl + v.fieldMap["fav_count"] = v.FavCount + v.fieldMap["com_count"] = v.ComCount + v.fieldMap["created_at"] = v.CreatedAt + v.fieldMap["updated_at"] = v.UpdatedAt +} + +func (v video) clone(db *gorm.DB) video { + v.videoDo.ReplaceConnPool(db.Statement.ConnPool) + return v +} + +func (v video) replaceDB(db *gorm.DB) video { + v.videoDo.ReplaceDB(db) + return v +} + +type videoDo struct{ gen.DO } + +type IVideoDo interface { + gen.SubQuery + Debug() IVideoDo + WithContext(ctx context.Context) IVideoDo + WithResult(fc func(tx gen.Dao)) gen.ResultInfo + ReplaceDB(db *gorm.DB) + ReadDB() IVideoDo + WriteDB() IVideoDo + As(alias string) gen.Dao + Session(config *gorm.Session) IVideoDo + Columns(cols ...field.Expr) gen.Columns + Clauses(conds ...clause.Expression) IVideoDo + Not(conds ...gen.Condition) IVideoDo + Or(conds ...gen.Condition) IVideoDo + Select(conds ...field.Expr) IVideoDo + Where(conds ...gen.Condition) IVideoDo + Order(conds ...field.Expr) IVideoDo + Distinct(cols ...field.Expr) IVideoDo + Omit(cols ...field.Expr) IVideoDo + Join(table schema.Tabler, on ...field.Expr) IVideoDo + LeftJoin(table schema.Tabler, on ...field.Expr) IVideoDo + RightJoin(table schema.Tabler, on ...field.Expr) IVideoDo + Group(cols ...field.Expr) IVideoDo + Having(conds ...gen.Condition) IVideoDo + Limit(limit int) IVideoDo + Offset(offset int) IVideoDo + Count() (count int64, err error) + Scopes(funcs ...func(gen.Dao) gen.Dao) IVideoDo + Unscoped() IVideoDo + Create(values ...*model.Video) error + CreateInBatches(values []*model.Video, batchSize int) error + Save(values ...*model.Video) error + First() (*model.Video, error) + Take() (*model.Video, error) + Last() (*model.Video, error) + Find() ([]*model.Video, error) + FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Video, err error) + FindInBatches(result *[]*model.Video, batchSize int, fc func(tx gen.Dao, batch int) error) error + Pluck(column field.Expr, dest interface{}) error + Delete(...*model.Video) (info gen.ResultInfo, err error) + Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + Updates(value interface{}) (info gen.ResultInfo, err error) + UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) + UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) + UpdateColumns(value interface{}) (info gen.ResultInfo, err error) + UpdateFrom(q gen.SubQuery) gen.Dao + Attrs(attrs ...field.AssignExpr) IVideoDo + Assign(attrs ...field.AssignExpr) IVideoDo + Joins(fields ...field.RelationField) IVideoDo + Preload(fields ...field.RelationField) IVideoDo + FirstOrInit() (*model.Video, error) + FirstOrCreate() (*model.Video, error) + FindByPage(offset int, limit int) (result []*model.Video, count int64, err error) + ScanByPage(result interface{}, offset int, limit int) (count int64, err error) + Scan(result interface{}) (err error) + Returning(value interface{}, columns ...string) IVideoDo + UnderlyingDB() *gorm.DB + schema.Tabler +} + +func (v videoDo) Debug() IVideoDo { + return v.withDO(v.DO.Debug()) +} + +func (v videoDo) WithContext(ctx context.Context) IVideoDo { + return v.withDO(v.DO.WithContext(ctx)) +} + +func (v videoDo) ReadDB() IVideoDo { + return v.Clauses(dbresolver.Read) +} + +func (v videoDo) WriteDB() IVideoDo { + return v.Clauses(dbresolver.Write) +} + +func (v videoDo) Session(config *gorm.Session) IVideoDo { + return v.withDO(v.DO.Session(config)) +} + +func (v videoDo) Clauses(conds ...clause.Expression) IVideoDo { + return v.withDO(v.DO.Clauses(conds...)) +} + +func (v videoDo) Returning(value interface{}, columns ...string) IVideoDo { + return v.withDO(v.DO.Returning(value, columns...)) +} + +func (v videoDo) Not(conds ...gen.Condition) IVideoDo { + return v.withDO(v.DO.Not(conds...)) +} + +func (v videoDo) Or(conds ...gen.Condition) IVideoDo { + return v.withDO(v.DO.Or(conds...)) +} + +func (v videoDo) Select(conds ...field.Expr) IVideoDo { + return v.withDO(v.DO.Select(conds...)) +} + +func (v videoDo) Where(conds ...gen.Condition) IVideoDo { + return v.withDO(v.DO.Where(conds...)) +} + +func (v videoDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) IVideoDo { + return v.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB())) +} + +func (v videoDo) Order(conds ...field.Expr) IVideoDo { + return v.withDO(v.DO.Order(conds...)) +} + +func (v videoDo) Distinct(cols ...field.Expr) IVideoDo { + return v.withDO(v.DO.Distinct(cols...)) +} + +func (v videoDo) Omit(cols ...field.Expr) IVideoDo { + return v.withDO(v.DO.Omit(cols...)) +} + +func (v videoDo) Join(table schema.Tabler, on ...field.Expr) IVideoDo { + return v.withDO(v.DO.Join(table, on...)) +} + +func (v videoDo) LeftJoin(table schema.Tabler, on ...field.Expr) IVideoDo { + return v.withDO(v.DO.LeftJoin(table, on...)) +} + +func (v videoDo) RightJoin(table schema.Tabler, on ...field.Expr) IVideoDo { + return v.withDO(v.DO.RightJoin(table, on...)) +} + +func (v videoDo) Group(cols ...field.Expr) IVideoDo { + return v.withDO(v.DO.Group(cols...)) +} + +func (v videoDo) Having(conds ...gen.Condition) IVideoDo { + return v.withDO(v.DO.Having(conds...)) +} + +func (v videoDo) Limit(limit int) IVideoDo { + return v.withDO(v.DO.Limit(limit)) +} + +func (v videoDo) Offset(offset int) IVideoDo { + return v.withDO(v.DO.Offset(offset)) +} + +func (v videoDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IVideoDo { + return v.withDO(v.DO.Scopes(funcs...)) +} + +func (v videoDo) Unscoped() IVideoDo { + return v.withDO(v.DO.Unscoped()) +} + +func (v videoDo) Create(values ...*model.Video) error { + if len(values) == 0 { + return nil + } + return v.DO.Create(values) +} + +func (v videoDo) CreateInBatches(values []*model.Video, batchSize int) error { + return v.DO.CreateInBatches(values, batchSize) +} + +// Save : !!! underlying implementation is different with GORM +// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) +func (v videoDo) Save(values ...*model.Video) error { + if len(values) == 0 { + return nil + } + return v.DO.Save(values) +} + +func (v videoDo) First() (*model.Video, error) { + if result, err := v.DO.First(); err != nil { + return nil, err + } else { + return result.(*model.Video), nil + } +} + +func (v videoDo) Take() (*model.Video, error) { + if result, err := v.DO.Take(); err != nil { + return nil, err + } else { + return result.(*model.Video), nil + } +} + +func (v videoDo) Last() (*model.Video, error) { + if result, err := v.DO.Last(); err != nil { + return nil, err + } else { + return result.(*model.Video), nil + } +} + +func (v videoDo) Find() ([]*model.Video, error) { + result, err := v.DO.Find() + return result.([]*model.Video), err +} + +func (v videoDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.Video, err error) { + buf := make([]*model.Video, 0, batchSize) + err = v.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { + defer func() { results = append(results, buf...) }() + return fc(tx, batch) + }) + return results, err +} + +func (v videoDo) FindInBatches(result *[]*model.Video, batchSize int, fc func(tx gen.Dao, batch int) error) error { + return v.DO.FindInBatches(result, batchSize, fc) +} + +func (v videoDo) Attrs(attrs ...field.AssignExpr) IVideoDo { + return v.withDO(v.DO.Attrs(attrs...)) +} + +func (v videoDo) Assign(attrs ...field.AssignExpr) IVideoDo { + return v.withDO(v.DO.Assign(attrs...)) +} + +func (v videoDo) Joins(fields ...field.RelationField) IVideoDo { + for _, _f := range fields { + v = *v.withDO(v.DO.Joins(_f)) + } + return &v +} + +func (v videoDo) Preload(fields ...field.RelationField) IVideoDo { + for _, _f := range fields { + v = *v.withDO(v.DO.Preload(_f)) + } + return &v +} + +func (v videoDo) FirstOrInit() (*model.Video, error) { + if result, err := v.DO.FirstOrInit(); err != nil { + return nil, err + } else { + return result.(*model.Video), nil + } +} + +func (v videoDo) FirstOrCreate() (*model.Video, error) { + if result, err := v.DO.FirstOrCreate(); err != nil { + return nil, err + } else { + return result.(*model.Video), nil + } +} + +func (v videoDo) FindByPage(offset int, limit int) (result []*model.Video, count int64, err error) { + result, err = v.Offset(offset).Limit(limit).Find() + if err != nil { + return + } + + if size := len(result); 0 < limit && 0 < size && size < limit { + count = int64(size + offset) + return + } + + count, err = v.Offset(-1).Limit(-1).Count() + return +} + +func (v videoDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { + count, err = v.Count() + if err != nil { + return + } + + err = v.Offset(offset).Limit(limit).Scan(result) + return +} + +func (v videoDo) Scan(result interface{}) (err error) { + return v.DO.Scan(result) +} + +func (v videoDo) Delete(models ...*model.Video) (result gen.ResultInfo, err error) { + return v.DO.Delete(models) +} + +func (v *videoDo) withDO(do gen.Dao) *videoDo { + v.DO = *do.(*gen.DO) + return v +} diff --git a/applications/publish/handler/publish_action.go b/applications/publish/handler/publish_action.go index 17a1afc8..cdb46f5d 100644 --- a/applications/publish/handler/publish_action.go +++ b/applications/publish/handler/publish_action.go @@ -2,18 +2,36 @@ package handler import ( "context" + "github.com/TremblingV5/DouTok/applications/publish/pack" - "github.com/TremblingV5/DouTok/applications/publish/rpc" + + "github.com/TremblingV5/DouTok/applications/publish/service" "github.com/TremblingV5/DouTok/kitex_gen/publish" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" ) func (s *PublishServiceImpl) PublishAction(ctx context.Context, req *publish.DouyinPublishActionRequest) (resp *publish.DouyinPublishActionResponse, err error) { - result, err := rpc.VideoDomainClient.AddPublish(ctx, &videoDomain.DoutokAddPublishRequest{ - Data: req.Data, - Title: req.Title, - UserId: req.UserId, - Name: req.Name, - }) - return pack.PackagePublishActionResponse(result, err) + if ok, msg := check(req); ok { + resp, _ := pack.PackPublishActionRes(1, msg) + return resp, nil + } + + if err := service.SavePublish(req.UserId, req.Title, req.Data); err != nil { + resp, _ := pack.PackPublishActionRes(1, "System error") + return resp, err + } + + resp, _ = pack.PackPublishActionRes(0, "Success") + return resp, nil +} + +func check(req *publish.DouyinPublishActionRequest) (bool, string) { + if len(req.Data) == 0 { + return true, "缺少视频数据" + } + + if len(req.Title) == 0 { + return true, "缺少标题" + } + + return false, "" } diff --git a/applications/publish/handler/publish_list.go b/applications/publish/handler/publish_list.go index eca1d4a6..6571809c 100644 --- a/applications/publish/handler/publish_list.go +++ b/applications/publish/handler/publish_list.go @@ -3,14 +3,24 @@ package handler import ( "context" "github.com/TremblingV5/DouTok/applications/publish/pack" - "github.com/TremblingV5/DouTok/applications/publish/rpc" + + "github.com/TremblingV5/DouTok/applications/publish/service" "github.com/TremblingV5/DouTok/kitex_gen/publish" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" ) func (s *PublishServiceImpl) PublishList(ctx context.Context, req *publish.DouyinPublishListRequest) (resp *publish.DouyinPublishListResponse, err error) { - result, err := rpc.VideoDomainClient.ListPublish(ctx, &videoDomain.DoutokListPublishRequest{ - UserId: req.UserId, - }) - return pack.PackagePublishListResponse(ctx, result, err) + user_id := req.UserId + + list, err := service.QueryPublishListInHBase(user_id) + + if err != nil { + return nil, err + } + + resp, err = pack.PackPublishListRes(list, 0, "Success", req) + if err != nil { + return resp, err + } + + return resp, nil } diff --git a/applications/publish/main.go b/applications/publish/main.go index 261098dd..77acb065 100644 --- a/applications/publish/main.go +++ b/applications/publish/main.go @@ -2,39 +2,28 @@ package main import ( "github.com/TremblingV5/DouTok/applications/publish/handler" + "github.com/TremblingV5/DouTok/applications/publish/misc" "github.com/TremblingV5/DouTok/applications/publish/rpc" - "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/applications/publish/service" "github.com/TremblingV5/DouTok/kitex_gen/publish/publishservice" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/TremblingV5/DouTok/pkg/constants" "github.com/TremblingV5/DouTok/pkg/dlog" - "github.com/TremblingV5/DouTok/pkg/services" - "github.com/bytedance/gopkg/util/logger" - "go.uber.org/zap" + "github.com/TremblingV5/DouTok/pkg/initHelper" ) -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_PUBLISH_"` -} - var ( Logger = dlog.InitLog(3) - config = &Config{} ) -func init() { - - _, err := configurator.Load(config, "DOUTOK_PUBLISH", "publish") - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", config)) - } - - rpc.Init() +func Init() { + misc.InitViperConfig() + service.Init() + rpc.InitPRCClient() } func main() { + Init() - options, shutdown := services.InitRPCServerArgs(constants.PUBLISH_SERVER_NAME, config.BaseConfig) + options, shutdown := initHelper.InitRPCServerArgs(misc.Config) defer shutdown() svr := publishservice.NewServer( diff --git a/applications/publish/misc/config.go b/applications/publish/misc/config.go new file mode 100644 index 00000000..aab0f3df --- /dev/null +++ b/applications/publish/misc/config.go @@ -0,0 +1,18 @@ +package misc + +import "github.com/TremblingV5/DouTok/pkg/dtviper" + +var Config *dtviper.Config + +func InitViperConfig() { + config := dtviper.ConfigInit(ViperConfigEnvPrefix, ViperConfigEnvFilename) + Config = &config +} + +func GetConfig(key string) string { + return Config.Viper.GetString(key) +} + +func GetConfigNum(key string) int64 { + return Config.Viper.GetInt64(key) +} diff --git a/applications/publish/misc/const.go b/applications/publish/misc/const.go new file mode 100644 index 00000000..e44e184d --- /dev/null +++ b/applications/publish/misc/const.go @@ -0,0 +1,6 @@ +package misc + +const ( + ViperConfigEnvPrefix = "DOUTOK_PUBLISH" + ViperConfigEnvFilename = "publish" +) diff --git a/applications/publish/misc/ensure_id_length.go b/applications/publish/misc/ensure_id_length.go new file mode 100644 index 00000000..243e6056 --- /dev/null +++ b/applications/publish/misc/ensure_id_length.go @@ -0,0 +1,7 @@ +package misc + +import "github.com/TremblingV5/DouTok/pkg/misc" + +func FillUserId(user_id string) string { + return misc.LFill(user_id, 20) +} diff --git a/applications/publish/misc/timestamp.go b/applications/publish/misc/timestamp.go new file mode 100644 index 00000000..f211204c --- /dev/null +++ b/applications/publish/misc/timestamp.go @@ -0,0 +1,9 @@ +package misc + +import "fmt" + +var MAX_TIMESTAMP = 99999999999 + +func GetTimeRebound(timestamp int64) string { + return fmt.Sprint(int64(MAX_TIMESTAMP) - timestamp) +} diff --git a/applications/publish/pack/publish_action.go b/applications/publish/pack/publish_action.go index dd388f93..d81a4db1 100644 --- a/applications/publish/pack/publish_action.go +++ b/applications/publish/pack/publish_action.go @@ -1,17 +1,12 @@ package pack -import ( - "github.com/TremblingV5/DouTok/kitex_gen/publish" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" -) +import "github.com/TremblingV5/DouTok/kitex_gen/publish" -func PackagePublishActionResponse(result *videoDomain.DoutokAddPublishResponse, err error) (*publish.DouyinPublishActionResponse, error) { - if err != nil { - return nil, err - } +func PackPublishActionRes(code int32, msg string) (*publish.DouyinPublishActionResponse, error) { + var resp publish.DouyinPublishActionResponse - return &publish.DouyinPublishActionResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - }, err + resp.StatusCode = code + resp.StatusMsg = msg + + return &resp, nil } diff --git a/applications/publish/pack/publish_list.go b/applications/publish/pack/publish_list.go index 9bf0b022..39c817ac 100644 --- a/applications/publish/pack/publish_list.go +++ b/applications/publish/pack/publish_list.go @@ -2,81 +2,42 @@ package pack import ( "context" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - "github.com/TremblingV5/DouTok/applications/publish/rpc" - "github.com/TremblingV5/DouTok/kitex_gen/entity" + "github.com/TremblingV5/DouTok/applications/publish/typedef" + "github.com/TremblingV5/DouTok/kitex_gen/feed" "github.com/TremblingV5/DouTok/kitex_gen/publish" + "github.com/TremblingV5/DouTok/kitex_gen/user" ) -func PackagePublishListResponse(ctx context.Context, result *videoDomain.DoutokListPublishResponse, err error) (*publish.DouyinPublishListResponse, error) { - if err != nil { - return nil, err +func PackPublishListRes(list []typedef.VideoInHB, code int32, msg string, req *publish.DouyinPublishListRequest) (*publish.DouyinPublishListResponse, error) { + res := publish.DouyinPublishListResponse{ + StatusCode: code, + StatusMsg: msg, } - if len(result.VideoList) <= 0 { - return &publish.DouyinPublishListResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - VideoList: []*entity.Video{}, - }, nil + newReq := user.DouyinUserRequest{ + UserId: req.UserId, + // Token: req.Token, } - var userIdList []int64 - var videoIdList []int64 - for _, v := range result.VideoList { - userIdList = append(userIdList, v.Author.GetId()) - videoIdList = append(videoIdList, v.GetId()) - } + resp, _ := rpc.GetUserById( + context.Background(), &newReq, + ) - userInfo, err := rpc.UserDomainClient.GetUserInfo(ctx, &userDomain.DoutokGetUserInfoRequest{ - UserId: userIdList, - }) - if err != nil { - return nil, err - } + var video_list []*feed.Video - favCount, err := rpc.FavoriteDomainClient.CountFavorite(ctx, &favoriteDomain.DoutokCountFavRequest{ - UserIdList: videoIdList, - }) - if err != nil { - return nil, err - } + for _, v := range list { + var temp feed.Video - var videoList []*entity.Video - for _, v := range result.VideoList { - temp := &entity.Video{ - Id: v.GetId(), - PlayUrl: v.GetPlayUrl(), - CoverUrl: v.GetCoverUrl(), - } + temp.Title = v.GetTitle() + temp.PlayUrl = v.GetVideoUrl() + temp.CoverUrl = v.GetCoverUrl() - if u, ok := userInfo.UserList[v.Author.GetId()]; ok { - temp.Author = &entity.User{ - Id: u.Id, - Name: u.Name, - Avatar: u.Avatar, - BackgroundImage: u.BackgroundImage, - Signature: u.Signature, - } - } else { - temp.Author = &entity.User{ - Id: u.GetId(), - } - } - - if favCnt, ok := favCount.CountFav[v.Id]; ok { - temp.FavoriteCount = favCnt - } - - videoList = append(videoList, temp) + temp.Author = resp.User + video_list = append(video_list, &temp) } - return &publish.DouyinPublishListResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - VideoList: videoList, - }, nil + res.VideoList = video_list + + return &res, nil } diff --git a/applications/publish/rpc/clients.go b/applications/publish/rpc/clients.go deleted file mode 100644 index 3a0b5c62..00000000 --- a/applications/publish/rpc/clients.go +++ /dev/null @@ -1,13 +0,0 @@ -package rpc - -import "github.com/TremblingV5/DouTok/pkg/initHelper" - -var UserDomainClient *initHelper.UserDomainClient -var VideoDomainClient *initHelper.VideoDomainClient -var FavoriteDomainClient *initHelper.FavoriteDomainClient - -func Init() { - UserDomainClient = initHelper.InitUserDomainRPCClient() - VideoDomainClient = initHelper.InitVideoDomainRPCClient() - FavoriteDomainClient = initHelper.InitFavoriteDomainRPCClient() -} diff --git a/applications/publish/rpc/init.go b/applications/publish/rpc/init.go new file mode 100644 index 00000000..f80989ed --- /dev/null +++ b/applications/publish/rpc/init.go @@ -0,0 +1,5 @@ +package rpc + +func InitPRCClient() { + InitUserRpc() +} diff --git a/applications/publish/rpc/user.go b/applications/publish/rpc/user.go new file mode 100644 index 00000000..4896cf4b --- /dev/null +++ b/applications/publish/rpc/user.go @@ -0,0 +1,40 @@ +package rpc + +import ( + "context" + "errors" + "github.com/TremblingV5/DouTok/kitex_gen/user" + "github.com/TremblingV5/DouTok/kitex_gen/user/userservice" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/initHelper" +) + +var userClient userservice.Client + +func InitUserRpc() { + config := dtviper.ConfigInit("DOUTOK_USER", "user") + + c, err := userservice.NewClient( + config.Viper.GetString("Server.Name"), + initHelper.InitRPCClientArgs(&config)..., + ) + + if err != nil { + panic(err) + } + + userClient = c +} + +func GetUserById(ctx context.Context, req *user.DouyinUserRequest) (resp *user.DouyinUserResponse, err error) { + resp, err = userClient.GetUserById(ctx, req) + if err != nil { + return nil, err + } + + if resp.StatusCode != 0 { + return nil, errors.New(resp.StatusMsg) + } + + return resp, nil +} diff --git a/applications/publish/rpc/var.go b/applications/publish/rpc/var.go new file mode 100644 index 00000000..4bef913e --- /dev/null +++ b/applications/publish/rpc/var.go @@ -0,0 +1,5 @@ +package rpc + +import "github.com/TremblingV5/DouTok/config/configStruct" + +var ClientConfig *configStruct.PublishConfig diff --git a/applications/publish/script/bootstrap.sh b/applications/publish/script/bootstrap.sh index a5882f2c..0ef68725 100644 --- a/applications/publish/script/bootstrap.sh +++ b/applications/publish/script/bootstrap.sh @@ -19,4 +19,3 @@ if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then fi exec "$CURDIR/bin/publish" - diff --git a/applications/publish/service/init.go b/applications/publish/service/init.go new file mode 100644 index 00000000..b930f4f8 --- /dev/null +++ b/applications/publish/service/init.go @@ -0,0 +1,76 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/publish/dal/query" + "github.com/TremblingV5/DouTok/applications/publish/misc" + "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/pkg/hbaseHandle" + "github.com/TremblingV5/DouTok/pkg/mysqlIniter" + "github.com/TremblingV5/DouTok/pkg/utils" +) + +func Init() { + misc.InitViperConfig() + + InitDb( + misc.GetConfig("MySQL.Username"), + misc.GetConfig("MySQL.Password"), + misc.GetConfig("MySQL.Host"), + misc.GetConfig("MySQL.Port"), + misc.GetConfig("MySQL.Database"), + ) + InitHB( + misc.GetConfig("HBase.Host"), + ) + InitOSS( + misc.GetConfig("OSS.Endpoint"), + misc.GetConfig("OSS.Key"), + misc.GetConfig("OSS.Secret"), + misc.GetConfig("OSS.Bucket"), + ) + utils.InitSnowFlake(misc.GetConfigNum("Snowflake.Node")) +} + +func InitDb(username string, password string, host string, port string, database string) error { + db, err := mysqlIniter.InitDb( + username, password, host, port, database, + ) + + if err != nil { + return err + } + + DB = db + + query.SetDefault(DB) + Video = query.Video + Do = Video.WithContext(context.Background()) + + return nil +} + +func InitHB(host string) error { + client := hbaseHandle.InitHB(host) + HBClient = &client + + return nil +} + +func InitOSS(endpoint string, key string, secret string, bucketName string) error { + OSSClient.Init( + endpoint, key, secret, bucketName, + ) + + config := configStruct.OssConfig{ + Endpoint: endpoint, + Key: key, + Secret: secret, + BucketName: bucketName, + //Callback: callback, + } + + OssCfg = &config + + return nil +} diff --git a/applications/publish/service/init_test.go b/applications/publish/service/init_test.go new file mode 100644 index 00000000..8ef9d018 --- /dev/null +++ b/applications/publish/service/init_test.go @@ -0,0 +1,7 @@ +package service + +import "testing" + +func TestInit(t *testing.T) { + Init() +} diff --git a/applications/publish/service/publish_action.go b/applications/publish/service/publish_action.go new file mode 100644 index 00000000..b7fd68e7 --- /dev/null +++ b/applications/publish/service/publish_action.go @@ -0,0 +1,112 @@ +package service + +import ( + "bytes" + "crypto/md5" + "encoding/hex" + "fmt" + "strconv" + "time" + + "github.com/TremblingV5/DouTok/applications/publish/dal/model" + "github.com/TremblingV5/DouTok/applications/publish/misc" + "github.com/TremblingV5/DouTok/pkg/dlog" + "github.com/TremblingV5/DouTok/pkg/utils" +) + +func SavePublish(user_id int64, title string, data []byte) error { + timestamp := time.Now().Unix() + + // 1. 上传封面和视频到OSS + hasher := md5.New() + hasher.Write([]byte(fmt.Sprint(user_id) + title)) + filename := hex.EncodeToString(hasher.Sum(nil)) + ".mp4" + + if err := OSSClient.Put( + "video", filename, bytes.NewReader(data), + ); err != nil { + return err + } + + play_url := "https://" + OssCfg.BucketName + "." + OssCfg.Endpoint + "/video/" + filename + cover_url := play_url + "?x-oss-process=video/snapshot,t_30000,f_jpg,w_0,h_0,m_fast,ar_auto" + + // 2. 写入数据到MySQl + id, err := SaveVideo2DB( + uint64(user_id), title, play_url, cover_url, + ) + if err != nil { + return err + } + + // 3. 写入数据到HBase,分别写入publish表和feed表 + + if err := SaveVideo2HB(id, uint64(user_id), title, play_url, cover_url, fmt.Sprint(timestamp)); err != nil { + dlog.Warn(err) + } + + return nil +} + +func SaveVideo2DB(user_id uint64, title string, play_url string, cover_url string) (uint64, error) { + newVideoId := utils.GetSnowFlakeId() + newVideo := model.Video{ + ID: uint64(newVideoId), + AuthorID: user_id, + Title: title, + VideoUrl: play_url, + CoverUrl: cover_url, + FavCount: 0, + ComCount: 0, + } + + err := Video.Create(&newVideo) + + if err != nil { + return 0, err + } + + return uint64(newVideoId), nil +} + +func SaveVideo2HB(id uint64, user_id uint64, title string, play_url string, cover_url string, timestamp string) error { + // newVideo := typedef.VideoInHB{ + // Id: int64(id), + // AuthorId: int64(user_id), + // AuthorName: "", + // Title: title, + // VideoUrl: play_url, + // CoverUrl: cover_url, + // Timestamp: timestamp, + // } + + timestamp_int, _ := strconv.Atoi(timestamp) + publish_rowkey := misc.FillUserId(fmt.Sprint(user_id)) + misc.GetTimeRebound(int64(timestamp_int)) + feed_rowkey := misc.GetTimeRebound(int64(timestamp_int)) + misc.FillUserId(fmt.Sprint(user_id)) + + hbData := map[string]map[string][]byte{ + "data": { + "id": []byte(fmt.Sprint(id)), + "author_id": []byte(fmt.Sprint(user_id)), + "author_name": []byte(""), + "title": []byte(title), + "video_url": []byte(play_url), + "cover_url": []byte(cover_url), + "timestamp": []byte(timestamp), + }, + } + + if err := HBClient.Put( + "publish", publish_rowkey, hbData, + ); err != nil { + + } + + if err := HBClient.Put( + "feed", feed_rowkey, hbData, + ); err != nil { + + } + + return nil +} diff --git a/applications/publish/service/publish_action_test.go b/applications/publish/service/publish_action_test.go new file mode 100644 index 00000000..e1cfcd4f --- /dev/null +++ b/applications/publish/service/publish_action_test.go @@ -0,0 +1,23 @@ +package service + +import ( + "fmt" + "testing" + "time" +) + +func TestSavePublish(t *testing.T) { + Init() + + timestamp := fmt.Sprint(time.Now().Unix()) + + userId := int64(1111111111111111111) + title := "Unit testing on " + timestamp + file := []byte("Unit testing on " + timestamp) + + err := SavePublish(userId, title, file) + + if err != nil { + panic(err) + } +} diff --git a/applications/publish/service/publish_list.go b/applications/publish/service/publish_list.go new file mode 100644 index 00000000..e9313c31 --- /dev/null +++ b/applications/publish/service/publish_list.go @@ -0,0 +1,38 @@ +package service + +import ( + "fmt" + "strconv" + + tools "github.com/TremblingV5/DouTok/applications/publish/misc" + "github.com/TremblingV5/DouTok/applications/publish/typedef" + "github.com/TremblingV5/DouTok/pkg/hbaseHandle" + "github.com/TremblingV5/DouTok/pkg/misc" +) + +func QueryPublishListInHBase(user_id int64) ([]typedef.VideoInHB, error) { + user_id_string := strconv.FormatInt(user_id, 10) + user_id_string = tools.FillUserId(fmt.Sprint(user_id)) + + filters := hbaseHandle.GetFilterByRowKeyPrefix(user_id_string) + + video_list, err := HBClient.Scan( + "publish", filters..., + ) + + list := []typedef.VideoInHB{} + if err != nil { + return list, err + } + + for _, v := range video_list { + temp := typedef.VideoInHB{} + err := misc.Map2Struct4HB(v, &temp) + if err != nil { + continue + } + list = append(list, temp) + } + + return list, nil +} diff --git a/applications/publish/service/publish_list_test.go b/applications/publish/service/publish_list_test.go new file mode 100644 index 00000000..48913b52 --- /dev/null +++ b/applications/publish/service/publish_list_test.go @@ -0,0 +1,27 @@ +package service + +import ( + "log" + "testing" +) + +func TestQueryPublishListInHBase(t *testing.T) { + Init() + + res, err := QueryPublishListInHBase(int64(1111111111111111111)) + if err != nil { + panic(err) + } + + log.Println(len(res)) + + cnt := 0 + for _, v := range res { + log.Println(v.GetId()) + cnt++ + + if cnt > 10 { + break + } + } +} diff --git a/applications/publish/service/var.go b/applications/publish/service/var.go new file mode 100644 index 00000000..72da8c4c --- /dev/null +++ b/applications/publish/service/var.go @@ -0,0 +1,21 @@ +package service + +import ( + "github.com/TremblingV5/DouTok/applications/publish/dal/query" + "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/pkg/hbaseHandle" + "github.com/TremblingV5/DouTok/pkg/ossHandle" + "github.com/aliyun/aliyun-oss-go-sdk/oss" + "gorm.io/gorm" +) + +var DB *gorm.DB +var Do query.IVideoDo +var Video = query.VideoStruct + +var HBClient *hbaseHandle.HBaseClient + +var OSSClient = &ossHandle.OssClient{ + Client: &oss.Client{}, +} +var OssCfg *configStruct.OssConfig diff --git a/applications/publish/service/video.go b/applications/publish/service/video.go new file mode 100644 index 00000000..15966478 --- /dev/null +++ b/applications/publish/service/video.go @@ -0,0 +1,29 @@ +package service + +import ( + "github.com/TremblingV5/DouTok/applications/publish/dal/model" +) + +func QueryVideoFromRBDById(id uint64) (*model.Video, error) { + v, err := Do.Where( + Video.ID.Eq(id), + ).First() + + if err != nil { + return v, err + } + + return v, nil +} + +func QuerySomeVideoFromRDBByIds(id ...uint64) ([]*model.Video, error) { + videos, err := Do.Where( + Video.ID.In(id...), + ).Find() + + if err != nil { + return videos, err + } + + return videos, nil +} diff --git a/applications/publish/service/video_test.go b/applications/publish/service/video_test.go new file mode 100644 index 00000000..4f862f4c --- /dev/null +++ b/applications/publish/service/video_test.go @@ -0,0 +1,32 @@ +package service + +import ( + "fmt" + "testing" +) + +func TestQueryVideoCountFromRDB(t *testing.T) { + Init() + + v, err := QueryVideoFromRBDById(1627179313688485888) + + if err != nil { + fmt.Println(err) + panic(err) + } + + fmt.Println(v) +} + +func TestQueryAFewVideoCountFromRDB(t *testing.T) { + Init() + + videos, err := QuerySomeVideoFromRDBByIds(1627179313688485888, 1627180724060954624) + + if err != nil { + fmt.Println(err) + panic(err) + } + + fmt.Println(videos) +} diff --git a/applications/publish/typedef/hbase.go b/applications/publish/typedef/hbase.go new file mode 100644 index 00000000..20d534f7 --- /dev/null +++ b/applications/publish/typedef/hbase.go @@ -0,0 +1,45 @@ +package typedef + +import "encoding/binary" + +type VideoInHB struct { + Id []byte `json:"id"` + AuthorId []byte `json:"author_id"` + AuthorName []byte `json:"author_name"` + Title []byte `json:"title"` + VideoUrl []byte `json:"video_url"` + CoverUrl []byte `json:"cover_url"` + Timestamp []byte `json:"timestamp"` +} + +func ToInt64(data []byte) int64 { + return int64(binary.BigEndian.Uint64(data)) +} + +func (v *VideoInHB) GetId() int64 { + return ToInt64(v.Id) +} + +func (v *VideoInHB) GetAuthorId() int64 { + return ToInt64(v.AuthorId) +} + +func (v *VideoInHB) GetVideoUrl() string { + return string(v.VideoUrl) +} + +func (v *VideoInHB) GetTitle() string { + return string(v.Title) +} + +func (v *VideoInHB) GetCoverUrl() string { + return string(v.CoverUrl) +} + +func (v *VideoInHB) GetTimestamp() string { + return string(v.Timestamp) +} + +func (v *VideoInHB) GetAuthorName() string { + return string(v.AuthorName) +} diff --git a/applications/relation/build.sh b/applications/relation/build.sh index 7f24d8f5..f9a96957 100644 --- a/applications/relation/build.sh +++ b/applications/relation/build.sh @@ -10,4 +10,3 @@ if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then else go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... fi - diff --git a/applications/relationDomain/dal/gen.go b/applications/relation/dal/gen.go similarity index 54% rename from applications/relationDomain/dal/gen.go rename to applications/relation/dal/gen.go index 66416d47..1ceedac4 100644 --- a/applications/relationDomain/dal/gen.go +++ b/applications/relation/dal/gen.go @@ -1,32 +1,26 @@ package main import ( - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" - "github.com/TremblingV5/DouTok/config/configStruct" - "github.com/TremblingV5/DouTok/pkg/configurator" + "github.com/TremblingV5/DouTok/applications/relation/dal/model" + "github.com/TremblingV5/DouTok/pkg/dtviper" "github.com/TremblingV5/DouTok/pkg/mysqlIniter" "gorm.io/gen" ) func main() { g := gen.NewGenerator(gen.Config{ - OutPath: "./query", + OutPath: "./applications/relation/dal/query", Mode: gen.WithoutContext | gen.WithDefaultQuery | gen.WithQueryInterface, }) - var config configStruct.MySQLConfig - if err := configurator.InitConfig( - &config, "mysql.yaml", - ); err != nil { - panic(err) - } + cfg := dtviper.ConfigInit("", "relation") db, err := mysqlIniter.InitDb( - config.Username, - config.Password, - config.Host, - config.Port, - config.Database, + cfg.Viper.GetString("MySQL.Username"), + cfg.Viper.GetString("MySQL.Password"), + cfg.Viper.GetString("MySQL.Host"), + cfg.Viper.GetString("MySQL.Port"), + cfg.Viper.GetString("MySQL.Database"), ) if err != nil { diff --git a/applications/relationDomain/dal/migrate/migration.go b/applications/relation/dal/migrate/migration.go similarity index 69% rename from applications/relationDomain/dal/migrate/migration.go rename to applications/relation/dal/migrate/migration.go index ff43335d..bce38ae3 100644 --- a/applications/relationDomain/dal/migrate/migration.go +++ b/applications/relation/dal/migrate/migration.go @@ -1,7 +1,7 @@ package main import ( - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/relation/dal/model" "github.com/TremblingV5/DouTok/pkg/dtviper" "github.com/TremblingV5/DouTok/pkg/mysqlIniter" ) @@ -20,7 +20,5 @@ func main() { if err != nil { panic(err) } - if err := db.AutoMigrate(&model.Relation{}, &model.FollowCount{}, &model.FollowerCount{}); err != nil { - panic(err) - } + db.AutoMigrate(&model.Relation{}, &model.FollowCount{}, &model.FollowerCount{}) } diff --git a/applications/relationDomain/dal/model/count.go b/applications/relation/dal/model/count.go similarity index 100% rename from applications/relationDomain/dal/model/count.go rename to applications/relation/dal/model/count.go diff --git a/applications/relationDomain/dal/model/relation.go b/applications/relation/dal/model/relation.go similarity index 100% rename from applications/relationDomain/dal/model/relation.go rename to applications/relation/dal/model/relation.go diff --git a/applications/relationDomain/dal/query/follow_counts.gen.go b/applications/relation/dal/query/follow_counts.gen.go similarity index 99% rename from applications/relationDomain/dal/query/follow_counts.gen.go rename to applications/relation/dal/query/follow_counts.gen.go index dbee77e7..77995a29 100644 --- a/applications/relationDomain/dal/query/follow_counts.gen.go +++ b/applications/relation/dal/query/follow_counts.gen.go @@ -16,7 +16,7 @@ import ( "gorm.io/plugin/dbresolver" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/relation/dal/model" ) func newFollowCount(db *gorm.DB, opts ...gen.DOOption) followCount { diff --git a/applications/relationDomain/dal/query/follower_counts.gen.go b/applications/relation/dal/query/follower_counts.gen.go similarity index 99% rename from applications/relationDomain/dal/query/follower_counts.gen.go rename to applications/relation/dal/query/follower_counts.gen.go index 3d60ab65..70bfa7e5 100644 --- a/applications/relationDomain/dal/query/follower_counts.gen.go +++ b/applications/relation/dal/query/follower_counts.gen.go @@ -16,7 +16,7 @@ import ( "gorm.io/plugin/dbresolver" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/relation/dal/model" ) func newFollowerCount(db *gorm.DB, opts ...gen.DOOption) followerCount { diff --git a/applications/relationDomain/dal/query/gen.go b/applications/relation/dal/query/gen.go similarity index 100% rename from applications/relationDomain/dal/query/gen.go rename to applications/relation/dal/query/gen.go diff --git a/applications/relationDomain/dal/query/relations.gen.go b/applications/relation/dal/query/relations.gen.go similarity index 99% rename from applications/relationDomain/dal/query/relations.gen.go rename to applications/relation/dal/query/relations.gen.go index a6c76f43..93af8299 100644 --- a/applications/relationDomain/dal/query/relations.gen.go +++ b/applications/relation/dal/query/relations.gen.go @@ -16,7 +16,7 @@ import ( "gorm.io/plugin/dbresolver" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/relation/dal/model" ) func newRelation(db *gorm.DB, opts ...gen.DOOption) relation { diff --git a/applications/relation/handler.go b/applications/relation/handler.go new file mode 100644 index 00000000..f4d06634 --- /dev/null +++ b/applications/relation/handler.go @@ -0,0 +1,91 @@ +package main + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/relation/pack" + "github.com/TremblingV5/DouTok/applications/relation/service" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/pkg/errno" +) + +// RelationServiceImpl implements the last service interface defined in the IDL. +type RelationServiceImpl struct{} + +// RelationAction implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) RelationAction(ctx context.Context, req *relation.DouyinRelationActionRequest) (resp *relation.DouyinRelationActionResponse, err error) { + // TODO: Your code here... + resp = new(relation.DouyinRelationActionResponse) + + err = service.NewRelationActionService(ctx).RelationAction(req) + if err != nil { + pack.BuildRelationActionResp(err, resp) + return resp, nil + } + pack.BuildRelationActionResp(errno.Success, resp) + return resp, nil +} + +// RelationFollowList implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) RelationFollowList(ctx context.Context, req *relation.DouyinRelationFollowListRequest) (resp *relation.DouyinRelationFollowListResponse, err error) { + // TODO: Your code here... + resp = new(relation.DouyinRelationFollowListResponse) + + err, followList := service.NewRelationFollowListService(ctx).RelationFollowList(req) + if err != nil { + pack.BuildRelationFollowListResp(err, resp) + return resp, nil + } + resp.UserList = followList + + pack.BuildRelationFollowListResp(errno.Success, resp) + return resp, nil +} + +// RelationFollowerList implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) RelationFollowerList(ctx context.Context, req *relation.DouyinRelationFollowerListRequest) (resp *relation.DouyinRelationFollowerListResponse, err error) { + // TODO: Your code here... + resp = new(relation.DouyinRelationFollowerListResponse) + + err, followerList := service.NewRelationFollowerListService(ctx).RelationFollowerList(req) + if err != nil { + pack.BuildRelationFollowerListResp(err, resp) + return resp, nil + } + resp.UserList = followerList + + pack.BuildRelationFollowerListResp(errno.Success, resp) + return resp, nil +} + +// RelationFriendList implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) RelationFriendList(ctx context.Context, req *relation.DouyinRelationFriendListRequest) (resp *relation.DouyinRelationFriendListResponse, err error) { + // TODO: Your code here... + resp = new(relation.DouyinRelationFriendListResponse) + + err, friendList := service.NewRelationFriendListService(ctx).RelationFriendList(req) + if err != nil { + pack.BuildRelationFriendListResp(err, resp) + return resp, nil + } + resp.UserList = friendList + + pack.BuildRelationFriendListResp(errno.Success, resp) + return resp, nil +} + +// GetFollowCount implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) GetFollowCount(ctx context.Context, req *relation.DouyinRelationCountRequest) (resp *relation.DouyinRelationCountResponse, err error) { + // TODO: Your code here... + resp = new(relation.DouyinRelationCountResponse) + + err, follow, follower := service.NewRelationCountService(ctx).RelationCount(req) + if err != nil { + pack.BuildRelationCountResp(err, resp) + return resp, nil + } + resp.FollowCount = follow + resp.FollowerCount = follower + + pack.BuildRelationCountResp(errno.Success, resp) + return resp, nil +} diff --git a/applications/relation/handler/handler.go b/applications/relation/handler/handler.go deleted file mode 100644 index cc260b43..00000000 --- a/applications/relation/handler/handler.go +++ /dev/null @@ -1,181 +0,0 @@ -package handler - -import ( - "context" - "errors" - - "github.com/TremblingV5/DouTok/applications/relation/rpc" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - "github.com/TremblingV5/DouTok/kitex_gen/relation" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain" -) - -type Handler struct { - clients *rpc.Clients -} - -func New(client *rpc.Clients) *Handler { - return &Handler{ - clients: client, - } -} - -func (s *Handler) RelationAction(ctx context.Context, req *relation.DouyinRelationActionRequest) (resp *relation.DouyinRelationActionResponse, err error) { - if req.ActionType == 0 { - result, err := s.clients.Relation.Client.AddRelation(ctx, &relationDomain.DoutokAddRelationRequest{ - UserId: req.UserId, - ToUserId: req.ToUserId, - }) - return &relation.DouyinRelationActionResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - }, err - } - - if req.ActionType == 1 { - result, err := s.clients.Relation.Client.RmRelation(ctx, &relationDomain.DoutokRmRelationRequest{ - UserId: req.UserId, - ToUserId: req.ToUserId, - }) - return &relation.DouyinRelationActionResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - }, err - } - - return &relation.DouyinRelationActionResponse{ - StatusCode: -1, - StatusMsg: "unknown action type", - }, errors.New("unknown action type") -} - -func (s *Handler) RelationFollowList(ctx context.Context, req *relation.DouyinRelationFollowListRequest) (resp *relation.DouyinRelationFollowListResponse, err error) { - result, err := s.clients.Relation.Client.ListRelation(ctx, &relationDomain.DoutokListRelationRequest{ - UserId: req.UserId, - ActionType: 0, - }) - - if err != nil { - return nil, err - } - - userIdList := make([]int64, 0) - if result.UserList != nil { - for _, v := range result.UserList { - userIdList = append(userIdList, v.GetId()) - } - } - userInfo, err := s.clients.User.Client.GetUserInfo(ctx, &userDomain.DoutokGetUserInfoRequest{ - UserId: userIdList, - }) - - resList := make([]*entity.User, 0) - if result.UserList != nil { - for _, v := range result.UserList { - if value, ok := userInfo.UserList[v.GetId()]; ok { - resList = append(resList, &entity.User{ - Id: value.GetId(), - Name: value.GetName(), - Avatar: value.GetAvatar(), - BackgroundImage: value.GetBackgroundImage(), - Signature: value.GetSignature(), - }) - } - } - } - - return &relation.DouyinRelationFollowListResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - UserList: resList, - }, err -} - -func (s *Handler) RelationFollowerList(ctx context.Context, req *relation.DouyinRelationFollowerListRequest) (resp *relation.DouyinRelationFollowerListResponse, err error) { - result, err := s.clients.Relation.Client.ListRelation(ctx, &relationDomain.DoutokListRelationRequest{ - UserId: req.UserId, - ActionType: 1, - }) - if err != nil { - return nil, err - } - - userIdList := make([]int64, 0) - if result != nil && result.UserList != nil { - for _, v := range result.UserList { - userIdList = append(userIdList, v.GetId()) - } - } - userInfo, err := s.clients.User.Client.GetUserInfo(ctx, &userDomain.DoutokGetUserInfoRequest{ - UserId: userIdList, - }) - - if err != nil { - return nil, err - } - - resList := make([]*entity.User, 0) - if result != nil && result.UserList != nil && userInfo != nil && userInfo.UserList != nil { - for _, v := range result.UserList { - if value, ok := userInfo.UserList[v.GetId()]; ok { - resList = append(resList, &entity.User{ - Id: value.GetId(), - Name: value.GetName(), - Avatar: value.GetAvatar(), - BackgroundImage: value.GetBackgroundImage(), - Signature: value.GetSignature(), - }) - } - } - } - - return &relation.DouyinRelationFollowerListResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - UserList: resList, - }, err -} - -func (s *Handler) RelationFriendList(ctx context.Context, req *relation.DouyinRelationFriendListRequest) (resp *relation.DouyinRelationFriendListResponse, err error) { - result, err := s.clients.Relation.Client.ListRelation(ctx, &relationDomain.DoutokListRelationRequest{ - UserId: req.UserId, - ActionType: 2, - }) - - friendUserList := make([]*entity.FriendUser, 0) - for _, v := range result.UserList { - messageInfo, err := s.clients.Message.Client.ListMessage(ctx, &messageDomain.DoutokListMessageRequest{ - UserId: req.UserId, - ToUserId: v.GetId(), - }) - if err != nil { - continue - } - var msgType int64 - if len(messageInfo.Message) > 0 { - if messageInfo.Message[len(messageInfo.Message)-1].ToUserId == req.UserId { - msgType = 0 - } else { - msgType = 1 - } - friendUserList = append(friendUserList, &entity.FriendUser{ - User: v, - Message: messageInfo.Message[len(messageInfo.Message)-1].Content, - MsgType: msgType, - }) - } - friendUserList = append(friendUserList, &entity.FriendUser{ - User: v, - Message: "", - MsgType: 0, - }) - } - - return &relation.DouyinRelationFriendListResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - UserList: friendUserList, - }, err -} diff --git a/applications/relation/main.go b/applications/relation/main.go index 260d1154..5f88afce 100644 --- a/applications/relation/main.go +++ b/applications/relation/main.go @@ -1,17 +1,24 @@ package main import ( - "github.com/TremblingV5/DouTok/applications/relation/handler" + "context" + "fmt" "github.com/TremblingV5/DouTok/applications/relation/rpc" "github.com/TremblingV5/DouTok/applications/relation/service" "github.com/TremblingV5/DouTok/kitex_gen/relation/relationservice" - "github.com/TremblingV5/DouTok/pkg/constants" "github.com/TremblingV5/DouTok/pkg/dlog" - "github.com/TremblingV5/DouTok/pkg/services" + "github.com/TremblingV5/DouTok/pkg/middleware" "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/limit" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" + "net" ) -func init() { +func Init() { service.InitViper() service.InitRedisClient() service.InitSyncProducer() @@ -20,10 +27,12 @@ func init() { service.InitDB() service.InitSafeMap() service.InitMutex() + rpc.InitRPC() + go service.Flush() } func main() { - + Init() defer func() { _ = service.SyncProducer.Close() }() @@ -36,17 +45,40 @@ func main() { klog.SetLogger(logger) - clients := rpc.New(services.InitRPCClientArgs(constants.USER_SERVER_NAME, service.DomainConfig.Etcd)) + ServiceName := service.ViperConfig.Viper.GetString("Server.Name") + ServiceAddr := fmt.Sprintf("%s:%d", service.ViperConfig.Viper.GetString("Server.Address"), service.ViperConfig.Viper.GetInt("Server.Port")) + EtcdAddress := fmt.Sprintf("%s:%d", service.ViperConfig.Viper.GetString("Etcd.Address"), service.ViperConfig.Viper.GetInt("Etcd.Port")) - options, shutdown := services.InitRPCServerArgs(constants.RELATION_SERVER_NAME, service.DomainConfig.BaseConfig) - defer shutdown() + r, err := etcd.NewEtcdRegistry([]string{EtcdAddress}) + if err != nil { + klog.Fatal(err) + } + addr, err := net.ResolveTCPAddr("tcp", ServiceAddr) + if err != nil { + klog.Fatal(err) + } + + p := provider.NewOpenTelemetryProvider( + provider.WithServiceName(ServiceName), + provider.WithExportEndpoint(fmt.Sprintf("%s:%s", service.ViperConfig.Viper.GetString("Otel.Host"), service.ViperConfig.Viper.GetString("Otel.Port"))), + provider.WithInsecure(), + ) + defer p.Shutdown(context.Background()) svr := relationservice.NewServer( - handler.New(clients), - options..., + new(RelationServiceImpl), + server.WithServiceAddr(addr), // address + server.WithMiddleware(middleware.CommonMiddleware), // middleware + server.WithMiddleware(middleware.ServerMiddleware), // middleware + server.WithRegistry(r), // registry + server.WithLimit(&limit.Option{MaxConnections: 1000, MaxQPS: 100}), // limit + server.WithMuxTransport(), // Multiplex + server.WithSuite(tracing.NewServerSuite()), // trace + // Please keep the same as provider.WithServiceName + server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: ServiceName}), ) if err := svr.Run(); err != nil { - klog.Fatalf("stopped with error:", err) + klog.Fatalf("%s stopped with error:", ServiceName, err) } } diff --git a/applications/relationDomain/pack/relation.go b/applications/relation/pack/relation.go similarity index 100% rename from applications/relationDomain/pack/relation.go rename to applications/relation/pack/relation.go diff --git a/applications/relation/pack/resp.go b/applications/relation/pack/resp.go new file mode 100644 index 00000000..0d299c79 --- /dev/null +++ b/applications/relation/pack/resp.go @@ -0,0 +1,36 @@ +package pack + +import ( + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/pkg/errno" +) + +func BuildRelationActionResp(err error, resp *relation.DouyinRelationActionResponse) { + e := errno.ConvertErr(err) + resp.StatusMsg = e.ErrMsg + resp.StatusCode = int32(e.ErrCode) +} + +func BuildRelationCountResp(err error, resp *relation.DouyinRelationCountResponse) { + e := errno.ConvertErr(err) + resp.StatusMsg = e.ErrMsg + resp.StatusCode = int32(e.ErrCode) +} + +func BuildRelationFollowListResp(err error, resp *relation.DouyinRelationFollowListResponse) { + e := errno.ConvertErr(err) + resp.StatusMsg = e.ErrMsg + resp.StatusCode = int32(e.ErrCode) +} + +func BuildRelationFollowerListResp(err error, resp *relation.DouyinRelationFollowerListResponse) { + e := errno.ConvertErr(err) + resp.StatusMsg = e.ErrMsg + resp.StatusCode = int32(e.ErrCode) +} + +func BuildRelationFriendListResp(err error, resp *relation.DouyinRelationFriendListResponse) { + e := errno.ConvertErr(err) + resp.StatusMsg = e.ErrMsg + resp.StatusCode = int32(e.ErrCode) +} diff --git a/applications/relation/rpc/clients.go b/applications/relation/rpc/clients.go deleted file mode 100644 index 7689b14f..00000000 --- a/applications/relation/rpc/clients.go +++ /dev/null @@ -1,24 +0,0 @@ -package rpc - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain/messagedomainservice" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain/relationdomainservice" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain/userdomainservice" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/services" - "github.com/cloudwego/kitex/client" -) - -type Clients struct { - User *services.Service[userdomainservice.Client] - Relation *services.Service[relationdomainservice.Client] - Message *services.Service[messagedomainservice.Client] -} - -func New(options []client.Option) *Clients { - return &Clients{ - User: services.New[userdomainservice.Client](constants.USER_DOMAIN_SERVER_NAME, userdomainservice.NewClient, options), - Relation: services.New[relationdomainservice.Client](constants.RELATION_DOMAIN_SERVER_NAME, relationdomainservice.NewClient, options), - Message: services.New[messagedomainservice.Client](constants.MESSAGE_DOMAIN_SERVER_NAME, messagedomainservice.NewClient, options), - } -} diff --git a/applications/relation/rpc/init.go b/applications/relation/rpc/init.go new file mode 100644 index 00000000..b888583c --- /dev/null +++ b/applications/relation/rpc/init.go @@ -0,0 +1,12 @@ +package rpc + +import "github.com/TremblingV5/DouTok/pkg/dtviper" + +// InitRPC init rpc client +func InitRPC() { + MessageConfig := dtviper.ConfigInit("DOUTOK_MESSAGE", "message") + initMessageRpc(&MessageConfig) + + UserConfig := dtviper.ConfigInit("DOUTOK_USER", "user") + initUserRpc(&UserConfig) +} diff --git a/applications/relation/rpc/message.go b/applications/relation/rpc/message.go new file mode 100644 index 00000000..8abad982 --- /dev/null +++ b/applications/relation/rpc/message.go @@ -0,0 +1,66 @@ +package rpc + +import ( + "context" + "fmt" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/TremblingV5/DouTok/kitex_gen/message/messageservice" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/errno" + "github.com/TremblingV5/DouTok/pkg/middleware" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/retry" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" + "time" +) + +var messageClient messageservice.Client + +// Comment RPC 客户端初始化 +func initMessageRpc(Config *dtviper.Config) { + EtcdAddress := fmt.Sprintf("%s:%d", Config.Viper.GetString("Etcd.Address"), Config.Viper.GetInt("Etcd.Port")) + r, err := etcd.NewEtcdResolver([]string{EtcdAddress}) + if err != nil { + panic(err) + } + ServiceName := Config.Viper.GetString("Server.Name") + + //p := provider.NewOpenTelemetryProvider( + // provider.WithServiceName(ServiceName), + // provider.WithExportEndpoint("localhost:4317"), + // provider.WithInsecure(), + //) + //defer p.Shutdown(context.Background()) + + c, err := messageservice.NewClient( + ServiceName, + client.WithMiddleware(middleware.CommonMiddleware), + client.WithInstanceMW(middleware.ClientMiddleware), + client.WithMuxConnection(1), // mux + client.WithRPCTimeout(30*time.Second), // rpc timeout + client.WithConnectTimeout(30000*time.Millisecond), // conn timeout + client.WithFailureRetry(retry.NewFailurePolicy()), // retry + client.WithSuite(tracing.NewClientSuite()), // tracer + client.WithResolver(r), // resolver + // Please keep the same as provider.WithServiceName + client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: ServiceName}), + ) + if err != nil { + panic(err) + } + messageClient = c +} + +// TODO 获取好友列表的最新一条消息 +func GetFriendList(ctx context.Context, req *message.DouyinFriendListMessageRequest) (resp *message.DouyinFriendListMessageResponse, err error) { + resp, err = messageClient.MessageFriendList(ctx, req) + if err != nil { + return nil, err + } + if resp.StatusCode != 0 { + return nil, errno.NewErrNo(int(resp.StatusCode), resp.StatusMsg) + } + return resp, nil +} diff --git a/applications/relation/rpc/user.go b/applications/relation/rpc/user.go new file mode 100644 index 00000000..9957cb41 --- /dev/null +++ b/applications/relation/rpc/user.go @@ -0,0 +1,65 @@ +package rpc + +import ( + "context" + "fmt" + "github.com/TremblingV5/DouTok/kitex_gen/user" + "github.com/TremblingV5/DouTok/kitex_gen/user/userservice" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/errno" + "github.com/TremblingV5/DouTok/pkg/middleware" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/retry" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" + "time" +) + +var userClient userservice.Client + +// Comment RPC 客户端初始化 +func initUserRpc(Config *dtviper.Config) { + EtcdAddress := fmt.Sprintf("%s:%d", Config.Viper.GetString("Etcd.Address"), Config.Viper.GetInt("Etcd.Port")) + r, err := etcd.NewEtcdResolver([]string{EtcdAddress}) + if err != nil { + panic(err) + } + ServiceName := Config.Viper.GetString("Server.Name") + + //p := provider.NewOpenTelemetryProvider( + // provider.WithServiceName(ServiceName), + // provider.WithExportEndpoint("localhost:4317"), + // provider.WithInsecure(), + //) + //defer p.Shutdown(context.Background()) + + c, err := userservice.NewClient( + ServiceName, + client.WithMiddleware(middleware.CommonMiddleware), + client.WithInstanceMW(middleware.ClientMiddleware), + client.WithMuxConnection(1), // mux + client.WithRPCTimeout(30*time.Second), // rpc timeout + client.WithConnectTimeout(30000*time.Millisecond), // conn timeout + client.WithFailureRetry(retry.NewFailurePolicy()), // retry + client.WithSuite(tracing.NewClientSuite()), // tracer + client.WithResolver(r), // resolver + // Please keep the same as provider.WithServiceName + client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: ServiceName}), + ) + if err != nil { + panic(err) + } + userClient = c +} + +func GetUserListByIds(ctx context.Context, req *user.DouyinUserListRequest) (resp *user.DouyinUserListResponse, err error) { + resp, err = userClient.GetUserListByIds(ctx, req) + if err != nil { + return nil, err + } + if resp.StatusCode != 0 { + return nil, errno.NewErrNo(int(resp.StatusCode), resp.StatusMsg) + } + return resp, nil +} diff --git a/applications/relation/script/bootstrap.sh b/applications/relation/script/bootstrap.sh index cb4966d4..b8af1494 100644 --- a/applications/relation/script/bootstrap.sh +++ b/applications/relation/script/bootstrap.sh @@ -19,4 +19,3 @@ if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then fi exec "$CURDIR/bin/relation" - diff --git a/applications/relation/service/consume_msg.go b/applications/relation/service/consume_msg.go index 3a038ad6..81588bf7 100644 --- a/applications/relation/service/consume_msg.go +++ b/applications/relation/service/consume_msg.go @@ -4,14 +4,12 @@ import ( "context" "encoding/json" "fmt" + "github.com/Shopify/sarama" + "github.com/TremblingV5/DouTok/applications/relation/pack" + "github.com/cloudwego/kitex/pkg/klog" "strconv" "strings" "time" - - "github.com/Shopify/sarama" - "github.com/cloudwego/kitex/pkg/klog" - - "github.com/TremblingV5/DouTok/applications/relationDomain/pack" ) type msgConsumerGroup struct{} @@ -23,9 +21,7 @@ func (m msgConsumerGroup) ConsumeClaim(sess sarama.ConsumerGroupSession, claim s klog.Infof("Message topic:%q partition:%d offset:%d value:%s\n", msg.Topic, msg.Partition, msg.Offset, string(msg.Value)) relation := pack.Relation{} - if err := json.Unmarshal(msg.Value, &relation); err != nil { - return err - } + json.Unmarshal(msg.Value, &relation) userId := fmt.Sprintf("%d", relation.UserId) toUserId := fmt.Sprintf("%d", relation.ToUserId) actionType := fmt.Sprintf("%d", relation.ActionType) @@ -69,14 +65,13 @@ func ConsumeMsg() { _ = ConsumerGroup.Close() } -/* -* +/** 1. 从 SafeMap 中获取关注数和粉丝数,累加入 MySQL 2. 删除 Redis 中对应的缓存 follow/follower 数量 */ func Flush() { for { - time.Sleep(time.Second * 5) + time.Sleep(time.Second * 1) klog.Infof("start iter\n") ConcurrentMap.Iter(iter) // 需要清空 @@ -101,30 +96,16 @@ func iter(key string, v interface{}) { klog.Infof("关注更新 %d\n", value) // follow_ // 更新关注数 db - err = UpdateFollowCountFromDB(userId, value) - if err != nil { - klog.Errorf("update follow count defeat, err = %s", err) - } - + UpdateFollowCountFromDB(userId, value) // 删除关注数 cache err = DeleteFollowCountCache(pair[1]) - if err != nil { - klog.Errorf("delete follow count defeat, err = %s", err) - } } else { klog.Infof("粉丝更新 %d\n", value) // follower_ // 更新粉丝数 db - err = UpdateFollowerCountFromDB(userId, value) - if err != nil { - klog.Errorf("update follow count defeat, err = %s", err) - } - + UpdateFollowerCountFromDB(userId, value) // 删除粉丝数 cache err = DeleteFollowerCountCache(pair[1]) - if err != nil { - klog.Errorf("delete follow count defeat, err = %s", err) - } } } } diff --git a/applications/relation/service/consume_msg_test.go b/applications/relation/service/consume_msg_test.go new file mode 100644 index 00000000..53759125 --- /dev/null +++ b/applications/relation/service/consume_msg_test.go @@ -0,0 +1,31 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/cloudwego/hertz/pkg/common/test/assert" + "testing" + "time" +) + +func TestConsumeMsg(t *testing.T) { + Init() + go ConsumeMsg() + time.Sleep(time.Second * 3) +} + +func TestFlush(t *testing.T) { + Init() + + relService := NewRelationActionService(context.Background()) + req := &relation.DouyinRelationActionRequest{ + UserId: 10001000, + ToUserId: 10002000, + ActionType: 1, + } + err := relService.RelationAction(req) + assert.Nil(t, err) + + go Flush() + time.Sleep(time.Second * 3) +} diff --git a/applications/relation/service/init.go b/applications/relation/service/init.go index 403c6e78..27030ab4 100644 --- a/applications/relation/service/init.go +++ b/applications/relation/service/init.go @@ -1,35 +1,26 @@ package service import ( - "github.com/TremblingV5/DouTok/config/configStruct" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/bytedance/gopkg/util/logger" - "go.uber.org/zap" - "sync" - + "fmt" "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/query" + "github.com/TremblingV5/DouTok/applications/relation/dal/query" "github.com/TremblingV5/DouTok/pkg/dtviper" "github.com/TremblingV5/DouTok/pkg/kafka" + "github.com/TremblingV5/DouTok/pkg/mysqlIniter" + redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" "github.com/TremblingV5/DouTok/pkg/safeMap" "github.com/TremblingV5/DouTok/pkg/utils" "github.com/go-redis/redis/v8" + "sync" ) -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_RELATION_"` - Redis configStruct.Redis `envPrefix:"DOUTOK_RELATION_"` - MySQL configStruct.MySQL `envPrefix:"DOUTOK_RELATION_"` -} - var ( RedisClient *redis.Client SyncProducer sarama.SyncProducer - ViperConfig *dtviper.Config + ViperConfig dtviper.Config ConsumerGroup sarama.ConsumerGroup ConcurrentMap *safeMap.SafeMap mu *sync.Mutex - DomainConfig = &Config{} ) func InitMutex() { @@ -37,11 +28,7 @@ func InitMutex() { } func InitViper() { - v, err := configurator.Load(DomainConfig, "DOUTOK_RELATION", "relation") - ViperConfig = v - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", DomainConfig)) - } + ViperConfig = dtviper.ConfigInit("DOUTOK_RELATION", "relation") } func InitSyncProducer() { @@ -55,7 +42,16 @@ func InitConsumerGroup() { } func InitRedisClient() { - RedisClient = DomainConfig.Redis.InitRedisClient(configStruct.DEFAULT_DATABASE) + + Client, err := redishandle.InitRedisClient( + fmt.Sprintf("%s:%d", ViperConfig.Viper.GetString("Redis.Host"), ViperConfig.Viper.GetInt("Redis.Port")), + ViperConfig.Viper.GetString("Redis.Password"), + ViperConfig.Viper.GetInt("Redis.Databases.Default"), + ) + if err != nil { + panic(err) + } + RedisClient = Client } func InitId() { @@ -64,7 +60,12 @@ func InitId() { } func InitDB() { - db, err := DomainConfig.MySQL.InitDB() + username := ViperConfig.Viper.GetString("MySQL.Username") + password := ViperConfig.Viper.GetString("MySQL.Password") + host := ViperConfig.Viper.GetString("MySQL.Host") + port := ViperConfig.Viper.GetString("MySQL.Port") + database := ViperConfig.Viper.GetString("MySQL.Database") + db, err := mysqlIniter.InitDb(username, password, host, port, database) if err != nil { panic(err) } diff --git a/applications/relation/service/init_test.go b/applications/relation/service/init_test.go new file mode 100644 index 00000000..a40e85e0 --- /dev/null +++ b/applications/relation/service/init_test.go @@ -0,0 +1,19 @@ +package service + +import "testing" + +func Init() { + InitViper() + InitRedisClient() + InitSyncProducer() + InitConsumerGroup() + InitId() + InitDB() + InitSafeMap() + InitMutex() + // TODO 待测试 Flush 协程 +} + +func TestInit(t *testing.T) { + Init() +} diff --git a/applications/relation/service/relation_action.go b/applications/relation/service/relation_action.go index c5d4447d..ff617fec 100644 --- a/applications/relation/service/relation_action.go +++ b/applications/relation/service/relation_action.go @@ -4,27 +4,13 @@ import ( "context" "encoding/json" "fmt" - "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" + "github.com/TremblingV5/DouTok/applications/relation/pack" + "github.com/TremblingV5/DouTok/kitex_gen/relation" "github.com/TremblingV5/DouTok/pkg/constants" "github.com/cloudwego/kitex/pkg/klog" ) -type Relation struct { - UserId int64 `json:"user_id"` - ToUserId int64 `json:"to_user_id"` - ActionType int32 `json:"action_type"` -} - -func NewRelation(userId int64, toUserId int64, actionType int64) *Relation { - return &Relation{ - UserId: userId, - ToUserId: toUserId, - ActionType: int32(actionType), - } -} - type RelationActionService struct { ctx context.Context } @@ -33,32 +19,8 @@ func NewRelationActionService(ctx context.Context) *RelationActionService { return &RelationActionService{ctx: ctx} } -func (s *RelationActionService) AddRelation(req *relationDomain.DoutokAddRelationRequest) error { - err, followList := ReadFollowListFromCache(fmt.Sprint(req.UserId)) - if err != nil { - return err - } - - isFollowed := false - - for _, v := range followList { - if v == req.ToUserId { - isFollowed = true - break - } - } - - if !isFollowed { - isFollowed, err = ReadIsFollowFromDB(req.UserId, req.ToUserId) - if err != nil { - isFollowed = false - } - } - - if isFollowed { - return nil - } - +// 关注 || 取关动作 +func (s *RelationActionService) RelationAction(req *relation.DouyinRelationActionRequest) error { // 在 SafeMap 中更新局部关注数和粉丝数 followKey := fmt.Sprintf("%s%d", constants.FollowCount, req.UserId) followerKey := fmt.Sprintf("%s%d", constants.FollowerCount, req.ToUserId) @@ -70,93 +32,12 @@ func (s *RelationActionService) AddRelation(req *relationDomain.DoutokAddRelatio if !ok { klog.Infof("get follow count from concurrentMap false") } - op := int64(1) - // TODO 如果关注或者取关对应的增加 safemap 值,前提是需要验证重复性操作 - mu.Lock() - if follow == nil { - klog.Infof("set follow %s, %d\n", followKey, op) - ConcurrentMap.Set(followKey, op) - } else { - klog.Infof("set follow %s, %d\n", followKey, follow.(int64)+op) - ConcurrentMap.Set(followKey, follow.(int64)+op) - } - if follower == nil { - klog.Infof("set follower %s, %d\n", followerKey, op) - ConcurrentMap.Set(followerKey, op) + op := int64(0) + if req.ActionType == 1 { + op = 1 } else { - klog.Infof("set follower %s, %d\n", followerKey, follower.(int64)+op) - ConcurrentMap.Set(followerKey, follower.(int64)+op) - } - follow, ok = ConcurrentMap.Get(followKey) - if !ok { - klog.Errorf("concurrentMap get false") - } - follower, ok = ConcurrentMap.Get(followerKey) - if !ok { - klog.Errorf("concurrentMap get false") - } - klog.Infof("%s follow = %d\n", followKey, follow.(int64)) - klog.Infof("%s follower = %d\n", followerKey, follower.(int64)) - mu.Unlock() - // 使用同步producer,将消息存入 kafka - // 构建消息 - val, err := json.Marshal(NewRelation(req.UserId, req.ToUserId, 0)) - if err != nil { - return err - } - msg := &sarama.ProducerMessage{ - Topic: ViperConfig.Viper.GetStringSlice("Kafka.Topics")[0], - Value: sarama.StringEncoder(val), - } - partition, offset, err := SyncProducer.SendMessage(msg) - - if err == nil { - klog.Infof("produce success, partition: %d, offset: %d\n", partition, offset) - } else { - return err - } - - return nil -} - -func (s *RelationActionService) RmRelation(req *relationDomain.DoutokRmRelationRequest) error { - err, followList := ReadFollowListFromCache(fmt.Sprint(req.UserId)) - if err != nil { - return nil - } - - isFollowed := false - - for _, v := range followList { - if v == req.ToUserId { - isFollowed = true - break - } - } - - if !isFollowed { - isFollowed, err = ReadIsFollowFromDB(req.UserId, req.ToUserId) - if err != nil { - isFollowed = true - } - } - - if !isFollowed { - return nil - } - - // 在 SafeMap 中更新局部关注数和粉丝数 - followKey := fmt.Sprintf("%s%d", constants.FollowCount, req.UserId) - followerKey := fmt.Sprintf("%s%d", constants.FollowerCount, req.ToUserId) - follow, ok := ConcurrentMap.Get(followKey) - if !ok { - klog.Infof("get follow count from concurrentMap false") - } - follower, ok := ConcurrentMap.Get(followerKey) - if !ok { - klog.Infof("get follow count from concurrentMap false") + op = -1 } - op := int64(-1) // TODO 如果关注或者取关对应的增加 safemap 值,前提是需要验证重复性操作 mu.Lock() if follow == nil { @@ -186,7 +67,7 @@ func (s *RelationActionService) RmRelation(req *relationDomain.DoutokRmRelationR mu.Unlock() // 使用同步producer,将消息存入 kafka // 构建消息 - val, err := json.Marshal(NewRelation(req.UserId, req.ToUserId, 1)) + val, err := json.Marshal(pack.NewRelation(req)) if err != nil { return err } diff --git a/applications/relation/service/relation_action_test.go b/applications/relation/service/relation_action_test.go new file mode 100644 index 00000000..928907d2 --- /dev/null +++ b/applications/relation/service/relation_action_test.go @@ -0,0 +1,20 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/cloudwego/hertz/pkg/common/test/assert" + "testing" +) + +func TestRelationActionService(t *testing.T) { + Init() + relService := NewRelationActionService(context.Background()) + req := &relation.DouyinRelationActionRequest{ + UserId: 10001000, + ToUserId: 10002000, + ActionType: 1, + } + err := relService.RelationAction(req) + assert.Nil(t, err) +} diff --git a/applications/relation/service/relation_count.go b/applications/relation/service/relation_count.go index 2ffe3b66..8209bda1 100644 --- a/applications/relation/service/relation_count.go +++ b/applications/relation/service/relation_count.go @@ -3,9 +3,9 @@ package service import ( "context" "fmt" - - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/query" + "github.com/TremblingV5/DouTok/applications/relation/dal/model" + "github.com/TremblingV5/DouTok/applications/relation/dal/query" + "github.com/TremblingV5/DouTok/kitex_gen/relation" "github.com/TremblingV5/DouTok/pkg/constants" "github.com/cloudwego/kitex/pkg/klog" ) @@ -18,85 +18,41 @@ func NewRelationCountService(ctx context.Context) *RelationCountService { return &RelationCountService{ctx: ctx} } -func (s *RelationCountService) GetFollowCount(userId int64) (int64, error) { - err, follow := ReadFollowCountFromCache(fmt.Sprintf("%d", userId)) - if err != nil || follow == 0 { - // 记录日志 - klog.Errorf("read follow count from cache error, err = %s", err) - // 读 db 获取关注数 - err, follow = ReadFollowCountFromDB(userId) - if err != nil { - // 记录日志 - klog.Errorf("read follow count from db error, err = %s", err) - follow = 0 - } - // 新增 cache 关注数 - err = WriteFollowCountToCache(fmt.Sprintf("%d", userId), follow) - if err != nil { - // 记录日志 - klog.Errorf("update follow count to cache error, err = %s", err) - } - } - return follow, nil -} - -func (s *RelationCountService) GetFollowerCount(userId int64) (int64, error) { - err, follower := ReadFollowerCountFromCache(fmt.Sprintf("%d", userId)) - if err != nil || follower == 0 { - // 记录日志 - klog.Errorf("read follower count from cache error, err = %s", err) - // 读 db 获取粉丝数 - err, follower = ReadFollowerCountFromDB(userId) - if err != nil { - // 记录日志 - klog.Errorf("read follower count from db error, err = %s", err) - follower = 0 - } - // 新增 cache 粉丝数 - err = WriteFollowerCountToCache(fmt.Sprintf("%d", userId), follower) - if err != nil { - // 记录日志 - klog.Errorf("update follower count to cache error, err = %s", err) - } - } - return follower, nil -} - -func (s *RelationCountService) RelationCount(userId int64) (error, int64, int64) { +func (s *RelationCountService) RelationCount(req *relation.DouyinRelationCountRequest) (error, int64, int64) { // 读 cache 获取关注数 - err, follow := ReadFollowCountFromCache(fmt.Sprintf("%d", userId)) + err, follow := ReadFollowCountFromCache(fmt.Sprintf("%d", req.UserId)) if err != nil || follow == 0 { // 记录日志 klog.Errorf("read follow count from cache error, err = %s", err) // 读 db 获取关注数 - err, follow = ReadFollowCountFromDB(userId) + err, follow = ReadFollowCountFromDB(req.UserId) if err != nil { // 记录日志 klog.Errorf("read follow count from db error, err = %s", err) follow = 0 } // 新增 cache 关注数 - err = WriteFollowCountToCache(fmt.Sprintf("%d", userId), follow) + err = WriteFollowCountToCache(fmt.Sprintf("%d", req.UserId), follow) if err != nil { // 记录日志 klog.Errorf("update follow count to cache error, err = %s", err) } } // 读 cache 获取粉丝数 - err, follower := ReadFollowerCountFromCache(fmt.Sprintf("%d", userId)) + err, follower := ReadFollowerCountFromCache(fmt.Sprintf("%d", req.UserId)) if err != nil || follower == 0 { // 记录日志 klog.Errorf("read follower count from cache error, err = %s", err) // 读 db 获取粉丝数 - err, follower = ReadFollowerCountFromDB(userId) + err, follower = ReadFollowerCountFromDB(req.UserId) if err != nil { // 记录日志 klog.Errorf("read follower count from db error, err = %s", err) follower = 0 } // 新增 cache 粉丝数 - err = WriteFollowerCountToCache(fmt.Sprintf("%d", userId), follower) + err = WriteFollowerCountToCache(fmt.Sprintf("%d", req.UserId), follower) if err != nil { // 记录日志 klog.Errorf("update follower count to cache error, err = %s", err) diff --git a/applications/relation/service/relation_count_test.go b/applications/relation/service/relation_count_test.go new file mode 100644 index 00000000..d55ca22d --- /dev/null +++ b/applications/relation/service/relation_count_test.go @@ -0,0 +1,28 @@ +package service + +import ( + "context" + "fmt" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/cloudwego/hertz/pkg/common/test/assert" + "testing" +) + +func TestRelationCountService(t *testing.T) { + Init() + relService := NewRelationCountService(context.Background()) + req := &relation.DouyinRelationCountRequest{ + UserId: 10001000, + } + err, follow, follower := relService.RelationCount(req) + assert.Nil(t, err) + fmt.Printf("userId = 10001000, follow = %d, follower = %d\n", follow, follower) + + relService = NewRelationCountService(context.Background()) + req = &relation.DouyinRelationCountRequest{ + UserId: 10004000, + } + err, follow, follower = relService.RelationCount(req) + assert.Nil(t, err) + fmt.Printf("userId = 10004000, follow = %d, follower = %d\n", follow, follower) +} diff --git a/applications/relation/service/relation_follow_list.go b/applications/relation/service/relation_follow_list.go index 45d8e494..b1dd3b8e 100644 --- a/applications/relation/service/relation_follow_list.go +++ b/applications/relation/service/relation_follow_list.go @@ -3,18 +3,17 @@ package service import ( "context" "fmt" - "strconv" - - "github.com/cloudwego/kitex/pkg/klog" - "github.com/go-redis/redis/v8" - - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/query" - "github.com/TremblingV5/DouTok/applications/relationDomain/pack" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" + "github.com/TremblingV5/DouTok/applications/relation/dal/model" + "github.com/TremblingV5/DouTok/applications/relation/dal/query" + "github.com/TremblingV5/DouTok/applications/relation/pack" + "github.com/TremblingV5/DouTok/applications/relation/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/kitex_gen/user" "github.com/TremblingV5/DouTok/pkg/constants" "github.com/TremblingV5/DouTok/pkg/utils" + "github.com/cloudwego/kitex/pkg/klog" + "github.com/go-redis/redis/v8" + "strconv" ) type RelationFollowListService struct { @@ -25,7 +24,7 @@ func NewRelationFollowListService(ctx context.Context) *RelationFollowListServic return &RelationFollowListService{ctx: ctx} } -func (s *RelationFollowListService) RelationFollowList(req *relationDomain.DoutokListRelationRequest) (error, []*entity.User) { +func (s *RelationFollowListService) RelationFollowList(req *relation.DouyinRelationFollowListRequest) (error, []*user.User) { // 从 cache 读 err, follow := ReadFollowListFromCache(fmt.Sprintf("%d", req.UserId)) if err != nil || follow == nil { @@ -49,27 +48,14 @@ func (s *RelationFollowListService) RelationFollowList(req *relationDomain.Douto follow = list } } - // 去用户服务查询 follow list 的 user 信息 - // request := new(userDomain.DoutokGetUserInfoRequest) - // request.UserId = follow - // resp, err := rpc.UserDomainRPCClient.GetUserInfo(context.Background(), request) - // if err != nil { - // return err, nil - // } - - // var result []*entity.User - // for _, v := range resp.UserList { - // result = append(result, v) - // } - result := make([]*entity.User, 0) - for _, v := range follow { - result = append(result, &entity.User{ - Id: v, - }) + request := new(user.DouyinUserListRequest) + request.UserList = follow + resp, err := rpc.GetUserListByIds(context.Background(), request) + if err != nil { + return err, nil } - - return nil, result + return nil, resp.GetUserList() } // 查缓存 @@ -102,23 +88,6 @@ func ReadFollowListFromDB(user_id int64) (error, []*model.Relation) { return nil, res } -func ReadIsFollowFromDB(userId int64, toUserId int64) (bool, error) { - res, err := query.Relation.Where( - query.Relation.UserId.Eq(userId), - query.Relation.ToUserId.Eq(toUserId), - ).First() - - if err != nil { - return false, err - } - - if res.Status == 1 { - return false, nil - } else { - return true, nil - } -} - // 写入缓存 func WriteFollowListToCache(user_id string, relations []*model.Relation) error { val := make([]string, len(relations)*2) diff --git a/applications/relation/service/relation_follow_list_test.go b/applications/relation/service/relation_follow_list_test.go new file mode 100644 index 00000000..47d1965e --- /dev/null +++ b/applications/relation/service/relation_follow_list_test.go @@ -0,0 +1,50 @@ +package service + +import ( + "bou.ke/monkey" + "context" + "github.com/TremblingV5/DouTok/applications/relation/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/kitex_gen/user" + "github.com/cloudwego/hertz/pkg/common/test/assert" + "testing" +) + +func TestRelationFollowListService(t *testing.T) { + Init() + relService := NewRelationFollowListService(context.Background()) + req := &relation.DouyinRelationFollowListRequest{ + UserId: 10001000, + } + + monkey.Patch(rpc.GetUserListByIds, func(ctx context.Context, req *user.DouyinUserListRequest) (resp *user.DouyinUserListResponse, err error) { + userList := []*user.User{{Id: 10002000, Name: "test2"}, {Id: 10003000, Name: "test3"}} + return &user.DouyinUserListResponse{ + UserList: userList, + }, nil + }) + + err, ret := relService.RelationFollowList(req) + assert.Nil(t, err) + for _, user := range ret { + println(user.Id, user.Name) + } + + relService = NewRelationFollowListService(context.Background()) + req = &relation.DouyinRelationFollowListRequest{ + UserId: 10006000, + } + + monkey.Patch(rpc.GetUserListByIds, func(ctx context.Context, req *user.DouyinUserListRequest) (resp *user.DouyinUserListResponse, err error) { + userList := []*user.User{{Id: 10002000, Name: "test2"}, {Id: 10003000, Name: "test3"}} + return &user.DouyinUserListResponse{ + UserList: userList, + }, nil + }) + + err, ret = relService.RelationFollowList(req) + assert.Nil(t, err) + for _, user := range ret { + println(user.Id, user.Name) + } +} diff --git a/applications/relation/service/relation_follower_list.go b/applications/relation/service/relation_follower_list.go index 47e8c389..77b9200c 100644 --- a/applications/relation/service/relation_follower_list.go +++ b/applications/relation/service/relation_follower_list.go @@ -3,16 +3,15 @@ package service import ( "context" "fmt" - "strconv" - - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/query" - "github.com/TremblingV5/DouTok/kitex_gen/entity" + "github.com/TremblingV5/DouTok/applications/relation/dal/model" + "github.com/TremblingV5/DouTok/applications/relation/dal/query" + "github.com/TremblingV5/DouTok/applications/relation/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/kitex_gen/user" "github.com/TremblingV5/DouTok/pkg/constants" "github.com/cloudwego/kitex/pkg/klog" "github.com/go-redis/redis/v8" + "strconv" ) type RelationFollowerListService struct { @@ -23,7 +22,7 @@ func NewRelationFollowerListService(ctx context.Context) *RelationFollowerListSe return &RelationFollowerListService{ctx: ctx} } -func (s *RelationFollowerListService) RelationFollowerList(req *relationDomain.DoutokListRelationRequest) (error, []*entity.User) { +func (s *RelationFollowerListService) RelationFollowerList(req *relation.DouyinRelationFollowerListRequest) (error, []*user.User) { // 从 cache 读 err, follower := ReadFollowerListFromCache(fmt.Sprintf("%d", req.UserId)) if err != nil || follower == nil { @@ -48,26 +47,13 @@ func (s *RelationFollowerListService) RelationFollowerList(req *relationDomain.D } } // 去用户服务查询 follow list 的 user 信息 - // request := new(userDomain.DoutokGetUserInfoRequest) - // request.UserId = follower - // resp, err := rpc.UserDomainRPCClient.GetUserInfo(context.Background(), request) - // if err != nil { - // return err, nil - // } - - // var result []*entity.User - // for _, v := range resp.UserList { - // result = append(result, v) - // } - - result := make([]*entity.User, 0) - for _, v := range follower { - result = append(result, &entity.User{ - Id: v, - }) + request := new(user.DouyinUserListRequest) + request.UserList = follower + resp, err := rpc.GetUserListByIds(context.Background(), request) + if err != nil { + return err, nil } - - return nil, result + return nil, resp.GetUserList() } // 查缓存 diff --git a/applications/relation/service/relation_follower_list_test.go b/applications/relation/service/relation_follower_list_test.go new file mode 100644 index 00000000..de0bc798 --- /dev/null +++ b/applications/relation/service/relation_follower_list_test.go @@ -0,0 +1,46 @@ +package service + +import ( + "bou.ke/monkey" + "context" + "github.com/TremblingV5/DouTok/applications/relation/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/kitex_gen/user" + "github.com/cloudwego/hertz/pkg/common/test/assert" + "testing" +) + +func TestRelationFollowerListService(t *testing.T) { + Init() + relService := NewRelationFollowerListService(context.Background()) + req := &relation.DouyinRelationFollowerListRequest{UserId: 10002000} + + monkey.Patch(rpc.GetUserListByIds, func(ctx context.Context, req *user.DouyinUserListRequest) (resp *user.DouyinUserListResponse, err error) { + userList := []*user.User{{Id: 10002000, Name: "test2"}, {Id: 10003000, Name: "test3"}} + return &user.DouyinUserListResponse{ + UserList: userList, + }, nil + }) + + err, ret := relService.RelationFollowerList(req) + assert.Nil(t, err) + for _, user := range ret { + println(user.Id, user.Name) + } + + relService = NewRelationFollowerListService(context.Background()) + req = &relation.DouyinRelationFollowerListRequest{UserId: 10007000} + + monkey.Patch(rpc.GetUserListByIds, func(ctx context.Context, req *user.DouyinUserListRequest) (resp *user.DouyinUserListResponse, err error) { + userList := []*user.User{{Id: 10002000, Name: "test2"}, {Id: 10003000, Name: "test3"}} + return &user.DouyinUserListResponse{ + UserList: userList, + }, nil + }) + + err, ret = relService.RelationFollowerList(req) + assert.Nil(t, err) + for _, user := range ret { + println(user.Id, user.Name) + } +} diff --git a/applications/relation/service/relation_friend_list.go b/applications/relation/service/relation_friend_list.go index 568a1580..a7accf5a 100644 --- a/applications/relation/service/relation_friend_list.go +++ b/applications/relation/service/relation_friend_list.go @@ -4,9 +4,10 @@ import ( "context" "fmt" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - - "github.com/TremblingV5/DouTok/kitex_gen/entity" + "github.com/TremblingV5/DouTok/applications/relation/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/kitex_gen/user" "github.com/cloudwego/kitex/pkg/klog" ) @@ -18,57 +19,51 @@ func NewRelationFriendListService(ctx context.Context) *RelationFriendListServic return &RelationFriendListService{ctx: ctx} } -func (s *RelationFriendListService) RelationFriendList(req *relationDomain.DoutokListRelationRequest) (error, []*entity.User) { +func (s *RelationFriendListService) RelationFriendList(req *relation.DouyinRelationFriendListRequest) (error, []*relation.FriendUser) { // 从 cache 读 err, friendList := GetFriendList(req.UserId) if err != nil { return err, nil } // 去用户服务查询 friendList 的 user 信息 - // reqUser := new(userDomain.DoutokGetUserInfoRequest) - // reqUser.UserId = friendList - // respUser, err := rpc.UserDomainRPCClient.GetUserInfo(context.Background(), reqUser) - // if err != nil { - // return err, nil - // } + reqUser := new(user.DouyinUserListRequest) + reqUser.UserList = friendList + respUser, err := rpc.GetUserListByIds(context.Background(), reqUser) + if err != nil { + return err, nil + } // 去 message 服务查询对应好友列表的最新消息 返回一个 map - reqMsg := new(relationDomain.DoutokListRelationRequest) + reqMsg := new(message.DouyinFriendListMessageRequest) reqMsg.UserId = req.UserId - reqMsg.ActionType = 2 - // reqMsg.FriendIdList = friendList - // _, err = rpc.RelationDomainRPCClient.ListRelation(context.Background(), reqMsg) + reqMsg.FriendIdList = friendList + respMsg, err := rpc.GetFriendList(context.Background(), reqMsg) - // for k, v := range respMsg.UserList { - // klog.Infof("res key = %d, msg = %s\n", k, v.Content) - // } + for k, v := range respMsg.Result { + klog.Infof("res key = %d, msg = %s\n", k, v.Content) + } if err != nil { return err, nil } - fList := make([]*entity.User, 0) - for _, v := range friendList { + fList := make([]*relation.FriendUser, 0, len(reqUser.GetUserList())) + for _, v := range respUser.GetUserList() { // 0为当前请求用户接受的消息,1为当前请求用户发送的消息 - // msgType := 0 - // if respMsg.UserList[v.Id].FromUserId == req.UserId { - // msgType = 1 - // } + msgType := 0 + if respMsg.Result[v.Id].FromUserId == req.UserId { + msgType = 1 + } - // klog.Infof("user_id = %s, msgType = %d\n", respMsg.UserList[v.Id].Content, int64(msgType)) + klog.Infof("user_id = %s, msgType = %d\n", respMsg.Result[v.Id].Content, int64(msgType)) - //friend := &entity.FriendUser{ - // User: &entity.User{ - // Id: v.Id, - // Name: v.Name, - // FollowCount: v.FollowCount, - // FollowerCount: v.FollowerCount, - // IsFollow: v.IsFollow, - // Avatar: v.Avatar, - // }, - // Message: respMsg.Result[v.Id].Content, - // MsgType: int64(msgType), - //} - friend := &entity.User{ - Id: v, + friend := &relation.FriendUser{ + Id: v.Id, + Name: v.Name, + FollowCount: v.FollowCount, + FollowerCount: v.FollowerCount, + IsFollow: v.IsFollow, + Avatar: v.Avatar, + Message: respMsg.Result[v.Id].Content, + MsgType: int64(msgType), } fList = append(fList, friend) } @@ -130,7 +125,7 @@ func GetFriendList(user_id int64) (error, []int64) { } friendList := make([]int64, 0) for _, v := range follower { - if followMap[v] { + if followMap[v] == true { friendList = append(friendList, v) } } diff --git a/applications/relation/service/relation_friend_list_test.go b/applications/relation/service/relation_friend_list_test.go new file mode 100644 index 00000000..0338ccee --- /dev/null +++ b/applications/relation/service/relation_friend_list_test.go @@ -0,0 +1,62 @@ +package service + +import ( + "context" + "testing" + + "bou.ke/monkey" + "github.com/TremblingV5/DouTok/applications/relation/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/kitex_gen/user" + "github.com/cloudwego/hertz/pkg/common/test/assert" +) + +func TestRelationFriendListService(t *testing.T) { + Init() + relService := NewRelationFriendListService(context.Background()) + req := &relation.DouyinRelationFriendListRequest{UserId: 10001000} + + monkey.Patch(rpc.GetUserListByIds, func(ctx context.Context, req *user.DouyinUserListRequest) (resp *user.DouyinUserListResponse, err error) { + userList := []*user.User{{Id: 10002000, Name: "test2"}, {Id: 10003000, Name: "test3"}} + return &user.DouyinUserListResponse{ + UserList: userList, + }, nil + }) + + monkey.Patch(rpc.GetFriendList, func(ctx context.Context, req *message.DouyinFriendListMessageRequest) (resp *message.DouyinFriendListMessageResponse, err error) { + msgMp := make(map[int64]*message.Message) + msgMp[10002000] = &message.Message{Content: "test msg"} + msgMp[10003000] = &message.Message{Content: "test msg"} + return &message.DouyinFriendListMessageResponse{Result: msgMp}, nil + }) + + err, ret := relService.RelationFriendList(req) + assert.Nil(t, err) + for _, friend := range ret { + println(friend.Id, friend.Message) + } + + relService = NewRelationFriendListService(context.Background()) + req = &relation.DouyinRelationFriendListRequest{UserId: 10008000} + + monkey.Patch(rpc.GetUserListByIds, func(ctx context.Context, req *user.DouyinUserListRequest) (resp *user.DouyinUserListResponse, err error) { + userList := []*user.User{{Id: 10002000, Name: "test2"}, {Id: 10003000, Name: "test3"}} + return &user.DouyinUserListResponse{ + UserList: userList, + }, nil + }) + + monkey.Patch(rpc.GetFriendList, func(ctx context.Context, req *message.DouyinFriendListMessageRequest) (resp *message.DouyinFriendListMessageResponse, err error) { + msgMp := make(map[int64]*message.Message) + msgMp[10002000] = &message.Message{Content: "test msg"} + msgMp[10003000] = &message.Message{Content: "test msg"} + return &message.DouyinFriendListMessageResponse{Result: msgMp}, nil + }) + + err, ret = relService.RelationFriendList(req) + assert.Nil(t, err) + for _, friend := range ret { + println(friend.Id, friend.Message) + } +} diff --git a/applications/relationDomain/Makefile b/applications/relationDomain/Makefile deleted file mode 100644 index 754f0bc9..00000000 --- a/applications/relationDomain/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -server: - kitex -module github.com/TremblingV5/DouTok -type protobuf -I ../../proto/ -service relationDomain ../../proto/relationDomain.proto \ No newline at end of file diff --git a/applications/relationDomain/build.sh b/applications/relationDomain/build.sh deleted file mode 100644 index 3603d201..00000000 --- a/applications/relationDomain/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -RUN_NAME="relationDomain" - -mkdir -p output/bin -cp script/* output/ -chmod +x output/bootstrap.sh - -if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then - go build -o output/bin/${RUN_NAME} -else - go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... -fi - diff --git a/applications/relationDomain/handler/add_relation.go b/applications/relationDomain/handler/add_relation.go deleted file mode 100644 index c6953aaa..00000000 --- a/applications/relationDomain/handler/add_relation.go +++ /dev/null @@ -1,21 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/relationDomain/pack" - "github.com/TremblingV5/DouTok/applications/relationDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func (s *RelationDomainServiceImpl) AddRelation(ctx context.Context, req *relationDomain.DoutokAddRelationRequest) (resp *relationDomain.DoutokAddRelationResponse, err error) { - resp = new(relationDomain.DoutokAddRelationResponse) - - err = service.NewRelationActionService(ctx).AddRelation(req) - if err != nil { - pack.BuildRelationActionResp(err, resp) - return resp, nil - } - pack.BuildRelationActionResp(errno.Success, resp) - return resp, nil -} diff --git a/applications/relationDomain/handler/count_relation.go b/applications/relationDomain/handler/count_relation.go deleted file mode 100644 index 3e3a9e5a..00000000 --- a/applications/relationDomain/handler/count_relation.go +++ /dev/null @@ -1,39 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/relationDomain/pack" - "github.com/TremblingV5/DouTok/applications/relationDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func (s *RelationDomainServiceImpl) CountRelation(ctx context.Context, req *relationDomain.DoutokCountRelationRequest) (resp *relationDomain.DoutokCountRelationResponse, err error) { - resp = &relationDomain.DoutokCountRelationResponse{ - Result: make(map[int64]int64), - } - - /* - 0 -> 关注数 1 -> 粉丝数 - */ - if req.ActionType == 0 { - for _, v := range req.UserId { - follow, err := service.NewRelationCountService(ctx).GetFollowCount(v) - if err != nil { - continue - } - resp.Result[v] = follow - } - } else if req.ActionType == 1 { - for _, v := range req.UserId { - follower, err := service.NewRelationCountService(ctx).GetFollowerCount(v) - if err != nil { - continue - } - resp.Result[v] = follower - } - } - - pack.BuildRelationCountResp(errno.Success, resp) - return resp, nil -} diff --git a/applications/relationDomain/handler/list_relation.go b/applications/relationDomain/handler/list_relation.go deleted file mode 100644 index bafd0e8d..00000000 --- a/applications/relationDomain/handler/list_relation.go +++ /dev/null @@ -1,47 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/relationDomain/pack" - "github.com/TremblingV5/DouTok/applications/relationDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func (s *RelationDomainServiceImpl) ListRelation(ctx context.Context, req *relationDomain.DoutokListRelationRequest) (resp *relationDomain.DoutokListRelationResponse, err error) { - resp = new(relationDomain.DoutokListRelationResponse) - if req.ActionType == 0 { - // 关注 - err, followList := service.NewRelationFollowListService(ctx).RelationFollowList(req) - if err != nil { - pack.BuildRelationFollowListResp(err, resp) - return resp, nil - } - resp.UserList = followList - pack.BuildRelationFollowListResp(errno.Success, resp) - return resp, nil - } else if req.ActionType == 1 { - // 粉丝 - // 关注 - err, followerList := service.NewRelationFollowerListService(ctx).RelationFollowerList(req) - if err != nil { - pack.BuildRelationFollowListResp(err, resp) - return resp, nil - } - resp.UserList = followerList - pack.BuildRelationFollowListResp(errno.Success, resp) - return resp, nil - } else if req.ActionType == 2 { - // 互相关注 - // 关注 - err, friendList := service.NewRelationFriendListService(ctx).RelationFriendList(req) - if err != nil { - pack.BuildRelationFollowListResp(err, resp) - return resp, nil - } - resp.UserList = friendList - pack.BuildRelationFollowListResp(errno.Success, resp) - return resp, nil - } - return resp, nil -} diff --git a/applications/relationDomain/handler/rm_relation.go b/applications/relationDomain/handler/rm_relation.go deleted file mode 100644 index afc0ce67..00000000 --- a/applications/relationDomain/handler/rm_relation.go +++ /dev/null @@ -1,21 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/relationDomain/pack" - "github.com/TremblingV5/DouTok/applications/relationDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func (s *RelationDomainServiceImpl) RmRelation(ctx context.Context, req *relationDomain.DoutokRmRelationRequest) (resp *relationDomain.DoutokRmRelationResponse, err error) { - resp = new(relationDomain.DoutokRmRelationResponse) - - err = service.NewRelationActionService(ctx).RmRelation(req) - if err != nil { - pack.BuildRmRelationActionResp(err, resp) - return resp, nil - } - pack.BuildRmRelationActionResp(errno.Success, resp) - return resp, nil -} diff --git a/applications/relationDomain/handler/typedef.go b/applications/relationDomain/handler/typedef.go deleted file mode 100644 index a136bca4..00000000 --- a/applications/relationDomain/handler/typedef.go +++ /dev/null @@ -1,3 +0,0 @@ -package handler - -type RelationDomainServiceImpl struct{} diff --git a/applications/relationDomain/main.go b/applications/relationDomain/main.go deleted file mode 100644 index 76e8b895..00000000 --- a/applications/relationDomain/main.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "github.com/TremblingV5/DouTok/applications/relationDomain/handler" - "github.com/TremblingV5/DouTok/applications/relationDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain/relationdomainservice" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/dlog" - "github.com/TremblingV5/DouTok/pkg/services" -) - -var ( - Logger = dlog.InitLog(3) -) - -func init() { - service.Init() -} - -func main() { - - options, shutdown := services.InitRPCServerArgs(constants.RELATION_DOMAIN_SERVER_NAME, service.DomainConfig.BaseConfig) - defer shutdown() - - svr := relationdomainservice.NewServer( - new(handler.RelationDomainServiceImpl), - options..., - ) - - if err := svr.Run(); err != nil { - Logger.Fatal(err) - } -} diff --git a/applications/relationDomain/pack/resp.go b/applications/relationDomain/pack/resp.go deleted file mode 100644 index f7f287f9..00000000 --- a/applications/relationDomain/pack/resp.go +++ /dev/null @@ -1,42 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func BuildRelationActionResp(err error, resp *relationDomain.DoutokAddRelationResponse) { - e := errno.ConvertErr(err) - resp.StatusMsg = e.ErrMsg - resp.StatusCode = int32(e.ErrCode) -} - -func BuildRmRelationActionResp(err error, resp *relationDomain.DoutokRmRelationResponse) { - e := errno.ConvertErr(err) - resp.StatusMsg = e.ErrMsg - resp.StatusCode = int32(e.ErrCode) -} - -func BuildRelationCountResp(err error, resp *relationDomain.DoutokCountRelationResponse) { - e := errno.ConvertErr(err) - resp.StatusMsg = e.ErrMsg - resp.StatusCode = int32(e.ErrCode) -} - -func BuildRelationFollowListResp(err error, resp *relationDomain.DoutokListRelationResponse) { - e := errno.ConvertErr(err) - resp.StatusMsg = e.ErrMsg - resp.StatusCode = int32(e.ErrCode) -} - -func BuildRelationFollowerListResp(err error, resp *relationDomain.DoutokListRelationResponse) { - e := errno.ConvertErr(err) - resp.StatusMsg = e.ErrMsg - resp.StatusCode = int32(e.ErrCode) -} - -func BuildRelationFriendListResp(err error, resp *relationDomain.DoutokListRelationResponse) { - e := errno.ConvertErr(err) - resp.StatusMsg = e.ErrMsg - resp.StatusCode = int32(e.ErrCode) -} diff --git a/applications/relationDomain/script/bootstrap.sh b/applications/relationDomain/script/bootstrap.sh deleted file mode 100644 index e12c8982..00000000 --- a/applications/relationDomain/script/bootstrap.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env bash -CURDIR=$(cd $(dirname $0); pwd) - -if [ "X$1" != "X" ]; then - RUNTIME_ROOT=$1 -else - RUNTIME_ROOT=${CURDIR} -fi - -export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT -export KITEX_LOG_DIR="$RUNTIME_ROOT/log" - -if [ ! -d "$KITEX_LOG_DIR/app" ]; then - mkdir -p "$KITEX_LOG_DIR/app" -fi - -if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then - mkdir -p "$KITEX_LOG_DIR/rpc" -fi - -exec "$CURDIR/bin/relationDomain" - diff --git a/applications/relationDomain/service/consume_msg.go b/applications/relationDomain/service/consume_msg.go deleted file mode 100644 index 3a038ad6..00000000 --- a/applications/relationDomain/service/consume_msg.go +++ /dev/null @@ -1,130 +0,0 @@ -package service - -import ( - "context" - "encoding/json" - "fmt" - "strconv" - "strings" - "time" - - "github.com/Shopify/sarama" - "github.com/cloudwego/kitex/pkg/klog" - - "github.com/TremblingV5/DouTok/applications/relationDomain/pack" -) - -type msgConsumerGroup struct{} - -func (m msgConsumerGroup) Setup(_ sarama.ConsumerGroupSession) error { return nil } -func (m msgConsumerGroup) Cleanup(_ sarama.ConsumerGroupSession) error { return nil } -func (m msgConsumerGroup) ConsumeClaim(sess sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { - for msg := range claim.Messages() { - klog.Infof("Message topic:%q partition:%d offset:%d value:%s\n", msg.Topic, msg.Partition, msg.Offset, string(msg.Value)) - - relation := pack.Relation{} - if err := json.Unmarshal(msg.Value, &relation); err != nil { - return err - } - userId := fmt.Sprintf("%d", relation.UserId) - toUserId := fmt.Sprintf("%d", relation.ToUserId) - actionType := fmt.Sprintf("%d", relation.ActionType) - - fmt.Printf("userId = %s, toUserId = %s, actionType = %s\n", userId, toUserId, actionType) - - // 更新关注表 cache - err := WriteFollowToCache(userId, toUserId, actionType) - if err != nil { - return err - } - // 更新粉丝表 cache - err = WriteFollowerToCache(toUserId, userId, actionType) - if err != nil { - return err - } - // 更新关注表 db - err = WriteFollowToDB(&relation) - if err != nil { - klog.Errorf("write follow to db error, err = %s", err) - return err - } - // 标记,sarama会自动进行提交,默认间隔1秒 - sess.MarkMessage(msg, "") - } - return nil -} - -var consumerGroup msgConsumerGroup - -func ConsumeMsg() { - - for { - err := ConsumerGroup.Consume(context.Background(), ViperConfig.Viper.GetStringSlice("Kafka.Topics"), consumerGroup) - if err != nil { - fmt.Println(err.Error()) - break - } - } - - _ = ConsumerGroup.Close() -} - -/* -* -1. 从 SafeMap 中获取关注数和粉丝数,累加入 MySQL -2. 删除 Redis 中对应的缓存 follow/follower 数量 -*/ -func Flush() { - for { - time.Sleep(time.Second * 5) - klog.Infof("start iter\n") - ConcurrentMap.Iter(iter) - // 需要清空 - ConcurrentMap.Clean() - } -} - -func iter(key string, v interface{}) { - if v == nil { - return - } - fmt.Printf("key = %s, v = %v\n", key, v) - value := v.(int64) - pair := strings.Split(key, "-") - userId, err := strconv.ParseInt(pair[1], 10, 64) - klog.Infof("userId = %d\n", userId) - if err != nil { - klog.Errorf("strconv.ParseInt error, err = %s", err) - } - if value != 0 { - if pair[0][6] == '_' { - klog.Infof("关注更新 %d\n", value) - // follow_ - // 更新关注数 db - err = UpdateFollowCountFromDB(userId, value) - if err != nil { - klog.Errorf("update follow count defeat, err = %s", err) - } - - // 删除关注数 cache - err = DeleteFollowCountCache(pair[1]) - if err != nil { - klog.Errorf("delete follow count defeat, err = %s", err) - } - } else { - klog.Infof("粉丝更新 %d\n", value) - // follower_ - // 更新粉丝数 db - err = UpdateFollowerCountFromDB(userId, value) - if err != nil { - klog.Errorf("update follow count defeat, err = %s", err) - } - - // 删除粉丝数 cache - err = DeleteFollowerCountCache(pair[1]) - if err != nil { - klog.Errorf("delete follow count defeat, err = %s", err) - } - } - } -} diff --git a/applications/relationDomain/service/init.go b/applications/relationDomain/service/init.go deleted file mode 100644 index 0ccde669..00000000 --- a/applications/relationDomain/service/init.go +++ /dev/null @@ -1,89 +0,0 @@ -package service - -import ( - "github.com/TremblingV5/DouTok/config/configStruct" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/bytedance/gopkg/util/logger" - "go.uber.org/zap" - "sync" - - "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/query" - "github.com/TremblingV5/DouTok/pkg/dtviper" - "github.com/TremblingV5/DouTok/pkg/kafka" - "github.com/TremblingV5/DouTok/pkg/safeMap" - "github.com/TremblingV5/DouTok/pkg/utils" - "github.com/go-redis/redis/v8" -) - -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_RELATIONDOMAIN_"` - Redis configStruct.Redis `envPrefix:"DOUTOK_RELATIONDOMAIN_"` - MySQL configStruct.MySQL `envPrefix:"DOUTOK_RELATIONDOMAIN_"` -} - -var ( - RedisClient *redis.Client - SyncProducer sarama.SyncProducer - ViperConfig *dtviper.Config - ConsumerGroup sarama.ConsumerGroup - ConcurrentMap *safeMap.SafeMap - mu *sync.Mutex - DomainConfig = &Config{} -) - -func Init() { - InitViper() - InitRedisClient() - InitSyncProducer() - InitConsumerGroup() - InitId() - InitDB() - InitSafeMap() - InitMutex() - - go Flush() -} - -func InitMutex() { - mu = &sync.Mutex{} -} - -func InitViper() { - v, err := configurator.Load(DomainConfig, "DOUTOK_RELATIONDOMAIN", "relationDomain") - ViperConfig = v - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", DomainConfig)) - } -} - -func InitSyncProducer() { - producer := kafka.InitSynProducer(ViperConfig.Viper.GetStringSlice("Kafka.Brokers")) - SyncProducer = producer -} - -func InitConsumerGroup() { - cGroup := kafka.InitConsumerGroup(ViperConfig.Viper.GetStringSlice("Kafka.Brokers"), ViperConfig.Viper.GetStringSlice("Kafka.GroupIds")[0]) - ConsumerGroup = cGroup -} - -func InitRedisClient() { - RedisClient = DomainConfig.Redis.InitRedisClient(configStruct.DEFAULT_DATABASE) -} - -func InitId() { - node := ViperConfig.Viper.GetInt64("Snowflake.Node") - utils.InitSnowFlake(node) -} - -func InitDB() { - db, err := DomainConfig.MySQL.InitDB() - if err != nil { - panic(err) - } - query.SetDefault(db) -} - -func InitSafeMap() { - ConcurrentMap = safeMap.New() -} diff --git a/applications/relationDomain/service/relation_action.go b/applications/relationDomain/service/relation_action.go deleted file mode 100644 index c5d4447d..00000000 --- a/applications/relationDomain/service/relation_action.go +++ /dev/null @@ -1,206 +0,0 @@ -package service - -import ( - "context" - "encoding/json" - "fmt" - - "github.com/Shopify/sarama" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/cloudwego/kitex/pkg/klog" -) - -type Relation struct { - UserId int64 `json:"user_id"` - ToUserId int64 `json:"to_user_id"` - ActionType int32 `json:"action_type"` -} - -func NewRelation(userId int64, toUserId int64, actionType int64) *Relation { - return &Relation{ - UserId: userId, - ToUserId: toUserId, - ActionType: int32(actionType), - } -} - -type RelationActionService struct { - ctx context.Context -} - -func NewRelationActionService(ctx context.Context) *RelationActionService { - return &RelationActionService{ctx: ctx} -} - -func (s *RelationActionService) AddRelation(req *relationDomain.DoutokAddRelationRequest) error { - err, followList := ReadFollowListFromCache(fmt.Sprint(req.UserId)) - if err != nil { - return err - } - - isFollowed := false - - for _, v := range followList { - if v == req.ToUserId { - isFollowed = true - break - } - } - - if !isFollowed { - isFollowed, err = ReadIsFollowFromDB(req.UserId, req.ToUserId) - if err != nil { - isFollowed = false - } - } - - if isFollowed { - return nil - } - - // 在 SafeMap 中更新局部关注数和粉丝数 - followKey := fmt.Sprintf("%s%d", constants.FollowCount, req.UserId) - followerKey := fmt.Sprintf("%s%d", constants.FollowerCount, req.ToUserId) - follow, ok := ConcurrentMap.Get(followKey) - if !ok { - klog.Infof("get follow count from concurrentMap false") - } - follower, ok := ConcurrentMap.Get(followerKey) - if !ok { - klog.Infof("get follow count from concurrentMap false") - } - op := int64(1) - // TODO 如果关注或者取关对应的增加 safemap 值,前提是需要验证重复性操作 - mu.Lock() - if follow == nil { - klog.Infof("set follow %s, %d\n", followKey, op) - ConcurrentMap.Set(followKey, op) - } else { - klog.Infof("set follow %s, %d\n", followKey, follow.(int64)+op) - ConcurrentMap.Set(followKey, follow.(int64)+op) - } - if follower == nil { - klog.Infof("set follower %s, %d\n", followerKey, op) - ConcurrentMap.Set(followerKey, op) - } else { - klog.Infof("set follower %s, %d\n", followerKey, follower.(int64)+op) - ConcurrentMap.Set(followerKey, follower.(int64)+op) - } - follow, ok = ConcurrentMap.Get(followKey) - if !ok { - klog.Errorf("concurrentMap get false") - } - follower, ok = ConcurrentMap.Get(followerKey) - if !ok { - klog.Errorf("concurrentMap get false") - } - klog.Infof("%s follow = %d\n", followKey, follow.(int64)) - klog.Infof("%s follower = %d\n", followerKey, follower.(int64)) - mu.Unlock() - // 使用同步producer,将消息存入 kafka - // 构建消息 - val, err := json.Marshal(NewRelation(req.UserId, req.ToUserId, 0)) - if err != nil { - return err - } - msg := &sarama.ProducerMessage{ - Topic: ViperConfig.Viper.GetStringSlice("Kafka.Topics")[0], - Value: sarama.StringEncoder(val), - } - partition, offset, err := SyncProducer.SendMessage(msg) - - if err == nil { - klog.Infof("produce success, partition: %d, offset: %d\n", partition, offset) - } else { - return err - } - - return nil -} - -func (s *RelationActionService) RmRelation(req *relationDomain.DoutokRmRelationRequest) error { - err, followList := ReadFollowListFromCache(fmt.Sprint(req.UserId)) - if err != nil { - return nil - } - - isFollowed := false - - for _, v := range followList { - if v == req.ToUserId { - isFollowed = true - break - } - } - - if !isFollowed { - isFollowed, err = ReadIsFollowFromDB(req.UserId, req.ToUserId) - if err != nil { - isFollowed = true - } - } - - if !isFollowed { - return nil - } - - // 在 SafeMap 中更新局部关注数和粉丝数 - followKey := fmt.Sprintf("%s%d", constants.FollowCount, req.UserId) - followerKey := fmt.Sprintf("%s%d", constants.FollowerCount, req.ToUserId) - follow, ok := ConcurrentMap.Get(followKey) - if !ok { - klog.Infof("get follow count from concurrentMap false") - } - follower, ok := ConcurrentMap.Get(followerKey) - if !ok { - klog.Infof("get follow count from concurrentMap false") - } - op := int64(-1) - // TODO 如果关注或者取关对应的增加 safemap 值,前提是需要验证重复性操作 - mu.Lock() - if follow == nil { - klog.Infof("set follow %s, %d\n", followKey, op) - ConcurrentMap.Set(followKey, op) - } else { - klog.Infof("set follow %s, %d\n", followKey, follow.(int64)+op) - ConcurrentMap.Set(followKey, follow.(int64)+op) - } - if follower == nil { - klog.Infof("set follower %s, %d\n", followerKey, op) - ConcurrentMap.Set(followerKey, op) - } else { - klog.Infof("set follower %s, %d\n", followerKey, follower.(int64)+op) - ConcurrentMap.Set(followerKey, follower.(int64)+op) - } - follow, ok = ConcurrentMap.Get(followKey) - if !ok { - klog.Errorf("concurrentMap get false") - } - follower, ok = ConcurrentMap.Get(followerKey) - if !ok { - klog.Errorf("concurrentMap get false") - } - klog.Infof("%s follow = %d\n", followKey, follow.(int64)) - klog.Infof("%s follower = %d\n", followerKey, follower.(int64)) - mu.Unlock() - // 使用同步producer,将消息存入 kafka - // 构建消息 - val, err := json.Marshal(NewRelation(req.UserId, req.ToUserId, 1)) - if err != nil { - return err - } - msg := &sarama.ProducerMessage{ - Topic: ViperConfig.Viper.GetStringSlice("Kafka.Topics")[0], - Value: sarama.StringEncoder(val), - } - partition, offset, err := SyncProducer.SendMessage(msg) - - if err == nil { - klog.Infof("produce success, partition: %d, offset: %d\n", partition, offset) - } else { - return err - } - - return nil -} diff --git a/applications/relationDomain/service/relation_count.go b/applications/relationDomain/service/relation_count.go deleted file mode 100644 index 2ffe3b66..00000000 --- a/applications/relationDomain/service/relation_count.go +++ /dev/null @@ -1,234 +0,0 @@ -package service - -import ( - "context" - "fmt" - - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/query" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/cloudwego/kitex/pkg/klog" -) - -type RelationCountService struct { - ctx context.Context -} - -func NewRelationCountService(ctx context.Context) *RelationCountService { - return &RelationCountService{ctx: ctx} -} - -func (s *RelationCountService) GetFollowCount(userId int64) (int64, error) { - err, follow := ReadFollowCountFromCache(fmt.Sprintf("%d", userId)) - if err != nil || follow == 0 { - // 记录日志 - klog.Errorf("read follow count from cache error, err = %s", err) - // 读 db 获取关注数 - err, follow = ReadFollowCountFromDB(userId) - if err != nil { - // 记录日志 - klog.Errorf("read follow count from db error, err = %s", err) - follow = 0 - } - // 新增 cache 关注数 - err = WriteFollowCountToCache(fmt.Sprintf("%d", userId), follow) - if err != nil { - // 记录日志 - klog.Errorf("update follow count to cache error, err = %s", err) - } - } - return follow, nil -} - -func (s *RelationCountService) GetFollowerCount(userId int64) (int64, error) { - err, follower := ReadFollowerCountFromCache(fmt.Sprintf("%d", userId)) - if err != nil || follower == 0 { - // 记录日志 - klog.Errorf("read follower count from cache error, err = %s", err) - // 读 db 获取粉丝数 - err, follower = ReadFollowerCountFromDB(userId) - if err != nil { - // 记录日志 - klog.Errorf("read follower count from db error, err = %s", err) - follower = 0 - } - // 新增 cache 粉丝数 - err = WriteFollowerCountToCache(fmt.Sprintf("%d", userId), follower) - if err != nil { - // 记录日志 - klog.Errorf("update follower count to cache error, err = %s", err) - } - } - return follower, nil -} - -func (s *RelationCountService) RelationCount(userId int64) (error, int64, int64) { - - // 读 cache 获取关注数 - err, follow := ReadFollowCountFromCache(fmt.Sprintf("%d", userId)) - if err != nil || follow == 0 { - // 记录日志 - klog.Errorf("read follow count from cache error, err = %s", err) - // 读 db 获取关注数 - err, follow = ReadFollowCountFromDB(userId) - if err != nil { - // 记录日志 - klog.Errorf("read follow count from db error, err = %s", err) - follow = 0 - } - // 新增 cache 关注数 - err = WriteFollowCountToCache(fmt.Sprintf("%d", userId), follow) - if err != nil { - // 记录日志 - klog.Errorf("update follow count to cache error, err = %s", err) - } - } - // 读 cache 获取粉丝数 - err, follower := ReadFollowerCountFromCache(fmt.Sprintf("%d", userId)) - if err != nil || follower == 0 { - // 记录日志 - klog.Errorf("read follower count from cache error, err = %s", err) - // 读 db 获取粉丝数 - err, follower = ReadFollowerCountFromDB(userId) - if err != nil { - // 记录日志 - klog.Errorf("read follower count from db error, err = %s", err) - follower = 0 - } - // 新增 cache 粉丝数 - err = WriteFollowerCountToCache(fmt.Sprintf("%d", userId), follower) - if err != nil { - // 记录日志 - klog.Errorf("update follower count to cache error, err = %s", err) - } - } - return nil, follow, follower -} - -func ReadFollowCountFromDB(user_id int64) (error, int64) { - res, err := query.FollowCount.Where(query.FollowCount.UserId.Eq(user_id)).First() - if err != nil { - return err, 0 - } - return nil, res.Number -} - -func ReadFollowCountFromCache(user_id string) (error, int64) { - ret := RedisClient.HGet(context.Background(), user_id, constants.FollowCount) - err := ret.Err() - if err != nil { - return err, 0 - } - follow, err := ret.Int64() - if err != nil { - return err, 0 - } - return nil, follow -} - -func WriteFollowCountToCache(user_id string, follow int64) error { - ret := RedisClient.HSet(context.Background(), user_id, map[string]interface{}{constants.FollowCount: follow}) - err := ret.Err() - if err != nil { - return err - } - return nil -} - -func UpdateFollowCountFromDB(user_id int64, op int64) error { - res, err := query.FollowCount.Where( - query.FollowCount.UserId.Eq(user_id), - ).Find() - if err != nil { - return err - } - if len(res) > 0 { - // 已经存在 - _, err := query.FollowCount.Where( - query.FollowCount.UserId.Eq(user_id), - ).Update(query.FollowCount.Number, query.FollowCount.Number.Add(op)) - return err - } else { - err := query.FollowCount.Create( - &model.FollowCount{ - UserId: user_id, - Number: op, - }, - ) - if err != nil { - return err - } - } - return nil -} - -func UpdateFollowerCountFromDB(user_id int64, op int64) error { - res, err := query.FollowerCount.Where( - query.FollowerCount.UserId.Eq(user_id)).Find() - if err != nil { - return err - } - if len(res) > 0 { - _, err := query.FollowerCount.Where( - query.FollowerCount.UserId.Eq(user_id), - ).Update(query.FollowerCount.Number, query.FollowerCount.Number.Add(op)) - return err - } else { - err := query.FollowerCount.Create( - &model.FollowerCount{ - UserId: user_id, - Number: op, - }, - ) - if err != nil { - return err - } - } - return nil -} - -func DeleteFollowCountCache(user_id string) error { - _, err := RedisClient.HDel(context.Background(), user_id, constants.FollowCount).Result() - if err != nil { - return err - } - return nil -} - -func ReadFollowerCountFromDB(user_id int64) (error, int64) { - res, err := query.FollowerCount.Where(query.FollowerCount.UserId.Eq(user_id)).First() - if err != nil { - return err, 0 - } - return nil, res.Number -} - -func ReadFollowerCountFromCache(user_id string) (error, int64) { - ret := RedisClient.HGet(context.Background(), user_id, constants.FollowerCount) - err := ret.Err() - if err != nil { - return err, 0 - } - follower, err := ret.Int64() - if err != nil { - return err, 0 - } - return nil, follower -} - -func WriteFollowerCountToCache(user_id string, follower int64) error { - ret := RedisClient.HSet(context.Background(), user_id, map[string]interface{}{constants.FollowerCount: follower}) - err := ret.Err() - if err != nil { - return err - } - return nil -} - -func DeleteFollowerCountCache(user_id string) error { - _, err := RedisClient.HDel(context.Background(), user_id, constants.FollowCount).Result() - if err != nil { - return err - } - return nil -} diff --git a/applications/relationDomain/service/relation_follow_list.go b/applications/relationDomain/service/relation_follow_list.go deleted file mode 100644 index 792c1423..00000000 --- a/applications/relationDomain/service/relation_follow_list.go +++ /dev/null @@ -1,179 +0,0 @@ -package service - -import ( - "context" - "fmt" - "strconv" - - "github.com/cloudwego/kitex/pkg/klog" - "github.com/go-redis/redis/v8" - - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/query" - "github.com/TremblingV5/DouTok/applications/relationDomain/pack" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/utils" -) - -type RelationFollowListService struct { - ctx context.Context -} - -func NewRelationFollowListService(ctx context.Context) *RelationFollowListService { - return &RelationFollowListService{ctx: ctx} -} - -func (s *RelationFollowListService) RelationFollowList(req *relationDomain.DoutokListRelationRequest) (error, []*entity.User) { - // 从 cache 读 - err, follow := ReadFollowListFromCache(fmt.Sprintf("%d", req.UserId)) - if err != nil || follow == nil { - klog.Errorf("read follow list from cache error, err = %s", err) - // 从 db 读 - err, relationList := ReadFollowListFromDB(req.UserId) - if err != nil { - klog.Errorf("read follow list from db error, err = %s", err) - return err, nil - } else { - // 添加 cache - err := WriteFollowListToCache(fmt.Sprintf("%d", req.UserId), relationList) - if err != nil { - klog.Errorf("update follow list to cache error, err = %s", err) - } - // 为 follow 赋值 - list := make([]int64, len(relationList)) - for _, v := range relationList { - list = append(list, v.ToUserId) - } - follow = list - } - } - - // 去用户服务查询 follow list 的 user 信息 - // request := new(userDomain.DoutokGetUserInfoRequest) - // request.UserId = follow - // resp, err := rpc.UserDomainRPCClient.GetUserInfo(context.Background(), request) - // if err != nil { - // return err, nil - // } - - // var result []*entity.User - // for _, v := range resp.UserList { - // result = append(result, v) - // } - result := make([]*entity.User, 1) - for _, v := range follow { - result = append(result, &entity.User{ - Id: v, - }) - } - - return nil, result -} - -// 查缓存 -func ReadFollowListFromCache(user_id string) (error, []int64) { - res, err := RedisClient.HGetAll(context.Background(), constants.FollowListPrefix+user_id).Result() - if err != nil { - return err, nil - } - ret := make([]int64, 0) - for k, v := range res { - k_i64, _ := strconv.ParseInt(k, 10, 64) - if v == "1" { - ret = append(ret, k_i64) - } - } - - if len(ret) <= 0 { - return redis.Nil, ret - } else { - return nil, ret - } -} - -// 查数据库 -func ReadFollowListFromDB(user_id int64) (error, []*model.Relation) { - res, err := query.Relation.Where(query.Relation.UserId.Eq(user_id)).Find() - if err != nil { - return err, nil - } - return nil, res -} - -func ReadIsFollowFromDB(userId int64, toUserId int64) (bool, error) { - res, err := query.Relation.Where( - query.Relation.UserId.Eq(userId), - query.Relation.ToUserId.Eq(toUserId), - ).First() - - if err != nil { - return false, err - } - - if res.Status == 1 { - return false, nil - } else { - return true, nil - } -} - -// 写入缓存 -func WriteFollowListToCache(user_id string, relations []*model.Relation) error { - val := make([]string, len(relations)*2) - for _, v := range relations { - val = append(val, fmt.Sprintf("%d", v.ToUserId)) - val = append(val, fmt.Sprintf("%d", v.Status)) - } - - _, err := RedisClient.HSet(context.Background(), constants.FollowListPrefix+user_id, val).Result() - if err != nil { - return err - } - return nil -} - -// 写入 DB -func WriteFollowToDB(rel *pack.Relation) error { - res, err := query.Relation.Where( - query.Relation.UserId.Eq(rel.UserId), - query.Relation.ToUserId.Eq(rel.ToUserId), - ).Find() - if err != nil { - return err - } - if len(res) > 0 { - // 已经存在关注关系 - _, err := query.Relation.Where( - query.Relation.UserId.Eq(rel.UserId), - query.Relation.ToUserId.Eq(rel.ToUserId), - ).Update( - query.Relation.Status, rel.ActionType, - ) - if err != nil { - return err - } - } else { - // 不存在则插入 - id := utils.GetSnowFlakeId().Int64() - err := query.Relation.Create( - &model.Relation{ - ID: id, - UserId: rel.UserId, - ToUserId: rel.ToUserId, - Status: int(rel.ActionType), - }, - ) - if err != nil { - return err - } - } - return nil -} - -// 单条写入/更新缓存 -func WriteFollowToCache(user_id string, to_user_id string, action_type string) error { - _, err := RedisClient.HSet(context.Background(), constants.FollowListPrefix+user_id, to_user_id, action_type).Result() - return err -} diff --git a/applications/relationDomain/service/relation_follower_list.go b/applications/relationDomain/service/relation_follower_list.go deleted file mode 100644 index 47e8c389..00000000 --- a/applications/relationDomain/service/relation_follower_list.go +++ /dev/null @@ -1,121 +0,0 @@ -package service - -import ( - "context" - "fmt" - "strconv" - - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/relationDomain/dal/query" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/cloudwego/kitex/pkg/klog" - "github.com/go-redis/redis/v8" -) - -type RelationFollowerListService struct { - ctx context.Context -} - -func NewRelationFollowerListService(ctx context.Context) *RelationFollowerListService { - return &RelationFollowerListService{ctx: ctx} -} - -func (s *RelationFollowerListService) RelationFollowerList(req *relationDomain.DoutokListRelationRequest) (error, []*entity.User) { - // 从 cache 读 - err, follower := ReadFollowerListFromCache(fmt.Sprintf("%d", req.UserId)) - if err != nil || follower == nil { - klog.Errorf("read follower list from cache error, err = %s", err) - // 从 db 读 - err, relationList := ReadFollowerListFromDB(req.UserId) - if err != nil { - klog.Errorf("read follower list from db error, err = %s", err) - return err, nil - } else { - // 添加 cache - err := WriteFollowerListToCache(fmt.Sprintf("%d", req.UserId), relationList) - if err != nil { - klog.Errorf("update follower list to cache error, err = %s", err) - } - // 为 follower 赋值 - list := make([]int64, len(relationList)) - for _, v := range relationList { - list = append(list, v.UserId) - } - follower = list - } - } - // 去用户服务查询 follow list 的 user 信息 - // request := new(userDomain.DoutokGetUserInfoRequest) - // request.UserId = follower - // resp, err := rpc.UserDomainRPCClient.GetUserInfo(context.Background(), request) - // if err != nil { - // return err, nil - // } - - // var result []*entity.User - // for _, v := range resp.UserList { - // result = append(result, v) - // } - - result := make([]*entity.User, 0) - for _, v := range follower { - result = append(result, &entity.User{ - Id: v, - }) - } - - return nil, result -} - -// 查缓存 -func ReadFollowerListFromCache(user_id string) (error, []int64) { - res, err := RedisClient.HGetAll(context.Background(), constants.FollowerListPrefix+user_id).Result() - if err != nil { - return err, nil - } - ret := make([]int64, 0) - for k, v := range res { - k_i64, _ := strconv.ParseInt(k, 10, 64) - if v == "1" { - ret = append(ret, k_i64) - } - } - - if len(ret) <= 0 { - return redis.Nil, ret - } else { - return nil, ret - } -} - -// 查数据库 -func ReadFollowerListFromDB(user_id int64) (error, []*model.Relation) { - res, err := query.Relation.Where(query.Relation.ToUserId.Eq(user_id)).Find() - if err != nil { - return err, nil - } - return nil, res -} - -// 写入缓存 -func WriteFollowerListToCache(user_id string, relations []*model.Relation) error { - val := make([]string, len(relations)*2) - for _, v := range relations { - val = append(val, fmt.Sprintf("%d", v.UserId)) - val = append(val, fmt.Sprintf("%d", v.Status)) - } - - _, err := RedisClient.HSet(context.Background(), constants.FollowerListPrefix+user_id, val).Result() - if err != nil { - return err - } - return nil -} - -func WriteFollowerToCache(user_id string, to_user_id string, action_type string) error { - _, err := RedisClient.HSet(context.Background(), constants.FollowerListPrefix+user_id, to_user_id, action_type).Result() - return err -} diff --git a/applications/relationDomain/service/relation_friend_list.go b/applications/relationDomain/service/relation_friend_list.go deleted file mode 100644 index ba13a1aa..00000000 --- a/applications/relationDomain/service/relation_friend_list.go +++ /dev/null @@ -1,138 +0,0 @@ -package service - -import ( - "context" - "fmt" - - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/cloudwego/kitex/pkg/klog" -) - -type RelationFriendListService struct { - ctx context.Context -} - -func NewRelationFriendListService(ctx context.Context) *RelationFriendListService { - return &RelationFriendListService{ctx: ctx} -} - -func (s *RelationFriendListService) RelationFriendList(req *relationDomain.DoutokListRelationRequest) (error, []*entity.User) { - // 从 cache 读 - err, friendList := GetFriendList(req.UserId) - if err != nil { - return err, nil - } - // 去用户服务查询 friendList 的 user 信息 - // reqUser := new(userDomain.DoutokGetUserInfoRequest) - // reqUser.UserId = friendList - // respUser, err := rpc.UserDomainRPCClient.GetUserInfo(context.Background(), reqUser) - // if err != nil { - // return err, nil - // } - // 去 message 服务查询对应好友列表的最新消息 返回一个 map - reqMsg := new(relationDomain.DoutokListRelationRequest) - reqMsg.UserId = req.UserId - reqMsg.ActionType = 2 - // reqMsg.FriendIdList = friendList - // _, err = rpc.RelationDomainRPCClient.ListRelation(context.Background(), reqMsg) - - // for k, v := range respMsg.UserList { - // klog.Infof("res key = %d, msg = %s\n", k, v.Content) - // } - - if err != nil { - return err, nil - } - var fList []*entity.User - for _, v := range friendList { - // 0为当前请求用户接受的消息,1为当前请求用户发送的消息 - // msgType := 0 - // if respMsg.UserList[v.Id].FromUserId == req.UserId { - // msgType = 1 - // } - - // klog.Infof("user_id = %s, msgType = %d\n", respMsg.UserList[v.Id].Content, int64(msgType)) - - //friend := &entity.FriendUser{ - // User: &entity.User{ - // Id: v.Id, - // Name: v.Name, - // FollowCount: v.FollowCount, - // FollowerCount: v.FollowerCount, - // IsFollow: v.IsFollow, - // Avatar: v.Avatar, - // }, - // Message: respMsg.Result[v.Id].Content, - // MsgType: int64(msgType), - //} - friend := &entity.User{ - Id: v, - } - fList = append(fList, friend) - } - return nil, fList -} - -// 查数据库 -func GetFriendList(user_id int64) (error, []int64) { - followMap := make(map[int64]bool) - // 获取 follow - err, follow := ReadFollowListFromCache(fmt.Sprintf("%d", user_id)) - if err != nil || follow == nil { - klog.Errorf("read follow list from cache error, err = %s", err) - // 从 db 读 - err, relationList := ReadFollowListFromDB(user_id) - if err != nil { - klog.Errorf("read follow list from db error, err = %s", err) - return err, nil - } else { - // 添加 cache - err := WriteFollowListToCache(fmt.Sprintf("%d", user_id), relationList) - if err != nil { - klog.Errorf("update follow list to cache error, err = %s", err) - } - // 为 follow 赋值 - list := make([]int64, len(relationList)) - for _, v := range relationList { - list = append(list, v.ToUserId) - } - follow = list - } - } - // 为 map 赋值 - for _, v := range follow { - followMap[v] = true - } - // 获取 follower - err, follower := ReadFollowerListFromCache(fmt.Sprintf("%d", user_id)) - if err != nil || follower == nil { - klog.Errorf("read follower list from cache error, err = %s", err) - // 从 db 读 - err, relationList := ReadFollowerListFromDB(user_id) - if err != nil { - klog.Errorf("read follower list from db error, err = %s", err) - return err, nil - } else { - // 添加 cache - err := WriteFollowerListToCache(fmt.Sprintf("%d", user_id), relationList) - if err != nil { - klog.Errorf("update follower list to cache error, err = %s", err) - } - // 为 follower 赋值 - list := make([]int64, len(relationList)) - for _, v := range relationList { - list = append(list, v.UserId) - } - follower = list - } - } - friendList := make([]int64, 0) - for _, v := range follower { - if followMap[v] { - friendList = append(friendList, v) - } - } - return nil, friendList -} diff --git a/applications/user/build.sh b/applications/user/build.sh index 29ac893d..d5506b56 100644 --- a/applications/user/build.sh +++ b/applications/user/build.sh @@ -10,4 +10,3 @@ if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then else go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... fi - diff --git a/applications/userDomain/dal/gen.go b/applications/user/dal/gen.go similarity index 83% rename from applications/userDomain/dal/gen.go rename to applications/user/dal/gen.go index f27216d6..335e2f2a 100644 --- a/applications/userDomain/dal/gen.go +++ b/applications/user/dal/gen.go @@ -1,7 +1,7 @@ package main import ( - "github.com/TremblingV5/DouTok/applications/userDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/user/dal/model" "github.com/TremblingV5/DouTok/config/configStruct" "github.com/TremblingV5/DouTok/pkg/configurator" "github.com/TremblingV5/DouTok/pkg/mysqlIniter" @@ -15,11 +15,9 @@ func main() { }) var config configStruct.MySQLConfig - if err := configurator.InitConfig( + configurator.InitConfig( &config, "mysql.yaml", - ); err != nil { - panic(err) - } + ) db, err := mysqlIniter.InitDb( config.Username, diff --git a/applications/user/dal/migrate.go b/applications/user/dal/migrate.go new file mode 100644 index 00000000..a02c46d8 --- /dev/null +++ b/applications/user/dal/migrate.go @@ -0,0 +1,21 @@ +package main + +import ( + "github.com/TremblingV5/DouTok/applications/user/dal/model" + "github.com/TremblingV5/DouTok/applications/user/misc" + "github.com/TremblingV5/DouTok/applications/user/service" +) + +func main() { + misc.InitViperConfig() + + service.InitDb( + misc.GetConfig("MySQL.Username"), + misc.GetConfig("MySQL.Password"), + misc.GetConfig("MySQL.Host"), + misc.GetConfig("MySQL.Port"), + misc.GetConfig("MySQL.Database"), + ) + + service.DB.AutoMigrate(&model.User{}) +} diff --git a/applications/userDomain/dal/model/user.go b/applications/user/dal/model/user.go similarity index 100% rename from applications/userDomain/dal/model/user.go rename to applications/user/dal/model/user.go diff --git a/applications/userDomain/dal/query/gen.go b/applications/user/dal/query/gen.go similarity index 100% rename from applications/userDomain/dal/query/gen.go rename to applications/user/dal/query/gen.go diff --git a/applications/user/dal/query/typedef.go b/applications/user/dal/query/typedef.go new file mode 100644 index 00000000..c6a086ed --- /dev/null +++ b/applications/user/dal/query/typedef.go @@ -0,0 +1,3 @@ +package query + +var UserStruct = &user{} diff --git a/applications/userDomain/dal/query/users.gen.go b/applications/user/dal/query/users.gen.go similarity index 99% rename from applications/userDomain/dal/query/users.gen.go rename to applications/user/dal/query/users.gen.go index 0f3a740d..a154c710 100644 --- a/applications/userDomain/dal/query/users.gen.go +++ b/applications/user/dal/query/users.gen.go @@ -16,7 +16,7 @@ import ( "gorm.io/plugin/dbresolver" - "github.com/TremblingV5/DouTok/applications/userDomain/dal/model" + "github.com/TremblingV5/DouTok/applications/user/dal/model" ) func newUser(db *gorm.DB, opts ...gen.DOOption) user { diff --git a/applications/user/errs/errors.go b/applications/user/errs/errors.go deleted file mode 100644 index dd757494..00000000 --- a/applications/user/errs/errors.go +++ /dev/null @@ -1,13 +0,0 @@ -package errs - -import "github.com/TremblingV5/DouTok/pkg/errno" - -var ( - NilErrCode = -1 - SuccessCode = 0 - EmptyUserListErrCode = 27001 -) - -var ( - EmptyUserListErr = errno.New(EmptyUserListErrCode, "Empty user list but downstream errors") -) diff --git a/applications/user/handler/get_user_by_id.go b/applications/user/handler/get_user_by_id.go new file mode 100644 index 00000000..9e7954f0 --- /dev/null +++ b/applications/user/handler/get_user_by_id.go @@ -0,0 +1,20 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/user/misc" + "github.com/TremblingV5/DouTok/applications/user/pack" + "github.com/TremblingV5/DouTok/applications/user/service" + "github.com/TremblingV5/DouTok/kitex_gen/user" +) + +func (s *UserServiceImpl) GetUserById(ctx context.Context, req *user.DouyinUserRequest) (resp *user.DouyinUserResponse, err error) { + user, err := service.QueryUserByIdInRDB(req.UserId) + + if err != nil { + return pack.PackUserResp(int32(misc.SearchErr.ErrCode), misc.SearchErr.ErrMsg, user) + } + + return pack.PackUserResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, user) +} diff --git a/applications/user/handler/get_user_list_by_id.go b/applications/user/handler/get_user_list_by_id.go new file mode 100644 index 00000000..0d28dca1 --- /dev/null +++ b/applications/user/handler/get_user_list_by_id.go @@ -0,0 +1,26 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/user/misc" + "github.com/TremblingV5/DouTok/applications/user/pack" + "github.com/TremblingV5/DouTok/applications/user/service" + "github.com/TremblingV5/DouTok/kitex_gen/user" +) + +func (s *UserServiceImpl) GetUserListByIds(ctx context.Context, req *user.DouyinUserListRequest) (resp *user.DouyinUserListResponse, err error) { + user_id_list := []uint64{} + + for _, v := range req.UserList { + user_id_list = append(user_id_list, uint64(v)) + } + + user_list, err := service.QueryUserListByIdInRDB(user_id_list...) + + if err != nil { + return pack.PackUserListResp(int32(misc.SystemErr.ErrCode), misc.SystemErr.ErrMsg, nil) + } + + return pack.PackUserListResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, user_list) +} diff --git a/applications/user/handler/handler.go b/applications/user/handler/handler.go deleted file mode 100644 index 27af1704..00000000 --- a/applications/user/handler/handler.go +++ /dev/null @@ -1,101 +0,0 @@ -package handler - -import ( - "context" - - "github.com/TremblingV5/DouTok/applications/user/errs" - "github.com/TremblingV5/DouTok/applications/user/rpc" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/kitex_gen/user" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -type Handler struct { - clients *rpc.Clients -} - -func New(rpcClient *rpc.Clients) *Handler { - return &Handler{ - clients: rpcClient, - } -} - -func (s *Handler) Login(ctx context.Context, req *user.DouyinUserLoginRequest) (resp *user.DouyinUserLoginResponse, err error) { - result, err := s.clients.User.Client.CheckUser(ctx, &userDomain.DoutokCheckUserRequest{ - Username: req.Username, - Password: req.Password, - }) - - if err != nil { - return nil, err - } - - return &user.DouyinUserLoginResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - UserId: result.UserId, - }, nil -} - -func (s *Handler) Register(ctx context.Context, req *user.DouyinUserRegisterRequest) (resp *user.DouyinUserRegisterResponse, err error) { - result, err := s.clients.User.Client.AddUser(ctx, &userDomain.DoutokAddUserRequest{ - Username: req.Username, - Password: req.Password, - }) - - if err != nil { - return nil, err - } - - return &user.DouyinUserRegisterResponse{ - StatusCode: result.StatusCode, - StatusMsg: result.StatusMsg, - UserId: result.UserId, - }, nil -} - -func (s *Handler) GetUserById(ctx context.Context, req *user.DouyinUserRequest) (resp *user.DouyinUserResponse, err error) { - userInfo, err := s.clients.User.Client.GetUserInfo(ctx, &userDomain.DoutokGetUserInfoRequest{UserId: []int64{req.UserId}}) - if userInfo == nil || err != nil { - return nil, err - } - - resp = &user.DouyinUserResponse{ - StatusCode: userInfo.StatusCode, //nolint - StatusMsg: userInfo.StatusMsg, //nolint - } - - if len(userInfo.UserList) <= 0 { - resp.StatusCode = int32(errs.EmptyUserListErrCode) - resp.StatusMsg = errs.EmptyUserListErr.ErrMsg - return resp, nil - } - resp.User = userInfo.UserList[req.UserId] - - // hydrate follow count - followCount, err := s.clients.Relation.Client.CountRelation(ctx, &relationDomain.DoutokCountRelationRequest{ - UserId: []int64{req.UserId}, - ActionType: int64(0), - }) - if err != nil { - resp.StatusCode = int32(errno.BadRequest.ErrCode) - resp.StatusMsg = errno.BadRequest.ErrMsg + " relation domain rpc error" - return resp, err - } - resp.User.FollowCount = followCount.Result[req.UserId] - - // hydrate follower count - followerCount, err := s.clients.Relation.Client.CountRelation(ctx, &relationDomain.DoutokCountRelationRequest{ - UserId: []int64{req.UserId}, - ActionType: int64(1), - }) - if err != nil { - resp.StatusCode = int32(errno.BadRequest.ErrCode) - resp.StatusMsg = errno.BadRequest.ErrMsg + " relation domain rpc error" - return resp, err - } - resp.User.FollowerCount = followerCount.Result[req.UserId] - - return resp, nil -} diff --git a/applications/user/handler/login.go b/applications/user/handler/login.go new file mode 100644 index 00000000..59b2db46 --- /dev/null +++ b/applications/user/handler/login.go @@ -0,0 +1,25 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/user/misc" + "github.com/TremblingV5/DouTok/applications/user/pack" + "github.com/TremblingV5/DouTok/applications/user/service" + "github.com/TremblingV5/DouTok/kitex_gen/user" +) + +func (s *UserServiceImpl) Login(ctx context.Context, req *user.DouyinUserLoginRequest) (resp *user.DouyinUserLoginResponse, err error) { + // 1. 检查参数是否非空 + if req.Username == "" || req.Password == "" { + return pack.PackLoginResp(int32(misc.EmptyErr.ErrCode), misc.EmptyErr.ErrMsg, 0) + } + + // 2. 检查用户名和密码是否匹配 + user_id, err, errNo := service.CheckPassword(req.Username, req.Password) + if err != nil || user_id == 0 { + return pack.PackLoginResp(int32(errNo.ErrCode), errNo.ErrMsg, 0) + } + + return pack.PackLoginResp(int32(misc.Success.ErrCode), misc.Success.ErrMsg, user_id) +} diff --git a/applications/user/handler/register.go b/applications/user/handler/register.go new file mode 100644 index 00000000..dba3ab59 --- /dev/null +++ b/applications/user/handler/register.go @@ -0,0 +1,21 @@ +package handler + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/user/misc" + "github.com/TremblingV5/DouTok/applications/user/pack" + "github.com/TremblingV5/DouTok/applications/user/service" + "github.com/TremblingV5/DouTok/kitex_gen/user" +) + +func (s *UserServiceImpl) Register(ctx context.Context, req *user.DouyinUserRegisterRequest) (resp *user.DouyinUserRegisterResponse, err error) { + // 1. 检查参数是否非空 + if req.Username == "" || req.Password == "" { + return pack.PackRegisterResp(int32(misc.EmptyErr.ErrCode), misc.EmptyErr.ErrMsg, 0) + } + + // 2. 写库 + user_id, _, errNo := service.WriteNewUser(req.Username, req.Password) + return pack.PackRegisterResp(int32(errNo.ErrCode), errNo.ErrMsg, user_id) +} diff --git a/applications/user/handler/typedef.go b/applications/user/handler/typedef.go new file mode 100644 index 00000000..1f14b3d2 --- /dev/null +++ b/applications/user/handler/typedef.go @@ -0,0 +1,3 @@ +package handler + +type UserServiceImpl struct{} diff --git a/applications/user/main.go b/applications/user/main.go index 3a668c08..e523baa6 100644 --- a/applications/user/main.go +++ b/applications/user/main.go @@ -1,51 +1,37 @@ package main import ( - "context" - - "go.uber.org/zap" - "github.com/TremblingV5/DouTok/applications/user/handler" + "github.com/TremblingV5/DouTok/applications/user/misc" "github.com/TremblingV5/DouTok/applications/user/rpc" - "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/applications/user/service" "github.com/TremblingV5/DouTok/kitex_gen/user/userservice" - "github.com/TremblingV5/DouTok/pkg/DouTokContext" - "github.com/TremblingV5/DouTok/pkg/DouTokLogger" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/services" + "github.com/TremblingV5/DouTok/pkg/dlog" + "github.com/TremblingV5/DouTok/pkg/initHelper" ) -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_USER_"` - Logger configStruct.Logger `envPrefix:"DOUTOK_USER_"` -} - var ( - logger *zap.Logger - config = &Config{} + Logger = dlog.InitLog(3) ) -func init() { - ctx := context.Background() - _, err := configurator.Load(config, "DOUTOK_USER", "user") - logger = DouTokLogger.InitLogger(config.Logger) - DouTokContext.DefaultLogger = logger - DouTokContext.AddLoggerToContext(ctx, logger) - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", config)) - } +func Init() { + misc.InitViperConfig() + service.Init() + rpc.InitPRCClient() } func main() { - clients := rpc.New(services.InitRPCClientArgs(constants.USER_SERVER_NAME, config.Etcd)) + Init() - options, shutdown := services.InitRPCServerArgs(constants.USER_SERVER_NAME, config.BaseConfig) + options, shutdown := initHelper.InitRPCServerArgs(misc.Config) defer shutdown() - svr := userservice.NewServer(handler.New(clients), options...) + svr := userservice.NewServer( + new(handler.UserServiceImpl), + options..., + ) if err := svr.Run(); err != nil { - logger.Fatal("run server err", zap.Error(err)) + Logger.Fatal(err) } } diff --git a/applications/user/misc/config.go b/applications/user/misc/config.go new file mode 100644 index 00000000..aab0f3df --- /dev/null +++ b/applications/user/misc/config.go @@ -0,0 +1,18 @@ +package misc + +import "github.com/TremblingV5/DouTok/pkg/dtviper" + +var Config *dtviper.Config + +func InitViperConfig() { + config := dtviper.ConfigInit(ViperConfigEnvPrefix, ViperConfigEnvFilename) + Config = &config +} + +func GetConfig(key string) string { + return Config.Viper.GetString(key) +} + +func GetConfigNum(key string) int64 { + return Config.Viper.GetInt64(key) +} diff --git a/applications/user/misc/const.go b/applications/user/misc/const.go new file mode 100644 index 00000000..5fa883a6 --- /dev/null +++ b/applications/user/misc/const.go @@ -0,0 +1,6 @@ +package misc + +const ( + ViperConfigEnvPrefix = "DOUTOK_USER" + ViperConfigEnvFilename = "user" +) diff --git a/applications/user/misc/err.go b/applications/user/misc/err.go new file mode 100644 index 00000000..80bbdb25 --- /dev/null +++ b/applications/user/misc/err.go @@ -0,0 +1,25 @@ +package misc + +import "github.com/TremblingV5/DouTok/pkg/errno" + +var ( + NilErrCode = -1 + SuccessCode = 0 + UserNameErrCode = 27001 + PasswordErrCode = 27002 + EmptyErrCode = 27003 + UserNameExistedErrCode = 27004 + SearchErrCode = 27005 + SystemErrCode = 27999 +) + +var ( + NilErr = errno.NewErrNo(NilErrCode, "Don't care") + Success = errno.NewErrNo(SuccessCode, "Success") + UserNameErr = errno.NewErrNo(UserNameErrCode, "Username error") + PasswordErr = errno.NewErrNo(PasswordErrCode, "Password error") + EmptyErr = errno.NewErrNo(EmptyErrCode, "Username or password is empty") + UserNameExistedErr = errno.NewErrNo(UserNameExistedErrCode, "Username existed") + SearchErr = errno.NewErrNo(SearchErrCode, "Search defeat") + SystemErr = errno.NewErrNo(SystemErrCode, "System error") +) diff --git a/applications/user/misc/get_misc.go b/applications/user/misc/get_misc.go new file mode 100644 index 00000000..4b2728e8 --- /dev/null +++ b/applications/user/misc/get_misc.go @@ -0,0 +1,16 @@ +package misc + +import "math/rand" + +func GetUserAvatar() string { + link1 := "https://doutok-video.oss-cn-shanghai.aliyuncs.com/video/hear.png" + link2 := "https://doutok-video.oss-cn-shanghai.aliyuncs.com/video/stop.png" + + r := rand.Int31n(100) + if r%2 == 0 { + return link1 + } else { + return link2 + } + +} diff --git a/applications/user/pack/get_user_list_by_id.go b/applications/user/pack/get_user_list_by_id.go new file mode 100644 index 00000000..5d44f60f --- /dev/null +++ b/applications/user/pack/get_user_list_by_id.go @@ -0,0 +1,45 @@ +package pack + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/user/dal/model" + "github.com/TremblingV5/DouTok/applications/user/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/kitex_gen/user" +) + +func PackUserListResp(code int32, msg string, list []*model.User) (resp *user.DouyinUserListResponse, err error) { + resp = &user.DouyinUserListResponse{ + StatusCode: code, + StatusMsg: msg, + } + + result := []*user.User{} + + for _, v := range list { + req, err := rpc.GetFollowCount( + context.Background(), + &relation.DouyinRelationCountRequest{UserId: int64(v.ID)}, + ) + if err != nil { + continue + } + + temp := &user.User{ + Id: int64(v.ID), + Name: v.UserName, + Avatar: v.Avatar, + BackgroundImage: v.BackgroundImage, + Signature: v.Signature, + FollowCount: req.FollowCount, + FollowerCount: req.FollowerCount, + IsFollow: false, + } + + result = append(result, temp) + } + + resp.UserList = result + return resp, nil +} diff --git a/applications/user/pack/login_register.go b/applications/user/pack/login_register.go new file mode 100644 index 00000000..ae45919b --- /dev/null +++ b/applications/user/pack/login_register.go @@ -0,0 +1,23 @@ +package pack + +import "github.com/TremblingV5/DouTok/kitex_gen/user" + +func PackLoginResp(code int32, msg string, user_id int64) (resp *user.DouyinUserLoginResponse, err error) { + resp = &user.DouyinUserLoginResponse{ + StatusCode: code, + StatusMsg: msg, + UserId: user_id, + } + + return resp, nil +} + +func PackRegisterResp(code int32, msg string, user_id int64) (resp *user.DouyinUserRegisterResponse, err error) { + resp = &user.DouyinUserRegisterResponse{ + StatusCode: code, + StatusMsg: msg, + UserId: user_id, + } + + return resp, nil +} diff --git a/applications/user/pack/user.go b/applications/user/pack/user.go new file mode 100644 index 00000000..64142f18 --- /dev/null +++ b/applications/user/pack/user.go @@ -0,0 +1,43 @@ +package pack + +import ( + "context" + + "github.com/TremblingV5/DouTok/applications/user/dal/model" + "github.com/TremblingV5/DouTok/applications/user/misc" + "github.com/TremblingV5/DouTok/applications/user/rpc" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/kitex_gen/user" +) + +func PackUserResp(code int32, msg string, u *model.User) (resp *user.DouyinUserResponse, err error) { + resp = &user.DouyinUserResponse{ + StatusCode: code, + StatusMsg: msg, + } + + userResp, err := rpc.GetFollowCount(context.Background(), &relation.DouyinRelationCountRequest{ + UserId: int64(u.ID), + }) + + if err != nil { + resp.StatusCode = int32(misc.SystemErr.ErrCode) + resp.StatusMsg = misc.SystemErr.ErrMsg + return resp, err + } + + info := user.User{ + Id: int64(u.ID), + Name: u.UserName, + Avatar: u.Avatar, + BackgroundImage: u.BackgroundImage, + Signature: u.Signature, + FollowCount: userResp.FollowCount, + FollowerCount: userResp.FollowerCount, + IsFollow: true, + } + + resp.User = &info + + return resp, nil +} diff --git a/applications/user/rpc/clients.go b/applications/user/rpc/clients.go deleted file mode 100644 index 210aaffb..00000000 --- a/applications/user/rpc/clients.go +++ /dev/null @@ -1,22 +0,0 @@ -package rpc - -import ( - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/cloudwego/kitex/client" - - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain/relationdomainservice" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain/userdomainservice" - "github.com/TremblingV5/DouTok/pkg/services" -) - -type Clients struct { - User *services.Service[userdomainservice.Client] - Relation *services.Service[relationdomainservice.Client] -} - -func New(options []client.Option) *Clients { - return &Clients{ - User: services.New[userdomainservice.Client](constants.USER_DOMAIN_SERVER_NAME, userdomainservice.NewClient, options), - Relation: services.New[relationdomainservice.Client](constants.RELATION_DOMAIN_SERVER_NAME, relationdomainservice.NewClient, options), - } -} diff --git a/applications/user/rpc/init.go b/applications/user/rpc/init.go new file mode 100644 index 00000000..67e0d682 --- /dev/null +++ b/applications/user/rpc/init.go @@ -0,0 +1,5 @@ +package rpc + +func InitPRCClient() { + InitRelationRpc() +} diff --git a/applications/user/rpc/relation.go b/applications/user/rpc/relation.go new file mode 100644 index 00000000..e6e37d0c --- /dev/null +++ b/applications/user/rpc/relation.go @@ -0,0 +1,31 @@ +package rpc + +import ( + "context" + "github.com/TremblingV5/DouTok/kitex_gen/relation" + "github.com/TremblingV5/DouTok/kitex_gen/relation/relationservice" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/initHelper" +) + +var relationClient relationservice.Client + +func InitRelationRpc() { + + config := dtviper.ConfigInit("DOUTOK_RELATION", "relation") + + c, err := relationservice.NewClient( + config.Viper.GetString("Server.Name"), + initHelper.InitRPCClientArgs(&config)..., + ) + + if err != nil { + panic(err) + } + + relationClient = c +} + +func GetFollowCount(ctx context.Context, req *relation.DouyinRelationCountRequest) (resp *relation.DouyinRelationCountResponse, err error) { + return relationClient.GetFollowCount(ctx, req) +} diff --git a/applications/user/rpc/var.go b/applications/user/rpc/var.go new file mode 100644 index 00000000..e428e748 --- /dev/null +++ b/applications/user/rpc/var.go @@ -0,0 +1,5 @@ +package rpc + +import "github.com/TremblingV5/DouTok/config/configStruct" + +var ClientConfig *configStruct.UserConfig diff --git a/applications/user/run.sh b/applications/user/run.sh deleted file mode 100644 index 606802cb..00000000 --- a/applications/user/run.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -# 设置环境变量 -export DOUTOK_USER_SERVER_NAME=DouTokUserServer -export DOUTOK_USER_SERVER_PORT=8084 -export DOUTOK_USER_ETCD_ADDRESS=localhost -export DOUTOK_USER_ETCD_PORT=2379 - -# 运行 Go 项目 -go run main.go diff --git a/applications/user/script/bootstrap.sh b/applications/user/script/bootstrap.sh index c0fd006e..e3daf0a1 100644 --- a/applications/user/script/bootstrap.sh +++ b/applications/user/script/bootstrap.sh @@ -19,4 +19,3 @@ if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then fi exec "$CURDIR/bin/user" - diff --git a/applications/user/service/encrypt.go b/applications/user/service/encrypt.go new file mode 100644 index 00000000..bc1bf82b --- /dev/null +++ b/applications/user/service/encrypt.go @@ -0,0 +1,94 @@ +package service + +import ( + "crypto/md5" + "fmt" + "math/rand" + "strconv" + "time" +) + +func PasswordEncrypt(user_id int64, src string, salt string) string { + opNum := GetOpNum(user_id) + + for i := 0; i < int(opNum); i++ { + src = GetMd5(src + salt) + } + + return src +} + +/* + 生成salt +*/ +func GenSalt() string { + return GenRandString(32) +} + +/* + 获取一个user id所对应的操作数 +*/ +func GetOpNum(id int64) int64 { + str := fmt.Sprint(id) + + l := 0 + r := len(str) - 1 + var lNum, rNum string + lNum = "" + rNum = "" + + for { + if string(str[l]) >= "0" && string(str[l]) <= "9" { + lNum = string(str[l]) + } else { + l++ + } + + if string(str[r]) >= "0" && string(str[r]) <= "9" { + rNum = string(str[r]) + } else { + r++ + } + + if l == r || (lNum != "" && rNum != "") { + break + } + } + + if lNum == "" { + lNum = "6" + } + + if rNum == "" { + rNum = "6" + } + + res := lNum + rNum + res_int, _ := strconv.Atoi(res) + + return int64(res_int) +} + +/* + 进行md5加密 +*/ +func GetMd5(str string) string { + code := md5.Sum([]byte(str)) + return fmt.Sprintf("%x", code) +} + +/* + 根据给定长度生成一个随机字符串 +*/ +func GenRandString(l int) string { + list := []byte("0123456789abcdefghigklmnopqrstuvwxyz") + + result := []byte{} + r := rand.New(rand.NewSource(time.Now().Unix())) + + for i := 0; i < l; i++ { + result = append(result, list[r.Intn(len(list))]) + } + + return string(result) +} diff --git a/applications/user/service/encrypt_test.go b/applications/user/service/encrypt_test.go new file mode 100644 index 00000000..88cf28ed --- /dev/null +++ b/applications/user/service/encrypt_test.go @@ -0,0 +1,16 @@ +package service + +import "testing" + +func TestPasswordEncrypt(t *testing.T) { + user_id := 1678546894123654781 + src := "DouTokNo1@" + salt := GenSalt() + + password1 := PasswordEncrypt(int64(user_id), src, salt) + password2 := PasswordEncrypt(int64(user_id), src, salt) + + if password1 != password2 { + panic("加密方案不能保证结果一致") + } +} diff --git a/applications/user/service/init.go b/applications/user/service/init.go new file mode 100644 index 00000000..baffc48c --- /dev/null +++ b/applications/user/service/init.go @@ -0,0 +1,43 @@ +package service + +import ( + "context" + "github.com/TremblingV5/DouTok/applications/user/misc" + "github.com/TremblingV5/DouTok/pkg/utils" + + "github.com/TremblingV5/DouTok/applications/user/dal/query" + "github.com/TremblingV5/DouTok/pkg/mysqlIniter" +) + +func Init() { + misc.InitViperConfig() + + InitDb( + misc.GetConfig("MySQL.Username"), + misc.GetConfig("MySQL.Password"), + misc.GetConfig("MySQL.Host"), + misc.GetConfig("MySQL.Port"), + misc.GetConfig("MySQL.Database"), + ) + + utils.InitSnowFlake(misc.GetConfigNum("Snowflake.Node")) +} + +func InitDb(username string, password string, host string, port string, database string) error { + db, err := mysqlIniter.InitDb( + username, password, host, port, database, + ) + + if err != nil { + return err + } + + DB = db + + query.SetDefault(DB) + + User = query.User + Do = User.WithContext(context.Background()) + + return nil +} diff --git a/applications/user/service/login.go b/applications/user/service/login.go new file mode 100644 index 00000000..036e67f0 --- /dev/null +++ b/applications/user/service/login.go @@ -0,0 +1,22 @@ +package service + +import ( + "github.com/TremblingV5/DouTok/applications/user/misc" + "github.com/TremblingV5/DouTok/pkg/errno" +) + +func CheckPassword(username string, password string) (int64, error, *errno.ErrNo) { + user, err := FindUserByUserName(username) + + if err != nil { + return 0, err, &misc.UserNameErr + } + + encrypted := PasswordEncrypt(int64(user.ID), password, user.Salt) + + if encrypted != user.Password { + return 0, nil, &misc.PasswordErr + } + + return int64(user.ID), nil, &misc.Success +} diff --git a/applications/user/service/login_test.go b/applications/user/service/login_test.go new file mode 100644 index 00000000..d3dc0592 --- /dev/null +++ b/applications/user/service/login_test.go @@ -0,0 +1,43 @@ +package service + +import ( + "fmt" + "github.com/TremblingV5/DouTok/applications/user/misc" + "log" + "testing" + "time" +) + +func TestCheckPassword(t *testing.T) { + Init() + + curr := fmt.Sprint(time.Now().Unix()) + + userId, err, errNo := WriteNewUser(curr, curr) + if err != nil { + log.Panicln(err) + } else { + log.Println(userId, errNo) + } + + notExistedUserId, err, errNo := CheckPassword("*****", "789456") + if notExistedUserId == 0 && errNo == &misc.UserNameErr { + log.Println("查询不存在的用户名返回正常") + } else { + log.Panicln("查询不存在的用户未报错") + } + + passwordWrongUserId, err, errNo := CheckPassword(curr, "-----") + if passwordWrongUserId == 0 && errNo == &misc.PasswordErr { + log.Println("密码错误情况返回正常") + } else { + log.Panicln("密码错误的用户未报错") + } + + userIdSearched, err, errNo := CheckPassword(curr, curr) + if err == nil && errNo == &misc.Success && userIdSearched == userId { + log.Println(userId, errNo, "登陆功能正常") + } else { + log.Panicln("登陆功能异常") + } +} diff --git a/applications/user/service/register.go b/applications/user/service/register.go new file mode 100644 index 00000000..2ff3536d --- /dev/null +++ b/applications/user/service/register.go @@ -0,0 +1,40 @@ +package service + +import ( + "github.com/TremblingV5/DouTok/applications/user/dal/model" + "github.com/TremblingV5/DouTok/applications/user/misc" + "github.com/TremblingV5/DouTok/pkg/errno" + "github.com/TremblingV5/DouTok/pkg/utils" +) + +func WriteNewUser(username string, password string) (int64, error, *errno.ErrNo) { + count, err := Do.Where( + User.UserName.Eq(username), + ).Count() + + if err != nil { + return 0, err, &misc.UserNameErr + } + + if count > 0 { + return 0, nil, &misc.UserNameExistedErr + } + + user_id := utils.GetSnowFlakeId() + salt := GenSalt() + encrypted := PasswordEncrypt(int64(user_id), password, salt) + + if err := Do.Create(&model.User{ + ID: uint64(user_id), + UserName: username, + Password: encrypted, + Salt: salt, + Avatar: misc.GetUserAvatar(), + BackgroundImage: misc.GetUserAvatar(), + Signature: "这个人很低调", + }); err != nil { + return 0, err, &misc.SystemErr + } + + return int64(user_id), nil, &misc.Success +} diff --git a/applications/user/service/register_test.go b/applications/user/service/register_test.go new file mode 100644 index 00000000..aacd5622 --- /dev/null +++ b/applications/user/service/register_test.go @@ -0,0 +1,31 @@ +package service + +import ( + "fmt" + "github.com/TremblingV5/DouTok/applications/user/misc" + "log" + "testing" + "time" +) + +func TestWriteNewUser(t *testing.T) { + Init() + + curr := fmt.Sprint(time.Now().Unix()) + + userId, err, errNo := WriteNewUser(curr, curr) + if err != nil { + log.Panicln(err) + } else { + log.Println(userId, errNo) + } + + userId, err, errNo = WriteNewUser(curr, curr) + if err != nil { + log.Panicln(err) + } else { + if errNo != &misc.UserNameExistedErr { + log.Panicln("插入重复用户未报错") + } + } +} diff --git a/applications/user/service/search.go b/applications/user/service/search.go new file mode 100644 index 00000000..a60876fe --- /dev/null +++ b/applications/user/service/search.go @@ -0,0 +1,39 @@ +package service + +import "github.com/TremblingV5/DouTok/applications/user/dal/model" + +func QueryUserByIdInRDB(user_id int64) (*model.User, error) { + user, err := Do.Where( + User.ID.Eq(uint64(user_id)), + ).First() + + if err != nil { + return user, err + } + + return user, nil +} + +func QueryUserListByIdInRDB(user_id ...uint64) ([]*model.User, error) { + user_list, err := Do.Where( + User.ID.In(user_id...), + ).Find() + + if err != nil { + return user_list, err + } + + return user_list, nil +} + +func FindUserByUserName(username string) (*model.User, error) { + res, err := Do.Where( + User.UserName.Eq(username), + ).First() + + if err != nil { + return &model.User{}, err + } + + return res, nil +} diff --git a/applications/user/service/search_test.go b/applications/user/service/search_test.go new file mode 100644 index 00000000..24c933e8 --- /dev/null +++ b/applications/user/service/search_test.go @@ -0,0 +1,36 @@ +package service + +import ( + "fmt" + "github.com/TremblingV5/DouTok/applications/user/misc" + "log" + "testing" + "time" +) + +func TestSearchUser(t *testing.T) { + Init() + + curr := fmt.Sprint(time.Now().Unix()) + + userId, err, errNo := WriteNewUser(curr, curr) + if err != nil { + log.Panicln(err) + } else if errNo != &misc.Success { + log.Println(userId, errNo) + log.Panicln(errNo) + } + + u1, err1 := QueryUserByIdInRDB(userId) + + u2, err2 := QueryUserByIdInRDB(userId) + + u3, err3 := FindUserByUserName(curr) + + if err1 != nil || err2 != nil || err3 != nil { + log.Panicln(err1, err2, err3) + } + + log.Println(u1, u3) + log.Println(u2) +} diff --git a/applications/user/service/var.go b/applications/user/service/var.go new file mode 100644 index 00000000..90f08d30 --- /dev/null +++ b/applications/user/service/var.go @@ -0,0 +1,10 @@ +package service + +import ( + "github.com/TremblingV5/DouTok/applications/user/dal/query" + "gorm.io/gorm" +) + +var DB *gorm.DB +var Do query.IUserDo +var User = query.UserStruct diff --git a/applications/userDomain/Makefile b/applications/userDomain/Makefile deleted file mode 100644 index 04f39c8f..00000000 --- a/applications/userDomain/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -server: - kitex -module github.com/TremblingV5/DouTok -type protobuf -I ../../proto/ -service userDomain ../../proto/userDomain.proto \ No newline at end of file diff --git a/applications/userDomain/build.sh b/applications/userDomain/build.sh deleted file mode 100644 index a9da3a9e..00000000 --- a/applications/userDomain/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -RUN_NAME="userDomain" - -mkdir -p output/bin -cp script/* output/ -chmod +x output/bootstrap.sh - -if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then - go build -o output/bin/${RUN_NAME} -else - go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... -fi - diff --git a/applications/userDomain/dal/repository/user/repository.go b/applications/userDomain/dal/repository/user/repository.go deleted file mode 100644 index fed87ffa..00000000 --- a/applications/userDomain/dal/repository/user/repository.go +++ /dev/null @@ -1,50 +0,0 @@ -package user - -import ( - "github.com/TremblingV5/DouTok/applications/userDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/userDomain/dal/query" - "gorm.io/gorm" -) - -type Repository interface { - Save(user *model.User) error - LoadByUsername(username string) (*model.User, error) - LoadById(id uint64) (*model.User, error) - LoadUserListByIds(ids ...uint64) ([]*model.User, error) - IsUserNameExisted(username string) (bool, error) -} - -type PersistRepository struct { - user query.IUserDo -} - -func New(db *gorm.DB) *PersistRepository { - return &PersistRepository{ - user: query.User.WithContext(db.Statement.Context), - } -} - -func (p *PersistRepository) Save(user *model.User) error { - return p.user.Create(user) -} - -func (p *PersistRepository) LoadByUsername(username string) (*model.User, error) { - return p.user.Where(query.User.UserName.Eq(username)).First() -} - -func (p *PersistRepository) LoadById(id uint64) (*model.User, error) { - return p.user.Where(query.User.ID.Eq(id)).First() -} - -func (p *PersistRepository) LoadUserListByIds(ids ...uint64) ([]*model.User, error) { - return p.user.Where(query.User.ID.In(ids...)).Find() -} - -func (p *PersistRepository) IsUserNameExisted(username string) (bool, error) { - count, err := p.user.Where(query.User.UserName.Eq(username)).Count() - if err != nil { - return false, err - } - - return count > 0, nil -} diff --git a/applications/userDomain/errs/errs.go b/applications/userDomain/errs/errs.go deleted file mode 100644 index d2aad355..00000000 --- a/applications/userDomain/errs/errs.go +++ /dev/null @@ -1,35 +0,0 @@ -package errs - -import "github.com/TremblingV5/DouTok/pkg/response" - -const ( - userNameError = "username error" - userNameErrorCode = 101 - passwordError = "password error" - passwordErrorCode = 102 - emptyError = "username or password is empty" - emptyErrorCode = 103 - userNameExisted = "username existed" - userNameExistedCode = 104 - systemError = "system error" - systemErrorCode = 105 -) - -var ( - Success *response.Response - UserNameErr *response.Response - PasswordErr *response.Response - EmptyErr *response.Response - UserNameExistedErr *response.Response - SystemErr *response.Response -) - -func Init(config response.Config) { - Success = response.Success(config) - - UserNameErr = Success.Copy().Update(response.Code(userNameErrorCode), response.Message(userNameError)) - PasswordErr = Success.Copy().Update(response.Code(passwordErrorCode), response.Message(passwordError)) - EmptyErr = Success.Copy().Update(response.Code(emptyErrorCode), response.Message(emptyError)) - UserNameExistedErr = Success.Copy().Update(response.Code(userNameExistedCode), response.Message(userNameExisted)) - SystemErr = Success.Copy().Update(response.Code(systemErrorCode), response.Message(systemError)) -} diff --git a/applications/userDomain/handler/handler.go b/applications/userDomain/handler/handler.go deleted file mode 100644 index 91cdea87..00000000 --- a/applications/userDomain/handler/handler.go +++ /dev/null @@ -1,74 +0,0 @@ -package handler - -import ( - "context" - "fmt" - "github.com/TremblingV5/DouTok/applications/userDomain/errs" - "github.com/TremblingV5/DouTok/applications/userDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain" -) - -type Handler struct { - user *service.Service -} - -func New(user *service.Service) *Handler { - return &Handler{ - user: user, - } -} - -func (s *Handler) AddUser(ctx context.Context, req *userDomain.DoutokAddUserRequest) (resp *userDomain.DoutokAddUserResponse, err error) { - if req.Username == "" || req.Password == "" { - return &userDomain.DoutokAddUserResponse{ - StatusCode: errs.EmptyErr.Code(), - StatusMsg: errs.EmptyErr.Message(), - UserId: 0, - }, nil - } - - userId, err := s.user.CreateNewUser(req.Username, req.Password) - - if err != nil { - return &userDomain.DoutokAddUserResponse{ - StatusCode: errs.SystemErr.Code(), - StatusMsg: fmt.Sprintf("%s %s", errs.SystemErr.Message(), err.Error()), - UserId: userId, - }, err - } - - return &userDomain.DoutokAddUserResponse{ - StatusCode: errs.Success.Code(), - StatusMsg: errs.Success.Message(), - UserId: userId, - }, nil -} - -func (s *Handler) CheckUser(ctx context.Context, req *userDomain.DoutokCheckUserRequest) (resp *userDomain.DoutokCheckUserResponse, err error) { - if req.Username == "" || req.Password == "" { - return packCheckUserResp(errs.EmptyErr.Code(), errs.EmptyErr.Message(), 0) - } - - userId, err := s.user.CheckPassword(req.Username, req.Password) - if err != nil || userId == 0 { - return packCheckUserResp(errs.PasswordErr.Code(), errs.PasswordErr.Message(), 0) - } - - return packCheckUserResp(errs.Success.Code(), errs.Success.Message(), userId) -} - -func (s *Handler) GetUserInfo(ctx context.Context, req *userDomain.DoutokGetUserInfoRequest) (resp *userDomain.DoutokGetUserInfoResponse, err error) { - userIdList := make([]uint64, 0) - if req != nil && req.UserId != nil { - for _, v := range req.UserId { - userIdList = append(userIdList, uint64(v)) - } - } - - userList, err := s.user.LoadUserListByIds(userIdList...) - if err != nil { - return packGetUserInfoResp(errs.SystemErr.Code(), err.Error(), nil) - } - - return packGetUserInfoResp(errs.Success.Code(), errs.Success.Message(), userList) -} diff --git a/applications/userDomain/handler/pack.go b/applications/userDomain/handler/pack.go deleted file mode 100644 index 1052b7a3..00000000 --- a/applications/userDomain/handler/pack.go +++ /dev/null @@ -1,35 +0,0 @@ -package handler - -import ( - "github.com/TremblingV5/DouTok/applications/userDomain/dal/model" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain" -) - -func packCheckUserResp(code int32, message string, user_id int64) (resp *userDomain.DoutokCheckUserResponse, err error) { - return &userDomain.DoutokCheckUserResponse{ - StatusCode: code, - StatusMsg: message, - UserId: user_id, - }, nil -} - -func packGetUserInfoResp(code int32, message string, userList []*model.User) (resp *userDomain.DoutokGetUserInfoResponse, err error) { - userListRes := make(map[int64]*entity.User) - - for _, v := range userList { - userListRes[int64(v.ID)] = &entity.User{ - Id: int64(v.ID), - Name: v.UserName, - Avatar: v.Avatar, - BackgroundImage: v.BackgroundImage, - Signature: v.Signature, - } - } - - return &userDomain.DoutokGetUserInfoResponse{ - StatusCode: code, - StatusMsg: message, - UserList: userListRes, - }, nil -} diff --git a/applications/userDomain/main.go b/applications/userDomain/main.go deleted file mode 100644 index ea261d48..00000000 --- a/applications/userDomain/main.go +++ /dev/null @@ -1,73 +0,0 @@ -package main - -import ( - "context" - "go.uber.org/zap" - - "github.com/TremblingV5/DouTok/applications/userDomain/dal/query" - "github.com/TremblingV5/DouTok/applications/userDomain/dal/repository/user" - "github.com/TremblingV5/DouTok/applications/userDomain/errs" - "github.com/TremblingV5/DouTok/applications/userDomain/handler" - "github.com/TremblingV5/DouTok/applications/userDomain/service" - "github.com/TremblingV5/DouTok/config/configStruct" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain/userdomainservice" - "github.com/TremblingV5/DouTok/pkg/DouTokContext" - "github.com/TremblingV5/DouTok/pkg/DouTokLogger" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/services" -) - -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_USER_DOMAIN_"` - Jwt configStruct.Jwt `envPrefix:"DOUTOK_USER_DOMAIN_"` - MySQL configStruct.MySQL `envPrefix:"DOUTOK_USER_DOMAIN_"` - Logger configStruct.Logger `envPrefix:"DOUTOK_USER_DOMAIN_"` -} - -var ( - logger *zap.Logger - config = &Config{} -) - -func init() { - ctx := context.Background() - - _, err := configurator.Load(config, "DOUTOK_USER_DOMAIN", "userDomain") - errs.Init(config.Base) - logger = DouTokLogger.InitLogger(config.Logger) - DouTokContext.DefaultLogger = logger - DouTokContext.AddLoggerToContext(ctx, logger) - - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", config)) - } - - logger = DouTokContext.Extract(ctx) -} - -func loadFeature() *handler.Handler { - db, err := config.MySQL.InitDB() - if err != nil { - panic(err) - } - query.SetDefault(db) - - userRepo := user.New(db) - userService := service.New(userRepo) - return handler.New(userService) -} - -func main() { - options, shutdown := services.InitRPCServerArgs(constants.USER_DOMAIN_SERVER_NAME, config.BaseConfig) - defer shutdown() - - svr := userdomainservice.NewServer( - loadFeature(), - options..., - ) - - if err := svr.Run(); err != nil { - logger.Fatal("failed to run server", zap.Any("error", err)) - } -} diff --git a/applications/userDomain/run.sh b/applications/userDomain/run.sh deleted file mode 100644 index 20e8c8b4..00000000 --- a/applications/userDomain/run.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# 设置环境变量 -export DOUTOK_USER_DOMAIN_SERVER_NAME=DouTokUserDomainServer -export DOUTOK_USER_DOMAIN_SERVER_PORT=8085 -export DOUTOK_USER_DOMAIN_ETCD_ADDRESS=localhost -export DOUTOK_USER_DOMAIN_ETCD_PORT=2379 -export DOUTOK_USER_DOMAIN_MYSQL_USERNAME=admin -export DOUTOK_USER_DOMAIN_MYSQL_PASSWORD=root -export DOUTOK_USER_DOMAIN_MYSQL_DATABASE=DouTok - -# 运行 Go 项目 -go run main.go diff --git a/applications/userDomain/script/bootstrap.sh b/applications/userDomain/script/bootstrap.sh deleted file mode 100644 index b0093e48..00000000 --- a/applications/userDomain/script/bootstrap.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env bash -CURDIR=$(cd $(dirname $0); pwd) - -if [ "X$1" != "X" ]; then - RUNTIME_ROOT=$1 -else - RUNTIME_ROOT=${CURDIR} -fi - -export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT -export KITEX_LOG_DIR="$RUNTIME_ROOT/log" - -if [ ! -d "$KITEX_LOG_DIR/app" ]; then - mkdir -p "$KITEX_LOG_DIR/app" -fi - -if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then - mkdir -p "$KITEX_LOG_DIR/rpc" -fi - -exec "$CURDIR/bin/userDomain" - diff --git a/applications/userDomain/service/service.go b/applications/userDomain/service/service.go deleted file mode 100644 index 1db8ea47..00000000 --- a/applications/userDomain/service/service.go +++ /dev/null @@ -1,84 +0,0 @@ -package service - -import ( - "github.com/TremblingV5/DouTok/applications/userDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/userDomain/dal/repository/user" - "github.com/TremblingV5/DouTok/pkg/encrypt" - "github.com/TremblingV5/DouTok/pkg/utils" - "math/rand" -) - -type Service struct { - user user.Repository - snowflake *utils.SnowflakeHandle -} - -func New(userRepo user.Repository) *Service { - return &Service{ - user: userRepo, - snowflake: utils.NewSnowflakeHandle(1), - } -} - -func (s *Service) CheckPassword(username string, password string) (int64, error) { - user, err := s.user.LoadByUsername(username) - - if err != nil { - return 0, err - } - - encrypted := encrypt.Encrypt(int64(user.ID), password, user.Salt) - - if encrypted != user.Password { - return 0, nil - } - - return int64(user.ID), nil -} - -func (s *Service) CreateNewUser(username string, password string) (int64, error) { - exist, err := s.user.IsUserNameExisted(username) - if err != nil { - return 0, err - } - if exist { - return 0, nil - } - - userId := s.snowflake.GetId() - salt := encrypt.GenSalt() - encrypted := encrypt.Encrypt(int64(userId), password, salt) - if err := s.user.Save(&model.User{ - ID: uint64(userId), - UserName: username, - Password: encrypted, - Salt: salt, - Avatar: getUserAvatar(), - BackgroundImage: getUserAvatar(), - Signature: "这个人很低调", - }); err != nil { - return 0, err - } - - return int64(userId), nil -} - -func (s *Service) LoadUserListByIds(userId ...uint64) ([]*model.User, error) { - userList, err := s.user.LoadUserListByIds(userId...) - if err != nil { - return nil, err - } - return userList, nil -} - -func getUserAvatar() string { - link1 := "https://doutok-video.oss-cn-shanghai.aliyuncs.com/video/hear.png" - link2 := "https://doutok-video.oss-cn-shanghai.aliyuncs.com/video/stop.png" - - r := rand.Int31n(100) - if r%2 == 0 { - return link1 - } else { - return link2 - } -} diff --git a/applications/videoDomain/Makefile b/applications/videoDomain/Makefile deleted file mode 100644 index cedae847..00000000 --- a/applications/videoDomain/Makefile +++ /dev/null @@ -1,2 +0,0 @@ -server: - kitex -module github.com/TremblingV5/DouTok -type protobuf -I ../../proto/ -service videoDomain ../../proto/videoDomain.proto \ No newline at end of file diff --git a/applications/videoDomain/build.sh b/applications/videoDomain/build.sh deleted file mode 100644 index f53a464f..00000000 --- a/applications/videoDomain/build.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash -RUN_NAME="videoDomain" - -mkdir -p output/bin -cp script/* output/ -chmod +x output/bootstrap.sh - -if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then - go build -o output/bin/${RUN_NAME} -else - go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... -fi - diff --git a/applications/videoDomain/dal/migrate/main.go b/applications/videoDomain/dal/migrate/main.go deleted file mode 100644 index f6ec6321..00000000 --- a/applications/videoDomain/dal/migrate/main.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import ( - "github.com/TremblingV5/DouTok/applications/videoDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/videoDomain/service" -) - -func main() { - service.Init() - - if err := service.DB.AutoMigrate(&model.Video{}, &model.VideoCount{}); err != nil { - panic(err) - } -} diff --git a/applications/videoDomain/dal/model/video_count.go b/applications/videoDomain/dal/model/video_count.go deleted file mode 100644 index 73282140..00000000 --- a/applications/videoDomain/dal/model/video_count.go +++ /dev/null @@ -1,11 +0,0 @@ -package model - -import "time" - -type VideoCount struct { - Id uint64 `gorm:"primarykey"` - UserId uint64 - PublishCount int64 - CreatedAt time.Time - UpdateAt time.Time -} diff --git a/applications/videoDomain/dal/query/video_counts.gen.go b/applications/videoDomain/dal/query/video_counts.gen.go deleted file mode 100644 index 88bea3ac..00000000 --- a/applications/videoDomain/dal/query/video_counts.gen.go +++ /dev/null @@ -1,392 +0,0 @@ -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. -// Code generated by gorm.io/gen. DO NOT EDIT. - -package query - -import ( - "context" - - "gorm.io/gorm" - "gorm.io/gorm/clause" - "gorm.io/gorm/schema" - - "gorm.io/gen" - "gorm.io/gen/field" - - "gorm.io/plugin/dbresolver" - - "github.com/TremblingV5/DouTok/applications/videoDomain/dal/model" -) - -func newVideoCount(db *gorm.DB, opts ...gen.DOOption) videoCount { - _videoCount := videoCount{} - - _videoCount.videoCountDo.UseDB(db, opts...) - _videoCount.videoCountDo.UseModel(&model.VideoCount{}) - - tableName := _videoCount.videoCountDo.TableName() - _videoCount.ALL = field.NewAsterisk(tableName) - _videoCount.Id = field.NewUint64(tableName, "id") - _videoCount.UserId = field.NewUint64(tableName, "user_id") - _videoCount.PublishCount = field.NewInt64(tableName, "publish_count") - - _videoCount.fillFieldMap() - - return _videoCount -} - -type videoCount struct { - videoCountDo - - ALL field.Asterisk - Id field.Uint64 - UserId field.Uint64 - PublishCount field.Int64 - - fieldMap map[string]field.Expr -} - -func (v videoCount) Table(newTableName string) *videoCount { - v.videoCountDo.UseTable(newTableName) - return v.updateTableName(newTableName) -} - -func (v videoCount) As(alias string) *videoCount { - v.videoCountDo.DO = *(v.videoCountDo.As(alias).(*gen.DO)) - return v.updateTableName(alias) -} - -func (v *videoCount) updateTableName(table string) *videoCount { - v.ALL = field.NewAsterisk(table) - v.Id = field.NewUint64(table, "id") - v.UserId = field.NewUint64(table, "user_id") - v.PublishCount = field.NewInt64(table, "publish_count") - - v.fillFieldMap() - - return v -} - -func (v *videoCount) GetFieldByName(fieldName string) (field.OrderExpr, bool) { - _f, ok := v.fieldMap[fieldName] - if !ok || _f == nil { - return nil, false - } - _oe, ok := _f.(field.OrderExpr) - return _oe, ok -} - -func (v *videoCount) fillFieldMap() { - v.fieldMap = make(map[string]field.Expr, 3) - v.fieldMap["id"] = v.Id - v.fieldMap["user_id"] = v.UserId - v.fieldMap["publish_count"] = v.PublishCount -} - -func (v videoCount) clone(db *gorm.DB) videoCount { - v.videoCountDo.ReplaceConnPool(db.Statement.ConnPool) - return v -} - -func (v videoCount) replaceDB(db *gorm.DB) videoCount { - v.videoCountDo.ReplaceDB(db) - return v -} - -type videoCountDo struct{ gen.DO } - -type IVideoCountDo interface { - gen.SubQuery - Debug() IVideoCountDo - WithContext(ctx context.Context) IVideoCountDo - WithResult(fc func(tx gen.Dao)) gen.ResultInfo - ReplaceDB(db *gorm.DB) - ReadDB() IVideoCountDo - WriteDB() IVideoCountDo - As(alias string) gen.Dao - Session(config *gorm.Session) IVideoCountDo - Columns(cols ...field.Expr) gen.Columns - Clauses(conds ...clause.Expression) IVideoCountDo - Not(conds ...gen.Condition) IVideoCountDo - Or(conds ...gen.Condition) IVideoCountDo - Select(conds ...field.Expr) IVideoCountDo - Where(conds ...gen.Condition) IVideoCountDo - Order(conds ...field.Expr) IVideoCountDo - Distinct(cols ...field.Expr) IVideoCountDo - Omit(cols ...field.Expr) IVideoCountDo - Join(table schema.Tabler, on ...field.Expr) IVideoCountDo - LeftJoin(table schema.Tabler, on ...field.Expr) IVideoCountDo - RightJoin(table schema.Tabler, on ...field.Expr) IVideoCountDo - Group(cols ...field.Expr) IVideoCountDo - Having(conds ...gen.Condition) IVideoCountDo - Limit(limit int) IVideoCountDo - Offset(offset int) IVideoCountDo - Count() (count int64, err error) - Scopes(funcs ...func(gen.Dao) gen.Dao) IVideoCountDo - Unscoped() IVideoCountDo - Create(values ...*model.VideoCount) error - CreateInBatches(values []*model.VideoCount, batchSize int) error - Save(values ...*model.VideoCount) error - First() (*model.VideoCount, error) - Take() (*model.VideoCount, error) - Last() (*model.VideoCount, error) - Find() ([]*model.VideoCount, error) - FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.VideoCount, err error) - FindInBatches(result *[]*model.VideoCount, batchSize int, fc func(tx gen.Dao, batch int) error) error - Pluck(column field.Expr, dest interface{}) error - Delete(...*model.VideoCount) (info gen.ResultInfo, err error) - Update(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - Updates(value interface{}) (info gen.ResultInfo, err error) - UpdateColumn(column field.Expr, value interface{}) (info gen.ResultInfo, err error) - UpdateColumnSimple(columns ...field.AssignExpr) (info gen.ResultInfo, err error) - UpdateColumns(value interface{}) (info gen.ResultInfo, err error) - UpdateFrom(q gen.SubQuery) gen.Dao - Attrs(attrs ...field.AssignExpr) IVideoCountDo - Assign(attrs ...field.AssignExpr) IVideoCountDo - Joins(fields ...field.RelationField) IVideoCountDo - Preload(fields ...field.RelationField) IVideoCountDo - FirstOrInit() (*model.VideoCount, error) - FirstOrCreate() (*model.VideoCount, error) - FindByPage(offset int, limit int) (result []*model.VideoCount, count int64, err error) - ScanByPage(result interface{}, offset int, limit int) (count int64, err error) - Scan(result interface{}) (err error) - Returning(value interface{}, columns ...string) IVideoCountDo - UnderlyingDB() *gorm.DB - schema.Tabler -} - -func (v videoCountDo) Debug() IVideoCountDo { - return v.withDO(v.DO.Debug()) -} - -func (v videoCountDo) WithContext(ctx context.Context) IVideoCountDo { - return v.withDO(v.DO.WithContext(ctx)) -} - -func (v videoCountDo) ReadDB() IVideoCountDo { - return v.Clauses(dbresolver.Read) -} - -func (v videoCountDo) WriteDB() IVideoCountDo { - return v.Clauses(dbresolver.Write) -} - -func (v videoCountDo) Session(config *gorm.Session) IVideoCountDo { - return v.withDO(v.DO.Session(config)) -} - -func (v videoCountDo) Clauses(conds ...clause.Expression) IVideoCountDo { - return v.withDO(v.DO.Clauses(conds...)) -} - -func (v videoCountDo) Returning(value interface{}, columns ...string) IVideoCountDo { - return v.withDO(v.DO.Returning(value, columns...)) -} - -func (v videoCountDo) Not(conds ...gen.Condition) IVideoCountDo { - return v.withDO(v.DO.Not(conds...)) -} - -func (v videoCountDo) Or(conds ...gen.Condition) IVideoCountDo { - return v.withDO(v.DO.Or(conds...)) -} - -func (v videoCountDo) Select(conds ...field.Expr) IVideoCountDo { - return v.withDO(v.DO.Select(conds...)) -} - -func (v videoCountDo) Where(conds ...gen.Condition) IVideoCountDo { - return v.withDO(v.DO.Where(conds...)) -} - -func (v videoCountDo) Exists(subquery interface{ UnderlyingDB() *gorm.DB }) IVideoCountDo { - return v.Where(field.CompareSubQuery(field.ExistsOp, nil, subquery.UnderlyingDB())) -} - -func (v videoCountDo) Order(conds ...field.Expr) IVideoCountDo { - return v.withDO(v.DO.Order(conds...)) -} - -func (v videoCountDo) Distinct(cols ...field.Expr) IVideoCountDo { - return v.withDO(v.DO.Distinct(cols...)) -} - -func (v videoCountDo) Omit(cols ...field.Expr) IVideoCountDo { - return v.withDO(v.DO.Omit(cols...)) -} - -func (v videoCountDo) Join(table schema.Tabler, on ...field.Expr) IVideoCountDo { - return v.withDO(v.DO.Join(table, on...)) -} - -func (v videoCountDo) LeftJoin(table schema.Tabler, on ...field.Expr) IVideoCountDo { - return v.withDO(v.DO.LeftJoin(table, on...)) -} - -func (v videoCountDo) RightJoin(table schema.Tabler, on ...field.Expr) IVideoCountDo { - return v.withDO(v.DO.RightJoin(table, on...)) -} - -func (v videoCountDo) Group(cols ...field.Expr) IVideoCountDo { - return v.withDO(v.DO.Group(cols...)) -} - -func (v videoCountDo) Having(conds ...gen.Condition) IVideoCountDo { - return v.withDO(v.DO.Having(conds...)) -} - -func (v videoCountDo) Limit(limit int) IVideoCountDo { - return v.withDO(v.DO.Limit(limit)) -} - -func (v videoCountDo) Offset(offset int) IVideoCountDo { - return v.withDO(v.DO.Offset(offset)) -} - -func (v videoCountDo) Scopes(funcs ...func(gen.Dao) gen.Dao) IVideoCountDo { - return v.withDO(v.DO.Scopes(funcs...)) -} - -func (v videoCountDo) Unscoped() IVideoCountDo { - return v.withDO(v.DO.Unscoped()) -} - -func (v videoCountDo) Create(values ...*model.VideoCount) error { - if len(values) == 0 { - return nil - } - return v.DO.Create(values) -} - -func (v videoCountDo) CreateInBatches(values []*model.VideoCount, batchSize int) error { - return v.DO.CreateInBatches(values, batchSize) -} - -// Save : !!! underlying implementation is different with GORM -// The method is equivalent to executing the statement: db.Clauses(clause.OnConflict{UpdateAll: true}).Create(values) -func (v videoCountDo) Save(values ...*model.VideoCount) error { - if len(values) == 0 { - return nil - } - return v.DO.Save(values) -} - -func (v videoCountDo) First() (*model.VideoCount, error) { - if result, err := v.DO.First(); err != nil { - return nil, err - } else { - return result.(*model.VideoCount), nil - } -} - -func (v videoCountDo) Take() (*model.VideoCount, error) { - if result, err := v.DO.Take(); err != nil { - return nil, err - } else { - return result.(*model.VideoCount), nil - } -} - -func (v videoCountDo) Last() (*model.VideoCount, error) { - if result, err := v.DO.Last(); err != nil { - return nil, err - } else { - return result.(*model.VideoCount), nil - } -} - -func (v videoCountDo) Find() ([]*model.VideoCount, error) { - result, err := v.DO.Find() - return result.([]*model.VideoCount), err -} - -func (v videoCountDo) FindInBatch(batchSize int, fc func(tx gen.Dao, batch int) error) (results []*model.VideoCount, err error) { - buf := make([]*model.VideoCount, 0, batchSize) - err = v.DO.FindInBatches(&buf, batchSize, func(tx gen.Dao, batch int) error { - defer func() { results = append(results, buf...) }() - return fc(tx, batch) - }) - return results, err -} - -func (v videoCountDo) FindInBatches(result *[]*model.VideoCount, batchSize int, fc func(tx gen.Dao, batch int) error) error { - return v.DO.FindInBatches(result, batchSize, fc) -} - -func (v videoCountDo) Attrs(attrs ...field.AssignExpr) IVideoCountDo { - return v.withDO(v.DO.Attrs(attrs...)) -} - -func (v videoCountDo) Assign(attrs ...field.AssignExpr) IVideoCountDo { - return v.withDO(v.DO.Assign(attrs...)) -} - -func (v videoCountDo) Joins(fields ...field.RelationField) IVideoCountDo { - for _, _f := range fields { - v = *v.withDO(v.DO.Joins(_f)) - } - return &v -} - -func (v videoCountDo) Preload(fields ...field.RelationField) IVideoCountDo { - for _, _f := range fields { - v = *v.withDO(v.DO.Preload(_f)) - } - return &v -} - -func (v videoCountDo) FirstOrInit() (*model.VideoCount, error) { - if result, err := v.DO.FirstOrInit(); err != nil { - return nil, err - } else { - return result.(*model.VideoCount), nil - } -} - -func (v videoCountDo) FirstOrCreate() (*model.VideoCount, error) { - if result, err := v.DO.FirstOrCreate(); err != nil { - return nil, err - } else { - return result.(*model.VideoCount), nil - } -} - -func (v videoCountDo) FindByPage(offset int, limit int) (result []*model.VideoCount, count int64, err error) { - result, err = v.Offset(offset).Limit(limit).Find() - if err != nil { - return - } - - if size := len(result); 0 < limit && 0 < size && size < limit { - count = int64(size + offset) - return - } - - count, err = v.Offset(-1).Limit(-1).Count() - return -} - -func (v videoCountDo) ScanByPage(result interface{}, offset int, limit int) (count int64, err error) { - count, err = v.Count() - if err != nil { - return - } - - err = v.Offset(offset).Limit(limit).Scan(result) - return -} - -func (v videoCountDo) Scan(result interface{}) (err error) { - return v.DO.Scan(result) -} - -func (v videoCountDo) Delete(models ...*model.VideoCount) (result gen.ResultInfo, err error) { - return v.DO.Delete(models) -} - -func (v *videoCountDo) withDO(do gen.Dao) *videoCountDo { - v.DO = *do.(*gen.DO) - return v -} diff --git a/applications/videoDomain/handler/add_publish.go b/applications/videoDomain/handler/add_publish.go deleted file mode 100644 index 0760d933..00000000 --- a/applications/videoDomain/handler/add_publish.go +++ /dev/null @@ -1,21 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/videoDomain/misc" - "github.com/TremblingV5/DouTok/applications/videoDomain/pack" - "github.com/TremblingV5/DouTok/applications/videoDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" -) - -func (s *VideoDomainServiceImpl) AddPublish(ctx context.Context, req *videoDomain.DoutokAddPublishRequest) (resp *videoDomain.DoutokAddPublishResponse, err error) { - if len(req.Data) == 0 || len(req.Title) == 0 { - return pack.PackageAddPublishResp(&misc.EmptyErr) - } - - if err := service.NewSavePublishService(ctx).SavePublish(req.UserId, req.Title, req.Data); err != nil { - return pack.PackageAddPublishResp(&misc.SystemErr) - } - - return pack.PackageAddPublishResp(&misc.Success) -} diff --git a/applications/videoDomain/handler/count_publish.go b/applications/videoDomain/handler/count_publish.go deleted file mode 100644 index 992db72c..00000000 --- a/applications/videoDomain/handler/count_publish.go +++ /dev/null @@ -1,10 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" -) - -func (s *VideoDomainServiceImpl) CountPublish(ctx context.Context, req *videoDomain.DoutokCountPublishRequest) (res *videoDomain.DoutokCountPublishResponse, err error) { - return nil, nil -} diff --git a/applications/videoDomain/handler/get_feed.go b/applications/videoDomain/handler/get_feed.go deleted file mode 100644 index 55ae6f7b..00000000 --- a/applications/videoDomain/handler/get_feed.go +++ /dev/null @@ -1,86 +0,0 @@ -package handler - -import ( - "context" - "fmt" - "time" - - "github.com/TremblingV5/DouTok/applications/videoDomain/misc" - "github.com/TremblingV5/DouTok/applications/videoDomain/pack" - "github.com/TremblingV5/DouTok/applications/videoDomain/service" - "github.com/TremblingV5/DouTok/applications/videoDomain/typedef" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - "github.com/cloudwego/kitex/pkg/klog" -) - -func (s *VideoDomainServiceImpl) GetFeed(ctx context.Context, req *videoDomain.DoutokGetFeedRequest) (resp *videoDomain.DoutokGetFeedResponse, err error) { - if req.LatestTime == 0 { - req.LatestTime = time.Now().Unix() - } - - userIdString := misc.FillUserId(fmt.Sprint(req.UserId)) - - // 1. 从Redis中获取Feed列表(通过LPop) - var list []typedef.VideoInHB - var ok bool - list, ok = service.GetFeedCache(ctx, userIdString, 10) - - // 2. 【视频条数不足】从hbase中从latest_time开始,以24h的周期向前查询,直至条数满足或超过current_time - 14 * 24h - if !ok { - listFromHB, err := service.SearchFeedEarlierInHB(req.LatestTime, req.LatestTime-7*86400) - if err != nil { - return pack.PackageFeedListResp([]typedef.VideoInHB{}, &misc.SystemErr, req.UserId) - } - - // 3. 取前10条视频作为本次feed的数据,其余的通过RPush进入投递箱 - err = service.SetFeedCache(ctx, "r", userIdString, listFromHB...) - if err != nil { - return pack.PackageFeedListResp([]typedef.VideoInHB{}, &misc.SystemErr, req.UserId) - } - - var newListNum int64 - if len(listFromHB) >= 10 { - newListNum = 10 - } else { - newListNum = int64(len(listFromHB)) - } - list, ok = service.GetFeedCache(ctx, userIdString, newListNum) - - if !ok { - return pack.PackageFeedListResp([]typedef.VideoInHB{}, &misc.SystemErr, req.UserId) - } - } - - // 4. 计算current_time与marked_time的差值是否超过6个小时,如是则进行查询 - currentTime := time.Now().Unix() - markedTime, err := service.GetMarkedTime(ctx, userIdString) - if err != nil { - markedTime = fmt.Sprint(currentTime) - } - - if err != nil { - markedTime = fmt.Sprint(currentTime) - if err := service.SetMarkedTime(ctx, userIdString, markedTime); err != nil { - klog.Info("set marked time error") - } - } - - if service.JudgeTimeDiff(currentTime, markedTime, 60*60*6) { - // 时间差值已经超过了6个小时 - laterVideoListInHB, newMarkedTime, err := service.SearchFeedLaterInHB(markedTime, fmt.Sprint(currentTime)) - if err != nil { - klog.Info("search feed later in hb error") - } - - if err := service.SetMarkedTime(ctx, userIdString, newMarkedTime); err != nil { - klog.Info("set marked time error") - } - - // 5. 若存在新更新的内容,将结果存入投递箱,根据比例选择RPush或LPush - if err := service.SetFeedCache(ctx, "r", userIdString, laterVideoListInHB...); err != nil { - klog.Info("set feed cache error") - } - } - - return pack.PackageFeedListResp(list, &misc.Success, req.UserId) -} diff --git a/applications/videoDomain/handler/get_video_info.go b/applications/videoDomain/handler/get_video_info.go deleted file mode 100644 index c2db03d6..00000000 --- a/applications/videoDomain/handler/get_video_info.go +++ /dev/null @@ -1,24 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/videoDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" -) - -func (s *VideoDomainServiceImpl) GetVideoInfo(ctx context.Context, req *videoDomain.DoutokGetVideoInfoRequest) (resp *entity.Video, err error) { - data, err := service.NewGetVideoService(ctx).GetVideoByIdInRDB(uint64(req.VideoId)) - if err != nil { - return nil, err - } - return &entity.Video{ - Id: int64(data.ID), - Author: &entity.User{ - Id: int64(data.AuthorID), - }, - PlayUrl: data.VideoUrl, - CoverUrl: data.CoverUrl, - Title: data.Title, - }, nil -} diff --git a/applications/videoDomain/handler/list_publish.go b/applications/videoDomain/handler/list_publish.go deleted file mode 100644 index 7af6ecdf..00000000 --- a/applications/videoDomain/handler/list_publish.go +++ /dev/null @@ -1,19 +0,0 @@ -package handler - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/videoDomain/misc" - "github.com/TremblingV5/DouTok/applications/videoDomain/pack" - "github.com/TremblingV5/DouTok/applications/videoDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" -) - -func (s *VideoDomainServiceImpl) ListPublish(ctx context.Context, req *videoDomain.DoutokListPublishRequest) (resp *videoDomain.DoutokListPublishResponse, err error) { - list, err := service.NewQueryPublishListService(ctx).QueryPublishListInHBase(req.UserId) - - if err != nil { - return pack.PackageListPublishResp(&misc.SystemErr, nil) - } - - return pack.PackageListPublishResp(&misc.Success, list) -} diff --git a/applications/videoDomain/handler/typedef.go b/applications/videoDomain/handler/typedef.go deleted file mode 100644 index 04ec90a5..00000000 --- a/applications/videoDomain/handler/typedef.go +++ /dev/null @@ -1,3 +0,0 @@ -package handler - -type VideoDomainServiceImpl struct{} diff --git a/applications/videoDomain/main.go b/applications/videoDomain/main.go deleted file mode 100644 index 8951dd09..00000000 --- a/applications/videoDomain/main.go +++ /dev/null @@ -1,33 +0,0 @@ -package main - -import ( - "github.com/TremblingV5/DouTok/applications/videoDomain/handler" - "github.com/TremblingV5/DouTok/applications/videoDomain/service" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain/videodomainservice" - "github.com/TremblingV5/DouTok/pkg/constants" - "github.com/TremblingV5/DouTok/pkg/dlog" - "github.com/TremblingV5/DouTok/pkg/services" -) - -var ( - Logger = dlog.InitLog(3) -) - -func init() { - service.Init() -} - -func main() { - - options, shutdown := services.InitRPCServerArgs(constants.VIDEO_DOMAIN_SERVER_NAME, service.DomainConfig.BaseConfig) - defer shutdown() - - svr := videodomainservice.NewServer( - new(handler.VideoDomainServiceImpl), - options..., - ) - - if err := svr.Run(); err != nil { - Logger.Fatal(err) - } -} diff --git a/applications/videoDomain/misc/err.go b/applications/videoDomain/misc/err.go deleted file mode 100644 index 7628b93c..00000000 --- a/applications/videoDomain/misc/err.go +++ /dev/null @@ -1,17 +0,0 @@ -package misc - -import "github.com/TremblingV5/DouTok/pkg/errno" - -var ( - NilErrCode = -1 - SuccessCode = 0 - EmptyErrCode = 31001 - SystemErrCode = 31002 -) - -var ( - NilErr = errno.New(NilErrCode, "Don't care") - Success = errno.New(SuccessCode, "Success") - EmptyErr = errno.New(EmptyErrCode, "size of title or data is zero") - SystemErr = errno.New(SystemErrCode, "System error") -) diff --git a/applications/videoDomain/pack/add_publish.go b/applications/videoDomain/pack/add_publish.go deleted file mode 100644 index f9306739..00000000 --- a/applications/videoDomain/pack/add_publish.go +++ /dev/null @@ -1,13 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func PackageAddPublishResp(errNo *errno.ErrNo) (request *videoDomain.DoutokAddPublishResponse, err error) { - return &videoDomain.DoutokAddPublishResponse{ - StatusCode: int32(errNo.ErrCode), - StatusMsg: errNo.ErrMsg, - }, nil -} diff --git a/applications/videoDomain/pack/count_publish.go b/applications/videoDomain/pack/count_publish.go deleted file mode 100644 index efa176a2..00000000 --- a/applications/videoDomain/pack/count_publish.go +++ /dev/null @@ -1 +0,0 @@ -package pack diff --git a/applications/videoDomain/pack/get_feed.go b/applications/videoDomain/pack/get_feed.go deleted file mode 100644 index 99286cd7..00000000 --- a/applications/videoDomain/pack/get_feed.go +++ /dev/null @@ -1,44 +0,0 @@ -package pack - -import ( - "strconv" - - "github.com/TremblingV5/DouTok/applications/videoDomain/typedef" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func PackageFeedListResp(list []typedef.VideoInHB, errNo *errno.ErrNo, userId int64) (resp *videoDomain.DoutokGetFeedResponse, err error) { - res := videoDomain.DoutokGetFeedResponse{ - StatusCode: int32(errNo.ErrCode), - StatusMsg: errNo.ErrMsg, - } - - nextTime := "9999999999" - var videoList []*entity.Video - - for _, v := range list { - var temp entity.Video - - temp.Id = v.GetId() - temp.Author = &entity.User{ - Id: v.GetAuthorId(), - } - temp.PlayUrl = v.GetVideoUrl() - temp.CoverUrl = v.GetCoverUrl() - temp.Title = v.GetTitle() - - videoList = append(videoList, &temp) - - if v.GetTimestamp() < nextTime { - nextTime = v.GetTimestamp() - } - } - - res.VideoList = videoList - nextTimeInt64, _ := strconv.Atoi(nextTime) - res.NextTime = int64(nextTimeInt64) - - return &res, nil -} diff --git a/applications/videoDomain/pack/get_video_info.go b/applications/videoDomain/pack/get_video_info.go deleted file mode 100644 index efa176a2..00000000 --- a/applications/videoDomain/pack/get_video_info.go +++ /dev/null @@ -1 +0,0 @@ -package pack diff --git a/applications/videoDomain/pack/list_publish.go b/applications/videoDomain/pack/list_publish.go deleted file mode 100644 index e367c17a..00000000 --- a/applications/videoDomain/pack/list_publish.go +++ /dev/null @@ -1,30 +0,0 @@ -package pack - -import ( - "github.com/TremblingV5/DouTok/applications/videoDomain/typedef" - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - "github.com/TremblingV5/DouTok/pkg/errno" -) - -func PackageListPublishResp(errNo *errno.ErrNo, videoList []*typedef.VideoInHB) (request *videoDomain.DoutokListPublishResponse, err error) { - var videoListRes []*entity.Video - - for _, v := range videoList { - videoListRes = append(videoListRes, &entity.Video{ - Id: v.GetId(), - Author: &entity.User{ - Id: v.GetAuthorId(), - }, - Title: v.GetTitle(), - PlayUrl: v.GetVideoUrl(), - CoverUrl: v.GetCoverUrl(), - }) - } - - return &videoDomain.DoutokListPublishResponse{ - StatusCode: int32(errNo.ErrCode), - StatusMsg: errNo.ErrMsg, - VideoList: videoListRes, - }, nil -} diff --git a/applications/videoDomain/script/bootstrap.sh b/applications/videoDomain/script/bootstrap.sh deleted file mode 100644 index 618b902c..00000000 --- a/applications/videoDomain/script/bootstrap.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /usr/bin/env bash -CURDIR=$(cd $(dirname $0); pwd) - -if [ "X$1" != "X" ]; then - RUNTIME_ROOT=$1 -else - RUNTIME_ROOT=${CURDIR} -fi - -export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT -export KITEX_LOG_DIR="$RUNTIME_ROOT/log" - -if [ ! -d "$KITEX_LOG_DIR/app" ]; then - mkdir -p "$KITEX_LOG_DIR/app" -fi - -if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then - mkdir -p "$KITEX_LOG_DIR/rpc" -fi - -exec "$CURDIR/bin/videoDomain" - diff --git a/applications/videoDomain/service/feed_cache.go b/applications/videoDomain/service/feed_cache.go deleted file mode 100644 index 4809ffbf..00000000 --- a/applications/videoDomain/service/feed_cache.go +++ /dev/null @@ -1,56 +0,0 @@ -package service - -import ( - "context" - "errors" - "github.com/TremblingV5/DouTok/applications/videoDomain/typedef" - "github.com/TremblingV5/DouTok/pkg/constants" - "time" -) - -/* -从Redis中获取缓存的feed列表,通过Redis事务执行若干次feed操作,从而获得足够的feed list -*/ -func GetFeedCache(ctx context.Context, userId string, num int64) ([]typedef.VideoInHB, bool) { - res, err := RedisClients[constants.FeedSendBox].LPops(ctx, userId, int(num)) - if err != nil { - return []typedef.VideoInHB{}, false - } - - videoList := String2VideoList(res) - - if err != nil { - return []typedef.VideoInHB{}, false - } - - return videoList, true -} - -/* -将新的feed列表存储到Redis中,method参数只允许l或r,代表选择不同的方法Push到Redis -*/ -func SetFeedCache(ctx context.Context, method string, userId string, values ...typedef.VideoInHB) error { - videoList := VideoList2String(values) - switch method { - case "l": - return RedisClients[constants.FeedSendBox].LPush(ctx, userId, videoList...) - case "r": - return RedisClients[constants.FeedSendBox].RPush(ctx, userId, videoList...) - default: - return errors.New("unknown method, only accept 'l' or 'r'") - } -} - -/* -获取某个user_id在系统中的marked_time -*/ -func GetMarkedTime(ctx context.Context, userId string) (string, error) { - return RedisClients[constants.TimeCache].Get(ctx, userId) -} - -/* -为某个user_id设置新的marked_time -*/ -func SetMarkedTime(ctx context.Context, userId string, markedTime string) error { - return RedisClients[constants.TimeCache].Set(ctx, userId, markedTime, 24*time.Hour) -} diff --git a/applications/videoDomain/service/hbase.go b/applications/videoDomain/service/hbase.go deleted file mode 100644 index 605b16a3..00000000 --- a/applications/videoDomain/service/hbase.go +++ /dev/null @@ -1,119 +0,0 @@ -package service - -import ( - "fmt" - "github.com/TremblingV5/DouTok/applications/videoDomain/misc" - "github.com/TremblingV5/DouTok/applications/videoDomain/typedef" - tools "github.com/TremblingV5/DouTok/pkg/misc" - "strconv" -) - -/* -在HBase中搜索start_time < time <= end_time的视频,作为feed使用 -函数中从HBase中获取了Map结构的数据,并打包成结构体列表 -*/ -func FindFeedInHB(startTime string, endTime string) ([]typedef.VideoInHB, error) { - startTimeInt, _ := strconv.Atoi(startTime) - endTimeInt, _ := strconv.Atoi(endTime) - - res, err := HBClient.ScanRange("feed", misc.GetTimeRebound(int64(endTimeInt)), misc.GetTimeRebound(int64(startTimeInt))) - if err != nil { - return []typedef.VideoInHB{}, err - } - - var videoList []typedef.VideoInHB - for _, v := range res { - temp := typedef.VideoInHB{} - err := tools.Map2Struct4HB(v, &temp) - if err != nil { - continue - } - videoList = append(videoList, temp) - } - - return videoList, nil -} - -/* -向前搜索Feed List,前为更早的时间点 -*/ -func SearchFeedEarlierInHB(latestTime int64, stopTime int64) ([]typedef.VideoInHB, error) { - nextTime := latestTime - 86400 - - var videoList []typedef.VideoInHB - - for { - temp, err := FindFeedInHB(fmt.Sprint(nextTime), fmt.Sprint(latestTime)) - - if err != nil { - return videoList, err - } - - videoList = append(videoList, temp...) - - // 终止条件1:视频列表长度已经大于30;长度列表已经至少满足3次feed的数量,且为一个feed list的最大允许长度 - // 故可以以此为停止条件,以减少资源的使用 - // 终止条件2:next_time少于stop_time,stop_time设置为了14天前,不断搜索14天前的视频作为feed不符合产品定义, - // 故作为终止条件 - if len(videoList) > 30 || nextTime < stopTime { - break - } - - latestTime = nextTime - nextTime -= 86400 - } - - return videoList, nil -} - -/* -向后搜索Feed List,后为更接近当前时间的时间点 -*/ -func SearchFeedLaterInHB(markedTime string, currentTime string) (res []typedef.VideoInHB, newMarkedTime string, err error) { - markedTimeInt, _ := strconv.Atoi(markedTime) - currentTimeInt, _ := strconv.Atoi(currentTime) - - nextMarkedTimeInt := int64(markedTimeInt) + 6*60*60 - - var videoList []typedef.VideoInHB - - for { - temp, err := FindFeedInHB(fmt.Sprint(markedTimeInt), fmt.Sprint(nextMarkedTimeInt)) - - if err != nil { - return videoList, markedTime, err - } - - videoList = append(videoList, temp...) - - // 终止条件1:视频列表长度已经大于30;长度列表已经至少满足3次feed的数量,且为一个feed list的最大允许长度 - // 故可以以此为停止条件,以减少资源的使用 - // 终止条件2:时间差小于6个小时 - if len(videoList) > 30 || JudgeTimeDiff(nextMarkedTimeInt, fmt.Sprint(currentTimeInt), 6*60*60) { - break - } - - markedTimeInt = int(nextMarkedTimeInt) - nextMarkedTimeInt += 6 * 60 * 60 - } - - return videoList, fmt.Sprint(nextMarkedTimeInt), nil -} - -/* -以下不等式是否成立: -t1 - t2 >= diff -*/ -func JudgeTimeDiff(t1 int64, t2 string, diff int64) bool { - t2I, _ := strconv.Atoi(t2) - t2I64 := int64(t2I) - return t1-t2I64 >= diff -} - -/* -以下不等式是否成立: -q1 / q2 >= ratio -*/ -func JudgeQuantityRatio(q1 float64, q2 float64, ratio float64) bool { - return q1/q2 >= ratio -} diff --git a/applications/videoDomain/service/init.go b/applications/videoDomain/service/init.go deleted file mode 100644 index b0631c85..00000000 --- a/applications/videoDomain/service/init.go +++ /dev/null @@ -1,104 +0,0 @@ -package service - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/videoDomain/dal/query" - "github.com/TremblingV5/DouTok/config/configStruct" - "github.com/TremblingV5/DouTok/pkg/LogBuilder" - "github.com/TremblingV5/DouTok/pkg/configurator" - "github.com/TremblingV5/DouTok/pkg/dtviper" - "github.com/TremblingV5/DouTok/pkg/hbaseHandle" - redishandle "github.com/TremblingV5/DouTok/pkg/redisHandle" - "github.com/TremblingV5/DouTok/pkg/utils" - "github.com/bytedance/gopkg/util/logger" - "go.uber.org/zap" -) - -type Config struct { - configStruct.BaseConfig `envPrefix:"DOUTOK_VIDEODOMAIN_"` - MySQL configStruct.MySQL `envPrefix:"DOUTOK_VIDEODOMAIN_"` - Redis configStruct.Redis `envPrefix:"DOUTOK_VIDEODOMAIN_"` - HBase configStruct.HBase `envPrefix:"DOUTOK_VIDEODOMAIN_"` - MinIO configStruct.MinIO `envPrefix:"DOUTOK_VIDEODOMAIN_"` -} - -var ( - ViperConfig *dtviper.Config - DomainConfig Config - Logger *LogBuilder.Logger -) - -func Init() { - - Logger = LogBuilder.New("./tmp/videoDomain.log", 1024*1024, 3, 10) - - // TODO 参数和行为不太一致,这个函数做了两件事:初始化DomainConfig,但是返回了ViperConfig - v, err := configurator.Load(&DomainConfig, "DOUTOK_VIDEODOMAIN", "videoDomain") - ViperConfig = v - if err != nil { - logger.Fatal("could not load env variables", zap.Error(err), zap.Any("config", DomainConfig)) - } - - if err := InitDb(); err != nil { - panic(err) - } - - InitHB() - - if err := InitMinio(); err != nil { - panic(err.Error()) - } - - utils.InitSnowFlake(ViperConfig.Viper.GetInt64("Snowflake.Node")) - redisMap := map[string]int{ - "SendBox": ViperConfig.Viper.GetInt("Redis.SendBox.Num"), - "MarkedTime": ViperConfig.Viper.GetInt("Redis.MarkedTime.Num"), - } - - InitRedis(redisMap) -} - -func InitRedis(dbs map[string]int) { - RedisClients = make(map[string]*redishandle.RedisClient) - for k, v := range dbs { - RedisClients[k] = &redishandle.RedisClient{ - Client: DomainConfig.Redis.InitRedisClient(v), - } - } -} - -func InitDb() error { - db, err := DomainConfig.MySQL.InitDB() - - if err != nil { - return err - } - - DB = db - - query.SetDefault(DB) - Video = query.Video - Do = Video.WithContext(context.Background()) - - VideoCount = query.VideoCount - VideoCountDo = VideoCount.WithContext(context.Background()) - - return nil -} - -func InitHB() { - HBClient = &hbaseHandle.HBaseClient{ - Client: *DomainConfig.HBase.InitHB(), - } -} - -func InitMinio() error { - client, err := DomainConfig.MinIO.InitIO() - if err != nil { - return err - } - MinioClient.Client = client - MinioClient.Bucket = DomainConfig.MinIO.Bucket - - return nil -} diff --git a/applications/videoDomain/service/publish_action.go b/applications/videoDomain/service/publish_action.go deleted file mode 100644 index 09de9a77..00000000 --- a/applications/videoDomain/service/publish_action.go +++ /dev/null @@ -1,133 +0,0 @@ -package service - -import ( - "bytes" - "context" - "crypto/md5" - "encoding/hex" - "fmt" - "strconv" - "time" - - "github.com/TremblingV5/DouTok/applications/videoDomain/dal/model" - "github.com/TremblingV5/DouTok/applications/videoDomain/misc" - "github.com/TremblingV5/DouTok/pkg/LogBuilder" - "github.com/TremblingV5/DouTok/pkg/utils" -) - -type SavePublishService struct { - ctx context.Context -} - -func NewSavePublishService(ctx context.Context) *SavePublishService { - return &SavePublishService{ - ctx: ctx, - } -} - -func (s *SavePublishService) SavePublish(userId int64, title string, data []byte) error { - log := LogBuilder.InitLogBuilder() - defer log.Write(Logger) - log.Collect("user_id", strconv.FormatInt(userId, 10)) - - timestamp := time.Now().Unix() - - // 1. 上传封面和视频到OSS - hasher := md5.New() - hasher.Write([]byte(fmt.Sprint(userId) + title)) - filename := hex.EncodeToString(hasher.Sum(nil)) + ".mp4" - - if err := MinioClient.Put( - "video", filename, bytes.NewReader(data), len(data), - ); err != nil { - log.SetLogType("error") - log.SetMessage("Put video to OSS failed") - log.Collect("errMsg", err.Error()) - return err - } - - playUrl := "http://" + DomainConfig.MinIO.Endpoint + "/" + DomainConfig.MinIO.Bucket + "/doutok/video/" + filename - coverUrl := playUrl + "?x-oss-process=video/snapshot,t_30000,f_jpg,w_0,h_0,m_fast,ar_auto" - - // 2. 写入数据到MySQl - id, err := SaveVideo2DB( - uint64(userId), title, playUrl, coverUrl, - ) - if err != nil { - log.SetLogType("error") - log.SetMessage("Save video info to db failed") - log.Collect("errMsg", err.Error()) - return err - } - - // 3. 写入数据到HBase,分别写入publish表和feed表 - err = SaveVideo2HB(id, uint64(userId), title, playUrl, coverUrl, fmt.Sprint(timestamp)) - if err != nil { - return err - } - return nil -} - -func SaveVideo2DB(userId uint64, title string, playUrl string, coverUrl string) (uint64, error) { - newVideoId := utils.GetSnowFlakeId() - newVideo := model.Video{ - ID: uint64(newVideoId), - AuthorID: userId, - Title: title, - VideoUrl: playUrl, - CoverUrl: coverUrl, - FavCount: 0, - ComCount: 0, - } - - err := Video.Create(&newVideo) - - if err != nil { - return 0, err - } - - return uint64(newVideoId), nil -} - -// SaveVideo2HB TODO 这里的错误error需要处理 -func SaveVideo2HB(id uint64, userId uint64, title string, playUrl string, coverUrl string, timestamp string) error { - // newVideo := typedef.VideoInHB{ - // Id: int64(id), - // AuthorId: int64(user_id), - // AuthorName: "", - // Title: title, - // VideoUrl: play_url, - // CoverUrl: cover_url, - // Timestamp: timestamp, - // } - - timestampInt, _ := strconv.Atoi(timestamp) - publishRowkey := misc.FillUserId(fmt.Sprint(userId)) + misc.GetTimeRebound(int64(timestampInt)) - feedRowkey := misc.GetTimeRebound(int64(timestampInt)) + misc.FillUserId(fmt.Sprint(userId)) - - hbData := map[string]map[string][]byte{ - "data": { - "id": []byte(fmt.Sprint(id)), - "author_id": []byte(fmt.Sprint(userId)), - "author_name": []byte(""), - "title": []byte(title), - "video_url": []byte(playUrl), - "cover_url": []byte(coverUrl), - "timestamp": []byte(timestamp), - }, - } - - err := HBClient.Put( - "publish", publishRowkey, hbData, - ) - if err != nil { - return nil - } - err = HBClient.Put( - "feed", feedRowkey, hbData, - ) - if err != nil { - return nil - } - return nil -} diff --git a/applications/videoDomain/service/publish_list.go b/applications/videoDomain/service/publish_list.go deleted file mode 100644 index e88f9167..00000000 --- a/applications/videoDomain/service/publish_list.go +++ /dev/null @@ -1,45 +0,0 @@ -package service - -import ( - "context" - "fmt" - - tools "github.com/TremblingV5/DouTok/applications/videoDomain/misc" - "github.com/TremblingV5/DouTok/applications/videoDomain/typedef" - "github.com/TremblingV5/DouTok/pkg/hbaseHandle" - "github.com/TremblingV5/DouTok/pkg/misc" -) - -type QueryPublishListService struct { - ctx context.Context -} - -func NewQueryPublishListService(ctx context.Context) *QueryPublishListService { - return &QueryPublishListService{ctx: ctx} -} - -func (s *QueryPublishListService) QueryPublishListInHBase(userId int64) ([]*typedef.VideoInHB, error) { - userIdString := tools.FillUserId(fmt.Sprint(userId)) - - filters := hbaseHandle.GetFilterByRowKeyPrefix(userIdString) - - videoList, err := HBClient.Scan( - "publish", filters..., - ) - - var list []*typedef.VideoInHB - if err != nil { - return list, err - } - - for _, v := range videoList { - temp := typedef.VideoInHB{} - err := misc.Map2Struct4HB(v, &temp) - if err != nil { - continue - } - list = append(list, &temp) - } - - return list, nil -} diff --git a/applications/videoDomain/service/serialize.go b/applications/videoDomain/service/serialize.go deleted file mode 100644 index da08a144..00000000 --- a/applications/videoDomain/service/serialize.go +++ /dev/null @@ -1,50 +0,0 @@ -package service - -import ( - "encoding/json" - "fmt" - - "github.com/TremblingV5/DouTok/applications/videoDomain/typedef" - "github.com/TremblingV5/DouTok/kitex_gen/entity" -) - -func VideoList2String(list []typedef.VideoInHB) []string { - var res []string - - for _, v := range list { - r, err := json.Marshal(v) - if err != nil { - continue - } - res = append(res, string(r)) - } - - return res -} - -func String2VideoList(list []string) []typedef.VideoInHB { - var res []typedef.VideoInHB - - for _, v := range list { - temp := typedef.VideoInHB{} - err := json.Unmarshal([]byte(v), &temp) - if err != nil { - fmt.Println(err) - } - res = append(res, temp) - } - - return res -} - -func HBaseType2RPCType(v typedef.VideoInHB) *entity.Video { - return &entity.Video{ - Id: v.GetId(), - Author: &entity.User{ - Id: v.GetAuthorId(), - }, - Title: v.GetTitle(), - PlayUrl: v.GetVideoUrl(), - CoverUrl: v.GetCoverUrl(), - } -} diff --git a/applications/videoDomain/service/video.go b/applications/videoDomain/service/video.go deleted file mode 100644 index 5005afbc..00000000 --- a/applications/videoDomain/service/video.go +++ /dev/null @@ -1,50 +0,0 @@ -package service - -import ( - "context" - "github.com/TremblingV5/DouTok/applications/videoDomain/dal/model" -) - -type GetVideoService struct { - ctx context.Context -} - -func NewGetVideoService(ctx context.Context) *GetVideoService { - return &GetVideoService{ctx: ctx} -} - -func (s *GetVideoService) GetVideoByIdInRDB(userId uint64) (*model.Video, error) { - v, err := Do.Where( - Video.ID.Eq(userId), - ).First() - - if err != nil { - return v, err - } - - return v, nil -} - -func QueryVideoFromRBDById(id uint64) (*model.Video, error) { - v, err := Do.Where( - Video.ID.Eq(id), - ).First() - - if err != nil { - return v, err - } - - return v, nil -} - -func QuerySomeVideoFromRDBByIds(id ...uint64) ([]*model.Video, error) { - videos, err := Do.Where( - Video.ID.In(id...), - ).Find() - - if err != nil { - return videos, err - } - - return videos, nil -} diff --git a/config/commentDomain.yaml b/config/commentDomain.yaml deleted file mode 100644 index 00c6bff5..00000000 --- a/config/commentDomain.yaml +++ /dev/null @@ -1,51 +0,0 @@ -Global: - Source: "config(local)" - ChangeMe: "v1" - -JWT: - signingKey: "signingKey" - -Etcd: - Address: "localhost" - Port: 2379 - -Server: - Name: "DouTokCommentDomainServer" - Address: "127.0.0.1" - Port: 8090 - -Client: - Echo: true - Foo: "bar" - Servers: - - "127.0.0.1" - - "192.168.1.1" - -MySQL: - Host: "localhost" - Port: 3306 - Username: "admin" - Password: "root" - Database: "DouTok" - CharSet: "utf8mb4" - ParseTime: true - loc: "Local" - -Snowflake: - Node: 70 - -HBase: - Host: "localhost" - -Redis: - Host: "localhost" - Port: "6379" - Password: "root" - ComCntCache: - Num: 8 - ComTotalCntCache: - Num: 9 - -Otel: - Host: "82.156.171.8" - Port: 4317 \ No newline at end of file diff --git a/config/configStruct/comment.go b/config/configStruct/comment.go new file mode 100644 index 00000000..1f7117b7 --- /dev/null +++ b/config/configStruct/comment.go @@ -0,0 +1,25 @@ +package configStruct + +type CommentConfig struct { + Global struct { + Source string `yaml:"Source"` + ChangeMe string `yaml:"ChangeMe"` + } `yaml:"Global"` + JWT struct { + SigningKey string `yaml:"signingKey"` + } `yaml:"JWT"` + Etcd struct { + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Etcd"` + Server struct { + Name string `yaml:"Name"` + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Server"` + Client struct { + Echo bool `yaml:"Echo"` + Foo string `yaml:"Foo"` + Servers []string `yaml:"Servers"` + } `yaml:"Client"` +} diff --git a/config/configStruct/favorite.go b/config/configStruct/favorite.go new file mode 100644 index 00000000..2401a3b1 --- /dev/null +++ b/config/configStruct/favorite.go @@ -0,0 +1,25 @@ +package configStruct + +type FavoriteConfig struct { + Global struct { + Source string `yaml:"Source"` + ChangeMe string `yaml:"ChangeMe"` + } `yaml:"Global"` + JWT struct { + SigningKey string `yaml:"signingKey"` + } `yaml:"JWT"` + Etcd struct { + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Etcd"` + Server struct { + Name string `yaml:"Name"` + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Server"` + Client struct { + Echo bool `yaml:"Echo"` + Foo string `yaml:"Foo"` + Servers []string `yaml:"Servers"` + } `yaml:"Client"` +} diff --git a/config/configStruct/feed.go b/config/configStruct/feed.go new file mode 100644 index 00000000..23ed9d94 --- /dev/null +++ b/config/configStruct/feed.go @@ -0,0 +1,25 @@ +package configStruct + +type FeedConfig struct { + Global struct { + Source string `yaml:"Source"` + ChangeMe string `yaml:"ChangeMe"` + } `yaml:"Global"` + JWT struct { + SigningKey string `yaml:"signingKey"` + } `yaml:"JWT"` + Etcd struct { + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Etcd"` + Server struct { + Name string `yaml:"Name"` + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Server"` + Client struct { + Echo bool `yaml:"Echo"` + Foo string `yaml:"Foo"` + Servers []string `yaml:"Servers"` + } `yaml:"Client"` +} diff --git a/config/configStruct/hbase.go b/config/configStruct/hbase.go index 6eeff26d..e6ef3a41 100644 --- a/config/configStruct/hbase.go +++ b/config/configStruct/hbase.go @@ -1,16 +1,5 @@ package configStruct -import "github.com/tsuna/gohbase" - -type HBase struct { - Host string `env:"HBASE_HOST" envDefault:"localhost" configPath:"HBase.Host"` -} - -func (h *HBase) InitHB() *gohbase.Client { - c := gohbase.NewClient(h.Host) - return &c -} - type HBaseConfig struct { Host string `yaml:"host"` } diff --git a/config/configStruct/mysql.go b/config/configStruct/mysql.go index 39d4b645..9f5ffbbe 100644 --- a/config/configStruct/mysql.go +++ b/config/configStruct/mysql.go @@ -1,36 +1,5 @@ package configStruct -import ( - "fmt" - "gorm.io/driver/mysql" - "gorm.io/gorm" -) - -type MySQL struct { - Host string `env:"MYSQL_HOST" envDefault:"localhost" configPath:"MySQL.Host"` - Port int `env:"MYSQL_PORT" envDefault:"3306" configPath:"MySQL.Port"` - Username string `env:"MYSQL_USERNAME" envDefault:"root" configPath:"MySQL.Username"` - Password string `env:"MYSQL_PASSWORD" envDefault:"root" configPath:"MySQL.Password"` - Database string `env:"MYSQL_DATABASE" envDefault:"DouTok" configPath:"MySQL.Database"` - CharSet string `env:"MYSQL_CHARSET" envDefault:"utf8mb4" configPath:"MySQL.CharSet"` - ParseTime bool `env:"MYSQL_PARSETIME" envDefault:"true" configPath:"MySQL.ParseTime"` - Loc string `env:"MYSQL_LOC" envDefault:"Local" configPath:"MySQL.loc"` -} - -func (m *MySQL) InitDB() (*gorm.DB, error) { - Db, err := gorm.Open( - mysql.Open( - fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", - m.Username, m.Password, m.Host, m.Port, m.Database), - ), - &gorm.Config{ - PrepareStmt: true, - SkipDefaultTransaction: true, - }, - ) - return Db, err -} - type MySQLConfig struct { Host string `yaml:"host"` Port string `yaml:"port"` diff --git a/config/configStruct/publish.go b/config/configStruct/publish.go new file mode 100644 index 00000000..46a90814 --- /dev/null +++ b/config/configStruct/publish.go @@ -0,0 +1,25 @@ +package configStruct + +type PublishConfig struct { + Global struct { + Source string `yaml:"Source"` + ChangeMe string `yaml:"ChangeMe"` + } `yaml:"Global"` + JWT struct { + SigningKey string `yaml:"signingKey"` + } `yaml:"JWT"` + Etcd struct { + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Etcd"` + Server struct { + Name string `yaml:"Name"` + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Server"` + Client struct { + Echo bool `yaml:"Echo"` + Foo string `yaml:"Foo"` + Servers []string `yaml:"Servers"` + } `yaml:"Client"` +} diff --git a/config/configStruct/redis.go b/config/configStruct/redis.go index 845d372d..59853fe1 100644 --- a/config/configStruct/redis.go +++ b/config/configStruct/redis.go @@ -1,37 +1,8 @@ package configStruct -import ( - "context" - "fmt" - "github.com/go-redis/redis/v8" - "time" -) - -const DEFAULT_DATABASE = -1 - -type Redis struct { - Host string `env:"REDIS_HOST" envDefault:"localhost" configPath:"Redis.Host"` - Port string `env:"REDIS_PORT" envDefault:"6379" configPath:"Redis.Port"` - Password string `env:"REDIS_PASSWORD" envDefault:"root" configPath:"Redis.Password"` - // {db name 1}:{db num 1},{db name 2}:{db num 2} - Databases int `mapstructure:"Databases" default:"0"` -} - -func (r *Redis) InitRedisClient(database int) *redis.Client { - if database == DEFAULT_DATABASE { - database = r.Databases - } - client := redis.NewClient(&redis.Options{ - Addr: fmt.Sprintf("%s:%s", r.Host, r.Port), - Password: r.Password, - DB: database, - PoolSize: 20, - }) - ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() - if _, err := client.Ping(ctx).Result(); err != nil { - panic(err) - } - - return client +type RedisConfig struct { + Host string `yaml:"host"` + Port string `yaml:"port"` + Password string `yaml:"password"` + Databases map[string]int `yaml:"databases"` } diff --git a/config/configStruct/user.go b/config/configStruct/user.go new file mode 100644 index 00000000..bf6a0fd8 --- /dev/null +++ b/config/configStruct/user.go @@ -0,0 +1,25 @@ +package configStruct + +type UserConfig struct { + Global struct { + Source string `yaml:"Source"` + ChangeMe string `yaml:"ChangeMe"` + } `yaml:"Global"` + JWT struct { + SigningKey string `yaml:"signingKey"` + } `yaml:"JWT"` + Etcd struct { + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Etcd"` + Server struct { + Name string `yaml:"Name"` + Address string `yaml:"Address"` + Port string `yaml:"Port"` + } `yaml:"Server"` + Client struct { + Echo bool `yaml:"Echo"` + Foo string `yaml:"Foo"` + Servers []string `yaml:"Servers"` + } `yaml:"Client"` +} diff --git a/config/favoriteDomain.yaml b/config/favoriteDomain.yaml deleted file mode 100644 index 74397359..00000000 --- a/config/favoriteDomain.yaml +++ /dev/null @@ -1,54 +0,0 @@ -Global: - Source: "config(local)" - ChangeMe: "v1" - -JWT: - signingKey: "signingKey" - -Etcd: - Address: "localhost" - Port: 2379 - -Server: - Name: "DouTokFavoriteDomainServer" - Address: "127.0.0.1" - Port: 8092 - -Client: - Echo: true - Foo: "bar" - Servers: - - "127.0.0.1" - - "192.168.1" - -Snowflake: - Node: 602 - -MySQL: - Host: "localhost" - Port: 3306 - Username: "admin" - Password: "root" - Database: "DouTok" - CharSet: "utf8mb4" - ParseTime: true - loc: "Local" - -Redis: - Host: "localhost" - Port: 6379 - Password: "root" - FavCache: - Num: 3 - FavCntCache: - Num: 4 - FavTotalCountCache: - Num: 8 - - -Kafka: - Broker: "localhost:9092" - -Otel: - Host: "82.156.171.8" - Port: 4317 \ No newline at end of file diff --git a/config/messageDomain.yaml b/config/messageDomain.yaml deleted file mode 100644 index f821f646..00000000 --- a/config/messageDomain.yaml +++ /dev/null @@ -1,50 +0,0 @@ -Global: - Source: "config(local)" - ChangeMe: "v1" - -Etcd: - Address: "localhost" - Port: 2379 - -Server: - Name: "DouTokMessageDomainServer" - Address: "127.0.0.1" - Port: 8095 - -Client: - Echo: true - Foo: "bar" - Servers: - - "127.0.0.1" - - "192.168.1.1" - -Snowflake: - Node: 10 - -Hbase: - Host: "localhost" - Table: "message" - MessageNum: 50 - -Redis: - Host: "localhost" - Port: 6379 - Password: "root" - DataBases: 5 - -Kafka: - Brokers: - - "YOUR_OWN_IP:9092" - Topics: - - "message_1" -# - "message_2" - GroupIds: - - "message01" - - "message02" - - "message03" - - "message04" - - "message05" - -Otel: - Host: "82.156.171.8" - Port: 4317 \ No newline at end of file diff --git a/config/relationDomain.yaml b/config/relationDomain.yaml deleted file mode 100644 index 3ec51d26..00000000 --- a/config/relationDomain.yaml +++ /dev/null @@ -1,54 +0,0 @@ -Global: - Source: "config(local)" - ChangeMe: "v1" - -Etcd: - Address: "localhost" - Port: 2379 - -Server: - Name: "DouTokRelationDomainServer" - Address: "127.0.0.1" - Port: 8098 - -Client: - Echo: true - Foo: "bar" - Servers: - - "127.0.0.1" - - "192.168.1.1" - -Snowflake: - Node: 30 - -Redis: - Host: "localhost" - Port: 6379 - Password: "root" - DataBases: 6 - -Kafka: - Brokers: - - "YOUR_OWN_IP:9092" - Topics: - - "relation_1" -# - "relation_2" - GroupIds: - - "relation01" - - "relation02" - - "relation03" - - "relation04" - - "relation05" - -MySQL: - Host: "localhost" - Port: 3306 - Username: "admin" - Password: "root" - Database: "DouTok" - CharSet: "utf8mb4" - ParseTime: true - loc: "Local" -Otel: - Host: "82.156.171.8" - Port: 4317 \ No newline at end of file diff --git a/config/userDomain.yaml b/config/userDomain.yaml deleted file mode 100644 index c06d10c3..00000000 --- a/config/userDomain.yaml +++ /dev/null @@ -1,45 +0,0 @@ -Global: - Source: "config(local)" - ChangeMe: "v1" - -JWT: - signingKey: "signingKey" - -Etcd: - Address: "localhost" - Port: 2379 - -Server: - Name: "DouTokUserDomainServer" - Address: "127.0.0.1" - Port: 8100 - Argon2ID: - Memory: 64*1024 - Iterations: 3 - Parallelism: 2 - SaltLength: 16 - keyLength: 32 - -Client: - Echo: true - Foo: "bar" - Servers: - - "127.0.0.1" - - "192.168.1.1" - -Snowflake: - Node: 40 - -MySQL: - Host: "localhost" - Port: 3306 - Username: "admin" - Password: "root" - Database: "DouTok" - CharSet: "utf8mb4" - ParseTime: true - loc: "Local" - -Otel: - Host: "82.156.171.8" - Port: 4317 \ No newline at end of file diff --git a/config/videoDomain.yaml b/config/videoDomain.yaml deleted file mode 100644 index e1ee2309..00000000 --- a/config/videoDomain.yaml +++ /dev/null @@ -1,66 +0,0 @@ -Global: - Source: "config(local)" - ChangeMe: "v1" - -JWT: - signingKey: "signingKey" - -Etcd: - Address: "localhost" - Port: 2379 - -Server: - Name: "DouTokVideoDomainServer" - Address: "127.0.0.1" - Port: 8101 - -Client: - Echo: true - Foo: "bar" - Servers: - - "127.0.0.1" - - "192.168.1.1" - - -MySQL: - Host: "localhost" - Port: 3306 - Username: "admin" - Password: "root" - Database: "DouTok" - CharSet: "utf8mb4" - ParseTime: true - loc: "Local" - -HBase: - Host: "localhost" - -Snowflake: - Node: 501 - -OSS: - Endpoint: "oss-cn-shanghai.aliyuncs.com" - Key: "" - Secret: "" - Bucket: "DouTok-video" - Callback: "" - -Minio: - Endpoint: "localhost:9000" - Key: "root" - Secret: "rootroot" - Bucket: "DouTok" - Callback: "" - -Redis: - Host: "localhost" - Port: "6379" - Password: "root" - SendBox: - Num: 1 - MarkedTime: - Num: 2 - -Otel: - Host: "82.156.171.8" - Port: 4317 \ No newline at end of file diff --git a/kitex_gen/comment/comment.pb.fast.go b/kitex_gen/comment/comment.pb.fast.go deleted file mode 100644 index 5aee4bf4..00000000 --- a/kitex_gen/comment/comment.pb.fast.go +++ /dev/null @@ -1,738 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package comment - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DouyinCommentActionRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - case 4: - offset, err = x.fastReadField4(buf, _type) - if err != nil { - goto ReadFieldError - } - case 5: - offset, err = x.fastReadField5(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinCommentActionRequest[number], err) -} - -func (x *DouyinCommentActionRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinCommentActionRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinCommentActionRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.ActionType, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinCommentActionRequest) fastReadField4(buf []byte, _type int8) (offset int, err error) { - x.CommentText, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinCommentActionRequest) fastReadField5(buf []byte, _type int8) (offset int, err error) { - x.CommentId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinCommentActionResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinCommentActionResponse[number], err) -} - -func (x *DouyinCommentActionResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinCommentActionResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinCommentActionResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Comment - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.Comment = &v - return offset, nil -} - -func (x *DouyinCommentListRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinCommentListRequest[number], err) -} - -func (x *DouyinCommentListRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinCommentListResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinCommentListResponse[number], err) -} - -func (x *DouyinCommentListResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinCommentListResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinCommentListResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Comment - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.CommentList = append(x.CommentList, &v) - return offset, nil -} - -func (x *DouyinCommentCountRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinCommentCountRequest[number], err) -} - -func (x *DouyinCommentCountRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.VideoIdList = append(x.VideoIdList, v) - return offset, err - }) - return offset, err -} - -func (x *DouyinCommentCountResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinCommentCountResponse[number], err) -} - -func (x *DouyinCommentCountResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinCommentCountResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinCommentCountResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.Result == nil { - x.Result = make(map[int64]int64) - } - var key int64 - var value int64 - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - value, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }) - if err != nil { - return offset, err - } - x.Result[key] = value - return offset, nil -} - -func (x *DouyinCommentActionRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - offset += x.fastWriteField4(buf[offset:]) - offset += x.fastWriteField5(buf[offset:]) - return offset -} - -func (x *DouyinCommentActionRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DouyinCommentActionRequest) fastWriteField2(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.VideoId) - return offset -} - -func (x *DouyinCommentActionRequest) fastWriteField3(buf []byte) (offset int) { - if x.ActionType == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 3, x.ActionType) - return offset -} - -func (x *DouyinCommentActionRequest) fastWriteField4(buf []byte) (offset int) { - if x.CommentText == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 4, x.CommentText) - return offset -} - -func (x *DouyinCommentActionRequest) fastWriteField5(buf []byte) (offset int) { - if x.CommentId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 5, x.CommentId) - return offset -} - -func (x *DouyinCommentActionResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinCommentActionResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinCommentActionResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinCommentActionResponse) fastWriteField3(buf []byte) (offset int) { - if x.Comment == nil { - return offset - } - offset += fastpb.WriteMessage(buf[offset:], 3, x.Comment) - return offset -} - -func (x *DouyinCommentListRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DouyinCommentListRequest) fastWriteField1(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.VideoId) - return offset -} - -func (x *DouyinCommentListResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinCommentListResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinCommentListResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinCommentListResponse) fastWriteField3(buf []byte) (offset int) { - if x.CommentList == nil { - return offset - } - for i := range x.CommentList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.CommentList[i]) - } - return offset -} - -func (x *DouyinCommentCountRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DouyinCommentCountRequest) fastWriteField1(buf []byte) (offset int) { - if len(x.VideoIdList) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 1, len(x.VideoIdList), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.VideoIdList[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DouyinCommentCountResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinCommentCountResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinCommentCountResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinCommentCountResponse) fastWriteField3(buf []byte) (offset int) { - if x.Result == nil { - return offset - } - for k, v := range x.Result { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteInt64(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DouyinCommentActionRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - n += x.sizeField4() - n += x.sizeField5() - return n -} - -func (x *DouyinCommentActionRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DouyinCommentActionRequest) sizeField2() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.VideoId) - return n -} - -func (x *DouyinCommentActionRequest) sizeField3() (n int) { - if x.ActionType == 0 { - return n - } - n += fastpb.SizeInt32(3, x.ActionType) - return n -} - -func (x *DouyinCommentActionRequest) sizeField4() (n int) { - if x.CommentText == "" { - return n - } - n += fastpb.SizeString(4, x.CommentText) - return n -} - -func (x *DouyinCommentActionRequest) sizeField5() (n int) { - if x.CommentId == 0 { - return n - } - n += fastpb.SizeInt64(5, x.CommentId) - return n -} - -func (x *DouyinCommentActionResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinCommentActionResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinCommentActionResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinCommentActionResponse) sizeField3() (n int) { - if x.Comment == nil { - return n - } - n += fastpb.SizeMessage(3, x.Comment) - return n -} - -func (x *DouyinCommentListRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DouyinCommentListRequest) sizeField1() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.VideoId) - return n -} - -func (x *DouyinCommentListResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinCommentListResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinCommentListResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinCommentListResponse) sizeField3() (n int) { - if x.CommentList == nil { - return n - } - for i := range x.CommentList { - n += fastpb.SizeMessage(3, x.CommentList[i]) - } - return n -} - -func (x *DouyinCommentCountRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DouyinCommentCountRequest) sizeField1() (n int) { - if len(x.VideoIdList) == 0 { - return n - } - n += fastpb.SizeListPacked(1, len(x.VideoIdList), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.VideoIdList[numIdxOrVal]) - return n - }) - return n -} - -func (x *DouyinCommentCountResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinCommentCountResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinCommentCountResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinCommentCountResponse) sizeField3() (n int) { - if x.Result == nil { - return n - } - for k, v := range x.Result { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeInt64(numIdxOrVal, v) - return n - }) - } - return n -} - -var fieldIDToName_DouyinCommentActionRequest = map[int32]string{ - 1: "UserId", - 2: "VideoId", - 3: "ActionType", - 4: "CommentText", - 5: "CommentId", -} - -var fieldIDToName_DouyinCommentActionResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "Comment", -} - -var fieldIDToName_DouyinCommentListRequest = map[int32]string{ - 1: "VideoId", -} - -var fieldIDToName_DouyinCommentListResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "CommentList", -} - -var fieldIDToName_DouyinCommentCountRequest = map[int32]string{ - 1: "VideoIdList", -} - -var fieldIDToName_DouyinCommentCountResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "Result", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/comment/comment.pb.go b/kitex_gen/comment/comment.pb.go index fd212919..7491f54a 100644 --- a/kitex_gen/comment/comment.pb.go +++ b/kitex_gen/comment/comment.pb.go @@ -1,14 +1,14 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 +// protoc-gen-go v1.28.0 +// protoc v3.19.4 // source: comment.proto package comment import ( context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" + user "github.com/TremblingV5/DouTok/kitex_gen/user" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -106,9 +106,9 @@ type DouyinCommentActionResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - Comment *entity.Comment `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"` // 评论成功返回评论内容,不需要重新拉取整个列表 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + Comment *Comment `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"` // 评论成功返回评论内容,不需要重新拉取整个列表 } func (x *DouyinCommentActionResponse) Reset() { @@ -157,7 +157,7 @@ func (x *DouyinCommentActionResponse) GetStatusMsg() string { return "" } -func (x *DouyinCommentActionResponse) GetComment() *entity.Comment { +func (x *DouyinCommentActionResponse) GetComment() *Comment { if x != nil { return x.Comment } @@ -216,9 +216,9 @@ type DouyinCommentListResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - CommentList []*entity.Comment `protobuf:"bytes,3,rep,name=comment_list,json=commentList,proto3" json:"comment_list,omitempty"` // 评论列表 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + CommentList []*Comment `protobuf:"bytes,3,rep,name=comment_list,json=commentList,proto3" json:"comment_list,omitempty"` // 评论列表 } func (x *DouyinCommentListResponse) Reset() { @@ -267,13 +267,100 @@ func (x *DouyinCommentListResponse) GetStatusMsg() string { return "" } -func (x *DouyinCommentListResponse) GetCommentList() []*entity.Comment { +func (x *DouyinCommentListResponse) GetCommentList() []*Comment { if x != nil { return x.CommentList } return nil } +type Comment struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 视频评论id + User *user.User `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` // 评论用户信息 + Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` // 评论内容 + CreateDate string `protobuf:"bytes,4,opt,name=create_date,json=createDate,proto3" json:"create_date,omitempty"` // 评论发布日期,格式 mm-dd + LikeCount int64 `protobuf:"varint,5,opt,name=like_count,json=likeCount,proto3" json:"like_count,omitempty"` // 该评论的点赞数 + TeaseCount int64 `protobuf:"varint,6,opt,name=tease_count,json=teaseCount,proto3" json:"tease_count,omitempty"` // 该评论diss数量 +} + +func (x *Comment) Reset() { + *x = Comment{} + if protoimpl.UnsafeEnabled { + mi := &file_comment_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Comment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Comment) ProtoMessage() {} + +func (x *Comment) ProtoReflect() protoreflect.Message { + mi := &file_comment_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Comment.ProtoReflect.Descriptor instead. +func (*Comment) Descriptor() ([]byte, []int) { + return file_comment_proto_rawDescGZIP(), []int{4} +} + +func (x *Comment) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Comment) GetUser() *user.User { + if x != nil { + return x.User + } + return nil +} + +func (x *Comment) GetContent() string { + if x != nil { + return x.Content + } + return "" +} + +func (x *Comment) GetCreateDate() string { + if x != nil { + return x.CreateDate + } + return "" +} + +func (x *Comment) GetLikeCount() int64 { + if x != nil { + return x.LikeCount + } + return 0 +} + +func (x *Comment) GetTeaseCount() int64 { + if x != nil { + return x.TeaseCount + } + return 0 +} + type DouyinCommentCountRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -285,7 +372,7 @@ type DouyinCommentCountRequest struct { func (x *DouyinCommentCountRequest) Reset() { *x = DouyinCommentCountRequest{} if protoimpl.UnsafeEnabled { - mi := &file_comment_proto_msgTypes[4] + mi := &file_comment_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -298,7 +385,7 @@ func (x *DouyinCommentCountRequest) String() string { func (*DouyinCommentCountRequest) ProtoMessage() {} func (x *DouyinCommentCountRequest) ProtoReflect() protoreflect.Message { - mi := &file_comment_proto_msgTypes[4] + mi := &file_comment_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -311,7 +398,7 @@ func (x *DouyinCommentCountRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DouyinCommentCountRequest.ProtoReflect.Descriptor instead. func (*DouyinCommentCountRequest) Descriptor() ([]byte, []int) { - return file_comment_proto_rawDescGZIP(), []int{4} + return file_comment_proto_rawDescGZIP(), []int{5} } func (x *DouyinCommentCountRequest) GetVideoIdList() []int64 { @@ -334,7 +421,7 @@ type DouyinCommentCountResponse struct { func (x *DouyinCommentCountResponse) Reset() { *x = DouyinCommentCountResponse{} if protoimpl.UnsafeEnabled { - mi := &file_comment_proto_msgTypes[5] + mi := &file_comment_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -347,7 +434,7 @@ func (x *DouyinCommentCountResponse) String() string { func (*DouyinCommentCountResponse) ProtoMessage() {} func (x *DouyinCommentCountResponse) ProtoReflect() protoreflect.Message { - mi := &file_comment_proto_msgTypes[5] + mi := &file_comment_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -360,7 +447,7 @@ func (x *DouyinCommentCountResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DouyinCommentCountResponse.ProtoReflect.Descriptor instead. func (*DouyinCommentCountResponse) Descriptor() ([]byte, []int) { - return file_comment_proto_rawDescGZIP(), []int{5} + return file_comment_proto_rawDescGZIP(), []int{6} } func (x *DouyinCommentCountResponse) GetStatusCode() int32 { @@ -388,77 +475,95 @@ var File_comment_proto protoreflect.FileDescriptor var file_comment_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, 0x01, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, 0x69, - 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, - 0x64, 0x12, 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, - 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x21, 0x0a, - 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x65, 0x78, 0x74, - 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, - 0x8b, 0x01, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, - 0x6e, 0x74, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, - 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, - 0x73, 0x67, 0x12, 0x29, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x6f, 0x6d, - 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x38, 0x0a, - 0x1b, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, - 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, - 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, - 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x22, 0x92, 0x01, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, - 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x32, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, - 0x65, 0x6e, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, - 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, - 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x42, 0x0a, 0x1c, - 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0d, - 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x03, 0x52, 0x0b, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x4c, 0x69, 0x73, 0x74, - 0x22, 0xe6, 0x01, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, - 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, - 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, - 0x73, 0x67, 0x12, 0x4a, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x6f, 0x75, - 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0x39, - 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, - 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, - 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0xce, 0x01, 0x0a, 0x0e, 0x43, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x0d, - 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, - 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, - 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x24, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x6f, - 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6c, 0x69, 0x73, - 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, - 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, 0x65, - 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x1a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb6, 0x01, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, + 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, + 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, + 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x54, 0x65, 0x78, 0x74, 0x12, 0x1d, + 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x09, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x8c, 0x01, + 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, + 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, + 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, + 0x12, 0x2a, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x10, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, + 0x65, 0x6e, 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x38, 0x0a, 0x1b, + 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6c, + 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x76, + 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, + 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x22, 0x93, 0x01, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, 0x69, + 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x33, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, + 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xb4, 0x01, 0x0a, + 0x07, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, + 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x64, 0x61, 0x74, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x44, + 0x61, 0x74, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x69, 0x6b, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6c, 0x69, 0x6b, 0x65, 0x43, 0x6f, 0x75, + 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x74, 0x65, 0x61, 0x73, 0x65, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x22, 0x42, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0d, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, + 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0b, 0x76, 0x69, 0x64, 0x65, + 0x6f, 0x49, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xe6, 0x01, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, + 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x4a, 0x0a, 0x06, 0x72, 0x65, 0x73, + 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x32, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, + 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x32, 0xad, 0x02, 0x0a, 0x0e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x53, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x0d, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x64, + 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x0b, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x64, + 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6c, 0x69, + 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x63, 0x6f, 0x6d, + 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, + 0x65, 0x6e, 0x74, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x5d, 0x0a, 0x0c, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x25, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x64, 0x6f, 0x75, 0x79, + 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, + 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, + 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, + 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, + 0x6b, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, + 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -473,30 +578,34 @@ func file_comment_proto_rawDescGZIP() []byte { return file_comment_proto_rawDescData } -var file_comment_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_comment_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_comment_proto_goTypes = []interface{}{ (*DouyinCommentActionRequest)(nil), // 0: comment.douyin_comment_action_request (*DouyinCommentActionResponse)(nil), // 1: comment.douyin_comment_action_response (*DouyinCommentListRequest)(nil), // 2: comment.douyin_comment_list_request (*DouyinCommentListResponse)(nil), // 3: comment.douyin_comment_list_response - (*DouyinCommentCountRequest)(nil), // 4: comment.douyin_comment_count_request - (*DouyinCommentCountResponse)(nil), // 5: comment.douyin_comment_count_response - nil, // 6: comment.douyin_comment_count_response.ResultEntry - (*entity.Comment)(nil), // 7: entity.Comment + (*Comment)(nil), // 4: comment.Comment + (*DouyinCommentCountRequest)(nil), // 5: comment.douyin_comment_count_request + (*DouyinCommentCountResponse)(nil), // 6: comment.douyin_comment_count_response + nil, // 7: comment.douyin_comment_count_response.ResultEntry + (*user.User)(nil), // 8: user.User } var file_comment_proto_depIdxs = []int32{ - 7, // 0: comment.douyin_comment_action_response.comment:type_name -> entity.Comment - 7, // 1: comment.douyin_comment_list_response.comment_list:type_name -> entity.Comment - 6, // 2: comment.douyin_comment_count_response.result:type_name -> comment.douyin_comment_count_response.ResultEntry - 0, // 3: comment.CommentService.CommentAction:input_type -> comment.douyin_comment_action_request - 2, // 4: comment.CommentService.CommentList:input_type -> comment.douyin_comment_list_request - 1, // 5: comment.CommentService.CommentAction:output_type -> comment.douyin_comment_action_response - 3, // 6: comment.CommentService.CommentList:output_type -> comment.douyin_comment_list_response - 5, // [5:7] is the sub-list for method output_type - 3, // [3:5] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 4, // 0: comment.douyin_comment_action_response.comment:type_name -> comment.Comment + 4, // 1: comment.douyin_comment_list_response.comment_list:type_name -> comment.Comment + 8, // 2: comment.Comment.user:type_name -> user.User + 7, // 3: comment.douyin_comment_count_response.result:type_name -> comment.douyin_comment_count_response.ResultEntry + 0, // 4: comment.CommentService.CommentAction:input_type -> comment.douyin_comment_action_request + 2, // 5: comment.CommentService.CommentList:input_type -> comment.douyin_comment_list_request + 5, // 6: comment.CommentService.CommentCount:input_type -> comment.douyin_comment_count_request + 1, // 7: comment.CommentService.CommentAction:output_type -> comment.douyin_comment_action_response + 3, // 8: comment.CommentService.CommentList:output_type -> comment.douyin_comment_list_response + 6, // 9: comment.CommentService.CommentCount:output_type -> comment.douyin_comment_count_response + 7, // [7:10] is the sub-list for method output_type + 4, // [4:7] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_comment_proto_init() } @@ -554,7 +663,7 @@ func file_comment_proto_init() { } } file_comment_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DouyinCommentCountRequest); i { + switch v := v.(*Comment); i { case 0: return &v.state case 1: @@ -566,6 +675,18 @@ func file_comment_proto_init() { } } file_comment_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DouyinCommentCountRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_comment_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DouyinCommentCountResponse); i { case 0: return &v.state @@ -584,7 +705,7 @@ func file_comment_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_comment_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, @@ -600,9 +721,10 @@ func file_comment_proto_init() { var _ context.Context -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. type CommentService interface { CommentAction(ctx context.Context, req *DouyinCommentActionRequest) (res *DouyinCommentActionResponse, err error) CommentList(ctx context.Context, req *DouyinCommentListRequest) (res *DouyinCommentListResponse, err error) + CommentCount(ctx context.Context, req *DouyinCommentCountRequest) (res *DouyinCommentCountResponse, err error) } diff --git a/kitex_gen/comment/commentservice/client.go b/kitex_gen/comment/commentservice/client.go index 6569038b..243532bd 100644 --- a/kitex_gen/comment/commentservice/client.go +++ b/kitex_gen/comment/commentservice/client.go @@ -1,18 +1,19 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package commentservice import ( "context" - comment "github.com/TremblingV5/DouTok/kitex_gen/comment" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { CommentAction(ctx context.Context, Req *comment.DouyinCommentActionRequest, callOptions ...callopt.Option) (r *comment.DouyinCommentActionResponse, err error) CommentList(ctx context.Context, Req *comment.DouyinCommentListRequest, callOptions ...callopt.Option) (r *comment.DouyinCommentListResponse, err error) + CommentCount(ctx context.Context, Req *comment.DouyinCommentCountRequest, callOptions ...callopt.Option) (r *comment.DouyinCommentCountResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -53,3 +54,8 @@ func (p *kCommentServiceClient) CommentList(ctx context.Context, Req *comment.Do ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.CommentList(ctx, Req) } + +func (p *kCommentServiceClient) CommentCount(ctx context.Context, Req *comment.DouyinCommentCountRequest, callOptions ...callopt.Option) (r *comment.DouyinCommentCountResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.CommentCount(ctx, Req) +} diff --git a/kitex_gen/comment/commentservice/commentservice.go b/kitex_gen/comment/commentservice/commentservice.go index d7621a78..f5dcb47a 100644 --- a/kitex_gen/comment/commentservice/commentservice.go +++ b/kitex_gen/comment/commentservice/commentservice.go @@ -1,15 +1,15 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package commentservice import ( "context" "fmt" - comment "github.com/TremblingV5/DouTok/kitex_gen/comment" - client "github.com/cloudwego/kitex/client" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" + "github.com/cloudwego/kitex/pkg/streaming" + "google.golang.org/protobuf/proto" ) func serviceInfo() *kitex.ServiceInfo { @@ -24,6 +24,7 @@ func NewServiceInfo() *kitex.ServiceInfo { methods := map[string]kitex.MethodInfo{ "CommentAction": kitex.NewMethodInfo(commentActionHandler, newCommentActionArgs, newCommentActionResult, false), "CommentList": kitex.NewMethodInfo(commentListHandler, newCommentListArgs, newCommentListResult, false), + "CommentCount": kitex.NewMethodInfo(commentCountHandler, newCommentCountArgs, newCommentCountResult, false), } extra := map[string]interface{}{ "PackageName": "comment", @@ -33,7 +34,7 @@ func NewServiceInfo() *kitex.ServiceInfo { HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", + KiteXGenVersion: "v0.3.4", Extra: extra, } return svcInfo @@ -76,27 +77,6 @@ type CommentActionArgs struct { Req *comment.DouyinCommentActionRequest } -func (p *CommentActionArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(comment.DouyinCommentActionRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *CommentActionArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *CommentActionArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *CommentActionArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in CommentActionArgs") @@ -132,27 +112,6 @@ type CommentActionResult struct { var CommentActionResult_Success_DEFAULT *comment.DouyinCommentActionResponse -func (p *CommentActionResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(comment.DouyinCommentActionResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *CommentActionResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *CommentActionResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - func (p *CommentActionResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { return out, fmt.Errorf("No req in CommentActionResult") @@ -221,27 +180,6 @@ type CommentListArgs struct { Req *comment.DouyinCommentListRequest } -func (p *CommentListArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(comment.DouyinCommentListRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *CommentListArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *CommentListArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *CommentListArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in CommentListArgs") @@ -277,36 +215,118 @@ type CommentListResult struct { var CommentListResult_Success_DEFAULT *comment.DouyinCommentListResponse -func (p *CommentListResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { +func (p *CommentListResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { - p.Success = new(comment.DouyinCommentListResponse) + return out, fmt.Errorf("No req in CommentListResult") } - return p.Success.FastRead(buf, _type, number) + return proto.Marshal(p.Success) } -func (p *CommentListResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 +func (p *CommentListResult) Unmarshal(in []byte) error { + msg := new(comment.DouyinCommentListResponse) + if err := proto.Unmarshal(in, msg); err != nil { + return err } - return p.Success.FastWrite(buf) + p.Success = msg + return nil } -func (p *CommentListResult) Size() (n int) { +func (p *CommentListResult) GetSuccess() *comment.DouyinCommentListResponse { if !p.IsSetSuccess() { - return 0 + return CommentListResult_Success_DEFAULT } - return p.Success.Size() + return p.Success } -func (p *CommentListResult) Marshal(out []byte) ([]byte, error) { +func (p *CommentListResult) SetSuccess(x interface{}) { + p.Success = x.(*comment.DouyinCommentListResponse) +} + +func (p *CommentListResult) IsSetSuccess() bool { + return p.Success != nil +} + +func commentCountHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(comment.DouyinCommentCountRequest) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(comment.CommentService).CommentCount(ctx, req) + if err != nil { + return err + } + if err := st.SendMsg(resp); err != nil { + return err + } + case *CommentCountArgs: + success, err := handler.(comment.CommentService).CommentCount(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*CommentCountResult) + realResult.Success = success + } + return nil +} +func newCommentCountArgs() interface{} { + return &CommentCountArgs{} +} + +func newCommentCountResult() interface{} { + return &CommentCountResult{} +} + +type CommentCountArgs struct { + Req *comment.DouyinCommentCountRequest +} + +func (p *CommentCountArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, fmt.Errorf("No req in CommentCountArgs") + } + return proto.Marshal(p.Req) +} + +func (p *CommentCountArgs) Unmarshal(in []byte) error { + msg := new(comment.DouyinCommentCountRequest) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var CommentCountArgs_Req_DEFAULT *comment.DouyinCommentCountRequest + +func (p *CommentCountArgs) GetReq() *comment.DouyinCommentCountRequest { + if !p.IsSetReq() { + return CommentCountArgs_Req_DEFAULT + } + return p.Req +} + +func (p *CommentCountArgs) IsSetReq() bool { + return p.Req != nil +} + +type CommentCountResult struct { + Success *comment.DouyinCommentCountResponse +} + +var CommentCountResult_Success_DEFAULT *comment.DouyinCommentCountResponse + +func (p *CommentCountResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in CommentListResult") + return out, fmt.Errorf("No req in CommentCountResult") } return proto.Marshal(p.Success) } -func (p *CommentListResult) Unmarshal(in []byte) error { - msg := new(comment.DouyinCommentListResponse) +func (p *CommentCountResult) Unmarshal(in []byte) error { + msg := new(comment.DouyinCommentCountResponse) if err := proto.Unmarshal(in, msg); err != nil { return err } @@ -314,18 +334,18 @@ func (p *CommentListResult) Unmarshal(in []byte) error { return nil } -func (p *CommentListResult) GetSuccess() *comment.DouyinCommentListResponse { +func (p *CommentCountResult) GetSuccess() *comment.DouyinCommentCountResponse { if !p.IsSetSuccess() { - return CommentListResult_Success_DEFAULT + return CommentCountResult_Success_DEFAULT } return p.Success } -func (p *CommentListResult) SetSuccess(x interface{}) { - p.Success = x.(*comment.DouyinCommentListResponse) +func (p *CommentCountResult) SetSuccess(x interface{}) { + p.Success = x.(*comment.DouyinCommentCountResponse) } -func (p *CommentListResult) IsSetSuccess() bool { +func (p *CommentCountResult) IsSetSuccess() bool { return p.Success != nil } @@ -358,3 +378,13 @@ func (p *kClient) CommentList(ctx context.Context, Req *comment.DouyinCommentLis } return _result.GetSuccess(), nil } + +func (p *kClient) CommentCount(ctx context.Context, Req *comment.DouyinCommentCountRequest) (r *comment.DouyinCommentCountResponse, err error) { + var _args CommentCountArgs + _args.Req = Req + var _result CommentCountResult + if err = p.c.Call(ctx, "CommentCount", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/kitex_gen/comment/commentservice/invoker.go b/kitex_gen/comment/commentservice/invoker.go index 66e44d1f..0197aa3d 100644 --- a/kitex_gen/comment/commentservice/invoker.go +++ b/kitex_gen/comment/commentservice/invoker.go @@ -1,10 +1,10 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package commentservice import ( - comment "github.com/TremblingV5/DouTok/kitex_gen/comment" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/cloudwego/kitex/server" ) // NewInvoker creates a server.Invoker with the given handler and options. diff --git a/kitex_gen/comment/commentservice/server.go b/kitex_gen/comment/commentservice/server.go index dc8247b9..979db802 100644 --- a/kitex_gen/comment/commentservice/server.go +++ b/kitex_gen/comment/commentservice/server.go @@ -1,9 +1,9 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package commentservice import ( - comment "github.com/TremblingV5/DouTok/kitex_gen/comment" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/comment" + "github.com/cloudwego/kitex/server" ) // NewServer creates a server.Server with the given handler and options. diff --git a/kitex_gen/commentDomain/commentDomain.pb.fast.go b/kitex_gen/commentDomain/commentDomain.pb.fast.go deleted file mode 100644 index 71d852f6..00000000 --- a/kitex_gen/commentDomain/commentDomain.pb.fast.go +++ /dev/null @@ -1,828 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package commentDomain - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DoutokAddCommentReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddCommentReq[number], err) -} - -func (x *DoutokAddCommentReq) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddCommentReq) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddCommentReq) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.CommentText, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokAddCommentResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddCommentResp[number], err) -} - -func (x *DoutokAddCommentResp) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokAddCommentResp) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokAddCommentResp) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Comment - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.Comment = &v - return offset, nil -} - -func (x *DoutokRmCommentReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokRmCommentReq[number], err) -} - -func (x *DoutokRmCommentReq) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokRmCommentReq) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokRmCommentReq) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.CommentId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListCommentReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListCommentReq[number], err) -} - -func (x *DoutokListCommentReq) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListCommentReq) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListCommentResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListCommentResp[number], err) -} - -func (x *DoutokListCommentResp) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokListCommentResp) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokListCommentResp) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Comment - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.CommentList = append(x.CommentList, &v) - return offset, nil -} - -func (x *DoutokCountCommentReq) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCountCommentReq[number], err) -} - -func (x *DoutokCountCommentReq) fastReadField1(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.VideoIdList = append(x.VideoIdList, v) - return offset, err - }) - return offset, err -} - -func (x *DoutokCountCommentResp) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCountCommentResp[number], err) -} - -func (x *DoutokCountCommentResp) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokCountCommentResp) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokCountCommentResp) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.CommentCount == nil { - x.CommentCount = make(map[int64]int64) - } - var key int64 - var value int64 - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - value, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }) - if err != nil { - return offset, err - } - x.CommentCount[key] = value - return offset, nil -} - -func (x *DoutokAddCommentReq) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokAddCommentReq) fastWriteField1(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.VideoId) - return offset -} - -func (x *DoutokAddCommentReq) fastWriteField2(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.UserId) - return offset -} - -func (x *DoutokAddCommentReq) fastWriteField3(buf []byte) (offset int) { - if x.CommentText == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 3, x.CommentText) - return offset -} - -func (x *DoutokAddCommentResp) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokAddCommentResp) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokAddCommentResp) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokAddCommentResp) fastWriteField3(buf []byte) (offset int) { - if x.Comment == nil { - return offset - } - offset += fastpb.WriteMessage(buf[offset:], 3, x.Comment) - return offset -} - -func (x *DoutokRmCommentReq) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokRmCommentReq) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DoutokRmCommentReq) fastWriteField2(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.VideoId) - return offset -} - -func (x *DoutokRmCommentReq) fastWriteField3(buf []byte) (offset int) { - if x.CommentId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 3, x.CommentId) - return offset -} - -func (x *DoutokListCommentReq) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokListCommentReq) fastWriteField1(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.VideoId) - return offset -} - -func (x *DoutokListCommentReq) fastWriteField2(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.UserId) - return offset -} - -func (x *DoutokListCommentResp) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokListCommentResp) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokListCommentResp) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokListCommentResp) fastWriteField3(buf []byte) (offset int) { - if x.CommentList == nil { - return offset - } - for i := range x.CommentList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.CommentList[i]) - } - return offset -} - -func (x *DoutokCountCommentReq) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DoutokCountCommentReq) fastWriteField1(buf []byte) (offset int) { - if len(x.VideoIdList) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 1, len(x.VideoIdList), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.VideoIdList[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DoutokCountCommentResp) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokCountCommentResp) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokCountCommentResp) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokCountCommentResp) fastWriteField3(buf []byte) (offset int) { - if x.CommentCount == nil { - return offset - } - for k, v := range x.CommentCount { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteInt64(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DoutokAddCommentReq) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokAddCommentReq) sizeField1() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.VideoId) - return n -} - -func (x *DoutokAddCommentReq) sizeField2() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.UserId) - return n -} - -func (x *DoutokAddCommentReq) sizeField3() (n int) { - if x.CommentText == "" { - return n - } - n += fastpb.SizeString(3, x.CommentText) - return n -} - -func (x *DoutokAddCommentResp) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokAddCommentResp) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokAddCommentResp) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokAddCommentResp) sizeField3() (n int) { - if x.Comment == nil { - return n - } - n += fastpb.SizeMessage(3, x.Comment) - return n -} - -func (x *DoutokRmCommentReq) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokRmCommentReq) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DoutokRmCommentReq) sizeField2() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.VideoId) - return n -} - -func (x *DoutokRmCommentReq) sizeField3() (n int) { - if x.CommentId == 0 { - return n - } - n += fastpb.SizeInt64(3, x.CommentId) - return n -} - -func (x *DoutokListCommentReq) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokListCommentReq) sizeField1() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.VideoId) - return n -} - -func (x *DoutokListCommentReq) sizeField2() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.UserId) - return n -} - -func (x *DoutokListCommentResp) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokListCommentResp) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokListCommentResp) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokListCommentResp) sizeField3() (n int) { - if x.CommentList == nil { - return n - } - for i := range x.CommentList { - n += fastpb.SizeMessage(3, x.CommentList[i]) - } - return n -} - -func (x *DoutokCountCommentReq) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DoutokCountCommentReq) sizeField1() (n int) { - if len(x.VideoIdList) == 0 { - return n - } - n += fastpb.SizeListPacked(1, len(x.VideoIdList), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.VideoIdList[numIdxOrVal]) - return n - }) - return n -} - -func (x *DoutokCountCommentResp) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokCountCommentResp) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokCountCommentResp) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokCountCommentResp) sizeField3() (n int) { - if x.CommentCount == nil { - return n - } - for k, v := range x.CommentCount { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeInt64(numIdxOrVal, v) - return n - }) - } - return n -} - -var fieldIDToName_DoutokAddCommentReq = map[int32]string{ - 1: "VideoId", - 2: "UserId", - 3: "CommentText", -} - -var fieldIDToName_DoutokAddCommentResp = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "Comment", -} - -var fieldIDToName_DoutokRmCommentReq = map[int32]string{ - 1: "UserId", - 2: "VideoId", - 3: "CommentId", -} - -var fieldIDToName_DoutokListCommentReq = map[int32]string{ - 1: "VideoId", - 2: "UserId", -} - -var fieldIDToName_DoutokListCommentResp = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "CommentList", -} - -var fieldIDToName_DoutokCountCommentReq = map[int32]string{ - 1: "VideoIdList", -} - -var fieldIDToName_DoutokCountCommentResp = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "CommentCount", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/commentDomain/commentDomain.pb.go b/kitex_gen/commentDomain/commentDomain.pb.go deleted file mode 100644 index d486efe9..00000000 --- a/kitex_gen/commentDomain/commentDomain.pb.go +++ /dev/null @@ -1,699 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 -// source: commentDomain.proto - -package commentDomain - -import ( - context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type DoutokAddCommentReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - VideoId int64 `protobuf:"varint,1,opt,name=video_id,json=videoId,proto3" json:"video_id,omitempty"` - UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - CommentText string `protobuf:"bytes,3,opt,name=comment_text,json=commentText,proto3" json:"comment_text,omitempty"` -} - -func (x *DoutokAddCommentReq) Reset() { - *x = DoutokAddCommentReq{} - if protoimpl.UnsafeEnabled { - mi := &file_commentDomain_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddCommentReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddCommentReq) ProtoMessage() {} - -func (x *DoutokAddCommentReq) ProtoReflect() protoreflect.Message { - mi := &file_commentDomain_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddCommentReq.ProtoReflect.Descriptor instead. -func (*DoutokAddCommentReq) Descriptor() ([]byte, []int) { - return file_commentDomain_proto_rawDescGZIP(), []int{0} -} - -func (x *DoutokAddCommentReq) GetVideoId() int64 { - if x != nil { - return x.VideoId - } - return 0 -} - -func (x *DoutokAddCommentReq) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokAddCommentReq) GetCommentText() string { - if x != nil { - return x.CommentText - } - return "" -} - -type DoutokAddCommentResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - Comment *entity.Comment `protobuf:"bytes,3,opt,name=comment,proto3" json:"comment,omitempty"` -} - -func (x *DoutokAddCommentResp) Reset() { - *x = DoutokAddCommentResp{} - if protoimpl.UnsafeEnabled { - mi := &file_commentDomain_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddCommentResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddCommentResp) ProtoMessage() {} - -func (x *DoutokAddCommentResp) ProtoReflect() protoreflect.Message { - mi := &file_commentDomain_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddCommentResp.ProtoReflect.Descriptor instead. -func (*DoutokAddCommentResp) Descriptor() ([]byte, []int) { - return file_commentDomain_proto_rawDescGZIP(), []int{1} -} - -func (x *DoutokAddCommentResp) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokAddCommentResp) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokAddCommentResp) GetComment() *entity.Comment { - if x != nil { - return x.Comment - } - return nil -} - -type DoutokRmCommentReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - VideoId int64 `protobuf:"varint,2,opt,name=video_id,json=videoId,proto3" json:"video_id,omitempty"` - CommentId int64 `protobuf:"varint,3,opt,name=comment_id,json=commentId,proto3" json:"comment_id,omitempty"` -} - -func (x *DoutokRmCommentReq) Reset() { - *x = DoutokRmCommentReq{} - if protoimpl.UnsafeEnabled { - mi := &file_commentDomain_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokRmCommentReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokRmCommentReq) ProtoMessage() {} - -func (x *DoutokRmCommentReq) ProtoReflect() protoreflect.Message { - mi := &file_commentDomain_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokRmCommentReq.ProtoReflect.Descriptor instead. -func (*DoutokRmCommentReq) Descriptor() ([]byte, []int) { - return file_commentDomain_proto_rawDescGZIP(), []int{2} -} - -func (x *DoutokRmCommentReq) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokRmCommentReq) GetVideoId() int64 { - if x != nil { - return x.VideoId - } - return 0 -} - -func (x *DoutokRmCommentReq) GetCommentId() int64 { - if x != nil { - return x.CommentId - } - return 0 -} - -type DoutokListCommentReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - VideoId int64 `protobuf:"varint,1,opt,name=video_id,json=videoId,proto3" json:"video_id,omitempty"` - UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` -} - -func (x *DoutokListCommentReq) Reset() { - *x = DoutokListCommentReq{} - if protoimpl.UnsafeEnabled { - mi := &file_commentDomain_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListCommentReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListCommentReq) ProtoMessage() {} - -func (x *DoutokListCommentReq) ProtoReflect() protoreflect.Message { - mi := &file_commentDomain_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListCommentReq.ProtoReflect.Descriptor instead. -func (*DoutokListCommentReq) Descriptor() ([]byte, []int) { - return file_commentDomain_proto_rawDescGZIP(), []int{3} -} - -func (x *DoutokListCommentReq) GetVideoId() int64 { - if x != nil { - return x.VideoId - } - return 0 -} - -func (x *DoutokListCommentReq) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type DoutokListCommentResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - CommentList []*entity.Comment `protobuf:"bytes,3,rep,name=comment_list,json=commentList,proto3" json:"comment_list,omitempty"` -} - -func (x *DoutokListCommentResp) Reset() { - *x = DoutokListCommentResp{} - if protoimpl.UnsafeEnabled { - mi := &file_commentDomain_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListCommentResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListCommentResp) ProtoMessage() {} - -func (x *DoutokListCommentResp) ProtoReflect() protoreflect.Message { - mi := &file_commentDomain_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListCommentResp.ProtoReflect.Descriptor instead. -func (*DoutokListCommentResp) Descriptor() ([]byte, []int) { - return file_commentDomain_proto_rawDescGZIP(), []int{4} -} - -func (x *DoutokListCommentResp) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokListCommentResp) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokListCommentResp) GetCommentList() []*entity.Comment { - if x != nil { - return x.CommentList - } - return nil -} - -type DoutokCountCommentReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - VideoIdList []int64 `protobuf:"varint,1,rep,packed,name=video_id_list,json=videoIdList,proto3" json:"video_id_list,omitempty"` -} - -func (x *DoutokCountCommentReq) Reset() { - *x = DoutokCountCommentReq{} - if protoimpl.UnsafeEnabled { - mi := &file_commentDomain_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCountCommentReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCountCommentReq) ProtoMessage() {} - -func (x *DoutokCountCommentReq) ProtoReflect() protoreflect.Message { - mi := &file_commentDomain_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCountCommentReq.ProtoReflect.Descriptor instead. -func (*DoutokCountCommentReq) Descriptor() ([]byte, []int) { - return file_commentDomain_proto_rawDescGZIP(), []int{5} -} - -func (x *DoutokCountCommentReq) GetVideoIdList() []int64 { - if x != nil { - return x.VideoIdList - } - return nil -} - -type DoutokCountCommentResp struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - CommentCount map[int64]int64 `protobuf:"bytes,3,rep,name=comment_count,json=commentCount,proto3" json:"comment_count,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` -} - -func (x *DoutokCountCommentResp) Reset() { - *x = DoutokCountCommentResp{} - if protoimpl.UnsafeEnabled { - mi := &file_commentDomain_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCountCommentResp) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCountCommentResp) ProtoMessage() {} - -func (x *DoutokCountCommentResp) ProtoReflect() protoreflect.Message { - mi := &file_commentDomain_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCountCommentResp.ProtoReflect.Descriptor instead. -func (*DoutokCountCommentResp) Descriptor() ([]byte, []int) { - return file_commentDomain_proto_rawDescGZIP(), []int{6} -} - -func (x *DoutokCountCommentResp) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokCountCommentResp) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokCountCommentResp) GetCommentCount() map[int64]int64 { - if x != nil { - return x.CommentCount - } - return nil -} - -var File_commentDomain_proto protoreflect.FileDescriptor - -var file_commentDomain_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x6f, 0x0a, 0x16, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, - 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x12, 0x19, 0x0a, 0x08, - 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, - 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, - 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x65, 0x78, 0x74, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x54, - 0x65, 0x78, 0x74, 0x22, 0x84, 0x01, 0x0a, 0x17, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, - 0x64, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x12, - 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, - 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, - 0x29, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, - 0x32, 0x0f, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, - 0x74, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x22, 0x6a, 0x0a, 0x15, 0x64, 0x6f, - 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x72, 0x6d, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, - 0x72, 0x65, 0x71, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, - 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, - 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x6d, 0x65, - 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x63, 0x6f, 0x6d, - 0x6d, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x22, 0x4d, 0x0a, 0x17, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, - 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, - 0x71, 0x12, 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, - 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x8e, 0x01, 0x0a, 0x18, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, - 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, - 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, - 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, - 0x73, 0x67, 0x12, 0x32, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x6c, 0x69, - 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0b, 0x63, 0x6f, 0x6d, 0x6d, 0x65, - 0x6e, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x3e, 0x0a, 0x18, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, - 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, - 0x65, 0x71, 0x12, 0x22, 0x0a, 0x0d, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, 0x6c, - 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0b, 0x76, 0x69, 0x64, 0x65, 0x6f, - 0x49, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xfd, 0x01, 0x0a, 0x19, 0x64, 0x6f, 0x75, 0x74, 0x6f, - 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, - 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, - 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x4d, 0x73, 0x67, 0x12, 0x5f, 0x0a, 0x0d, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x63, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, - 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, - 0x5f, 0x72, 0x65, 0x73, 0x70, 0x2e, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, - 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x1a, 0x3f, 0x0a, 0x11, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, - 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, - 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, - 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0x91, 0x03, 0x0a, 0x14, 0x43, 0x6f, 0x6d, 0x6d, 0x65, - 0x6e, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x5b, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x25, 0x2e, - 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, - 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, - 0x5f, 0x72, 0x65, 0x71, 0x1a, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, - 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x12, 0x59, 0x0a, 0x09, - 0x52, 0x6d, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x24, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, - 0x65, 0x6e, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, - 0x5f, 0x72, 0x6d, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x1a, - 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, - 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x12, 0x5e, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x43, - 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x26, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, - 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x1a, 0x27, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, - 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, - 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x12, 0x61, 0x0a, 0x0c, 0x43, 0x6f, 0x75, 0x6e, 0x74, - 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x27, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, - 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, - 0x1a, 0x28, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x63, 0x6f, - 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, - 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, 0x65, - 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x44, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_commentDomain_proto_rawDescOnce sync.Once - file_commentDomain_proto_rawDescData = file_commentDomain_proto_rawDesc -) - -func file_commentDomain_proto_rawDescGZIP() []byte { - file_commentDomain_proto_rawDescOnce.Do(func() { - file_commentDomain_proto_rawDescData = protoimpl.X.CompressGZIP(file_commentDomain_proto_rawDescData) - }) - return file_commentDomain_proto_rawDescData -} - -var file_commentDomain_proto_msgTypes = make([]protoimpl.MessageInfo, 8) -var file_commentDomain_proto_goTypes = []interface{}{ - (*DoutokAddCommentReq)(nil), // 0: commentDomain.doutok_add_comment_req - (*DoutokAddCommentResp)(nil), // 1: commentDomain.doutok_add_comment_resp - (*DoutokRmCommentReq)(nil), // 2: commentDomain.doutok_rm_comment_req - (*DoutokListCommentReq)(nil), // 3: commentDomain.doutok_list_comment_req - (*DoutokListCommentResp)(nil), // 4: commentDomain.doutok_list_comment_resp - (*DoutokCountCommentReq)(nil), // 5: commentDomain.doutok_count_comment_req - (*DoutokCountCommentResp)(nil), // 6: commentDomain.doutok_count_comment_resp - nil, // 7: commentDomain.doutok_count_comment_resp.CommentCountEntry - (*entity.Comment)(nil), // 8: entity.Comment -} -var file_commentDomain_proto_depIdxs = []int32{ - 8, // 0: commentDomain.doutok_add_comment_resp.comment:type_name -> entity.Comment - 8, // 1: commentDomain.doutok_list_comment_resp.comment_list:type_name -> entity.Comment - 7, // 2: commentDomain.doutok_count_comment_resp.comment_count:type_name -> commentDomain.doutok_count_comment_resp.CommentCountEntry - 0, // 3: commentDomain.CommentDomainService.AddComment:input_type -> commentDomain.doutok_add_comment_req - 2, // 4: commentDomain.CommentDomainService.RmComment:input_type -> commentDomain.doutok_rm_comment_req - 3, // 5: commentDomain.CommentDomainService.ListComment:input_type -> commentDomain.doutok_list_comment_req - 5, // 6: commentDomain.CommentDomainService.CountComment:input_type -> commentDomain.doutok_count_comment_req - 1, // 7: commentDomain.CommentDomainService.AddComment:output_type -> commentDomain.doutok_add_comment_resp - 1, // 8: commentDomain.CommentDomainService.RmComment:output_type -> commentDomain.doutok_add_comment_resp - 4, // 9: commentDomain.CommentDomainService.ListComment:output_type -> commentDomain.doutok_list_comment_resp - 6, // 10: commentDomain.CommentDomainService.CountComment:output_type -> commentDomain.doutok_count_comment_resp - 7, // [7:11] is the sub-list for method output_type - 3, // [3:7] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_commentDomain_proto_init() } -func file_commentDomain_proto_init() { - if File_commentDomain_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_commentDomain_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddCommentReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_commentDomain_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddCommentResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_commentDomain_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokRmCommentReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_commentDomain_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListCommentReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_commentDomain_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListCommentResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_commentDomain_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCountCommentReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_commentDomain_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCountCommentResp); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_commentDomain_proto_rawDesc, - NumEnums: 0, - NumMessages: 8, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_commentDomain_proto_goTypes, - DependencyIndexes: file_commentDomain_proto_depIdxs, - MessageInfos: file_commentDomain_proto_msgTypes, - }.Build() - File_commentDomain_proto = out.File - file_commentDomain_proto_rawDesc = nil - file_commentDomain_proto_goTypes = nil - file_commentDomain_proto_depIdxs = nil -} - -var _ context.Context - -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -type CommentDomainService interface { - AddComment(ctx context.Context, req *DoutokAddCommentReq) (res *DoutokAddCommentResp, err error) - RmComment(ctx context.Context, req *DoutokRmCommentReq) (res *DoutokAddCommentResp, err error) - ListComment(ctx context.Context, req *DoutokListCommentReq) (res *DoutokListCommentResp, err error) - CountComment(ctx context.Context, req *DoutokCountCommentReq) (res *DoutokCountCommentResp, err error) -} diff --git a/kitex_gen/commentDomain/commentdomainservice/client.go b/kitex_gen/commentDomain/commentdomainservice/client.go deleted file mode 100644 index 5367c902..00000000 --- a/kitex_gen/commentDomain/commentdomainservice/client.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package commentdomainservice - -import ( - "context" - commentDomain "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - AddComment(ctx context.Context, Req *commentDomain.DoutokAddCommentReq, callOptions ...callopt.Option) (r *commentDomain.DoutokAddCommentResp, err error) - RmComment(ctx context.Context, Req *commentDomain.DoutokRmCommentReq, callOptions ...callopt.Option) (r *commentDomain.DoutokAddCommentResp, err error) - ListComment(ctx context.Context, Req *commentDomain.DoutokListCommentReq, callOptions ...callopt.Option) (r *commentDomain.DoutokListCommentResp, err error) - CountComment(ctx context.Context, Req *commentDomain.DoutokCountCommentReq, callOptions ...callopt.Option) (r *commentDomain.DoutokCountCommentResp, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfo(), options...) - if err != nil { - return nil, err - } - return &kCommentDomainServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kCommentDomainServiceClient struct { - *kClient -} - -func (p *kCommentDomainServiceClient) AddComment(ctx context.Context, Req *commentDomain.DoutokAddCommentReq, callOptions ...callopt.Option) (r *commentDomain.DoutokAddCommentResp, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.AddComment(ctx, Req) -} - -func (p *kCommentDomainServiceClient) RmComment(ctx context.Context, Req *commentDomain.DoutokRmCommentReq, callOptions ...callopt.Option) (r *commentDomain.DoutokAddCommentResp, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.RmComment(ctx, Req) -} - -func (p *kCommentDomainServiceClient) ListComment(ctx context.Context, Req *commentDomain.DoutokListCommentReq, callOptions ...callopt.Option) (r *commentDomain.DoutokListCommentResp, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.ListComment(ctx, Req) -} - -func (p *kCommentDomainServiceClient) CountComment(ctx context.Context, Req *commentDomain.DoutokCountCommentReq, callOptions ...callopt.Option) (r *commentDomain.DoutokCountCommentResp, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.CountComment(ctx, Req) -} diff --git a/kitex_gen/commentDomain/commentdomainservice/commentdomainservice.go b/kitex_gen/commentDomain/commentdomainservice/commentdomainservice.go deleted file mode 100644 index f18d7869..00000000 --- a/kitex_gen/commentDomain/commentdomainservice/commentdomainservice.go +++ /dev/null @@ -1,672 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package commentdomainservice - -import ( - "context" - "fmt" - commentDomain "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" -) - -func serviceInfo() *kitex.ServiceInfo { - return commentDomainServiceServiceInfo -} - -var commentDomainServiceServiceInfo = NewServiceInfo() - -func NewServiceInfo() *kitex.ServiceInfo { - serviceName := "CommentDomainService" - handlerType := (*commentDomain.CommentDomainService)(nil) - methods := map[string]kitex.MethodInfo{ - "AddComment": kitex.NewMethodInfo(addCommentHandler, newAddCommentArgs, newAddCommentResult, false), - "RmComment": kitex.NewMethodInfo(rmCommentHandler, newRmCommentArgs, newRmCommentResult, false), - "ListComment": kitex.NewMethodInfo(listCommentHandler, newListCommentArgs, newListCommentResult, false), - "CountComment": kitex.NewMethodInfo(countCommentHandler, newCountCommentArgs, newCountCommentResult, false), - } - extra := map[string]interface{}{ - "PackageName": "commentDomain", - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", - Extra: extra, - } - return svcInfo -} - -func addCommentHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(commentDomain.DoutokAddCommentReq) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(commentDomain.CommentDomainService).AddComment(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *AddCommentArgs: - success, err := handler.(commentDomain.CommentDomainService).AddComment(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*AddCommentResult) - realResult.Success = success - } - return nil -} -func newAddCommentArgs() interface{} { - return &AddCommentArgs{} -} - -func newAddCommentResult() interface{} { - return &AddCommentResult{} -} - -type AddCommentArgs struct { - Req *commentDomain.DoutokAddCommentReq -} - -func (p *AddCommentArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(commentDomain.DoutokAddCommentReq) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *AddCommentArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *AddCommentArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *AddCommentArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in AddCommentArgs") - } - return proto.Marshal(p.Req) -} - -func (p *AddCommentArgs) Unmarshal(in []byte) error { - msg := new(commentDomain.DoutokAddCommentReq) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var AddCommentArgs_Req_DEFAULT *commentDomain.DoutokAddCommentReq - -func (p *AddCommentArgs) GetReq() *commentDomain.DoutokAddCommentReq { - if !p.IsSetReq() { - return AddCommentArgs_Req_DEFAULT - } - return p.Req -} - -func (p *AddCommentArgs) IsSetReq() bool { - return p.Req != nil -} - -type AddCommentResult struct { - Success *commentDomain.DoutokAddCommentResp -} - -var AddCommentResult_Success_DEFAULT *commentDomain.DoutokAddCommentResp - -func (p *AddCommentResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(commentDomain.DoutokAddCommentResp) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *AddCommentResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *AddCommentResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *AddCommentResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in AddCommentResult") - } - return proto.Marshal(p.Success) -} - -func (p *AddCommentResult) Unmarshal(in []byte) error { - msg := new(commentDomain.DoutokAddCommentResp) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *AddCommentResult) GetSuccess() *commentDomain.DoutokAddCommentResp { - if !p.IsSetSuccess() { - return AddCommentResult_Success_DEFAULT - } - return p.Success -} - -func (p *AddCommentResult) SetSuccess(x interface{}) { - p.Success = x.(*commentDomain.DoutokAddCommentResp) -} - -func (p *AddCommentResult) IsSetSuccess() bool { - return p.Success != nil -} - -func rmCommentHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(commentDomain.DoutokRmCommentReq) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(commentDomain.CommentDomainService).RmComment(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *RmCommentArgs: - success, err := handler.(commentDomain.CommentDomainService).RmComment(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*RmCommentResult) - realResult.Success = success - } - return nil -} -func newRmCommentArgs() interface{} { - return &RmCommentArgs{} -} - -func newRmCommentResult() interface{} { - return &RmCommentResult{} -} - -type RmCommentArgs struct { - Req *commentDomain.DoutokRmCommentReq -} - -func (p *RmCommentArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(commentDomain.DoutokRmCommentReq) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *RmCommentArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *RmCommentArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *RmCommentArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in RmCommentArgs") - } - return proto.Marshal(p.Req) -} - -func (p *RmCommentArgs) Unmarshal(in []byte) error { - msg := new(commentDomain.DoutokRmCommentReq) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var RmCommentArgs_Req_DEFAULT *commentDomain.DoutokRmCommentReq - -func (p *RmCommentArgs) GetReq() *commentDomain.DoutokRmCommentReq { - if !p.IsSetReq() { - return RmCommentArgs_Req_DEFAULT - } - return p.Req -} - -func (p *RmCommentArgs) IsSetReq() bool { - return p.Req != nil -} - -type RmCommentResult struct { - Success *commentDomain.DoutokAddCommentResp -} - -var RmCommentResult_Success_DEFAULT *commentDomain.DoutokAddCommentResp - -func (p *RmCommentResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(commentDomain.DoutokAddCommentResp) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *RmCommentResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *RmCommentResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *RmCommentResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in RmCommentResult") - } - return proto.Marshal(p.Success) -} - -func (p *RmCommentResult) Unmarshal(in []byte) error { - msg := new(commentDomain.DoutokAddCommentResp) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *RmCommentResult) GetSuccess() *commentDomain.DoutokAddCommentResp { - if !p.IsSetSuccess() { - return RmCommentResult_Success_DEFAULT - } - return p.Success -} - -func (p *RmCommentResult) SetSuccess(x interface{}) { - p.Success = x.(*commentDomain.DoutokAddCommentResp) -} - -func (p *RmCommentResult) IsSetSuccess() bool { - return p.Success != nil -} - -func listCommentHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(commentDomain.DoutokListCommentReq) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(commentDomain.CommentDomainService).ListComment(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *ListCommentArgs: - success, err := handler.(commentDomain.CommentDomainService).ListComment(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*ListCommentResult) - realResult.Success = success - } - return nil -} -func newListCommentArgs() interface{} { - return &ListCommentArgs{} -} - -func newListCommentResult() interface{} { - return &ListCommentResult{} -} - -type ListCommentArgs struct { - Req *commentDomain.DoutokListCommentReq -} - -func (p *ListCommentArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(commentDomain.DoutokListCommentReq) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *ListCommentArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *ListCommentArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *ListCommentArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in ListCommentArgs") - } - return proto.Marshal(p.Req) -} - -func (p *ListCommentArgs) Unmarshal(in []byte) error { - msg := new(commentDomain.DoutokListCommentReq) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var ListCommentArgs_Req_DEFAULT *commentDomain.DoutokListCommentReq - -func (p *ListCommentArgs) GetReq() *commentDomain.DoutokListCommentReq { - if !p.IsSetReq() { - return ListCommentArgs_Req_DEFAULT - } - return p.Req -} - -func (p *ListCommentArgs) IsSetReq() bool { - return p.Req != nil -} - -type ListCommentResult struct { - Success *commentDomain.DoutokListCommentResp -} - -var ListCommentResult_Success_DEFAULT *commentDomain.DoutokListCommentResp - -func (p *ListCommentResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(commentDomain.DoutokListCommentResp) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *ListCommentResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *ListCommentResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *ListCommentResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in ListCommentResult") - } - return proto.Marshal(p.Success) -} - -func (p *ListCommentResult) Unmarshal(in []byte) error { - msg := new(commentDomain.DoutokListCommentResp) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *ListCommentResult) GetSuccess() *commentDomain.DoutokListCommentResp { - if !p.IsSetSuccess() { - return ListCommentResult_Success_DEFAULT - } - return p.Success -} - -func (p *ListCommentResult) SetSuccess(x interface{}) { - p.Success = x.(*commentDomain.DoutokListCommentResp) -} - -func (p *ListCommentResult) IsSetSuccess() bool { - return p.Success != nil -} - -func countCommentHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(commentDomain.DoutokCountCommentReq) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(commentDomain.CommentDomainService).CountComment(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *CountCommentArgs: - success, err := handler.(commentDomain.CommentDomainService).CountComment(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*CountCommentResult) - realResult.Success = success - } - return nil -} -func newCountCommentArgs() interface{} { - return &CountCommentArgs{} -} - -func newCountCommentResult() interface{} { - return &CountCommentResult{} -} - -type CountCommentArgs struct { - Req *commentDomain.DoutokCountCommentReq -} - -func (p *CountCommentArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(commentDomain.DoutokCountCommentReq) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *CountCommentArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *CountCommentArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *CountCommentArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in CountCommentArgs") - } - return proto.Marshal(p.Req) -} - -func (p *CountCommentArgs) Unmarshal(in []byte) error { - msg := new(commentDomain.DoutokCountCommentReq) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var CountCommentArgs_Req_DEFAULT *commentDomain.DoutokCountCommentReq - -func (p *CountCommentArgs) GetReq() *commentDomain.DoutokCountCommentReq { - if !p.IsSetReq() { - return CountCommentArgs_Req_DEFAULT - } - return p.Req -} - -func (p *CountCommentArgs) IsSetReq() bool { - return p.Req != nil -} - -type CountCommentResult struct { - Success *commentDomain.DoutokCountCommentResp -} - -var CountCommentResult_Success_DEFAULT *commentDomain.DoutokCountCommentResp - -func (p *CountCommentResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(commentDomain.DoutokCountCommentResp) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *CountCommentResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *CountCommentResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *CountCommentResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in CountCommentResult") - } - return proto.Marshal(p.Success) -} - -func (p *CountCommentResult) Unmarshal(in []byte) error { - msg := new(commentDomain.DoutokCountCommentResp) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *CountCommentResult) GetSuccess() *commentDomain.DoutokCountCommentResp { - if !p.IsSetSuccess() { - return CountCommentResult_Success_DEFAULT - } - return p.Success -} - -func (p *CountCommentResult) SetSuccess(x interface{}) { - p.Success = x.(*commentDomain.DoutokCountCommentResp) -} - -func (p *CountCommentResult) IsSetSuccess() bool { - return p.Success != nil -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) AddComment(ctx context.Context, Req *commentDomain.DoutokAddCommentReq) (r *commentDomain.DoutokAddCommentResp, err error) { - var _args AddCommentArgs - _args.Req = Req - var _result AddCommentResult - if err = p.c.Call(ctx, "AddComment", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) RmComment(ctx context.Context, Req *commentDomain.DoutokRmCommentReq) (r *commentDomain.DoutokAddCommentResp, err error) { - var _args RmCommentArgs - _args.Req = Req - var _result RmCommentResult - if err = p.c.Call(ctx, "RmComment", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) ListComment(ctx context.Context, Req *commentDomain.DoutokListCommentReq) (r *commentDomain.DoutokListCommentResp, err error) { - var _args ListCommentArgs - _args.Req = Req - var _result ListCommentResult - if err = p.c.Call(ctx, "ListComment", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) CountComment(ctx context.Context, Req *commentDomain.DoutokCountCommentReq) (r *commentDomain.DoutokCountCommentResp, err error) { - var _args CountCommentArgs - _args.Req = Req - var _result CountCommentResult - if err = p.c.Call(ctx, "CountComment", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/kitex_gen/commentDomain/commentdomainservice/invoker.go b/kitex_gen/commentDomain/commentdomainservice/invoker.go deleted file mode 100644 index 098ce40b..00000000 --- a/kitex_gen/commentDomain/commentdomainservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package commentdomainservice - -import ( - commentDomain "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler commentDomain.CommentDomainService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/kitex_gen/commentDomain/commentdomainservice/server.go b/kitex_gen/commentDomain/commentdomainservice/server.go deleted file mode 100644 index 6d561931..00000000 --- a/kitex_gen/commentDomain/commentdomainservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. -package commentdomainservice - -import ( - commentDomain "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler commentDomain.CommentDomainService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/kitex_gen/favorite/favorite.pb.fast.go b/kitex_gen/favorite/favorite.pb.fast.go deleted file mode 100644 index 5e38475d..00000000 --- a/kitex_gen/favorite/favorite.pb.fast.go +++ /dev/null @@ -1,907 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package favorite - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DouyinFavoriteActionRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFavoriteActionRequest[number], err) -} - -func (x *DouyinFavoriteActionRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteActionRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteActionRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.ActionType, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteActionResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFavoriteActionResponse[number], err) -} - -func (x *DouyinFavoriteActionResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteActionResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteListRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFavoriteListRequest[number], err) -} - -func (x *DouyinFavoriteListRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteListResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFavoriteListResponse[number], err) -} - -func (x *DouyinFavoriteListResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteListResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteListResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Video - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.VideoList = append(x.VideoList, &v) - return offset, nil -} - -func (x *DouyinIsFavoriteRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinIsFavoriteRequest[number], err) -} - -func (x *DouyinIsFavoriteRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinIsFavoriteRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.VideoIdList = append(x.VideoIdList, v) - return offset, err - }) - return offset, err -} - -func (x *DouyinIsFavoriteResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinIsFavoriteResponse[number], err) -} - -func (x *DouyinIsFavoriteResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinIsFavoriteResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinIsFavoriteResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.Result == nil { - x.Result = make(map[int64]bool) - } - var key int64 - var value bool - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - value, offset, err = fastpb.ReadBool(buf, _type) - return offset, err - }) - if err != nil { - return offset, err - } - x.Result[key] = value - return offset, nil -} - -func (x *DouyinFavoriteCountRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFavoriteCountRequest[number], err) -} - -func (x *DouyinFavoriteCountRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.VideoIdList = append(x.VideoIdList, v) - return offset, err - }) - return offset, err -} - -func (x *DouyinFavoriteCountResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFavoriteCountResponse[number], err) -} - -func (x *DouyinFavoriteCountResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteCountResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinFavoriteCountResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.Result == nil { - x.Result = make(map[int64]int64) - } - var key int64 - var value int64 - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - value, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }) - if err != nil { - return offset, err - } - x.Result[key] = value - return offset, nil -} - -func (x *DouyinFavoriteActionRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinFavoriteActionRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DouyinFavoriteActionRequest) fastWriteField2(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.VideoId) - return offset -} - -func (x *DouyinFavoriteActionRequest) fastWriteField3(buf []byte) (offset int) { - if x.ActionType == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 3, x.ActionType) - return offset -} - -func (x *DouyinFavoriteActionResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DouyinFavoriteActionResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinFavoriteActionResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinFavoriteListRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DouyinFavoriteListRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DouyinFavoriteListResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinFavoriteListResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinFavoriteListResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinFavoriteListResponse) fastWriteField3(buf []byte) (offset int) { - if x.VideoList == nil { - return offset - } - for i := range x.VideoList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.VideoList[i]) - } - return offset -} - -func (x *DouyinIsFavoriteRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DouyinIsFavoriteRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DouyinIsFavoriteRequest) fastWriteField2(buf []byte) (offset int) { - if len(x.VideoIdList) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 2, len(x.VideoIdList), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.VideoIdList[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DouyinIsFavoriteResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinIsFavoriteResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinIsFavoriteResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinIsFavoriteResponse) fastWriteField3(buf []byte) (offset int) { - if x.Result == nil { - return offset - } - for k, v := range x.Result { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteBool(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DouyinFavoriteCountRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DouyinFavoriteCountRequest) fastWriteField1(buf []byte) (offset int) { - if len(x.VideoIdList) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 1, len(x.VideoIdList), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.VideoIdList[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DouyinFavoriteCountResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinFavoriteCountResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinFavoriteCountResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinFavoriteCountResponse) fastWriteField3(buf []byte) (offset int) { - if x.Result == nil { - return offset - } - for k, v := range x.Result { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteInt64(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DouyinFavoriteActionRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinFavoriteActionRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DouyinFavoriteActionRequest) sizeField2() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.VideoId) - return n -} - -func (x *DouyinFavoriteActionRequest) sizeField3() (n int) { - if x.ActionType == 0 { - return n - } - n += fastpb.SizeInt32(3, x.ActionType) - return n -} - -func (x *DouyinFavoriteActionResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DouyinFavoriteActionResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinFavoriteActionResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinFavoriteListRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DouyinFavoriteListRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DouyinFavoriteListResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinFavoriteListResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinFavoriteListResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinFavoriteListResponse) sizeField3() (n int) { - if x.VideoList == nil { - return n - } - for i := range x.VideoList { - n += fastpb.SizeMessage(3, x.VideoList[i]) - } - return n -} - -func (x *DouyinIsFavoriteRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DouyinIsFavoriteRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DouyinIsFavoriteRequest) sizeField2() (n int) { - if len(x.VideoIdList) == 0 { - return n - } - n += fastpb.SizeListPacked(2, len(x.VideoIdList), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.VideoIdList[numIdxOrVal]) - return n - }) - return n -} - -func (x *DouyinIsFavoriteResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinIsFavoriteResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinIsFavoriteResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinIsFavoriteResponse) sizeField3() (n int) { - if x.Result == nil { - return n - } - for k, v := range x.Result { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeBool(numIdxOrVal, v) - return n - }) - } - return n -} - -func (x *DouyinFavoriteCountRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DouyinFavoriteCountRequest) sizeField1() (n int) { - if len(x.VideoIdList) == 0 { - return n - } - n += fastpb.SizeListPacked(1, len(x.VideoIdList), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.VideoIdList[numIdxOrVal]) - return n - }) - return n -} - -func (x *DouyinFavoriteCountResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinFavoriteCountResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinFavoriteCountResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinFavoriteCountResponse) sizeField3() (n int) { - if x.Result == nil { - return n - } - for k, v := range x.Result { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeInt64(numIdxOrVal, v) - return n - }) - } - return n -} - -var fieldIDToName_DouyinFavoriteActionRequest = map[int32]string{ - 1: "UserId", - 2: "VideoId", - 3: "ActionType", -} - -var fieldIDToName_DouyinFavoriteActionResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", -} - -var fieldIDToName_DouyinFavoriteListRequest = map[int32]string{ - 1: "UserId", -} - -var fieldIDToName_DouyinFavoriteListResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "VideoList", -} - -var fieldIDToName_DouyinIsFavoriteRequest = map[int32]string{ - 1: "UserId", - 2: "VideoIdList", -} - -var fieldIDToName_DouyinIsFavoriteResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "Result", -} - -var fieldIDToName_DouyinFavoriteCountRequest = map[int32]string{ - 1: "VideoIdList", -} - -var fieldIDToName_DouyinFavoriteCountResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "Result", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/favorite/favorite.pb.go b/kitex_gen/favorite/favorite.pb.go index ea694618..0fb6805b 100644 --- a/kitex_gen/favorite/favorite.pb.go +++ b/kitex_gen/favorite/favorite.pb.go @@ -1,14 +1,14 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 +// protoc-gen-go v1.28.0 +// protoc v3.19.4 // source: favorite.proto package favorite import ( context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" + feed "github.com/TremblingV5/DouTok/kitex_gen/feed" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -90,8 +90,8 @@ type DouyinFavoriteActionResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 } func (x *DouyinFavoriteActionResponse) Reset() { @@ -192,9 +192,9 @@ type DouyinFavoriteListResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - VideoList []*entity.Video `protobuf:"bytes,3,rep,name=video_list,json=videoList,proto3" json:"video_list,omitempty"` // 用户点赞视频列表 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + VideoList []*feed.Video `protobuf:"bytes,3,rep,name=video_list,json=videoList,proto3" json:"video_list,omitempty"` // 用户点赞视频列表 } func (x *DouyinFavoriteListResponse) Reset() { @@ -243,7 +243,7 @@ func (x *DouyinFavoriteListResponse) GetStatusMsg() string { return "" } -func (x *DouyinFavoriteListResponse) GetVideoList() []*entity.Video { +func (x *DouyinFavoriteListResponse) GetVideoList() []*feed.Video { if x != nil { return x.VideoList } @@ -482,91 +482,104 @@ var File_favorite_proto protoreflect.FileDescriptor var file_favorite_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x75, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, - 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x12, 0x1f, - 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22, - 0x61, 0x0a, 0x1f, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, - 0x74, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x12, 0x08, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x1a, 0x0a, 0x66, 0x65, 0x65, 0x64, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x75, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, + 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, + 0x64, 0x12, 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, + 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22, 0x61, 0x0a, + 0x1f, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, + 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, + 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, + 0x22, 0x37, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, + 0x69, 0x74, 0x65, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x8b, 0x01, 0x0a, 0x1d, 0x64, 0x6f, + 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x6c, 0x69, + 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x2a, 0x0a, 0x0a, 0x76, + 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0b, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, 0x09, 0x76, 0x69, + 0x64, 0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x59, 0x0a, 0x1a, 0x64, 0x6f, 0x75, 0x79, 0x69, + 0x6e, 0x5f, 0x69, 0x73, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, + 0x0a, 0x0d, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, + 0x02, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0b, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x4c, 0x69, + 0x73, 0x74, 0x22, 0xe3, 0x01, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x69, 0x73, + 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, - 0x73, 0x67, 0x22, 0x37, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, - 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x8d, 0x01, 0x0a, 0x1d, + 0x73, 0x67, 0x12, 0x49, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, + 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x69, 0x73, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, + 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, + 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0x39, 0x0a, + 0x0b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, + 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, + 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x43, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, + 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0d, 0x76, 0x69, 0x64, + 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, + 0x52, 0x0b, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xe9, 0x01, + 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, + 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, + 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, + 0x12, 0x4c, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x34, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, + 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, + 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0x39, + 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, + 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, + 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0x98, 0x03, 0x0a, 0x0f, 0x46, 0x61, + 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x65, 0x0a, + 0x0e, 0x46, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x28, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, + 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x66, 0x61, 0x76, 0x6f, + 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, + 0x72, 0x69, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x0c, 0x46, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x26, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, - 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, - 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, - 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x2c, 0x0a, - 0x0a, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0d, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, - 0x52, 0x09, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x59, 0x0a, 0x1a, 0x64, + 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x66, + 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, + 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x0a, 0x49, 0x73, 0x46, 0x61, 0x76, 0x6f, 0x72, + 0x69, 0x74, 0x65, 0x12, 0x24, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x69, 0x73, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, - 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, - 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0d, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, 0x6c, - 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0b, 0x76, 0x69, 0x64, 0x65, 0x6f, - 0x49, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xe3, 0x01, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x79, 0x69, - 0x6e, 0x5f, 0x69, 0x73, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x72, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x49, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, - 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x69, 0x73, 0x5f, 0x66, 0x61, 0x76, 0x6f, - 0x72, 0x69, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x43, 0x0a, 0x1d, - 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, - 0x0d, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, - 0x20, 0x03, 0x28, 0x03, 0x52, 0x0b, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x4c, 0x69, 0x73, - 0x74, 0x22, 0xe9, 0x01, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, + 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x66, 0x61, 0x76, 0x6f, + 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x69, 0x73, 0x5f, 0x66, + 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x62, 0x0a, 0x0d, 0x46, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x27, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, + 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x66, 0x61, 0x76, + 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, - 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, - 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x4d, 0x73, 0x67, 0x12, 0x4c, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, - 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, - 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, - 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, - 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0xd9, 0x01, - 0x0a, 0x0f, 0x46, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x65, 0x0a, 0x0e, 0x46, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x41, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, - 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, - 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, - 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x0c, 0x46, 0x61, 0x76, 0x6f, - 0x72, 0x69, 0x74, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x26, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, - 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, - 0x69, 0x74, 0x65, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x27, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, - 0x69, 0x6e, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x6c, 0x69, 0x73, 0x74, - 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, - 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, - 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, + 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x2f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x2f, 0x6b, 0x69, 0x74, 0x65, + 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -593,18 +606,22 @@ var file_favorite_proto_goTypes = []interface{}{ (*DouyinFavoriteCountResponse)(nil), // 7: favorite.douyin_favorite_count_response nil, // 8: favorite.douyin_is_favorite_response.ResultEntry nil, // 9: favorite.douyin_favorite_count_response.ResultEntry - (*entity.Video)(nil), // 10: entity.Video + (*feed.Video)(nil), // 10: feed.Video } var file_favorite_proto_depIdxs = []int32{ - 10, // 0: favorite.douyin_favorite_list_response.video_list:type_name -> entity.Video + 10, // 0: favorite.douyin_favorite_list_response.video_list:type_name -> feed.Video 8, // 1: favorite.douyin_is_favorite_response.result:type_name -> favorite.douyin_is_favorite_response.ResultEntry 9, // 2: favorite.douyin_favorite_count_response.result:type_name -> favorite.douyin_favorite_count_response.ResultEntry 0, // 3: favorite.FavoriteService.FavoriteAction:input_type -> favorite.douyin_favorite_action_request 2, // 4: favorite.FavoriteService.FavoriteList:input_type -> favorite.douyin_favorite_list_request - 1, // 5: favorite.FavoriteService.FavoriteAction:output_type -> favorite.douyin_favorite_action_response - 3, // 6: favorite.FavoriteService.FavoriteList:output_type -> favorite.douyin_favorite_list_response - 5, // [5:7] is the sub-list for method output_type - 3, // [3:5] is the sub-list for method input_type + 4, // 5: favorite.FavoriteService.IsFavorite:input_type -> favorite.douyin_is_favorite_request + 6, // 6: favorite.FavoriteService.FavoriteCount:input_type -> favorite.douyin_favorite_count_request + 1, // 7: favorite.FavoriteService.FavoriteAction:output_type -> favorite.douyin_favorite_action_response + 3, // 8: favorite.FavoriteService.FavoriteList:output_type -> favorite.douyin_favorite_list_response + 5, // 9: favorite.FavoriteService.IsFavorite:output_type -> favorite.douyin_is_favorite_response + 7, // 10: favorite.FavoriteService.FavoriteCount:output_type -> favorite.douyin_favorite_count_response + 7, // [7:11] is the sub-list for method output_type + 3, // [3:7] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name @@ -735,9 +752,11 @@ func file_favorite_proto_init() { var _ context.Context -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. type FavoriteService interface { FavoriteAction(ctx context.Context, req *DouyinFavoriteActionRequest) (res *DouyinFavoriteActionResponse, err error) FavoriteList(ctx context.Context, req *DouyinFavoriteListRequest) (res *DouyinFavoriteListResponse, err error) + IsFavorite(ctx context.Context, req *DouyinIsFavoriteRequest) (res *DouyinIsFavoriteResponse, err error) + FavoriteCount(ctx context.Context, req *DouyinFavoriteCountRequest) (res *DouyinFavoriteCountResponse, err error) } diff --git a/kitex_gen/favorite/favoriteservice/client.go b/kitex_gen/favorite/favoriteservice/client.go index c1a03953..6b4bfdc2 100644 --- a/kitex_gen/favorite/favoriteservice/client.go +++ b/kitex_gen/favorite/favoriteservice/client.go @@ -1,18 +1,20 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package favoriteservice import ( "context" - favorite "github.com/TremblingV5/DouTok/kitex_gen/favorite" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { FavoriteAction(ctx context.Context, Req *favorite.DouyinFavoriteActionRequest, callOptions ...callopt.Option) (r *favorite.DouyinFavoriteActionResponse, err error) FavoriteList(ctx context.Context, Req *favorite.DouyinFavoriteListRequest, callOptions ...callopt.Option) (r *favorite.DouyinFavoriteListResponse, err error) + IsFavorite(ctx context.Context, Req *favorite.DouyinIsFavoriteRequest, callOptions ...callopt.Option) (r *favorite.DouyinIsFavoriteResponse, err error) + FavoriteCount(ctx context.Context, Req *favorite.DouyinFavoriteCountRequest, callOptions ...callopt.Option) (r *favorite.DouyinFavoriteCountResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -53,3 +55,13 @@ func (p *kFavoriteServiceClient) FavoriteList(ctx context.Context, Req *favorite ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.FavoriteList(ctx, Req) } + +func (p *kFavoriteServiceClient) IsFavorite(ctx context.Context, Req *favorite.DouyinIsFavoriteRequest, callOptions ...callopt.Option) (r *favorite.DouyinIsFavoriteResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.IsFavorite(ctx, Req) +} + +func (p *kFavoriteServiceClient) FavoriteCount(ctx context.Context, Req *favorite.DouyinFavoriteCountRequest, callOptions ...callopt.Option) (r *favorite.DouyinFavoriteCountResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.FavoriteCount(ctx, Req) +} diff --git a/kitex_gen/favorite/favoriteservice/favoriteservice.go b/kitex_gen/favorite/favoriteservice/favoriteservice.go index 78904281..3e02ac09 100644 --- a/kitex_gen/favorite/favoriteservice/favoriteservice.go +++ b/kitex_gen/favorite/favoriteservice/favoriteservice.go @@ -1,15 +1,15 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package favoriteservice import ( "context" "fmt" - favorite "github.com/TremblingV5/DouTok/kitex_gen/favorite" - client "github.com/cloudwego/kitex/client" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" + "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" + "github.com/cloudwego/kitex/pkg/streaming" + "google.golang.org/protobuf/proto" ) func serviceInfo() *kitex.ServiceInfo { @@ -24,6 +24,8 @@ func NewServiceInfo() *kitex.ServiceInfo { methods := map[string]kitex.MethodInfo{ "FavoriteAction": kitex.NewMethodInfo(favoriteActionHandler, newFavoriteActionArgs, newFavoriteActionResult, false), "FavoriteList": kitex.NewMethodInfo(favoriteListHandler, newFavoriteListArgs, newFavoriteListResult, false), + "IsFavorite": kitex.NewMethodInfo(isFavoriteHandler, newIsFavoriteArgs, newIsFavoriteResult, false), + "FavoriteCount": kitex.NewMethodInfo(favoriteCountHandler, newFavoriteCountArgs, newFavoriteCountResult, false), } extra := map[string]interface{}{ "PackageName": "favorite", @@ -33,7 +35,7 @@ func NewServiceInfo() *kitex.ServiceInfo { HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", + KiteXGenVersion: "v0.3.4", Extra: extra, } return svcInfo @@ -76,27 +78,6 @@ type FavoriteActionArgs struct { Req *favorite.DouyinFavoriteActionRequest } -func (p *FavoriteActionArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(favorite.DouyinFavoriteActionRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *FavoriteActionArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *FavoriteActionArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *FavoriteActionArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in FavoriteActionArgs") @@ -132,27 +113,6 @@ type FavoriteActionResult struct { var FavoriteActionResult_Success_DEFAULT *favorite.DouyinFavoriteActionResponse -func (p *FavoriteActionResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(favorite.DouyinFavoriteActionResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *FavoriteActionResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *FavoriteActionResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - func (p *FavoriteActionResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { return out, fmt.Errorf("No req in FavoriteActionResult") @@ -221,27 +181,6 @@ type FavoriteListArgs struct { Req *favorite.DouyinFavoriteListRequest } -func (p *FavoriteListArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(favorite.DouyinFavoriteListRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *FavoriteListArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *FavoriteListArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *FavoriteListArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in FavoriteListArgs") @@ -277,36 +216,221 @@ type FavoriteListResult struct { var FavoriteListResult_Success_DEFAULT *favorite.DouyinFavoriteListResponse -func (p *FavoriteListResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { +func (p *FavoriteListResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, fmt.Errorf("No req in FavoriteListResult") + } + return proto.Marshal(p.Success) +} + +func (p *FavoriteListResult) Unmarshal(in []byte) error { + msg := new(favorite.DouyinFavoriteListResponse) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *FavoriteListResult) GetSuccess() *favorite.DouyinFavoriteListResponse { if !p.IsSetSuccess() { - p.Success = new(favorite.DouyinFavoriteListResponse) + return FavoriteListResult_Success_DEFAULT + } + return p.Success +} + +func (p *FavoriteListResult) SetSuccess(x interface{}) { + p.Success = x.(*favorite.DouyinFavoriteListResponse) +} + +func (p *FavoriteListResult) IsSetSuccess() bool { + return p.Success != nil +} + +func isFavoriteHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(favorite.DouyinIsFavoriteRequest) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(favorite.FavoriteService).IsFavorite(ctx, req) + if err != nil { + return err + } + if err := st.SendMsg(resp); err != nil { + return err + } + case *IsFavoriteArgs: + success, err := handler.(favorite.FavoriteService).IsFavorite(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*IsFavoriteResult) + realResult.Success = success + } + return nil +} +func newIsFavoriteArgs() interface{} { + return &IsFavoriteArgs{} +} + +func newIsFavoriteResult() interface{} { + return &IsFavoriteResult{} +} + +type IsFavoriteArgs struct { + Req *favorite.DouyinIsFavoriteRequest +} + +func (p *IsFavoriteArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, fmt.Errorf("No req in IsFavoriteArgs") + } + return proto.Marshal(p.Req) +} + +func (p *IsFavoriteArgs) Unmarshal(in []byte) error { + msg := new(favorite.DouyinIsFavoriteRequest) + if err := proto.Unmarshal(in, msg); err != nil { + return err } - return p.Success.FastRead(buf, _type, number) + p.Req = msg + return nil +} + +var IsFavoriteArgs_Req_DEFAULT *favorite.DouyinIsFavoriteRequest + +func (p *IsFavoriteArgs) GetReq() *favorite.DouyinIsFavoriteRequest { + if !p.IsSetReq() { + return IsFavoriteArgs_Req_DEFAULT + } + return p.Req +} + +func (p *IsFavoriteArgs) IsSetReq() bool { + return p.Req != nil +} + +type IsFavoriteResult struct { + Success *favorite.DouyinIsFavoriteResponse } -func (p *FavoriteListResult) FastWrite(buf []byte) (n int) { +var IsFavoriteResult_Success_DEFAULT *favorite.DouyinIsFavoriteResponse + +func (p *IsFavoriteResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { - return 0 + return out, fmt.Errorf("No req in IsFavoriteResult") + } + return proto.Marshal(p.Success) +} + +func (p *IsFavoriteResult) Unmarshal(in []byte) error { + msg := new(favorite.DouyinIsFavoriteResponse) + if err := proto.Unmarshal(in, msg); err != nil { + return err } - return p.Success.FastWrite(buf) + p.Success = msg + return nil } -func (p *FavoriteListResult) Size() (n int) { +func (p *IsFavoriteResult) GetSuccess() *favorite.DouyinIsFavoriteResponse { if !p.IsSetSuccess() { - return 0 + return IsFavoriteResult_Success_DEFAULT } - return p.Success.Size() + return p.Success } -func (p *FavoriteListResult) Marshal(out []byte) ([]byte, error) { +func (p *IsFavoriteResult) SetSuccess(x interface{}) { + p.Success = x.(*favorite.DouyinIsFavoriteResponse) +} + +func (p *IsFavoriteResult) IsSetSuccess() bool { + return p.Success != nil +} + +func favoriteCountHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(favorite.DouyinFavoriteCountRequest) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(favorite.FavoriteService).FavoriteCount(ctx, req) + if err != nil { + return err + } + if err := st.SendMsg(resp); err != nil { + return err + } + case *FavoriteCountArgs: + success, err := handler.(favorite.FavoriteService).FavoriteCount(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*FavoriteCountResult) + realResult.Success = success + } + return nil +} +func newFavoriteCountArgs() interface{} { + return &FavoriteCountArgs{} +} + +func newFavoriteCountResult() interface{} { + return &FavoriteCountResult{} +} + +type FavoriteCountArgs struct { + Req *favorite.DouyinFavoriteCountRequest +} + +func (p *FavoriteCountArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, fmt.Errorf("No req in FavoriteCountArgs") + } + return proto.Marshal(p.Req) +} + +func (p *FavoriteCountArgs) Unmarshal(in []byte) error { + msg := new(favorite.DouyinFavoriteCountRequest) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var FavoriteCountArgs_Req_DEFAULT *favorite.DouyinFavoriteCountRequest + +func (p *FavoriteCountArgs) GetReq() *favorite.DouyinFavoriteCountRequest { + if !p.IsSetReq() { + return FavoriteCountArgs_Req_DEFAULT + } + return p.Req +} + +func (p *FavoriteCountArgs) IsSetReq() bool { + return p.Req != nil +} + +type FavoriteCountResult struct { + Success *favorite.DouyinFavoriteCountResponse +} + +var FavoriteCountResult_Success_DEFAULT *favorite.DouyinFavoriteCountResponse + +func (p *FavoriteCountResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in FavoriteListResult") + return out, fmt.Errorf("No req in FavoriteCountResult") } return proto.Marshal(p.Success) } -func (p *FavoriteListResult) Unmarshal(in []byte) error { - msg := new(favorite.DouyinFavoriteListResponse) +func (p *FavoriteCountResult) Unmarshal(in []byte) error { + msg := new(favorite.DouyinFavoriteCountResponse) if err := proto.Unmarshal(in, msg); err != nil { return err } @@ -314,18 +438,18 @@ func (p *FavoriteListResult) Unmarshal(in []byte) error { return nil } -func (p *FavoriteListResult) GetSuccess() *favorite.DouyinFavoriteListResponse { +func (p *FavoriteCountResult) GetSuccess() *favorite.DouyinFavoriteCountResponse { if !p.IsSetSuccess() { - return FavoriteListResult_Success_DEFAULT + return FavoriteCountResult_Success_DEFAULT } return p.Success } -func (p *FavoriteListResult) SetSuccess(x interface{}) { - p.Success = x.(*favorite.DouyinFavoriteListResponse) +func (p *FavoriteCountResult) SetSuccess(x interface{}) { + p.Success = x.(*favorite.DouyinFavoriteCountResponse) } -func (p *FavoriteListResult) IsSetSuccess() bool { +func (p *FavoriteCountResult) IsSetSuccess() bool { return p.Success != nil } @@ -358,3 +482,23 @@ func (p *kClient) FavoriteList(ctx context.Context, Req *favorite.DouyinFavorite } return _result.GetSuccess(), nil } + +func (p *kClient) IsFavorite(ctx context.Context, Req *favorite.DouyinIsFavoriteRequest) (r *favorite.DouyinIsFavoriteResponse, err error) { + var _args IsFavoriteArgs + _args.Req = Req + var _result IsFavoriteResult + if err = p.c.Call(ctx, "IsFavorite", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} + +func (p *kClient) FavoriteCount(ctx context.Context, Req *favorite.DouyinFavoriteCountRequest) (r *favorite.DouyinFavoriteCountResponse, err error) { + var _args FavoriteCountArgs + _args.Req = Req + var _result FavoriteCountResult + if err = p.c.Call(ctx, "FavoriteCount", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/kitex_gen/favorite/favoriteservice/invoker.go b/kitex_gen/favorite/favoriteservice/invoker.go index ca0169e3..f7ef5728 100644 --- a/kitex_gen/favorite/favoriteservice/invoker.go +++ b/kitex_gen/favorite/favoriteservice/invoker.go @@ -1,10 +1,10 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package favoriteservice import ( - favorite "github.com/TremblingV5/DouTok/kitex_gen/favorite" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" + "github.com/cloudwego/kitex/server" ) // NewInvoker creates a server.Invoker with the given handler and options. diff --git a/kitex_gen/favorite/favoriteservice/server.go b/kitex_gen/favorite/favoriteservice/server.go index ee124f47..61814985 100644 --- a/kitex_gen/favorite/favoriteservice/server.go +++ b/kitex_gen/favorite/favoriteservice/server.go @@ -1,9 +1,9 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package favoriteservice import ( - favorite "github.com/TremblingV5/DouTok/kitex_gen/favorite" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/favorite" + "github.com/cloudwego/kitex/server" ) // NewServer creates a server.Server with the given handler and options. diff --git a/kitex_gen/favoriteDomain/favoriteDomain.pb.fast.go b/kitex_gen/favoriteDomain/favoriteDomain.pb.fast.go deleted file mode 100644 index 3eb9a0f4..00000000 --- a/kitex_gen/favoriteDomain/favoriteDomain.pb.fast.go +++ /dev/null @@ -1,1058 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package favoriteDomain - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DoutokAddFavRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddFavRequest[number], err) -} - -func (x *DoutokAddFavRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddFavRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddFavResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddFavResponse[number], err) -} - -func (x *DoutokAddFavResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokAddFavResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokRmFavRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokRmFavRequest[number], err) -} - -func (x *DoutokRmFavRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokRmFavRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokRmFavResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokRmFavResponse[number], err) -} - -func (x *DoutokRmFavResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokRmFavResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokListFavRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListFavRequest[number], err) -} - -func (x *DoutokListFavRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListFavResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListFavResponse[number], err) -} - -func (x *DoutokListFavResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokListFavResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokListFavResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Video - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.VideoList = append(x.VideoList, &v) - return offset, nil -} - -func (x *DoutokIsFavRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokIsFavRequest[number], err) -} - -func (x *DoutokIsFavRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokIsFavRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.VideoId = append(x.VideoId, v) - return offset, err - }) - return offset, err -} - -func (x *DoutokIsFavResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokIsFavResponse[number], err) -} - -func (x *DoutokIsFavResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokIsFavResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokIsFavResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.IsFav == nil { - x.IsFav = make(map[int64]bool) - } - var key int64 - var value bool - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - value, offset, err = fastpb.ReadBool(buf, _type) - return offset, err - }) - if err != nil { - return offset, err - } - x.IsFav[key] = value - return offset, nil -} - -func (x *DoutokCountFavRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCountFavRequest[number], err) -} - -func (x *DoutokCountFavRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.UserIdList = append(x.UserIdList, v) - return offset, err - }) - return offset, err -} - -func (x *DoutokCountFavResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCountFavResponse[number], err) -} - -func (x *DoutokCountFavResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokCountFavResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokCountFavResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.CountFav == nil { - x.CountFav = make(map[int64]int64) - } - var key int64 - var value int64 - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - value, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }) - if err != nil { - return offset, err - } - x.CountFav[key] = value - return offset, nil -} - -func (x *DoutokAddFavRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokAddFavRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DoutokAddFavRequest) fastWriteField2(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.VideoId) - return offset -} - -func (x *DoutokAddFavResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokAddFavResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokAddFavResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokRmFavRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokRmFavRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DoutokRmFavRequest) fastWriteField2(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.VideoId) - return offset -} - -func (x *DoutokRmFavResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokRmFavResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokRmFavResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokListFavRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DoutokListFavRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DoutokListFavResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokListFavResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokListFavResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokListFavResponse) fastWriteField3(buf []byte) (offset int) { - if x.VideoList == nil { - return offset - } - for i := range x.VideoList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.VideoList[i]) - } - return offset -} - -func (x *DoutokIsFavRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokIsFavRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DoutokIsFavRequest) fastWriteField2(buf []byte) (offset int) { - if len(x.VideoId) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 2, len(x.VideoId), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.VideoId[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DoutokIsFavResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokIsFavResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokIsFavResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokIsFavResponse) fastWriteField3(buf []byte) (offset int) { - if x.IsFav == nil { - return offset - } - for k, v := range x.IsFav { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteBool(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DoutokCountFavRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DoutokCountFavRequest) fastWriteField1(buf []byte) (offset int) { - if len(x.UserIdList) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 1, len(x.UserIdList), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.UserIdList[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DoutokCountFavResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokCountFavResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokCountFavResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokCountFavResponse) fastWriteField3(buf []byte) (offset int) { - if x.CountFav == nil { - return offset - } - for k, v := range x.CountFav { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteInt64(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DoutokAddFavRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokAddFavRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DoutokAddFavRequest) sizeField2() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.VideoId) - return n -} - -func (x *DoutokAddFavResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokAddFavResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokAddFavResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokRmFavRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokRmFavRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DoutokRmFavRequest) sizeField2() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.VideoId) - return n -} - -func (x *DoutokRmFavResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokRmFavResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokRmFavResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokListFavRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DoutokListFavRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DoutokListFavResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokListFavResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokListFavResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokListFavResponse) sizeField3() (n int) { - if x.VideoList == nil { - return n - } - for i := range x.VideoList { - n += fastpb.SizeMessage(3, x.VideoList[i]) - } - return n -} - -func (x *DoutokIsFavRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokIsFavRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DoutokIsFavRequest) sizeField2() (n int) { - if len(x.VideoId) == 0 { - return n - } - n += fastpb.SizeListPacked(2, len(x.VideoId), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.VideoId[numIdxOrVal]) - return n - }) - return n -} - -func (x *DoutokIsFavResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokIsFavResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokIsFavResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokIsFavResponse) sizeField3() (n int) { - if x.IsFav == nil { - return n - } - for k, v := range x.IsFav { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeBool(numIdxOrVal, v) - return n - }) - } - return n -} - -func (x *DoutokCountFavRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DoutokCountFavRequest) sizeField1() (n int) { - if len(x.UserIdList) == 0 { - return n - } - n += fastpb.SizeListPacked(1, len(x.UserIdList), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.UserIdList[numIdxOrVal]) - return n - }) - return n -} - -func (x *DoutokCountFavResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokCountFavResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokCountFavResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokCountFavResponse) sizeField3() (n int) { - if x.CountFav == nil { - return n - } - for k, v := range x.CountFav { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeInt64(numIdxOrVal, v) - return n - }) - } - return n -} - -var fieldIDToName_DoutokAddFavRequest = map[int32]string{ - 1: "UserId", - 2: "VideoId", -} - -var fieldIDToName_DoutokAddFavResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", -} - -var fieldIDToName_DoutokRmFavRequest = map[int32]string{ - 1: "UserId", - 2: "VideoId", -} - -var fieldIDToName_DoutokRmFavResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", -} - -var fieldIDToName_DoutokListFavRequest = map[int32]string{ - 1: "UserId", -} - -var fieldIDToName_DoutokListFavResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "VideoList", -} - -var fieldIDToName_DoutokIsFavRequest = map[int32]string{ - 1: "UserId", - 2: "VideoId", -} - -var fieldIDToName_DoutokIsFavResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "IsFav", -} - -var fieldIDToName_DoutokCountFavRequest = map[int32]string{ - 1: "UserIdList", -} - -var fieldIDToName_DoutokCountFavResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "CountFav", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/favoriteDomain/favoriteDomain.pb.go b/kitex_gen/favoriteDomain/favoriteDomain.pb.go deleted file mode 100644 index f6597b45..00000000 --- a/kitex_gen/favoriteDomain/favoriteDomain.pb.go +++ /dev/null @@ -1,904 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 -// source: favoriteDomain.proto - -package favoriteDomain - -import ( - context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type DoutokAddFavRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - VideoId int64 `protobuf:"varint,2,opt,name=video_id,json=videoId,proto3" json:"video_id,omitempty"` -} - -func (x *DoutokAddFavRequest) Reset() { - *x = DoutokAddFavRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddFavRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddFavRequest) ProtoMessage() {} - -func (x *DoutokAddFavRequest) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddFavRequest.ProtoReflect.Descriptor instead. -func (*DoutokAddFavRequest) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{0} -} - -func (x *DoutokAddFavRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokAddFavRequest) GetVideoId() int64 { - if x != nil { - return x.VideoId - } - return 0 -} - -type DoutokAddFavResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` -} - -func (x *DoutokAddFavResponse) Reset() { - *x = DoutokAddFavResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddFavResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddFavResponse) ProtoMessage() {} - -func (x *DoutokAddFavResponse) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddFavResponse.ProtoReflect.Descriptor instead. -func (*DoutokAddFavResponse) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{1} -} - -func (x *DoutokAddFavResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokAddFavResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -type DoutokRmFavRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - VideoId int64 `protobuf:"varint,2,opt,name=video_id,json=videoId,proto3" json:"video_id,omitempty"` -} - -func (x *DoutokRmFavRequest) Reset() { - *x = DoutokRmFavRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokRmFavRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokRmFavRequest) ProtoMessage() {} - -func (x *DoutokRmFavRequest) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokRmFavRequest.ProtoReflect.Descriptor instead. -func (*DoutokRmFavRequest) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{2} -} - -func (x *DoutokRmFavRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokRmFavRequest) GetVideoId() int64 { - if x != nil { - return x.VideoId - } - return 0 -} - -type DoutokRmFavResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` -} - -func (x *DoutokRmFavResponse) Reset() { - *x = DoutokRmFavResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokRmFavResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokRmFavResponse) ProtoMessage() {} - -func (x *DoutokRmFavResponse) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokRmFavResponse.ProtoReflect.Descriptor instead. -func (*DoutokRmFavResponse) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{3} -} - -func (x *DoutokRmFavResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokRmFavResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -type DoutokListFavRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` -} - -func (x *DoutokListFavRequest) Reset() { - *x = DoutokListFavRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListFavRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListFavRequest) ProtoMessage() {} - -func (x *DoutokListFavRequest) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListFavRequest.ProtoReflect.Descriptor instead. -func (*DoutokListFavRequest) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{4} -} - -func (x *DoutokListFavRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type DoutokListFavResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - VideoList []*entity.Video `protobuf:"bytes,3,rep,name=video_list,json=videoList,proto3" json:"video_list,omitempty"` -} - -func (x *DoutokListFavResponse) Reset() { - *x = DoutokListFavResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListFavResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListFavResponse) ProtoMessage() {} - -func (x *DoutokListFavResponse) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListFavResponse.ProtoReflect.Descriptor instead. -func (*DoutokListFavResponse) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{5} -} - -func (x *DoutokListFavResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokListFavResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokListFavResponse) GetVideoList() []*entity.Video { - if x != nil { - return x.VideoList - } - return nil -} - -type DoutokIsFavRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - VideoId []int64 `protobuf:"varint,2,rep,packed,name=video_id,json=videoId,proto3" json:"video_id,omitempty"` -} - -func (x *DoutokIsFavRequest) Reset() { - *x = DoutokIsFavRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokIsFavRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokIsFavRequest) ProtoMessage() {} - -func (x *DoutokIsFavRequest) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokIsFavRequest.ProtoReflect.Descriptor instead. -func (*DoutokIsFavRequest) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{6} -} - -func (x *DoutokIsFavRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokIsFavRequest) GetVideoId() []int64 { - if x != nil { - return x.VideoId - } - return nil -} - -type DoutokIsFavResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - IsFav map[int64]bool `protobuf:"bytes,3,rep,name=is_fav,json=isFav,proto3" json:"is_fav,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` -} - -func (x *DoutokIsFavResponse) Reset() { - *x = DoutokIsFavResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokIsFavResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokIsFavResponse) ProtoMessage() {} - -func (x *DoutokIsFavResponse) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokIsFavResponse.ProtoReflect.Descriptor instead. -func (*DoutokIsFavResponse) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{7} -} - -func (x *DoutokIsFavResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokIsFavResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokIsFavResponse) GetIsFav() map[int64]bool { - if x != nil { - return x.IsFav - } - return nil -} - -type DoutokCountFavRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserIdList []int64 `protobuf:"varint,1,rep,packed,name=user_id_list,json=userIdList,proto3" json:"user_id_list,omitempty"` -} - -func (x *DoutokCountFavRequest) Reset() { - *x = DoutokCountFavRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCountFavRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCountFavRequest) ProtoMessage() {} - -func (x *DoutokCountFavRequest) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCountFavRequest.ProtoReflect.Descriptor instead. -func (*DoutokCountFavRequest) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{8} -} - -func (x *DoutokCountFavRequest) GetUserIdList() []int64 { - if x != nil { - return x.UserIdList - } - return nil -} - -type DoutokCountFavResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - CountFav map[int64]int64 `protobuf:"bytes,3,rep,name=count_fav,json=countFav,proto3" json:"count_fav,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` -} - -func (x *DoutokCountFavResponse) Reset() { - *x = DoutokCountFavResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_favoriteDomain_proto_msgTypes[9] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCountFavResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCountFavResponse) ProtoMessage() {} - -func (x *DoutokCountFavResponse) ProtoReflect() protoreflect.Message { - mi := &file_favoriteDomain_proto_msgTypes[9] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCountFavResponse.ProtoReflect.Descriptor instead. -func (*DoutokCountFavResponse) Descriptor() ([]byte, []int) { - return file_favoriteDomain_proto_rawDescGZIP(), []int{9} -} - -func (x *DoutokCountFavResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokCountFavResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokCountFavResponse) GetCountFav() map[int64]int64 { - if x != nil { - return x.CountFav - } - return nil -} - -var File_favoriteDomain_proto protoreflect.FileDescriptor - -var file_favoriteDomain_proto_rawDesc = []byte{ - 0x0a, 0x14, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4c, 0x0a, 0x16, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, - 0x64, 0x64, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, - 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, - 0x49, 0x64, 0x22, 0x59, 0x0a, 0x17, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, - 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, - 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, - 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x22, 0x4b, 0x0a, - 0x15, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x72, 0x6d, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, - 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x22, 0x58, 0x0a, 0x16, 0x64, 0x6f, - 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x72, 0x6d, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, - 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, - 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x4d, 0x73, 0x67, 0x22, 0x32, 0x0a, 0x17, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, - 0x69, 0x73, 0x74, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x88, 0x01, 0x0a, 0x18, 0x64, 0x6f, 0x75, - 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, - 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x2c, 0x0a, 0x0a, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x6c, - 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, 0x09, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x4c, - 0x69, 0x73, 0x74, 0x22, 0x4b, 0x0a, 0x15, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x69, 0x73, - 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, - 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, - 0x22, 0xdc, 0x01, 0x0a, 0x16, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x69, 0x73, 0x5f, 0x66, - 0x61, 0x76, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x48, 0x0a, 0x06, 0x69, - 0x73, 0x5f, 0x66, 0x61, 0x76, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x31, 0x2e, 0x66, 0x61, - 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, - 0x74, 0x6f, 0x6b, 0x5f, 0x69, 0x73, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x2e, 0x49, 0x73, 0x46, 0x61, 0x76, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x05, - 0x69, 0x73, 0x46, 0x61, 0x76, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x73, 0x46, 0x61, 0x76, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0x3c, 0x0a, 0x18, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, - 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x0c, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x03, 0x52, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xee, 0x01, - 0x0a, 0x19, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, - 0x61, 0x76, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x54, 0x0a, 0x09, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x61, 0x76, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, - 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x61, 0x76, - 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x46, - 0x61, 0x76, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x61, - 0x76, 0x1a, 0x3b, 0x0a, 0x0d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x61, 0x76, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0xfa, - 0x03, 0x0a, 0x15, 0x46, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5e, 0x0a, 0x0b, 0x41, 0x64, 0x64, 0x46, - 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x26, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, - 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, - 0x61, 0x64, 0x64, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x27, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x66, 0x61, 0x76, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a, 0x0a, 0x52, 0x6d, 0x46, 0x61, - 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x25, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, - 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x72, - 0x6d, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, - 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, - 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x72, 0x6d, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x61, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x46, 0x61, 0x76, - 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x27, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, - 0x73, 0x74, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, - 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x66, 0x61, 0x76, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5b, 0x0a, 0x0a, 0x49, 0x73, 0x46, 0x61, - 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x25, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, - 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x69, - 0x73, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, - 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, - 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x69, 0x73, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x64, 0x0a, 0x0d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x46, 0x61, - 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x12, 0x28, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, - 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, 0x61, 0x76, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x29, 0x2e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x66, - 0x61, 0x76, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x38, 0x5a, 0x36, 0x67, - 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, - 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, - 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_favoriteDomain_proto_rawDescOnce sync.Once - file_favoriteDomain_proto_rawDescData = file_favoriteDomain_proto_rawDesc -) - -func file_favoriteDomain_proto_rawDescGZIP() []byte { - file_favoriteDomain_proto_rawDescOnce.Do(func() { - file_favoriteDomain_proto_rawDescData = protoimpl.X.CompressGZIP(file_favoriteDomain_proto_rawDescData) - }) - return file_favoriteDomain_proto_rawDescData -} - -var file_favoriteDomain_proto_msgTypes = make([]protoimpl.MessageInfo, 12) -var file_favoriteDomain_proto_goTypes = []interface{}{ - (*DoutokAddFavRequest)(nil), // 0: favoriteDomain.doutok_add_fav_request - (*DoutokAddFavResponse)(nil), // 1: favoriteDomain.doutok_add_fav_response - (*DoutokRmFavRequest)(nil), // 2: favoriteDomain.doutok_rm_fav_request - (*DoutokRmFavResponse)(nil), // 3: favoriteDomain.doutok_rm_fav_response - (*DoutokListFavRequest)(nil), // 4: favoriteDomain.doutok_list_fav_request - (*DoutokListFavResponse)(nil), // 5: favoriteDomain.doutok_list_fav_response - (*DoutokIsFavRequest)(nil), // 6: favoriteDomain.doutok_is_fav_request - (*DoutokIsFavResponse)(nil), // 7: favoriteDomain.doutok_is_fav_response - (*DoutokCountFavRequest)(nil), // 8: favoriteDomain.doutok_count_fav_request - (*DoutokCountFavResponse)(nil), // 9: favoriteDomain.doutok_count_fav_response - nil, // 10: favoriteDomain.doutok_is_fav_response.IsFavEntry - nil, // 11: favoriteDomain.doutok_count_fav_response.CountFavEntry - (*entity.Video)(nil), // 12: entity.Video -} -var file_favoriteDomain_proto_depIdxs = []int32{ - 12, // 0: favoriteDomain.doutok_list_fav_response.video_list:type_name -> entity.Video - 10, // 1: favoriteDomain.doutok_is_fav_response.is_fav:type_name -> favoriteDomain.doutok_is_fav_response.IsFavEntry - 11, // 2: favoriteDomain.doutok_count_fav_response.count_fav:type_name -> favoriteDomain.doutok_count_fav_response.CountFavEntry - 0, // 3: favoriteDomain.FavoriteDomainService.AddFavorite:input_type -> favoriteDomain.doutok_add_fav_request - 2, // 4: favoriteDomain.FavoriteDomainService.RmFavorite:input_type -> favoriteDomain.doutok_rm_fav_request - 4, // 5: favoriteDomain.FavoriteDomainService.ListFavorite:input_type -> favoriteDomain.doutok_list_fav_request - 6, // 6: favoriteDomain.FavoriteDomainService.IsFavorite:input_type -> favoriteDomain.doutok_is_fav_request - 8, // 7: favoriteDomain.FavoriteDomainService.CountFavorite:input_type -> favoriteDomain.doutok_count_fav_request - 1, // 8: favoriteDomain.FavoriteDomainService.AddFavorite:output_type -> favoriteDomain.doutok_add_fav_response - 3, // 9: favoriteDomain.FavoriteDomainService.RmFavorite:output_type -> favoriteDomain.doutok_rm_fav_response - 5, // 10: favoriteDomain.FavoriteDomainService.ListFavorite:output_type -> favoriteDomain.doutok_list_fav_response - 7, // 11: favoriteDomain.FavoriteDomainService.IsFavorite:output_type -> favoriteDomain.doutok_is_fav_response - 9, // 12: favoriteDomain.FavoriteDomainService.CountFavorite:output_type -> favoriteDomain.doutok_count_fav_response - 8, // [8:13] is the sub-list for method output_type - 3, // [3:8] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_favoriteDomain_proto_init() } -func file_favoriteDomain_proto_init() { - if File_favoriteDomain_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_favoriteDomain_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddFavRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_favoriteDomain_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddFavResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_favoriteDomain_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokRmFavRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_favoriteDomain_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokRmFavResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_favoriteDomain_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListFavRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_favoriteDomain_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListFavResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_favoriteDomain_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokIsFavRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_favoriteDomain_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokIsFavResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_favoriteDomain_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCountFavRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_favoriteDomain_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCountFavResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_favoriteDomain_proto_rawDesc, - NumEnums: 0, - NumMessages: 12, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_favoriteDomain_proto_goTypes, - DependencyIndexes: file_favoriteDomain_proto_depIdxs, - MessageInfos: file_favoriteDomain_proto_msgTypes, - }.Build() - File_favoriteDomain_proto = out.File - file_favoriteDomain_proto_rawDesc = nil - file_favoriteDomain_proto_goTypes = nil - file_favoriteDomain_proto_depIdxs = nil -} - -var _ context.Context - -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -type FavoriteDomainService interface { - AddFavorite(ctx context.Context, req *DoutokAddFavRequest) (res *DoutokAddFavResponse, err error) - RmFavorite(ctx context.Context, req *DoutokRmFavRequest) (res *DoutokRmFavResponse, err error) - ListFavorite(ctx context.Context, req *DoutokListFavRequest) (res *DoutokListFavResponse, err error) - IsFavorite(ctx context.Context, req *DoutokIsFavRequest) (res *DoutokIsFavResponse, err error) - CountFavorite(ctx context.Context, req *DoutokCountFavRequest) (res *DoutokCountFavResponse, err error) -} diff --git a/kitex_gen/favoriteDomain/favoritedomainservice/client.go b/kitex_gen/favoriteDomain/favoritedomainservice/client.go deleted file mode 100644 index 11d48ca8..00000000 --- a/kitex_gen/favoriteDomain/favoritedomainservice/client.go +++ /dev/null @@ -1,73 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package favoritedomainservice - -import ( - "context" - favoriteDomain "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - AddFavorite(ctx context.Context, Req *favoriteDomain.DoutokAddFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokAddFavResponse, err error) - RmFavorite(ctx context.Context, Req *favoriteDomain.DoutokRmFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokRmFavResponse, err error) - ListFavorite(ctx context.Context, Req *favoriteDomain.DoutokListFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokListFavResponse, err error) - IsFavorite(ctx context.Context, Req *favoriteDomain.DoutokIsFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokIsFavResponse, err error) - CountFavorite(ctx context.Context, Req *favoriteDomain.DoutokCountFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokCountFavResponse, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfo(), options...) - if err != nil { - return nil, err - } - return &kFavoriteDomainServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kFavoriteDomainServiceClient struct { - *kClient -} - -func (p *kFavoriteDomainServiceClient) AddFavorite(ctx context.Context, Req *favoriteDomain.DoutokAddFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokAddFavResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.AddFavorite(ctx, Req) -} - -func (p *kFavoriteDomainServiceClient) RmFavorite(ctx context.Context, Req *favoriteDomain.DoutokRmFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokRmFavResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.RmFavorite(ctx, Req) -} - -func (p *kFavoriteDomainServiceClient) ListFavorite(ctx context.Context, Req *favoriteDomain.DoutokListFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokListFavResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.ListFavorite(ctx, Req) -} - -func (p *kFavoriteDomainServiceClient) IsFavorite(ctx context.Context, Req *favoriteDomain.DoutokIsFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokIsFavResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.IsFavorite(ctx, Req) -} - -func (p *kFavoriteDomainServiceClient) CountFavorite(ctx context.Context, Req *favoriteDomain.DoutokCountFavRequest, callOptions ...callopt.Option) (r *favoriteDomain.DoutokCountFavResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.CountFavorite(ctx, Req) -} diff --git a/kitex_gen/favoriteDomain/favoritedomainservice/favoritedomainservice.go b/kitex_gen/favoriteDomain/favoritedomainservice/favoritedomainservice.go deleted file mode 100644 index d524aab2..00000000 --- a/kitex_gen/favoriteDomain/favoritedomainservice/favoritedomainservice.go +++ /dev/null @@ -1,828 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package favoritedomainservice - -import ( - "context" - "fmt" - favoriteDomain "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" -) - -func serviceInfo() *kitex.ServiceInfo { - return favoriteDomainServiceServiceInfo -} - -var favoriteDomainServiceServiceInfo = NewServiceInfo() - -func NewServiceInfo() *kitex.ServiceInfo { - serviceName := "FavoriteDomainService" - handlerType := (*favoriteDomain.FavoriteDomainService)(nil) - methods := map[string]kitex.MethodInfo{ - "AddFavorite": kitex.NewMethodInfo(addFavoriteHandler, newAddFavoriteArgs, newAddFavoriteResult, false), - "RmFavorite": kitex.NewMethodInfo(rmFavoriteHandler, newRmFavoriteArgs, newRmFavoriteResult, false), - "ListFavorite": kitex.NewMethodInfo(listFavoriteHandler, newListFavoriteArgs, newListFavoriteResult, false), - "IsFavorite": kitex.NewMethodInfo(isFavoriteHandler, newIsFavoriteArgs, newIsFavoriteResult, false), - "CountFavorite": kitex.NewMethodInfo(countFavoriteHandler, newCountFavoriteArgs, newCountFavoriteResult, false), - } - extra := map[string]interface{}{ - "PackageName": "favoriteDomain", - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", - Extra: extra, - } - return svcInfo -} - -func addFavoriteHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(favoriteDomain.DoutokAddFavRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(favoriteDomain.FavoriteDomainService).AddFavorite(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *AddFavoriteArgs: - success, err := handler.(favoriteDomain.FavoriteDomainService).AddFavorite(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*AddFavoriteResult) - realResult.Success = success - } - return nil -} -func newAddFavoriteArgs() interface{} { - return &AddFavoriteArgs{} -} - -func newAddFavoriteResult() interface{} { - return &AddFavoriteResult{} -} - -type AddFavoriteArgs struct { - Req *favoriteDomain.DoutokAddFavRequest -} - -func (p *AddFavoriteArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(favoriteDomain.DoutokAddFavRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *AddFavoriteArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *AddFavoriteArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *AddFavoriteArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in AddFavoriteArgs") - } - return proto.Marshal(p.Req) -} - -func (p *AddFavoriteArgs) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokAddFavRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var AddFavoriteArgs_Req_DEFAULT *favoriteDomain.DoutokAddFavRequest - -func (p *AddFavoriteArgs) GetReq() *favoriteDomain.DoutokAddFavRequest { - if !p.IsSetReq() { - return AddFavoriteArgs_Req_DEFAULT - } - return p.Req -} - -func (p *AddFavoriteArgs) IsSetReq() bool { - return p.Req != nil -} - -type AddFavoriteResult struct { - Success *favoriteDomain.DoutokAddFavResponse -} - -var AddFavoriteResult_Success_DEFAULT *favoriteDomain.DoutokAddFavResponse - -func (p *AddFavoriteResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(favoriteDomain.DoutokAddFavResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *AddFavoriteResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *AddFavoriteResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *AddFavoriteResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in AddFavoriteResult") - } - return proto.Marshal(p.Success) -} - -func (p *AddFavoriteResult) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokAddFavResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *AddFavoriteResult) GetSuccess() *favoriteDomain.DoutokAddFavResponse { - if !p.IsSetSuccess() { - return AddFavoriteResult_Success_DEFAULT - } - return p.Success -} - -func (p *AddFavoriteResult) SetSuccess(x interface{}) { - p.Success = x.(*favoriteDomain.DoutokAddFavResponse) -} - -func (p *AddFavoriteResult) IsSetSuccess() bool { - return p.Success != nil -} - -func rmFavoriteHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(favoriteDomain.DoutokRmFavRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(favoriteDomain.FavoriteDomainService).RmFavorite(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *RmFavoriteArgs: - success, err := handler.(favoriteDomain.FavoriteDomainService).RmFavorite(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*RmFavoriteResult) - realResult.Success = success - } - return nil -} -func newRmFavoriteArgs() interface{} { - return &RmFavoriteArgs{} -} - -func newRmFavoriteResult() interface{} { - return &RmFavoriteResult{} -} - -type RmFavoriteArgs struct { - Req *favoriteDomain.DoutokRmFavRequest -} - -func (p *RmFavoriteArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(favoriteDomain.DoutokRmFavRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *RmFavoriteArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *RmFavoriteArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *RmFavoriteArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in RmFavoriteArgs") - } - return proto.Marshal(p.Req) -} - -func (p *RmFavoriteArgs) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokRmFavRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var RmFavoriteArgs_Req_DEFAULT *favoriteDomain.DoutokRmFavRequest - -func (p *RmFavoriteArgs) GetReq() *favoriteDomain.DoutokRmFavRequest { - if !p.IsSetReq() { - return RmFavoriteArgs_Req_DEFAULT - } - return p.Req -} - -func (p *RmFavoriteArgs) IsSetReq() bool { - return p.Req != nil -} - -type RmFavoriteResult struct { - Success *favoriteDomain.DoutokRmFavResponse -} - -var RmFavoriteResult_Success_DEFAULT *favoriteDomain.DoutokRmFavResponse - -func (p *RmFavoriteResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(favoriteDomain.DoutokRmFavResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *RmFavoriteResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *RmFavoriteResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *RmFavoriteResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in RmFavoriteResult") - } - return proto.Marshal(p.Success) -} - -func (p *RmFavoriteResult) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokRmFavResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *RmFavoriteResult) GetSuccess() *favoriteDomain.DoutokRmFavResponse { - if !p.IsSetSuccess() { - return RmFavoriteResult_Success_DEFAULT - } - return p.Success -} - -func (p *RmFavoriteResult) SetSuccess(x interface{}) { - p.Success = x.(*favoriteDomain.DoutokRmFavResponse) -} - -func (p *RmFavoriteResult) IsSetSuccess() bool { - return p.Success != nil -} - -func listFavoriteHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(favoriteDomain.DoutokListFavRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(favoriteDomain.FavoriteDomainService).ListFavorite(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *ListFavoriteArgs: - success, err := handler.(favoriteDomain.FavoriteDomainService).ListFavorite(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*ListFavoriteResult) - realResult.Success = success - } - return nil -} -func newListFavoriteArgs() interface{} { - return &ListFavoriteArgs{} -} - -func newListFavoriteResult() interface{} { - return &ListFavoriteResult{} -} - -type ListFavoriteArgs struct { - Req *favoriteDomain.DoutokListFavRequest -} - -func (p *ListFavoriteArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(favoriteDomain.DoutokListFavRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *ListFavoriteArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *ListFavoriteArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *ListFavoriteArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in ListFavoriteArgs") - } - return proto.Marshal(p.Req) -} - -func (p *ListFavoriteArgs) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokListFavRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var ListFavoriteArgs_Req_DEFAULT *favoriteDomain.DoutokListFavRequest - -func (p *ListFavoriteArgs) GetReq() *favoriteDomain.DoutokListFavRequest { - if !p.IsSetReq() { - return ListFavoriteArgs_Req_DEFAULT - } - return p.Req -} - -func (p *ListFavoriteArgs) IsSetReq() bool { - return p.Req != nil -} - -type ListFavoriteResult struct { - Success *favoriteDomain.DoutokListFavResponse -} - -var ListFavoriteResult_Success_DEFAULT *favoriteDomain.DoutokListFavResponse - -func (p *ListFavoriteResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(favoriteDomain.DoutokListFavResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *ListFavoriteResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *ListFavoriteResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *ListFavoriteResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in ListFavoriteResult") - } - return proto.Marshal(p.Success) -} - -func (p *ListFavoriteResult) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokListFavResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *ListFavoriteResult) GetSuccess() *favoriteDomain.DoutokListFavResponse { - if !p.IsSetSuccess() { - return ListFavoriteResult_Success_DEFAULT - } - return p.Success -} - -func (p *ListFavoriteResult) SetSuccess(x interface{}) { - p.Success = x.(*favoriteDomain.DoutokListFavResponse) -} - -func (p *ListFavoriteResult) IsSetSuccess() bool { - return p.Success != nil -} - -func isFavoriteHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(favoriteDomain.DoutokIsFavRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(favoriteDomain.FavoriteDomainService).IsFavorite(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *IsFavoriteArgs: - success, err := handler.(favoriteDomain.FavoriteDomainService).IsFavorite(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*IsFavoriteResult) - realResult.Success = success - } - return nil -} -func newIsFavoriteArgs() interface{} { - return &IsFavoriteArgs{} -} - -func newIsFavoriteResult() interface{} { - return &IsFavoriteResult{} -} - -type IsFavoriteArgs struct { - Req *favoriteDomain.DoutokIsFavRequest -} - -func (p *IsFavoriteArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(favoriteDomain.DoutokIsFavRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *IsFavoriteArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *IsFavoriteArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *IsFavoriteArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in IsFavoriteArgs") - } - return proto.Marshal(p.Req) -} - -func (p *IsFavoriteArgs) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokIsFavRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var IsFavoriteArgs_Req_DEFAULT *favoriteDomain.DoutokIsFavRequest - -func (p *IsFavoriteArgs) GetReq() *favoriteDomain.DoutokIsFavRequest { - if !p.IsSetReq() { - return IsFavoriteArgs_Req_DEFAULT - } - return p.Req -} - -func (p *IsFavoriteArgs) IsSetReq() bool { - return p.Req != nil -} - -type IsFavoriteResult struct { - Success *favoriteDomain.DoutokIsFavResponse -} - -var IsFavoriteResult_Success_DEFAULT *favoriteDomain.DoutokIsFavResponse - -func (p *IsFavoriteResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(favoriteDomain.DoutokIsFavResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *IsFavoriteResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *IsFavoriteResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *IsFavoriteResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in IsFavoriteResult") - } - return proto.Marshal(p.Success) -} - -func (p *IsFavoriteResult) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokIsFavResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *IsFavoriteResult) GetSuccess() *favoriteDomain.DoutokIsFavResponse { - if !p.IsSetSuccess() { - return IsFavoriteResult_Success_DEFAULT - } - return p.Success -} - -func (p *IsFavoriteResult) SetSuccess(x interface{}) { - p.Success = x.(*favoriteDomain.DoutokIsFavResponse) -} - -func (p *IsFavoriteResult) IsSetSuccess() bool { - return p.Success != nil -} - -func countFavoriteHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(favoriteDomain.DoutokCountFavRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(favoriteDomain.FavoriteDomainService).CountFavorite(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *CountFavoriteArgs: - success, err := handler.(favoriteDomain.FavoriteDomainService).CountFavorite(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*CountFavoriteResult) - realResult.Success = success - } - return nil -} -func newCountFavoriteArgs() interface{} { - return &CountFavoriteArgs{} -} - -func newCountFavoriteResult() interface{} { - return &CountFavoriteResult{} -} - -type CountFavoriteArgs struct { - Req *favoriteDomain.DoutokCountFavRequest -} - -func (p *CountFavoriteArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(favoriteDomain.DoutokCountFavRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *CountFavoriteArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *CountFavoriteArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *CountFavoriteArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in CountFavoriteArgs") - } - return proto.Marshal(p.Req) -} - -func (p *CountFavoriteArgs) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokCountFavRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var CountFavoriteArgs_Req_DEFAULT *favoriteDomain.DoutokCountFavRequest - -func (p *CountFavoriteArgs) GetReq() *favoriteDomain.DoutokCountFavRequest { - if !p.IsSetReq() { - return CountFavoriteArgs_Req_DEFAULT - } - return p.Req -} - -func (p *CountFavoriteArgs) IsSetReq() bool { - return p.Req != nil -} - -type CountFavoriteResult struct { - Success *favoriteDomain.DoutokCountFavResponse -} - -var CountFavoriteResult_Success_DEFAULT *favoriteDomain.DoutokCountFavResponse - -func (p *CountFavoriteResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(favoriteDomain.DoutokCountFavResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *CountFavoriteResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *CountFavoriteResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *CountFavoriteResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in CountFavoriteResult") - } - return proto.Marshal(p.Success) -} - -func (p *CountFavoriteResult) Unmarshal(in []byte) error { - msg := new(favoriteDomain.DoutokCountFavResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *CountFavoriteResult) GetSuccess() *favoriteDomain.DoutokCountFavResponse { - if !p.IsSetSuccess() { - return CountFavoriteResult_Success_DEFAULT - } - return p.Success -} - -func (p *CountFavoriteResult) SetSuccess(x interface{}) { - p.Success = x.(*favoriteDomain.DoutokCountFavResponse) -} - -func (p *CountFavoriteResult) IsSetSuccess() bool { - return p.Success != nil -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) AddFavorite(ctx context.Context, Req *favoriteDomain.DoutokAddFavRequest) (r *favoriteDomain.DoutokAddFavResponse, err error) { - var _args AddFavoriteArgs - _args.Req = Req - var _result AddFavoriteResult - if err = p.c.Call(ctx, "AddFavorite", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) RmFavorite(ctx context.Context, Req *favoriteDomain.DoutokRmFavRequest) (r *favoriteDomain.DoutokRmFavResponse, err error) { - var _args RmFavoriteArgs - _args.Req = Req - var _result RmFavoriteResult - if err = p.c.Call(ctx, "RmFavorite", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) ListFavorite(ctx context.Context, Req *favoriteDomain.DoutokListFavRequest) (r *favoriteDomain.DoutokListFavResponse, err error) { - var _args ListFavoriteArgs - _args.Req = Req - var _result ListFavoriteResult - if err = p.c.Call(ctx, "ListFavorite", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) IsFavorite(ctx context.Context, Req *favoriteDomain.DoutokIsFavRequest) (r *favoriteDomain.DoutokIsFavResponse, err error) { - var _args IsFavoriteArgs - _args.Req = Req - var _result IsFavoriteResult - if err = p.c.Call(ctx, "IsFavorite", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) CountFavorite(ctx context.Context, Req *favoriteDomain.DoutokCountFavRequest) (r *favoriteDomain.DoutokCountFavResponse, err error) { - var _args CountFavoriteArgs - _args.Req = Req - var _result CountFavoriteResult - if err = p.c.Call(ctx, "CountFavorite", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/kitex_gen/favoriteDomain/favoritedomainservice/invoker.go b/kitex_gen/favoriteDomain/favoritedomainservice/invoker.go deleted file mode 100644 index 278087d9..00000000 --- a/kitex_gen/favoriteDomain/favoritedomainservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package favoritedomainservice - -import ( - favoriteDomain "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler favoriteDomain.FavoriteDomainService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/kitex_gen/favoriteDomain/favoritedomainservice/server.go b/kitex_gen/favoriteDomain/favoritedomainservice/server.go deleted file mode 100644 index 3cc543e9..00000000 --- a/kitex_gen/favoriteDomain/favoritedomainservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. -package favoritedomainservice - -import ( - favoriteDomain "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler favoriteDomain.FavoriteDomainService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/kitex_gen/feed/feed.pb.fast.go b/kitex_gen/feed/feed.pb.fast.go deleted file mode 100644 index 6287423c..00000000 --- a/kitex_gen/feed/feed.pb.fast.go +++ /dev/null @@ -1,353 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package feed - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DouyinFeedRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFeedRequest[number], err) -} - -func (x *DouyinFeedRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.LatestTime, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinFeedRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinFeedResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - case 4: - offset, err = x.fastReadField4(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFeedResponse[number], err) -} - -func (x *DouyinFeedResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinFeedResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinFeedResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Video - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.VideoList = append(x.VideoList, &v) - return offset, nil -} - -func (x *DouyinFeedResponse) fastReadField4(buf []byte, _type int8) (offset int, err error) { - x.NextTime, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *VideoIdRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_VideoIdRequest[number], err) -} - -func (x *VideoIdRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *VideoIdRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.SearchId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinFeedRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DouyinFeedRequest) fastWriteField1(buf []byte) (offset int) { - if x.LatestTime == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.LatestTime) - return offset -} - -func (x *DouyinFeedRequest) fastWriteField2(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.UserId) - return offset -} - -func (x *DouyinFeedResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - offset += x.fastWriteField4(buf[offset:]) - return offset -} - -func (x *DouyinFeedResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinFeedResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinFeedResponse) fastWriteField3(buf []byte) (offset int) { - if x.VideoList == nil { - return offset - } - for i := range x.VideoList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.VideoList[i]) - } - return offset -} - -func (x *DouyinFeedResponse) fastWriteField4(buf []byte) (offset int) { - if x.NextTime == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 4, x.NextTime) - return offset -} - -func (x *VideoIdRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *VideoIdRequest) fastWriteField1(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.VideoId) - return offset -} - -func (x *VideoIdRequest) fastWriteField2(buf []byte) (offset int) { - if x.SearchId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.SearchId) - return offset -} - -func (x *DouyinFeedRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DouyinFeedRequest) sizeField1() (n int) { - if x.LatestTime == 0 { - return n - } - n += fastpb.SizeInt64(1, x.LatestTime) - return n -} - -func (x *DouyinFeedRequest) sizeField2() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.UserId) - return n -} - -func (x *DouyinFeedResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - n += x.sizeField4() - return n -} - -func (x *DouyinFeedResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinFeedResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinFeedResponse) sizeField3() (n int) { - if x.VideoList == nil { - return n - } - for i := range x.VideoList { - n += fastpb.SizeMessage(3, x.VideoList[i]) - } - return n -} - -func (x *DouyinFeedResponse) sizeField4() (n int) { - if x.NextTime == 0 { - return n - } - n += fastpb.SizeInt64(4, x.NextTime) - return n -} - -func (x *VideoIdRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *VideoIdRequest) sizeField1() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.VideoId) - return n -} - -func (x *VideoIdRequest) sizeField2() (n int) { - if x.SearchId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.SearchId) - return n -} - -var fieldIDToName_DouyinFeedRequest = map[int32]string{ - 1: "LatestTime", - 2: "UserId", -} - -var fieldIDToName_DouyinFeedResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "VideoList", - 4: "NextTime", -} - -var fieldIDToName_VideoIdRequest = map[int32]string{ - 1: "VideoId", - 2: "SearchId", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/feed/feed.pb.go b/kitex_gen/feed/feed.pb.go index 7cc1adf8..65d9577d 100644 --- a/kitex_gen/feed/feed.pb.go +++ b/kitex_gen/feed/feed.pb.go @@ -1,14 +1,14 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 +// protoc-gen-go v1.28.0 +// protoc v3.19.4 // source: feed.proto package feed import ( context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" + user "github.com/TremblingV5/DouTok/kitex_gen/user" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -85,10 +85,10 @@ type DouyinFeedResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - VideoList []*entity.Video `protobuf:"bytes,3,rep,name=video_list,json=videoList,proto3" json:"video_list,omitempty"` // 视频列表 - NextTime int64 `protobuf:"varint,4,opt,name=next_time,json=nextTime,proto3" json:"next_time,omitempty"` // 本次返回的视频中,发布最早的时间,作为下次请求时的latest_time + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + VideoList []*Video `protobuf:"bytes,3,rep,name=video_list,json=videoList,proto3" json:"video_list,omitempty"` // 视频列表 + NextTime int64 `protobuf:"varint,4,opt,name=next_time,json=nextTime,proto3" json:"next_time,omitempty"` // 本次返回的视频中,发布最早的时间,作为下次请求时的latest_time } func (x *DouyinFeedResponse) Reset() { @@ -137,7 +137,7 @@ func (x *DouyinFeedResponse) GetStatusMsg() string { return "" } -func (x *DouyinFeedResponse) GetVideoList() []*entity.Video { +func (x *DouyinFeedResponse) GetVideoList() []*Video { if x != nil { return x.VideoList } @@ -206,44 +206,163 @@ func (x *VideoIdRequest) GetSearchId() int64 { return 0 } +type Video struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 视频唯一标识 + Author *user.User `protobuf:"bytes,2,opt,name=author,proto3" json:"author,omitempty"` // 视频作者信息 + PlayUrl string `protobuf:"bytes,3,opt,name=play_url,json=playUrl,proto3" json:"play_url,omitempty"` // 视频播放地址 + CoverUrl string `protobuf:"bytes,4,opt,name=cover_url,json=coverUrl,proto3" json:"cover_url,omitempty"` // 视频封面地址 + FavoriteCount int64 `protobuf:"varint,5,opt,name=favorite_count,json=favoriteCount,proto3" json:"favorite_count,omitempty"` // 视频的点赞总数 + CommentCount int64 `protobuf:"varint,6,opt,name=comment_count,json=commentCount,proto3" json:"comment_count,omitempty"` // 视频的评论总数 + IsFavorite bool `protobuf:"varint,7,opt,name=is_favorite,json=isFavorite,proto3" json:"is_favorite,omitempty"` // true-已点赞,false-未点赞 + Title string `protobuf:"bytes,8,opt,name=title,proto3" json:"title,omitempty"` // 视频标题 +} + +func (x *Video) Reset() { + *x = Video{} + if protoimpl.UnsafeEnabled { + mi := &file_feed_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Video) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Video) ProtoMessage() {} + +func (x *Video) ProtoReflect() protoreflect.Message { + mi := &file_feed_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Video.ProtoReflect.Descriptor instead. +func (*Video) Descriptor() ([]byte, []int) { + return file_feed_proto_rawDescGZIP(), []int{3} +} + +func (x *Video) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Video) GetAuthor() *user.User { + if x != nil { + return x.Author + } + return nil +} + +func (x *Video) GetPlayUrl() string { + if x != nil { + return x.PlayUrl + } + return "" +} + +func (x *Video) GetCoverUrl() string { + if x != nil { + return x.CoverUrl + } + return "" +} + +func (x *Video) GetFavoriteCount() int64 { + if x != nil { + return x.FavoriteCount + } + return 0 +} + +func (x *Video) GetCommentCount() int64 { + if x != nil { + return x.CommentCount + } + return 0 +} + +func (x *Video) GetIsFavorite() bool { + if x != nil { + return x.IsFavorite + } + return false +} + +func (x *Video) GetTitle() string { + if x != nil { + return x.Title + } + return "" +} + var File_feed_proto protoreflect.FileDescriptor var file_feed_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x66, 0x65, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x66, 0x65, - 0x65, 0x64, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x4f, 0x0a, 0x13, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x65, 0x65, 0x64, 0x5f, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x61, 0x74, 0x65, 0x73, - 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6c, 0x61, - 0x74, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, - 0x64, 0x22, 0xa1, 0x01, 0x0a, 0x14, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x65, 0x65, - 0x64, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x2c, 0x0a, 0x0a, 0x76, 0x69, - 0x64, 0x65, 0x6f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, - 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, 0x09, 0x76, - 0x69, 0x64, 0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, - 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6e, 0x65, 0x78, - 0x74, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x4a, 0x0a, 0x10, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, - 0x64, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, - 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, - 0x65, 0x6f, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x49, - 0x64, 0x32, 0x8a, 0x01, 0x0a, 0x0b, 0x46, 0x65, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, - 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x46, 0x65, 0x65, 0x64, - 0x12, 0x19, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, - 0x65, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x66, 0x65, - 0x65, 0x64, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x65, 0x65, 0x64, 0x5f, 0x72, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x35, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x56, 0x69, - 0x64, 0x65, 0x6f, 0x42, 0x79, 0x49, 0x64, 0x12, 0x16, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x2e, 0x76, - 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0d, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x42, 0x2e, - 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, - 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, - 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x66, 0x65, 0x65, 0x64, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x64, 0x1a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4f, + 0x0a, 0x13, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x65, 0x65, 0x64, 0x5f, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, + 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x6c, 0x61, 0x74, 0x65, + 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, + 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, + 0x9f, 0x01, 0x0a, 0x14, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x65, 0x65, 0x64, 0x5f, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x2a, 0x0a, 0x0a, 0x76, 0x69, 0x64, 0x65, + 0x6f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x66, + 0x65, 0x65, 0x64, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, 0x09, 0x76, 0x69, 0x64, 0x65, 0x6f, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x6d, + 0x65, 0x22, 0x4a, 0x0a, 0x10, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, + 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x49, 0x64, 0x22, 0xf6, 0x01, + 0x0a, 0x05, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x22, 0x0a, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, + 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x06, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x70, + 0x6c, 0x61, 0x79, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, + 0x6c, 0x61, 0x79, 0x55, 0x72, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x5f, + 0x75, 0x72, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x6f, 0x76, 0x65, 0x72, + 0x55, 0x72, 0x6c, 0x12, 0x25, 0x0a, 0x0e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x66, 0x61, 0x76, + 0x6f, 0x72, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, + 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0c, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x1f, 0x0a, 0x0b, 0x69, 0x73, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x69, 0x73, 0x46, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, + 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x32, 0x88, 0x01, 0x0a, 0x0b, 0x46, 0x65, 0x65, 0x64, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, + 0x72, 0x46, 0x65, 0x65, 0x64, 0x12, 0x19, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x2e, 0x64, 0x6f, 0x75, + 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x65, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x1a, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, + 0x65, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x33, 0x0a, 0x0c, + 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x42, 0x79, 0x49, 0x64, 0x12, 0x16, 0x2e, 0x66, + 0x65, 0x65, 0x64, 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x5f, 0x72, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0b, 0x2e, 0x66, 0x65, 0x65, 0x64, 0x2e, 0x56, 0x69, 0x64, 0x65, + 0x6f, 0x42, 0x43, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, + 0x6f, 0x6b, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, + 0x6e, 0x2f, 0x66, 0x65, 0x65, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -258,24 +377,26 @@ func file_feed_proto_rawDescGZIP() []byte { return file_feed_proto_rawDescData } -var file_feed_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_feed_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_feed_proto_goTypes = []interface{}{ (*DouyinFeedRequest)(nil), // 0: feed.douyin_feed_request (*DouyinFeedResponse)(nil), // 1: feed.douyin_feed_response (*VideoIdRequest)(nil), // 2: feed.video_id_request - (*entity.Video)(nil), // 3: entity.Video + (*Video)(nil), // 3: feed.Video + (*user.User)(nil), // 4: user.User } var file_feed_proto_depIdxs = []int32{ - 3, // 0: feed.douyin_feed_response.video_list:type_name -> entity.Video - 0, // 1: feed.FeedService.GetUserFeed:input_type -> feed.douyin_feed_request - 2, // 2: feed.FeedService.GetVideoById:input_type -> feed.video_id_request - 1, // 3: feed.FeedService.GetUserFeed:output_type -> feed.douyin_feed_response - 3, // 4: feed.FeedService.GetVideoById:output_type -> entity.Video - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 3, // 0: feed.douyin_feed_response.video_list:type_name -> feed.Video + 4, // 1: feed.Video.author:type_name -> user.User + 0, // 2: feed.FeedService.GetUserFeed:input_type -> feed.douyin_feed_request + 2, // 3: feed.FeedService.GetVideoById:input_type -> feed.video_id_request + 1, // 4: feed.FeedService.GetUserFeed:output_type -> feed.douyin_feed_response + 3, // 5: feed.FeedService.GetVideoById:output_type -> feed.Video + 4, // [4:6] is the sub-list for method output_type + 2, // [2:4] is the sub-list for method input_type + 2, // [2:2] is the sub-list for extension type_name + 2, // [2:2] is the sub-list for extension extendee + 0, // [0:2] is the sub-list for field type_name } func init() { file_feed_proto_init() } @@ -320,6 +441,18 @@ func file_feed_proto_init() { return nil } } + file_feed_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Video); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -327,7 +460,7 @@ func file_feed_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_feed_proto_rawDesc, NumEnums: 0, - NumMessages: 3, + NumMessages: 4, NumExtensions: 0, NumServices: 1, }, @@ -343,9 +476,9 @@ func file_feed_proto_init() { var _ context.Context -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. type FeedService interface { GetUserFeed(ctx context.Context, req *DouyinFeedRequest) (res *DouyinFeedResponse, err error) - GetVideoById(ctx context.Context, req *VideoIdRequest) (res *entity.Video, err error) + GetVideoById(ctx context.Context, req *VideoIdRequest) (res *Video, err error) } diff --git a/kitex_gen/feed/feedservice/client.go b/kitex_gen/feed/feedservice/client.go index 927f3c65..f26a9621 100644 --- a/kitex_gen/feed/feedservice/client.go +++ b/kitex_gen/feed/feedservice/client.go @@ -1,19 +1,18 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package feedservice import ( "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - feed "github.com/TremblingV5/DouTok/kitex_gen/feed" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/TremblingV5/DouTok/kitex_gen/feed" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { GetUserFeed(ctx context.Context, Req *feed.DouyinFeedRequest, callOptions ...callopt.Option) (r *feed.DouyinFeedResponse, err error) - GetVideoById(ctx context.Context, Req *feed.VideoIdRequest, callOptions ...callopt.Option) (r *entity.Video, err error) + GetVideoById(ctx context.Context, Req *feed.VideoIdRequest, callOptions ...callopt.Option) (r *feed.Video, err error) } // NewClient creates a client for the service defined in IDL. @@ -50,7 +49,7 @@ func (p *kFeedServiceClient) GetUserFeed(ctx context.Context, Req *feed.DouyinFe return p.kClient.GetUserFeed(ctx, Req) } -func (p *kFeedServiceClient) GetVideoById(ctx context.Context, Req *feed.VideoIdRequest, callOptions ...callopt.Option) (r *entity.Video, err error) { +func (p *kFeedServiceClient) GetVideoById(ctx context.Context, Req *feed.VideoIdRequest, callOptions ...callopt.Option) (r *feed.Video, err error) { ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.GetVideoById(ctx, Req) } diff --git a/kitex_gen/feed/feedservice/feedservice.go b/kitex_gen/feed/feedservice/feedservice.go index 48eba1c4..5f701909 100644 --- a/kitex_gen/feed/feedservice/feedservice.go +++ b/kitex_gen/feed/feedservice/feedservice.go @@ -1,16 +1,15 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package feedservice import ( "context" "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - feed "github.com/TremblingV5/DouTok/kitex_gen/feed" - client "github.com/cloudwego/kitex/client" + "github.com/TremblingV5/DouTok/kitex_gen/feed" + "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" + "github.com/cloudwego/kitex/pkg/streaming" + "google.golang.org/protobuf/proto" ) func serviceInfo() *kitex.ServiceInfo { @@ -34,7 +33,7 @@ func NewServiceInfo() *kitex.ServiceInfo { HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", + KiteXGenVersion: "v0.3.4", Extra: extra, } return svcInfo @@ -77,27 +76,6 @@ type GetUserFeedArgs struct { Req *feed.DouyinFeedRequest } -func (p *GetUserFeedArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(feed.DouyinFeedRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *GetUserFeedArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *GetUserFeedArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *GetUserFeedArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in GetUserFeedArgs") @@ -133,27 +111,6 @@ type GetUserFeedResult struct { var GetUserFeedResult_Success_DEFAULT *feed.DouyinFeedResponse -func (p *GetUserFeedResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(feed.DouyinFeedResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *GetUserFeedResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *GetUserFeedResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - func (p *GetUserFeedResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { return out, fmt.Errorf("No req in GetUserFeedResult") @@ -222,27 +179,6 @@ type GetVideoByIdArgs struct { Req *feed.VideoIdRequest } -func (p *GetVideoByIdArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(feed.VideoIdRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *GetVideoByIdArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *GetVideoByIdArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *GetVideoByIdArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in GetVideoByIdArgs") @@ -273,31 +209,10 @@ func (p *GetVideoByIdArgs) IsSetReq() bool { } type GetVideoByIdResult struct { - Success *entity.Video + Success *feed.Video } -var GetVideoByIdResult_Success_DEFAULT *entity.Video - -func (p *GetVideoByIdResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(entity.Video) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *GetVideoByIdResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *GetVideoByIdResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} +var GetVideoByIdResult_Success_DEFAULT *feed.Video func (p *GetVideoByIdResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { @@ -307,7 +222,7 @@ func (p *GetVideoByIdResult) Marshal(out []byte) ([]byte, error) { } func (p *GetVideoByIdResult) Unmarshal(in []byte) error { - msg := new(entity.Video) + msg := new(feed.Video) if err := proto.Unmarshal(in, msg); err != nil { return err } @@ -315,7 +230,7 @@ func (p *GetVideoByIdResult) Unmarshal(in []byte) error { return nil } -func (p *GetVideoByIdResult) GetSuccess() *entity.Video { +func (p *GetVideoByIdResult) GetSuccess() *feed.Video { if !p.IsSetSuccess() { return GetVideoByIdResult_Success_DEFAULT } @@ -323,7 +238,7 @@ func (p *GetVideoByIdResult) GetSuccess() *entity.Video { } func (p *GetVideoByIdResult) SetSuccess(x interface{}) { - p.Success = x.(*entity.Video) + p.Success = x.(*feed.Video) } func (p *GetVideoByIdResult) IsSetSuccess() bool { @@ -350,7 +265,7 @@ func (p *kClient) GetUserFeed(ctx context.Context, Req *feed.DouyinFeedRequest) return _result.GetSuccess(), nil } -func (p *kClient) GetVideoById(ctx context.Context, Req *feed.VideoIdRequest) (r *entity.Video, err error) { +func (p *kClient) GetVideoById(ctx context.Context, Req *feed.VideoIdRequest) (r *feed.Video, err error) { var _args GetVideoByIdArgs _args.Req = Req var _result GetVideoByIdResult diff --git a/kitex_gen/feed/feedservice/invoker.go b/kitex_gen/feed/feedservice/invoker.go index 3dc51f4b..2f5c22d5 100644 --- a/kitex_gen/feed/feedservice/invoker.go +++ b/kitex_gen/feed/feedservice/invoker.go @@ -1,10 +1,10 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package feedservice import ( - feed "github.com/TremblingV5/DouTok/kitex_gen/feed" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/feed" + "github.com/cloudwego/kitex/server" ) // NewInvoker creates a server.Invoker with the given handler and options. diff --git a/kitex_gen/feed/feedservice/server.go b/kitex_gen/feed/feedservice/server.go index bedc128a..d4c762f3 100644 --- a/kitex_gen/feed/feedservice/server.go +++ b/kitex_gen/feed/feedservice/server.go @@ -1,9 +1,9 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package feedservice import ( - feed "github.com/TremblingV5/DouTok/kitex_gen/feed" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/feed" + "github.com/cloudwego/kitex/server" ) // NewServer creates a server.Server with the given handler and options. diff --git a/kitex_gen/message/message.pb.fast.go b/kitex_gen/message/message.pb.fast.go deleted file mode 100644 index 6c18a363..00000000 --- a/kitex_gen/message/message.pb.fast.go +++ /dev/null @@ -1,767 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package message - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DouyinMessageChatRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinMessageChatRequest[number], err) -} - -func (x *DouyinMessageChatRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.ToUserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinMessageChatRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinMessageChatRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.PreMsgTime, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinMessageChatResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinMessageChatResponse[number], err) -} - -func (x *DouyinMessageChatResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinMessageChatResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinMessageChatResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Message - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.MessageList = append(x.MessageList, &v) - return offset, nil -} - -func (x *DouyinMessageActionRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - case 4: - offset, err = x.fastReadField4(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinMessageActionRequest[number], err) -} - -func (x *DouyinMessageActionRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.ToUserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinMessageActionRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinMessageActionRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.ActionType, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinMessageActionRequest) fastReadField4(buf []byte, _type int8) (offset int, err error) { - x.Content, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinMessageActionResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinMessageActionResponse[number], err) -} - -func (x *DouyinMessageActionResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinMessageActionResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinFriendListMessageRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFriendListMessageRequest[number], err) -} - -func (x *DouyinFriendListMessageRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinFriendListMessageRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.FriendIdList = append(x.FriendIdList, v) - return offset, err - }) - return offset, err -} - -func (x *DouyinFriendListMessageResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinFriendListMessageResponse[number], err) -} - -func (x *DouyinFriendListMessageResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinFriendListMessageResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinFriendListMessageResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.Result == nil { - x.Result = make(map[int64]*entity.Message) - } - var key int64 - var value *entity.Message - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - var v entity.Message - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - value = &v - return offset, nil - }) - if err != nil { - return offset, err - } - x.Result[key] = value - return offset, nil -} - -func (x *DouyinMessageChatRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinMessageChatRequest) fastWriteField1(buf []byte) (offset int) { - if x.ToUserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.ToUserId) - return offset -} - -func (x *DouyinMessageChatRequest) fastWriteField2(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.UserId) - return offset -} - -func (x *DouyinMessageChatRequest) fastWriteField3(buf []byte) (offset int) { - if x.PreMsgTime == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 3, x.PreMsgTime) - return offset -} - -func (x *DouyinMessageChatResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinMessageChatResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinMessageChatResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinMessageChatResponse) fastWriteField3(buf []byte) (offset int) { - if x.MessageList == nil { - return offset - } - for i := range x.MessageList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.MessageList[i]) - } - return offset -} - -func (x *DouyinMessageActionRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - offset += x.fastWriteField4(buf[offset:]) - return offset -} - -func (x *DouyinMessageActionRequest) fastWriteField1(buf []byte) (offset int) { - if x.ToUserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.ToUserId) - return offset -} - -func (x *DouyinMessageActionRequest) fastWriteField2(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.UserId) - return offset -} - -func (x *DouyinMessageActionRequest) fastWriteField3(buf []byte) (offset int) { - if x.ActionType == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 3, x.ActionType) - return offset -} - -func (x *DouyinMessageActionRequest) fastWriteField4(buf []byte) (offset int) { - if x.Content == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 4, x.Content) - return offset -} - -func (x *DouyinMessageActionResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DouyinMessageActionResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinMessageActionResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinFriendListMessageRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DouyinFriendListMessageRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DouyinFriendListMessageRequest) fastWriteField2(buf []byte) (offset int) { - if len(x.FriendIdList) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 2, len(x.FriendIdList), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.FriendIdList[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DouyinFriendListMessageResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinFriendListMessageResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinFriendListMessageResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinFriendListMessageResponse) fastWriteField3(buf []byte) (offset int) { - if x.Result == nil { - return offset - } - for k, v := range x.Result { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteMessage(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DouyinMessageChatRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinMessageChatRequest) sizeField1() (n int) { - if x.ToUserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.ToUserId) - return n -} - -func (x *DouyinMessageChatRequest) sizeField2() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.UserId) - return n -} - -func (x *DouyinMessageChatRequest) sizeField3() (n int) { - if x.PreMsgTime == 0 { - return n - } - n += fastpb.SizeInt64(3, x.PreMsgTime) - return n -} - -func (x *DouyinMessageChatResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinMessageChatResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinMessageChatResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinMessageChatResponse) sizeField3() (n int) { - if x.MessageList == nil { - return n - } - for i := range x.MessageList { - n += fastpb.SizeMessage(3, x.MessageList[i]) - } - return n -} - -func (x *DouyinMessageActionRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - n += x.sizeField4() - return n -} - -func (x *DouyinMessageActionRequest) sizeField1() (n int) { - if x.ToUserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.ToUserId) - return n -} - -func (x *DouyinMessageActionRequest) sizeField2() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.UserId) - return n -} - -func (x *DouyinMessageActionRequest) sizeField3() (n int) { - if x.ActionType == 0 { - return n - } - n += fastpb.SizeInt32(3, x.ActionType) - return n -} - -func (x *DouyinMessageActionRequest) sizeField4() (n int) { - if x.Content == "" { - return n - } - n += fastpb.SizeString(4, x.Content) - return n -} - -func (x *DouyinMessageActionResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DouyinMessageActionResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinMessageActionResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinFriendListMessageRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DouyinFriendListMessageRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DouyinFriendListMessageRequest) sizeField2() (n int) { - if len(x.FriendIdList) == 0 { - return n - } - n += fastpb.SizeListPacked(2, len(x.FriendIdList), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.FriendIdList[numIdxOrVal]) - return n - }) - return n -} - -func (x *DouyinFriendListMessageResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinFriendListMessageResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinFriendListMessageResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinFriendListMessageResponse) sizeField3() (n int) { - if x.Result == nil { - return n - } - for k, v := range x.Result { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeMessage(numIdxOrVal, v) - return n - }) - } - return n -} - -var fieldIDToName_DouyinMessageChatRequest = map[int32]string{ - 1: "ToUserId", - 2: "UserId", - 3: "PreMsgTime", -} - -var fieldIDToName_DouyinMessageChatResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "MessageList", -} - -var fieldIDToName_DouyinMessageActionRequest = map[int32]string{ - 1: "ToUserId", - 2: "UserId", - 3: "ActionType", - 4: "Content", -} - -var fieldIDToName_DouyinMessageActionResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", -} - -var fieldIDToName_DouyinFriendListMessageRequest = map[int32]string{ - 1: "UserId", - 2: "FriendIdList", -} - -var fieldIDToName_DouyinFriendListMessageResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "Result", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/message/message.pb.go b/kitex_gen/message/message.pb.go index e6fbf07d..cfed5384 100644 --- a/kitex_gen/message/message.pb.go +++ b/kitex_gen/message/message.pb.go @@ -1,14 +1,13 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 +// protoc-gen-go v1.28.0 +// protoc v3.19.4 // source: message.proto package message import ( context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -90,9 +89,9 @@ type DouyinMessageChatResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - MessageList []*entity.Message `protobuf:"bytes,3,rep,name=message_list,json=messageList,proto3" json:"message_list,omitempty"` // 消息列表 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + MessageList []*Message `protobuf:"bytes,3,rep,name=message_list,json=messageList,proto3" json:"message_list,omitempty"` // 消息列表 } func (x *DouyinMessageChatResponse) Reset() { @@ -141,13 +140,92 @@ func (x *DouyinMessageChatResponse) GetStatusMsg() string { return "" } -func (x *DouyinMessageChatResponse) GetMessageList() []*entity.Message { +func (x *DouyinMessageChatResponse) GetMessageList() []*Message { if x != nil { return x.MessageList } return nil } +type Message struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 消息id + ToUserId int64 `protobuf:"varint,2,opt,name=to_user_id,json=toUserId,proto3" json:"to_user_id,omitempty"` // 该消息接收者的id + FromUserId int64 `protobuf:"varint,3,opt,name=from_user_id,json=fromUserId,proto3" json:"from_user_id,omitempty"` // 该消息发送者的id + Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` // 消息内容 + CreateTime int64 `protobuf:"varint,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` // 消息创建时间 +} + +func (x *Message) Reset() { + *x = Message{} + if protoimpl.UnsafeEnabled { + mi := &file_message_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Message) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Message) ProtoMessage() {} + +func (x *Message) ProtoReflect() protoreflect.Message { + mi := &file_message_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Message.ProtoReflect.Descriptor instead. +func (*Message) Descriptor() ([]byte, []int) { + return file_message_proto_rawDescGZIP(), []int{2} +} + +func (x *Message) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *Message) GetToUserId() int64 { + if x != nil { + return x.ToUserId + } + return 0 +} + +func (x *Message) GetFromUserId() int64 { + if x != nil { + return x.FromUserId + } + return 0 +} + +func (x *Message) GetContent() string { + if x != nil { + return x.Content + } + return "" +} + +func (x *Message) GetCreateTime() int64 { + if x != nil { + return x.CreateTime + } + return 0 +} + type DouyinMessageActionRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -162,7 +240,7 @@ type DouyinMessageActionRequest struct { func (x *DouyinMessageActionRequest) Reset() { *x = DouyinMessageActionRequest{} if protoimpl.UnsafeEnabled { - mi := &file_message_proto_msgTypes[2] + mi := &file_message_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -175,7 +253,7 @@ func (x *DouyinMessageActionRequest) String() string { func (*DouyinMessageActionRequest) ProtoMessage() {} func (x *DouyinMessageActionRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_proto_msgTypes[2] + mi := &file_message_proto_msgTypes[3] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -188,7 +266,7 @@ func (x *DouyinMessageActionRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DouyinMessageActionRequest.ProtoReflect.Descriptor instead. func (*DouyinMessageActionRequest) Descriptor() ([]byte, []int) { - return file_message_proto_rawDescGZIP(), []int{2} + return file_message_proto_rawDescGZIP(), []int{3} } func (x *DouyinMessageActionRequest) GetToUserId() int64 { @@ -224,14 +302,14 @@ type DouyinMessageActionResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 } func (x *DouyinMessageActionResponse) Reset() { *x = DouyinMessageActionResponse{} if protoimpl.UnsafeEnabled { - mi := &file_message_proto_msgTypes[3] + mi := &file_message_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -244,7 +322,7 @@ func (x *DouyinMessageActionResponse) String() string { func (*DouyinMessageActionResponse) ProtoMessage() {} func (x *DouyinMessageActionResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_proto_msgTypes[3] + mi := &file_message_proto_msgTypes[4] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -257,7 +335,7 @@ func (x *DouyinMessageActionResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DouyinMessageActionResponse.ProtoReflect.Descriptor instead. func (*DouyinMessageActionResponse) Descriptor() ([]byte, []int) { - return file_message_proto_rawDescGZIP(), []int{3} + return file_message_proto_rawDescGZIP(), []int{4} } func (x *DouyinMessageActionResponse) GetStatusCode() int32 { @@ -286,7 +364,7 @@ type DouyinFriendListMessageRequest struct { func (x *DouyinFriendListMessageRequest) Reset() { *x = DouyinFriendListMessageRequest{} if protoimpl.UnsafeEnabled { - mi := &file_message_proto_msgTypes[4] + mi := &file_message_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -299,7 +377,7 @@ func (x *DouyinFriendListMessageRequest) String() string { func (*DouyinFriendListMessageRequest) ProtoMessage() {} func (x *DouyinFriendListMessageRequest) ProtoReflect() protoreflect.Message { - mi := &file_message_proto_msgTypes[4] + mi := &file_message_proto_msgTypes[5] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -312,7 +390,7 @@ func (x *DouyinFriendListMessageRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DouyinFriendListMessageRequest.ProtoReflect.Descriptor instead. func (*DouyinFriendListMessageRequest) Descriptor() ([]byte, []int) { - return file_message_proto_rawDescGZIP(), []int{4} + return file_message_proto_rawDescGZIP(), []int{5} } func (x *DouyinFriendListMessageRequest) GetUserId() int64 { @@ -334,15 +412,15 @@ type DouyinFriendListMessageResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - Result map[int64]*entity.Message `protobuf:"bytes,3,rep,name=result,proto3" json:"result,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // key 为好友id,value 为和该好友的最新聊天消息 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + Result map[int64]*Message `protobuf:"bytes,3,rep,name=result,proto3" json:"result,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // key 为好友id,value 为和该好友的最新聊天消息 } func (x *DouyinFriendListMessageResponse) Reset() { *x = DouyinFriendListMessageResponse{} if protoimpl.UnsafeEnabled { - mi := &file_message_proto_msgTypes[5] + mi := &file_message_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -355,7 +433,7 @@ func (x *DouyinFriendListMessageResponse) String() string { func (*DouyinFriendListMessageResponse) ProtoMessage() {} func (x *DouyinFriendListMessageResponse) ProtoReflect() protoreflect.Message { - mi := &file_message_proto_msgTypes[5] + mi := &file_message_proto_msgTypes[6] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -368,7 +446,7 @@ func (x *DouyinFriendListMessageResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DouyinFriendListMessageResponse.ProtoReflect.Descriptor instead. func (*DouyinFriendListMessageResponse) Descriptor() ([]byte, []int) { - return file_message_proto_rawDescGZIP(), []int{5} + return file_message_proto_rawDescGZIP(), []int{6} } func (x *DouyinFriendListMessageResponse) GetStatusCode() int32 { @@ -385,7 +463,7 @@ func (x *DouyinFriendListMessageResponse) GetStatusMsg() string { return "" } -func (x *DouyinFriendListMessageResponse) GetResult() map[int64]*entity.Message { +func (x *DouyinFriendListMessageResponse) GetResult() map[int64]*Message { if x != nil { return x.Result } @@ -396,78 +474,95 @@ var File_message_proto protoreflect.FileDescriptor var file_message_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x76, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, - 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0c, - 0x70, 0x72, 0x65, 0x5f, 0x6d, 0x73, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x4d, 0x73, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x92, - 0x01, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, - 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, - 0x32, 0x0a, 0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, - 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x4d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x4c, - 0x69, 0x73, 0x74, 0x22, 0x91, 0x01, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, - 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, - 0x05, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, - 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x60, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, - 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x22, 0x63, 0x0a, 0x22, 0x64, 0x6f, 0x75, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x76, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x79, + 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, + 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, + 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, + 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x5f, 0x6d, 0x73, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x70, 0x72, 0x65, 0x4d, 0x73, 0x67, 0x54, 0x69, 0x6d, 0x65, + 0x22, 0x93, 0x01, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, + 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, + 0x67, 0x12, 0x33, 0x0a, 0x0c, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x6c, 0x69, 0x73, + 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x0b, 0x6d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x94, 0x01, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, + 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, + 0x12, 0x20, 0x0a, 0x0c, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x66, 0x72, 0x6f, 0x6d, 0x55, 0x73, 0x65, 0x72, + 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x1f, 0x0a, 0x0b, + 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x91, 0x01, + 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x17, 0x0a, + 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x61, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x22, 0x60, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, + 0x61, 0x67, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, + 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, + 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x4d, 0x73, 0x67, 0x22, 0x63, 0x0a, 0x22, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x72, + 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, + 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x5f, + 0x6c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x03, 0x52, 0x0c, 0x66, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x49, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x84, 0x02, 0x0a, 0x23, 0x64, 0x6f, 0x75, + 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, + 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, + 0x12, 0x50, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x38, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, + 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x6d, 0x65, + 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, + 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, + 0x6c, 0x74, 0x1a, 0x4b, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, + 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, + 0x6b, 0x65, 0x79, 0x12, 0x26, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x4d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, + 0xbe, 0x02, 0x0a, 0x0e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, + 0x63, 0x65, 0x12, 0x5a, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x43, 0x68, 0x61, + 0x74, 0x12, 0x24, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, + 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x5f, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x60, + 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, + 0x26, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, + 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, + 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x6e, 0x0a, 0x11, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x46, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2b, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, + 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, + 0x73, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x24, 0x0a, 0x0e, 0x66, 0x72, 0x69, 0x65, - 0x6e, 0x64, 0x5f, 0x69, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x02, 0x20, 0x03, 0x28, 0x03, - 0x52, 0x0c, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x83, - 0x02, 0x0a, 0x23, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, - 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x50, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, - 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x38, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, - 0x69, 0x73, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0x4a, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x75, - 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, - 0x79, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, - 0x3a, 0x02, 0x38, 0x01, 0x32, 0xce, 0x01, 0x0a, 0x0e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x5a, 0x0a, 0x0b, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x43, 0x68, 0x61, 0x74, 0x12, 0x24, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, - 0x63, 0x68, 0x61, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x63, 0x68, 0x61, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x60, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x64, - 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, - 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, - 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, + 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, + 0x6b, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } @@ -483,27 +578,29 @@ func file_message_proto_rawDescGZIP() []byte { return file_message_proto_rawDescData } -var file_message_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_message_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_message_proto_goTypes = []interface{}{ (*DouyinMessageChatRequest)(nil), // 0: message.douyin_message_chat_request (*DouyinMessageChatResponse)(nil), // 1: message.douyin_message_chat_response - (*DouyinMessageActionRequest)(nil), // 2: message.douyin_message_action_request - (*DouyinMessageActionResponse)(nil), // 3: message.douyin_message_action_response - (*DouyinFriendListMessageRequest)(nil), // 4: message.douyin_friend_list_message_request - (*DouyinFriendListMessageResponse)(nil), // 5: message.douyin_friend_list_message_response - nil, // 6: message.douyin_friend_list_message_response.ResultEntry - (*entity.Message)(nil), // 7: entity.Message + (*Message)(nil), // 2: message.Message + (*DouyinMessageActionRequest)(nil), // 3: message.douyin_message_action_request + (*DouyinMessageActionResponse)(nil), // 4: message.douyin_message_action_response + (*DouyinFriendListMessageRequest)(nil), // 5: message.douyin_friend_list_message_request + (*DouyinFriendListMessageResponse)(nil), // 6: message.douyin_friend_list_message_response + nil, // 7: message.douyin_friend_list_message_response.ResultEntry } var file_message_proto_depIdxs = []int32{ - 7, // 0: message.douyin_message_chat_response.message_list:type_name -> entity.Message - 6, // 1: message.douyin_friend_list_message_response.result:type_name -> message.douyin_friend_list_message_response.ResultEntry - 7, // 2: message.douyin_friend_list_message_response.ResultEntry.value:type_name -> entity.Message + 2, // 0: message.douyin_message_chat_response.message_list:type_name -> message.Message + 7, // 1: message.douyin_friend_list_message_response.result:type_name -> message.douyin_friend_list_message_response.ResultEntry + 2, // 2: message.douyin_friend_list_message_response.ResultEntry.value:type_name -> message.Message 0, // 3: message.MessageService.MessageChat:input_type -> message.douyin_message_chat_request - 2, // 4: message.MessageService.MessageAction:input_type -> message.douyin_message_action_request - 1, // 5: message.MessageService.MessageChat:output_type -> message.douyin_message_chat_response - 3, // 6: message.MessageService.MessageAction:output_type -> message.douyin_message_action_response - 5, // [5:7] is the sub-list for method output_type - 3, // [3:5] is the sub-list for method input_type + 3, // 4: message.MessageService.MessageAction:input_type -> message.douyin_message_action_request + 5, // 5: message.MessageService.MessageFriendList:input_type -> message.douyin_friend_list_message_request + 1, // 6: message.MessageService.MessageChat:output_type -> message.douyin_message_chat_response + 4, // 7: message.MessageService.MessageAction:output_type -> message.douyin_message_action_response + 6, // 8: message.MessageService.MessageFriendList:output_type -> message.douyin_friend_list_message_response + 6, // [6:9] is the sub-list for method output_type + 3, // [3:6] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name @@ -540,7 +637,7 @@ func file_message_proto_init() { } } file_message_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DouyinMessageActionRequest); i { + switch v := v.(*Message); i { case 0: return &v.state case 1: @@ -552,7 +649,7 @@ func file_message_proto_init() { } } file_message_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DouyinMessageActionResponse); i { + switch v := v.(*DouyinMessageActionRequest); i { case 0: return &v.state case 1: @@ -564,7 +661,7 @@ func file_message_proto_init() { } } file_message_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DouyinFriendListMessageRequest); i { + switch v := v.(*DouyinMessageActionResponse); i { case 0: return &v.state case 1: @@ -576,6 +673,18 @@ func file_message_proto_init() { } } file_message_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DouyinFriendListMessageRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_message_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DouyinFriendListMessageResponse); i { case 0: return &v.state @@ -594,7 +703,7 @@ func file_message_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_message_proto_rawDesc, NumEnums: 0, - NumMessages: 7, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, @@ -610,9 +719,10 @@ func file_message_proto_init() { var _ context.Context -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. type MessageService interface { MessageChat(ctx context.Context, req *DouyinMessageChatRequest) (res *DouyinMessageChatResponse, err error) MessageAction(ctx context.Context, req *DouyinMessageActionRequest) (res *DouyinMessageActionResponse, err error) + MessageFriendList(ctx context.Context, req *DouyinFriendListMessageRequest) (res *DouyinFriendListMessageResponse, err error) } diff --git a/kitex_gen/message/messageservice/client.go b/kitex_gen/message/messageservice/client.go index d1f8d3ed..6e625fb3 100644 --- a/kitex_gen/message/messageservice/client.go +++ b/kitex_gen/message/messageservice/client.go @@ -1,18 +1,19 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package messageservice import ( "context" - message "github.com/TremblingV5/DouTok/kitex_gen/message" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. type Client interface { MessageChat(ctx context.Context, Req *message.DouyinMessageChatRequest, callOptions ...callopt.Option) (r *message.DouyinMessageChatResponse, err error) MessageAction(ctx context.Context, Req *message.DouyinMessageActionRequest, callOptions ...callopt.Option) (r *message.DouyinMessageActionResponse, err error) + MessageFriendList(ctx context.Context, Req *message.DouyinFriendListMessageRequest, callOptions ...callopt.Option) (r *message.DouyinFriendListMessageResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -53,3 +54,8 @@ func (p *kMessageServiceClient) MessageAction(ctx context.Context, Req *message. ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.MessageAction(ctx, Req) } + +func (p *kMessageServiceClient) MessageFriendList(ctx context.Context, Req *message.DouyinFriendListMessageRequest, callOptions ...callopt.Option) (r *message.DouyinFriendListMessageResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.MessageFriendList(ctx, Req) +} diff --git a/kitex_gen/message/messageservice/invoker.go b/kitex_gen/message/messageservice/invoker.go index 65281fbc..c6703011 100644 --- a/kitex_gen/message/messageservice/invoker.go +++ b/kitex_gen/message/messageservice/invoker.go @@ -1,10 +1,10 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package messageservice import ( - message "github.com/TremblingV5/DouTok/kitex_gen/message" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/cloudwego/kitex/server" ) // NewInvoker creates a server.Invoker with the given handler and options. diff --git a/kitex_gen/message/messageservice/messageservice.go b/kitex_gen/message/messageservice/messageservice.go index 0aef1ccc..9f6f8b84 100644 --- a/kitex_gen/message/messageservice/messageservice.go +++ b/kitex_gen/message/messageservice/messageservice.go @@ -1,15 +1,15 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package messageservice import ( "context" "fmt" - message "github.com/TremblingV5/DouTok/kitex_gen/message" - client "github.com/cloudwego/kitex/client" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" + "github.com/cloudwego/kitex/pkg/streaming" + "google.golang.org/protobuf/proto" ) func serviceInfo() *kitex.ServiceInfo { @@ -22,8 +22,9 @@ func NewServiceInfo() *kitex.ServiceInfo { serviceName := "MessageService" handlerType := (*message.MessageService)(nil) methods := map[string]kitex.MethodInfo{ - "MessageChat": kitex.NewMethodInfo(messageChatHandler, newMessageChatArgs, newMessageChatResult, false), - "MessageAction": kitex.NewMethodInfo(messageActionHandler, newMessageActionArgs, newMessageActionResult, false), + "MessageChat": kitex.NewMethodInfo(messageChatHandler, newMessageChatArgs, newMessageChatResult, false), + "MessageAction": kitex.NewMethodInfo(messageActionHandler, newMessageActionArgs, newMessageActionResult, false), + "MessageFriendList": kitex.NewMethodInfo(messageFriendListHandler, newMessageFriendListArgs, newMessageFriendListResult, false), } extra := map[string]interface{}{ "PackageName": "message", @@ -33,7 +34,7 @@ func NewServiceInfo() *kitex.ServiceInfo { HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", + KiteXGenVersion: "v0.3.4", Extra: extra, } return svcInfo @@ -76,27 +77,6 @@ type MessageChatArgs struct { Req *message.DouyinMessageChatRequest } -func (p *MessageChatArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(message.DouyinMessageChatRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *MessageChatArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *MessageChatArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *MessageChatArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in MessageChatArgs") @@ -132,27 +112,6 @@ type MessageChatResult struct { var MessageChatResult_Success_DEFAULT *message.DouyinMessageChatResponse -func (p *MessageChatResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(message.DouyinMessageChatResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *MessageChatResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *MessageChatResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - func (p *MessageChatResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { return out, fmt.Errorf("No req in MessageChatResult") @@ -221,27 +180,6 @@ type MessageActionArgs struct { Req *message.DouyinMessageActionRequest } -func (p *MessageActionArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(message.DouyinMessageActionRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *MessageActionArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *MessageActionArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *MessageActionArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in MessageActionArgs") @@ -277,36 +215,118 @@ type MessageActionResult struct { var MessageActionResult_Success_DEFAULT *message.DouyinMessageActionResponse -func (p *MessageActionResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { +func (p *MessageActionResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { - p.Success = new(message.DouyinMessageActionResponse) + return out, fmt.Errorf("No req in MessageActionResult") } - return p.Success.FastRead(buf, _type, number) + return proto.Marshal(p.Success) } -func (p *MessageActionResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 +func (p *MessageActionResult) Unmarshal(in []byte) error { + msg := new(message.DouyinMessageActionResponse) + if err := proto.Unmarshal(in, msg); err != nil { + return err } - return p.Success.FastWrite(buf) + p.Success = msg + return nil } -func (p *MessageActionResult) Size() (n int) { +func (p *MessageActionResult) GetSuccess() *message.DouyinMessageActionResponse { if !p.IsSetSuccess() { - return 0 + return MessageActionResult_Success_DEFAULT } - return p.Success.Size() + return p.Success } -func (p *MessageActionResult) Marshal(out []byte) ([]byte, error) { +func (p *MessageActionResult) SetSuccess(x interface{}) { + p.Success = x.(*message.DouyinMessageActionResponse) +} + +func (p *MessageActionResult) IsSetSuccess() bool { + return p.Success != nil +} + +func messageFriendListHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(message.DouyinFriendListMessageRequest) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(message.MessageService).MessageFriendList(ctx, req) + if err != nil { + return err + } + if err := st.SendMsg(resp); err != nil { + return err + } + case *MessageFriendListArgs: + success, err := handler.(message.MessageService).MessageFriendList(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*MessageFriendListResult) + realResult.Success = success + } + return nil +} +func newMessageFriendListArgs() interface{} { + return &MessageFriendListArgs{} +} + +func newMessageFriendListResult() interface{} { + return &MessageFriendListResult{} +} + +type MessageFriendListArgs struct { + Req *message.DouyinFriendListMessageRequest +} + +func (p *MessageFriendListArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, fmt.Errorf("No req in MessageFriendListArgs") + } + return proto.Marshal(p.Req) +} + +func (p *MessageFriendListArgs) Unmarshal(in []byte) error { + msg := new(message.DouyinFriendListMessageRequest) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var MessageFriendListArgs_Req_DEFAULT *message.DouyinFriendListMessageRequest + +func (p *MessageFriendListArgs) GetReq() *message.DouyinFriendListMessageRequest { + if !p.IsSetReq() { + return MessageFriendListArgs_Req_DEFAULT + } + return p.Req +} + +func (p *MessageFriendListArgs) IsSetReq() bool { + return p.Req != nil +} + +type MessageFriendListResult struct { + Success *message.DouyinFriendListMessageResponse +} + +var MessageFriendListResult_Success_DEFAULT *message.DouyinFriendListMessageResponse + +func (p *MessageFriendListResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in MessageActionResult") + return out, fmt.Errorf("No req in MessageFriendListResult") } return proto.Marshal(p.Success) } -func (p *MessageActionResult) Unmarshal(in []byte) error { - msg := new(message.DouyinMessageActionResponse) +func (p *MessageFriendListResult) Unmarshal(in []byte) error { + msg := new(message.DouyinFriendListMessageResponse) if err := proto.Unmarshal(in, msg); err != nil { return err } @@ -314,18 +334,18 @@ func (p *MessageActionResult) Unmarshal(in []byte) error { return nil } -func (p *MessageActionResult) GetSuccess() *message.DouyinMessageActionResponse { +func (p *MessageFriendListResult) GetSuccess() *message.DouyinFriendListMessageResponse { if !p.IsSetSuccess() { - return MessageActionResult_Success_DEFAULT + return MessageFriendListResult_Success_DEFAULT } return p.Success } -func (p *MessageActionResult) SetSuccess(x interface{}) { - p.Success = x.(*message.DouyinMessageActionResponse) +func (p *MessageFriendListResult) SetSuccess(x interface{}) { + p.Success = x.(*message.DouyinFriendListMessageResponse) } -func (p *MessageActionResult) IsSetSuccess() bool { +func (p *MessageFriendListResult) IsSetSuccess() bool { return p.Success != nil } @@ -358,3 +378,13 @@ func (p *kClient) MessageAction(ctx context.Context, Req *message.DouyinMessageA } return _result.GetSuccess(), nil } + +func (p *kClient) MessageFriendList(ctx context.Context, Req *message.DouyinFriendListMessageRequest) (r *message.DouyinFriendListMessageResponse, err error) { + var _args MessageFriendListArgs + _args.Req = Req + var _result MessageFriendListResult + if err = p.c.Call(ctx, "MessageFriendList", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/kitex_gen/message/messageservice/server.go b/kitex_gen/message/messageservice/server.go index aefe1f55..92489fdb 100644 --- a/kitex_gen/message/messageservice/server.go +++ b/kitex_gen/message/messageservice/server.go @@ -1,9 +1,9 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package messageservice import ( - message "github.com/TremblingV5/DouTok/kitex_gen/message" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/message" + "github.com/cloudwego/kitex/server" ) // NewServer creates a server.Server with the given handler and options. diff --git a/kitex_gen/messageDomain/messageDomain.pb.fast.go b/kitex_gen/messageDomain/messageDomain.pb.fast.go deleted file mode 100644 index 0b658fde..00000000 --- a/kitex_gen/messageDomain/messageDomain.pb.fast.go +++ /dev/null @@ -1,501 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package messageDomain - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DoutokAddMessageRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - case 4: - offset, err = x.fastReadField4(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddMessageRequest[number], err) -} - -func (x *DoutokAddMessageRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.ToUserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddMessageRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddMessageRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.ActionType, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokAddMessageRequest) fastReadField4(buf []byte, _type int8) (offset int, err error) { - x.Content, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokAddMessageResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddMessageResponse[number], err) -} - -func (x *DoutokAddMessageResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokAddMessageResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokListMessageRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListMessageRequest[number], err) -} - -func (x *DoutokListMessageRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.ToUserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListMessageRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListMessageRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.PreMsgTime, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListMessageResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListMessageResponse[number], err) -} - -func (x *DoutokListMessageResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokListMessageResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokListMessageResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Message - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.Message = append(x.Message, &v) - return offset, nil -} - -func (x *DoutokAddMessageRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - offset += x.fastWriteField4(buf[offset:]) - return offset -} - -func (x *DoutokAddMessageRequest) fastWriteField1(buf []byte) (offset int) { - if x.ToUserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.ToUserId) - return offset -} - -func (x *DoutokAddMessageRequest) fastWriteField2(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.UserId) - return offset -} - -func (x *DoutokAddMessageRequest) fastWriteField3(buf []byte) (offset int) { - if x.ActionType == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 3, x.ActionType) - return offset -} - -func (x *DoutokAddMessageRequest) fastWriteField4(buf []byte) (offset int) { - if x.Content == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 4, x.Content) - return offset -} - -func (x *DoutokAddMessageResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokAddMessageResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokAddMessageResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokListMessageRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokListMessageRequest) fastWriteField1(buf []byte) (offset int) { - if x.ToUserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.ToUserId) - return offset -} - -func (x *DoutokListMessageRequest) fastWriteField2(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.UserId) - return offset -} - -func (x *DoutokListMessageRequest) fastWriteField3(buf []byte) (offset int) { - if x.PreMsgTime == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 3, x.PreMsgTime) - return offset -} - -func (x *DoutokListMessageResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokListMessageResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokListMessageResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokListMessageResponse) fastWriteField3(buf []byte) (offset int) { - if x.Message == nil { - return offset - } - for i := range x.Message { - offset += fastpb.WriteMessage(buf[offset:], 3, x.Message[i]) - } - return offset -} - -func (x *DoutokAddMessageRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - n += x.sizeField4() - return n -} - -func (x *DoutokAddMessageRequest) sizeField1() (n int) { - if x.ToUserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.ToUserId) - return n -} - -func (x *DoutokAddMessageRequest) sizeField2() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.UserId) - return n -} - -func (x *DoutokAddMessageRequest) sizeField3() (n int) { - if x.ActionType == 0 { - return n - } - n += fastpb.SizeInt32(3, x.ActionType) - return n -} - -func (x *DoutokAddMessageRequest) sizeField4() (n int) { - if x.Content == "" { - return n - } - n += fastpb.SizeString(4, x.Content) - return n -} - -func (x *DoutokAddMessageResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokAddMessageResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokAddMessageResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokListMessageRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokListMessageRequest) sizeField1() (n int) { - if x.ToUserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.ToUserId) - return n -} - -func (x *DoutokListMessageRequest) sizeField2() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.UserId) - return n -} - -func (x *DoutokListMessageRequest) sizeField3() (n int) { - if x.PreMsgTime == 0 { - return n - } - n += fastpb.SizeInt64(3, x.PreMsgTime) - return n -} - -func (x *DoutokListMessageResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokListMessageResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokListMessageResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokListMessageResponse) sizeField3() (n int) { - if x.Message == nil { - return n - } - for i := range x.Message { - n += fastpb.SizeMessage(3, x.Message[i]) - } - return n -} - -var fieldIDToName_DoutokAddMessageRequest = map[int32]string{ - 1: "ToUserId", - 2: "UserId", - 3: "ActionType", - 4: "Content", -} - -var fieldIDToName_DoutokAddMessageResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", -} - -var fieldIDToName_DoutokListMessageRequest = map[int32]string{ - 1: "ToUserId", - 2: "UserId", - 3: "PreMsgTime", -} - -var fieldIDToName_DoutokListMessageResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "Message", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/messageDomain/messageDomain.pb.go b/kitex_gen/messageDomain/messageDomain.pb.go deleted file mode 100644 index 214ad052..00000000 --- a/kitex_gen/messageDomain/messageDomain.pb.go +++ /dev/null @@ -1,450 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 -// source: messageDomain.proto - -package messageDomain - -import ( - context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type DoutokAddMessageRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ToUserId int64 `protobuf:"varint,1,opt,name=to_user_id,json=toUserId,proto3" json:"to_user_id,omitempty"` // 对方用户id - UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 发消息的user id - ActionType int32 `protobuf:"varint,3,opt,name=action_type,json=actionType,proto3" json:"action_type,omitempty"` // 1-发送消息 - Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` // 消息内容 -} - -func (x *DoutokAddMessageRequest) Reset() { - *x = DoutokAddMessageRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_messageDomain_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddMessageRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddMessageRequest) ProtoMessage() {} - -func (x *DoutokAddMessageRequest) ProtoReflect() protoreflect.Message { - mi := &file_messageDomain_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddMessageRequest.ProtoReflect.Descriptor instead. -func (*DoutokAddMessageRequest) Descriptor() ([]byte, []int) { - return file_messageDomain_proto_rawDescGZIP(), []int{0} -} - -func (x *DoutokAddMessageRequest) GetToUserId() int64 { - if x != nil { - return x.ToUserId - } - return 0 -} - -func (x *DoutokAddMessageRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokAddMessageRequest) GetActionType() int32 { - if x != nil { - return x.ActionType - } - return 0 -} - -func (x *DoutokAddMessageRequest) GetContent() string { - if x != nil { - return x.Content - } - return "" -} - -type DoutokAddMessageResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` -} - -func (x *DoutokAddMessageResponse) Reset() { - *x = DoutokAddMessageResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_messageDomain_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddMessageResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddMessageResponse) ProtoMessage() {} - -func (x *DoutokAddMessageResponse) ProtoReflect() protoreflect.Message { - mi := &file_messageDomain_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddMessageResponse.ProtoReflect.Descriptor instead. -func (*DoutokAddMessageResponse) Descriptor() ([]byte, []int) { - return file_messageDomain_proto_rawDescGZIP(), []int{1} -} - -func (x *DoutokAddMessageResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokAddMessageResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -type DoutokListMessageRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - ToUserId int64 `protobuf:"varint,1,opt,name=to_user_id,json=toUserId,proto3" json:"to_user_id,omitempty"` // 对方用户id - UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 发出动作的user id - PreMsgTime int64 `protobuf:"varint,3,opt,name=pre_msg_time,json=preMsgTime,proto3" json:"pre_msg_time,omitempty"` // 上次最新消息的时间 -} - -func (x *DoutokListMessageRequest) Reset() { - *x = DoutokListMessageRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_messageDomain_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListMessageRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListMessageRequest) ProtoMessage() {} - -func (x *DoutokListMessageRequest) ProtoReflect() protoreflect.Message { - mi := &file_messageDomain_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListMessageRequest.ProtoReflect.Descriptor instead. -func (*DoutokListMessageRequest) Descriptor() ([]byte, []int) { - return file_messageDomain_proto_rawDescGZIP(), []int{2} -} - -func (x *DoutokListMessageRequest) GetToUserId() int64 { - if x != nil { - return x.ToUserId - } - return 0 -} - -func (x *DoutokListMessageRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokListMessageRequest) GetPreMsgTime() int64 { - if x != nil { - return x.PreMsgTime - } - return 0 -} - -type DoutokListMessageResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - Message []*entity.Message `protobuf:"bytes,3,rep,name=message,proto3" json:"message,omitempty"` -} - -func (x *DoutokListMessageResponse) Reset() { - *x = DoutokListMessageResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_messageDomain_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListMessageResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListMessageResponse) ProtoMessage() {} - -func (x *DoutokListMessageResponse) ProtoReflect() protoreflect.Message { - mi := &file_messageDomain_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListMessageResponse.ProtoReflect.Descriptor instead. -func (*DoutokListMessageResponse) Descriptor() ([]byte, []int) { - return file_messageDomain_proto_rawDescGZIP(), []int{3} -} - -func (x *DoutokListMessageResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokListMessageResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokListMessageResponse) GetMessage() []*entity.Message { - if x != nil { - return x.Message - } - return nil -} - -var File_messageDomain_proto protoreflect.FileDescriptor - -var file_messageDomain_proto_rawDesc = []byte{ - 0x0a, 0x13, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x22, 0x8e, 0x01, 0x0a, 0x1a, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, - 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, - 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x61, - 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, - 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, - 0x65, 0x6e, 0x74, 0x22, 0x5d, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, - 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, - 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, - 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, - 0x73, 0x67, 0x22, 0x76, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, - 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, - 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0c, 0x70, 0x72, 0x65, 0x5f, - 0x6d, 0x73, 0x67, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, - 0x70, 0x72, 0x65, 0x4d, 0x73, 0x67, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x89, 0x01, 0x0a, 0x1c, 0x64, - 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x29, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x65, - 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x52, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0xe3, 0x01, 0x0a, 0x14, 0x4d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x63, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x29, 0x2e, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, - 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, - 0x67, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, - 0x61, 0x64, 0x64, 0x5f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x66, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x12, 0x2a, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, - 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x2b, 0x2e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x6d, 0x65, 0x73, 0x73, - 0x61, 0x67, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x37, 0x5a, 0x35, - 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, - 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, - 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_messageDomain_proto_rawDescOnce sync.Once - file_messageDomain_proto_rawDescData = file_messageDomain_proto_rawDesc -) - -func file_messageDomain_proto_rawDescGZIP() []byte { - file_messageDomain_proto_rawDescOnce.Do(func() { - file_messageDomain_proto_rawDescData = protoimpl.X.CompressGZIP(file_messageDomain_proto_rawDescData) - }) - return file_messageDomain_proto_rawDescData -} - -var file_messageDomain_proto_msgTypes = make([]protoimpl.MessageInfo, 4) -var file_messageDomain_proto_goTypes = []interface{}{ - (*DoutokAddMessageRequest)(nil), // 0: messageDomain.doutok_add_message_request - (*DoutokAddMessageResponse)(nil), // 1: messageDomain.doutok_add_message_response - (*DoutokListMessageRequest)(nil), // 2: messageDomain.doutok_list_message_request - (*DoutokListMessageResponse)(nil), // 3: messageDomain.doutok_list_message_response - (*entity.Message)(nil), // 4: entity.Message -} -var file_messageDomain_proto_depIdxs = []int32{ - 4, // 0: messageDomain.doutok_list_message_response.message:type_name -> entity.Message - 0, // 1: messageDomain.MessageDomainService.AddMessage:input_type -> messageDomain.doutok_add_message_request - 2, // 2: messageDomain.MessageDomainService.ListMessage:input_type -> messageDomain.doutok_list_message_request - 1, // 3: messageDomain.MessageDomainService.AddMessage:output_type -> messageDomain.doutok_add_message_response - 3, // 4: messageDomain.MessageDomainService.ListMessage:output_type -> messageDomain.doutok_list_message_response - 3, // [3:5] is the sub-list for method output_type - 1, // [1:3] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name -} - -func init() { file_messageDomain_proto_init() } -func file_messageDomain_proto_init() { - if File_messageDomain_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_messageDomain_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddMessageRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_messageDomain_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddMessageResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_messageDomain_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListMessageRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_messageDomain_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListMessageResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_messageDomain_proto_rawDesc, - NumEnums: 0, - NumMessages: 4, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_messageDomain_proto_goTypes, - DependencyIndexes: file_messageDomain_proto_depIdxs, - MessageInfos: file_messageDomain_proto_msgTypes, - }.Build() - File_messageDomain_proto = out.File - file_messageDomain_proto_rawDesc = nil - file_messageDomain_proto_goTypes = nil - file_messageDomain_proto_depIdxs = nil -} - -var _ context.Context - -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -type MessageDomainService interface { - AddMessage(ctx context.Context, req *DoutokAddMessageRequest) (res *DoutokAddMessageResponse, err error) - ListMessage(ctx context.Context, req *DoutokListMessageRequest) (res *DoutokListMessageResponse, err error) -} diff --git a/kitex_gen/messageDomain/messagedomainservice/client.go b/kitex_gen/messageDomain/messagedomainservice/client.go deleted file mode 100644 index d6f4d985..00000000 --- a/kitex_gen/messageDomain/messagedomainservice/client.go +++ /dev/null @@ -1,55 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package messagedomainservice - -import ( - "context" - messageDomain "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - AddMessage(ctx context.Context, Req *messageDomain.DoutokAddMessageRequest, callOptions ...callopt.Option) (r *messageDomain.DoutokAddMessageResponse, err error) - ListMessage(ctx context.Context, Req *messageDomain.DoutokListMessageRequest, callOptions ...callopt.Option) (r *messageDomain.DoutokListMessageResponse, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfo(), options...) - if err != nil { - return nil, err - } - return &kMessageDomainServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kMessageDomainServiceClient struct { - *kClient -} - -func (p *kMessageDomainServiceClient) AddMessage(ctx context.Context, Req *messageDomain.DoutokAddMessageRequest, callOptions ...callopt.Option) (r *messageDomain.DoutokAddMessageResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.AddMessage(ctx, Req) -} - -func (p *kMessageDomainServiceClient) ListMessage(ctx context.Context, Req *messageDomain.DoutokListMessageRequest, callOptions ...callopt.Option) (r *messageDomain.DoutokListMessageResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.ListMessage(ctx, Req) -} diff --git a/kitex_gen/messageDomain/messagedomainservice/invoker.go b/kitex_gen/messageDomain/messagedomainservice/invoker.go deleted file mode 100644 index fb30f6a2..00000000 --- a/kitex_gen/messageDomain/messagedomainservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package messagedomainservice - -import ( - messageDomain "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler messageDomain.MessageDomainService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/kitex_gen/messageDomain/messagedomainservice/messagedomainservice.go b/kitex_gen/messageDomain/messagedomainservice/messagedomainservice.go deleted file mode 100644 index 862e30ad..00000000 --- a/kitex_gen/messageDomain/messagedomainservice/messagedomainservice.go +++ /dev/null @@ -1,360 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package messagedomainservice - -import ( - "context" - "fmt" - messageDomain "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" -) - -func serviceInfo() *kitex.ServiceInfo { - return messageDomainServiceServiceInfo -} - -var messageDomainServiceServiceInfo = NewServiceInfo() - -func NewServiceInfo() *kitex.ServiceInfo { - serviceName := "MessageDomainService" - handlerType := (*messageDomain.MessageDomainService)(nil) - methods := map[string]kitex.MethodInfo{ - "AddMessage": kitex.NewMethodInfo(addMessageHandler, newAddMessageArgs, newAddMessageResult, false), - "ListMessage": kitex.NewMethodInfo(listMessageHandler, newListMessageArgs, newListMessageResult, false), - } - extra := map[string]interface{}{ - "PackageName": "messageDomain", - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", - Extra: extra, - } - return svcInfo -} - -func addMessageHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(messageDomain.DoutokAddMessageRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(messageDomain.MessageDomainService).AddMessage(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *AddMessageArgs: - success, err := handler.(messageDomain.MessageDomainService).AddMessage(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*AddMessageResult) - realResult.Success = success - } - return nil -} -func newAddMessageArgs() interface{} { - return &AddMessageArgs{} -} - -func newAddMessageResult() interface{} { - return &AddMessageResult{} -} - -type AddMessageArgs struct { - Req *messageDomain.DoutokAddMessageRequest -} - -func (p *AddMessageArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(messageDomain.DoutokAddMessageRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *AddMessageArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *AddMessageArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *AddMessageArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in AddMessageArgs") - } - return proto.Marshal(p.Req) -} - -func (p *AddMessageArgs) Unmarshal(in []byte) error { - msg := new(messageDomain.DoutokAddMessageRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var AddMessageArgs_Req_DEFAULT *messageDomain.DoutokAddMessageRequest - -func (p *AddMessageArgs) GetReq() *messageDomain.DoutokAddMessageRequest { - if !p.IsSetReq() { - return AddMessageArgs_Req_DEFAULT - } - return p.Req -} - -func (p *AddMessageArgs) IsSetReq() bool { - return p.Req != nil -} - -type AddMessageResult struct { - Success *messageDomain.DoutokAddMessageResponse -} - -var AddMessageResult_Success_DEFAULT *messageDomain.DoutokAddMessageResponse - -func (p *AddMessageResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(messageDomain.DoutokAddMessageResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *AddMessageResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *AddMessageResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *AddMessageResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in AddMessageResult") - } - return proto.Marshal(p.Success) -} - -func (p *AddMessageResult) Unmarshal(in []byte) error { - msg := new(messageDomain.DoutokAddMessageResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *AddMessageResult) GetSuccess() *messageDomain.DoutokAddMessageResponse { - if !p.IsSetSuccess() { - return AddMessageResult_Success_DEFAULT - } - return p.Success -} - -func (p *AddMessageResult) SetSuccess(x interface{}) { - p.Success = x.(*messageDomain.DoutokAddMessageResponse) -} - -func (p *AddMessageResult) IsSetSuccess() bool { - return p.Success != nil -} - -func listMessageHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(messageDomain.DoutokListMessageRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(messageDomain.MessageDomainService).ListMessage(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *ListMessageArgs: - success, err := handler.(messageDomain.MessageDomainService).ListMessage(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*ListMessageResult) - realResult.Success = success - } - return nil -} -func newListMessageArgs() interface{} { - return &ListMessageArgs{} -} - -func newListMessageResult() interface{} { - return &ListMessageResult{} -} - -type ListMessageArgs struct { - Req *messageDomain.DoutokListMessageRequest -} - -func (p *ListMessageArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(messageDomain.DoutokListMessageRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *ListMessageArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *ListMessageArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *ListMessageArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in ListMessageArgs") - } - return proto.Marshal(p.Req) -} - -func (p *ListMessageArgs) Unmarshal(in []byte) error { - msg := new(messageDomain.DoutokListMessageRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var ListMessageArgs_Req_DEFAULT *messageDomain.DoutokListMessageRequest - -func (p *ListMessageArgs) GetReq() *messageDomain.DoutokListMessageRequest { - if !p.IsSetReq() { - return ListMessageArgs_Req_DEFAULT - } - return p.Req -} - -func (p *ListMessageArgs) IsSetReq() bool { - return p.Req != nil -} - -type ListMessageResult struct { - Success *messageDomain.DoutokListMessageResponse -} - -var ListMessageResult_Success_DEFAULT *messageDomain.DoutokListMessageResponse - -func (p *ListMessageResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(messageDomain.DoutokListMessageResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *ListMessageResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *ListMessageResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *ListMessageResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in ListMessageResult") - } - return proto.Marshal(p.Success) -} - -func (p *ListMessageResult) Unmarshal(in []byte) error { - msg := new(messageDomain.DoutokListMessageResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *ListMessageResult) GetSuccess() *messageDomain.DoutokListMessageResponse { - if !p.IsSetSuccess() { - return ListMessageResult_Success_DEFAULT - } - return p.Success -} - -func (p *ListMessageResult) SetSuccess(x interface{}) { - p.Success = x.(*messageDomain.DoutokListMessageResponse) -} - -func (p *ListMessageResult) IsSetSuccess() bool { - return p.Success != nil -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) AddMessage(ctx context.Context, Req *messageDomain.DoutokAddMessageRequest) (r *messageDomain.DoutokAddMessageResponse, err error) { - var _args AddMessageArgs - _args.Req = Req - var _result AddMessageResult - if err = p.c.Call(ctx, "AddMessage", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) ListMessage(ctx context.Context, Req *messageDomain.DoutokListMessageRequest) (r *messageDomain.DoutokListMessageResponse, err error) { - var _args ListMessageArgs - _args.Req = Req - var _result ListMessageResult - if err = p.c.Call(ctx, "ListMessage", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/kitex_gen/messageDomain/messagedomainservice/server.go b/kitex_gen/messageDomain/messagedomainservice/server.go deleted file mode 100644 index 2627122e..00000000 --- a/kitex_gen/messageDomain/messagedomainservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. -package messagedomainservice - -import ( - messageDomain "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler messageDomain.MessageDomainService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/kitex_gen/publish/publish.pb.fast.go b/kitex_gen/publish/publish.pb.fast.go deleted file mode 100644 index 2500a735..00000000 --- a/kitex_gen/publish/publish.pb.fast.go +++ /dev/null @@ -1,443 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package publish - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DouyinPublishActionRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - case 4: - offset, err = x.fastReadField4(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinPublishActionRequest[number], err) -} - -func (x *DouyinPublishActionRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.Data, offset, err = fastpb.ReadBytes(buf, _type) - return offset, err -} - -func (x *DouyinPublishActionRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.Title, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinPublishActionRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinPublishActionRequest) fastReadField4(buf []byte, _type int8) (offset int, err error) { - x.Name, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinPublishActionResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinPublishActionResponse[number], err) -} - -func (x *DouyinPublishActionResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinPublishActionResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinPublishListRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinPublishListRequest[number], err) -} - -func (x *DouyinPublishListRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DouyinPublishListResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DouyinPublishListResponse[number], err) -} - -func (x *DouyinPublishListResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DouyinPublishListResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DouyinPublishListResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Video - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.VideoList = append(x.VideoList, &v) - return offset, nil -} - -func (x *DouyinPublishActionRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - offset += x.fastWriteField4(buf[offset:]) - return offset -} - -func (x *DouyinPublishActionRequest) fastWriteField1(buf []byte) (offset int) { - if len(x.Data) == 0 { - return offset - } - offset += fastpb.WriteBytes(buf[offset:], 1, x.Data) - return offset -} - -func (x *DouyinPublishActionRequest) fastWriteField2(buf []byte) (offset int) { - if x.Title == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.Title) - return offset -} - -func (x *DouyinPublishActionRequest) fastWriteField3(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 3, x.UserId) - return offset -} - -func (x *DouyinPublishActionRequest) fastWriteField4(buf []byte) (offset int) { - if x.Name == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 4, x.Name) - return offset -} - -func (x *DouyinPublishActionResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DouyinPublishActionResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinPublishActionResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinPublishListRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DouyinPublishListRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DouyinPublishListResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DouyinPublishListResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DouyinPublishListResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DouyinPublishListResponse) fastWriteField3(buf []byte) (offset int) { - if x.VideoList == nil { - return offset - } - for i := range x.VideoList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.VideoList[i]) - } - return offset -} - -func (x *DouyinPublishActionRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - n += x.sizeField4() - return n -} - -func (x *DouyinPublishActionRequest) sizeField1() (n int) { - if len(x.Data) == 0 { - return n - } - n += fastpb.SizeBytes(1, x.Data) - return n -} - -func (x *DouyinPublishActionRequest) sizeField2() (n int) { - if x.Title == "" { - return n - } - n += fastpb.SizeString(2, x.Title) - return n -} - -func (x *DouyinPublishActionRequest) sizeField3() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(3, x.UserId) - return n -} - -func (x *DouyinPublishActionRequest) sizeField4() (n int) { - if x.Name == "" { - return n - } - n += fastpb.SizeString(4, x.Name) - return n -} - -func (x *DouyinPublishActionResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DouyinPublishActionResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinPublishActionResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinPublishListRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DouyinPublishListRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DouyinPublishListResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DouyinPublishListResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DouyinPublishListResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DouyinPublishListResponse) sizeField3() (n int) { - if x.VideoList == nil { - return n - } - for i := range x.VideoList { - n += fastpb.SizeMessage(3, x.VideoList[i]) - } - return n -} - -var fieldIDToName_DouyinPublishActionRequest = map[int32]string{ - 1: "Data", - 2: "Title", - 3: "UserId", - 4: "Name", -} - -var fieldIDToName_DouyinPublishActionResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", -} - -var fieldIDToName_DouyinPublishListRequest = map[int32]string{ - 1: "UserId", -} - -var fieldIDToName_DouyinPublishListResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "VideoList", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/publish/publish.pb.go b/kitex_gen/publish/publish.pb.go index 9bcfcc22..9bbdd294 100644 --- a/kitex_gen/publish/publish.pb.go +++ b/kitex_gen/publish/publish.pb.go @@ -1,14 +1,14 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 +// protoc-gen-go v1.28.0 +// protoc v3.19.4 // source: publish.proto package publish import ( context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" + "github.com/TremblingV5/DouTok/kitex_gen/feed" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -98,8 +98,8 @@ type DouyinPublishActionResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 } func (x *DouyinPublishActionResponse) Reset() { @@ -200,9 +200,9 @@ type DouyinPublishListResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - VideoList []*entity.Video `protobuf:"bytes,3,rep,name=video_list,json=videoList,proto3" json:"video_list,omitempty"` // 用户发布的视频列表 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + VideoList []*feed.Video `protobuf:"bytes,3,rep,name=video_list,json=videoList,proto3" json:"video_list,omitempty"` // 用户发布的视频列表 } func (x *DouyinPublishListResponse) Reset() { @@ -251,7 +251,7 @@ func (x *DouyinPublishListResponse) GetStatusMsg() string { return "" } -func (x *DouyinPublishListResponse) GetVideoList() []*entity.Video { +func (x *DouyinPublishListResponse) GetVideoList() []*feed.Video { if x != nil { return x.VideoList } @@ -262,51 +262,52 @@ var File_publish_proto protoreflect.FileDescriptor var file_publish_proto_rawDesc = []byte{ 0x0a, 0x0d, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, - 0x07, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x76, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, + 0x07, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x1a, 0x0a, 0x66, 0x65, 0x65, 0x64, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x76, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x74, + 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x12, + 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x60, 0x0a, 0x1e, + 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x61, + 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, + 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x22, 0x36, + 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, + 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, + 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x8a, 0x01, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, 0x69, + 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x2a, 0x0a, 0x0a, 0x76, 0x69, 0x64, 0x65, 0x6f, + 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x66, 0x65, + 0x65, 0x64, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, 0x09, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x4c, + 0x69, 0x73, 0x74, 0x32, 0xce, 0x01, 0x0a, 0x0e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x53, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x0d, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, + 0x68, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x2e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, + 0x68, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x27, 0x2e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, - 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, - 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, - 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x60, - 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, - 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, - 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, - 0x22, 0x36, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, - 0x73, 0x68, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x8c, 0x01, 0x0a, 0x1c, 0x64, 0x6f, 0x75, - 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x6c, 0x69, 0x73, 0x74, - 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x2c, 0x0a, 0x0a, 0x76, 0x69, 0x64, - 0x65, 0x6f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, - 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, 0x09, 0x76, 0x69, - 0x64, 0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x32, 0xce, 0x01, 0x0a, 0x0e, 0x50, 0x75, 0x62, 0x6c, - 0x69, 0x73, 0x68, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x60, 0x0a, 0x0d, 0x50, 0x75, - 0x62, 0x6c, 0x69, 0x73, 0x68, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x26, 0x2e, 0x70, 0x75, - 0x62, 0x6c, 0x69, 0x73, 0x68, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x2e, 0x64, 0x6f, - 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x61, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x0b, - 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x24, 0x2e, 0x70, 0x75, - 0x62, 0x6c, 0x69, 0x73, 0x68, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x25, 0x2e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x2e, 0x64, 0x6f, 0x75, 0x79, - 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x31, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, - 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, - 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x62, 0x06, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x33, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x0b, 0x50, 0x75, 0x62, 0x6c, + 0x69, 0x73, 0x68, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x24, 0x2e, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, + 0x68, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, + 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x25, 0x2e, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x70, + 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x46, 0x5a, 0x44, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, + 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, + 0x6e, 0x73, 0x2f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, + 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -327,10 +328,10 @@ var file_publish_proto_goTypes = []interface{}{ (*DouyinPublishActionResponse)(nil), // 1: publish.douyin_publish_action_response (*DouyinPublishListRequest)(nil), // 2: publish.douyin_publish_list_request (*DouyinPublishListResponse)(nil), // 3: publish.douyin_publish_list_response - (*entity.Video)(nil), // 4: entity.Video + (*feed.Video)(nil), // 4: feed.Video } var file_publish_proto_depIdxs = []int32{ - 4, // 0: publish.douyin_publish_list_response.video_list:type_name -> entity.Video + 4, // 0: publish.douyin_publish_list_response.video_list:type_name -> feed.Video 0, // 1: publish.PublishService.PublishAction:input_type -> publish.douyin_publish_action_request 2, // 2: publish.PublishService.PublishList:input_type -> publish.douyin_publish_list_request 1, // 3: publish.PublishService.PublishAction:output_type -> publish.douyin_publish_action_response @@ -419,7 +420,7 @@ func file_publish_proto_init() { var _ context.Context -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. type PublishService interface { PublishAction(ctx context.Context, req *DouyinPublishActionRequest) (res *DouyinPublishActionResponse, err error) diff --git a/kitex_gen/publish/publishservice/client.go b/kitex_gen/publish/publishservice/client.go index f0d3d326..1e941f96 100644 --- a/kitex_gen/publish/publishservice/client.go +++ b/kitex_gen/publish/publishservice/client.go @@ -1,12 +1,12 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package publishservice import ( "context" - publish "github.com/TremblingV5/DouTok/kitex_gen/publish" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" + "github.com/TremblingV5/DouTok/kitex_gen/publish" + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/client/callopt" ) // Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. diff --git a/kitex_gen/publish/publishservice/invoker.go b/kitex_gen/publish/publishservice/invoker.go index eab80d9d..ac438471 100644 --- a/kitex_gen/publish/publishservice/invoker.go +++ b/kitex_gen/publish/publishservice/invoker.go @@ -1,10 +1,10 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package publishservice import ( - publish "github.com/TremblingV5/DouTok/kitex_gen/publish" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/publish" + "github.com/cloudwego/kitex/server" ) // NewInvoker creates a server.Invoker with the given handler and options. diff --git a/kitex_gen/publish/publishservice/publishservice.go b/kitex_gen/publish/publishservice/publishservice.go index a9c4c9b5..f425c658 100644 --- a/kitex_gen/publish/publishservice/publishservice.go +++ b/kitex_gen/publish/publishservice/publishservice.go @@ -1,15 +1,15 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package publishservice import ( "context" "fmt" - publish "github.com/TremblingV5/DouTok/kitex_gen/publish" - client "github.com/cloudwego/kitex/client" + "github.com/TremblingV5/DouTok/kitex_gen/publish" + "github.com/cloudwego/kitex/client" kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" + "github.com/cloudwego/kitex/pkg/streaming" + "google.golang.org/protobuf/proto" ) func serviceInfo() *kitex.ServiceInfo { @@ -33,7 +33,7 @@ func NewServiceInfo() *kitex.ServiceInfo { HandlerType: handlerType, Methods: methods, PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", + KiteXGenVersion: "v0.3.4", Extra: extra, } return svcInfo @@ -76,27 +76,6 @@ type PublishActionArgs struct { Req *publish.DouyinPublishActionRequest } -func (p *PublishActionArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(publish.DouyinPublishActionRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *PublishActionArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *PublishActionArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *PublishActionArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in PublishActionArgs") @@ -132,27 +111,6 @@ type PublishActionResult struct { var PublishActionResult_Success_DEFAULT *publish.DouyinPublishActionResponse -func (p *PublishActionResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(publish.DouyinPublishActionResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *PublishActionResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *PublishActionResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - func (p *PublishActionResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { return out, fmt.Errorf("No req in PublishActionResult") @@ -221,27 +179,6 @@ type PublishListArgs struct { Req *publish.DouyinPublishListRequest } -func (p *PublishListArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(publish.DouyinPublishListRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *PublishListArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *PublishListArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - func (p *PublishListArgs) Marshal(out []byte) ([]byte, error) { if !p.IsSetReq() { return out, fmt.Errorf("No req in PublishListArgs") @@ -277,27 +214,6 @@ type PublishListResult struct { var PublishListResult_Success_DEFAULT *publish.DouyinPublishListResponse -func (p *PublishListResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(publish.DouyinPublishListResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *PublishListResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *PublishListResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - func (p *PublishListResult) Marshal(out []byte) ([]byte, error) { if !p.IsSetSuccess() { return out, fmt.Errorf("No req in PublishListResult") diff --git a/kitex_gen/publish/publishservice/server.go b/kitex_gen/publish/publishservice/server.go index fc26c293..b9bb1fff 100644 --- a/kitex_gen/publish/publishservice/server.go +++ b/kitex_gen/publish/publishservice/server.go @@ -1,9 +1,9 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. +// Code generated by Kitex v0.3.4. DO NOT EDIT. package publishservice import ( - publish "github.com/TremblingV5/DouTok/kitex_gen/publish" - server "github.com/cloudwego/kitex/server" + "github.com/TremblingV5/DouTok/kitex_gen/publish" + "github.com/cloudwego/kitex/server" ) // NewServer creates a server.Server with the given handler and options. diff --git a/kitex_gen/relation/relation.pb.fast.go b/kitex_gen/relation/relation.pb.fast.go index 845e451d..540aa2e0 100644 --- a/kitex_gen/relation/relation.pb.fast.go +++ b/kitex_gen/relation/relation.pb.fast.go @@ -4,7 +4,7 @@ package relation import ( fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" + user "github.com/TremblingV5/DouTok/kitex_gen/user" fastpb "github.com/cloudwego/fastpb" ) @@ -159,7 +159,7 @@ func (x *DouyinRelationFollowListResponse) fastReadField2(buf []byte, _type int8 } func (x *DouyinRelationFollowListResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.User + var v user.User offset, err = fastpb.ReadMessage(buf, _type, &v) if err != nil { return offset, err @@ -234,7 +234,7 @@ func (x *DouyinRelationFollowerListResponse) fastReadField2(buf []byte, _type in } func (x *DouyinRelationFollowerListResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.User + var v user.User offset, err = fastpb.ReadMessage(buf, _type, &v) if err != nil { return offset, err @@ -309,7 +309,7 @@ func (x *DouyinRelationFriendListResponse) fastReadField2(buf []byte, _type int8 } func (x *DouyinRelationFriendListResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.FriendUser + var v FriendUser offset, err = fastpb.ReadMessage(buf, _type, &v) if err != nil { return offset, err @@ -318,6 +318,151 @@ func (x *DouyinRelationFriendListResponse) fastReadField3(buf []byte, _type int8 return offset, nil } +func (x *FriendUser) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + case 3: + offset, err = x.fastReadField3(buf, _type) + if err != nil { + goto ReadFieldError + } + case 4: + offset, err = x.fastReadField4(buf, _type) + if err != nil { + goto ReadFieldError + } + case 5: + offset, err = x.fastReadField5(buf, _type) + if err != nil { + goto ReadFieldError + } + case 6: + offset, err = x.fastReadField6(buf, _type) + if err != nil { + goto ReadFieldError + } + case 7: + offset, err = x.fastReadField7(buf, _type) + if err != nil { + goto ReadFieldError + } + case 8: + offset, err = x.fastReadField8(buf, _type) + if err != nil { + goto ReadFieldError + } + case 9: + offset, err = x.fastReadField9(buf, _type) + if err != nil { + goto ReadFieldError + } + case 10: + offset, err = x.fastReadField10(buf, _type) + if err != nil { + goto ReadFieldError + } + case 11: + offset, err = x.fastReadField11(buf, _type) + if err != nil { + goto ReadFieldError + } + case 12: + offset, err = x.fastReadField12(buf, _type) + if err != nil { + goto ReadFieldError + } + case 13: + offset, err = x.fastReadField13(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_FriendUser[number], err) +} + +func (x *FriendUser) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Id, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField2(buf []byte, _type int8) (offset int, err error) { + x.Name, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField3(buf []byte, _type int8) (offset int, err error) { + x.FollowCount, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField4(buf []byte, _type int8) (offset int, err error) { + x.FollowerCount, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField5(buf []byte, _type int8) (offset int, err error) { + x.IsFollow, offset, err = fastpb.ReadBool(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField6(buf []byte, _type int8) (offset int, err error) { + x.Avatar, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField7(buf []byte, _type int8) (offset int, err error) { + x.BackgroundImage, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField8(buf []byte, _type int8) (offset int, err error) { + x.Signature, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField9(buf []byte, _type int8) (offset int, err error) { + x.TotalFavorited, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField10(buf []byte, _type int8) (offset int, err error) { + x.WorkCount, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField11(buf []byte, _type int8) (offset int, err error) { + x.FavoriteCount, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField12(buf []byte, _type int8) (offset int, err error) { + x.Message, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *FriendUser) fastReadField13(buf []byte, _type int8) (offset int, err error) { + x.MsgType, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + func (x *DouyinRelationCountRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { switch number { case 1: @@ -613,6 +758,130 @@ func (x *DouyinRelationFriendListResponse) fastWriteField3(buf []byte) (offset i return offset } +func (x *FriendUser) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + offset += x.fastWriteField3(buf[offset:]) + offset += x.fastWriteField4(buf[offset:]) + offset += x.fastWriteField5(buf[offset:]) + offset += x.fastWriteField6(buf[offset:]) + offset += x.fastWriteField7(buf[offset:]) + offset += x.fastWriteField8(buf[offset:]) + offset += x.fastWriteField9(buf[offset:]) + offset += x.fastWriteField10(buf[offset:]) + offset += x.fastWriteField11(buf[offset:]) + offset += x.fastWriteField12(buf[offset:]) + offset += x.fastWriteField13(buf[offset:]) + return offset +} + +func (x *FriendUser) fastWriteField1(buf []byte) (offset int) { + if x.Id == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 1, x.Id) + return offset +} + +func (x *FriendUser) fastWriteField2(buf []byte) (offset int) { + if x.Name == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 2, x.Name) + return offset +} + +func (x *FriendUser) fastWriteField3(buf []byte) (offset int) { + if x.FollowCount == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 3, x.FollowCount) + return offset +} + +func (x *FriendUser) fastWriteField4(buf []byte) (offset int) { + if x.FollowerCount == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 4, x.FollowerCount) + return offset +} + +func (x *FriendUser) fastWriteField5(buf []byte) (offset int) { + if !x.IsFollow { + return offset + } + offset += fastpb.WriteBool(buf[offset:], 5, x.IsFollow) + return offset +} + +func (x *FriendUser) fastWriteField6(buf []byte) (offset int) { + if x.Avatar == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 6, x.Avatar) + return offset +} + +func (x *FriendUser) fastWriteField7(buf []byte) (offset int) { + if x.BackgroundImage == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 7, x.BackgroundImage) + return offset +} + +func (x *FriendUser) fastWriteField8(buf []byte) (offset int) { + if x.Signature == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 8, x.Signature) + return offset +} + +func (x *FriendUser) fastWriteField9(buf []byte) (offset int) { + if x.TotalFavorited == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 9, x.TotalFavorited) + return offset +} + +func (x *FriendUser) fastWriteField10(buf []byte) (offset int) { + if x.WorkCount == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 10, x.WorkCount) + return offset +} + +func (x *FriendUser) fastWriteField11(buf []byte) (offset int) { + if x.FavoriteCount == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 11, x.FavoriteCount) + return offset +} + +func (x *FriendUser) fastWriteField12(buf []byte) (offset int) { + if x.Message == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 12, x.Message) + return offset +} + +func (x *FriendUser) fastWriteField13(buf []byte) (offset int) { + if x.MsgType == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 13, x.MsgType) + return offset +} + func (x *DouyinRelationCountRequest) FastWrite(buf []byte) (offset int) { if x == nil { return offset @@ -887,6 +1156,130 @@ func (x *DouyinRelationFriendListResponse) sizeField3() (n int) { return n } +func (x *FriendUser) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + n += x.sizeField3() + n += x.sizeField4() + n += x.sizeField5() + n += x.sizeField6() + n += x.sizeField7() + n += x.sizeField8() + n += x.sizeField9() + n += x.sizeField10() + n += x.sizeField11() + n += x.sizeField12() + n += x.sizeField13() + return n +} + +func (x *FriendUser) sizeField1() (n int) { + if x.Id == 0 { + return n + } + n += fastpb.SizeInt64(1, x.Id) + return n +} + +func (x *FriendUser) sizeField2() (n int) { + if x.Name == "" { + return n + } + n += fastpb.SizeString(2, x.Name) + return n +} + +func (x *FriendUser) sizeField3() (n int) { + if x.FollowCount == 0 { + return n + } + n += fastpb.SizeInt64(3, x.FollowCount) + return n +} + +func (x *FriendUser) sizeField4() (n int) { + if x.FollowerCount == 0 { + return n + } + n += fastpb.SizeInt64(4, x.FollowerCount) + return n +} + +func (x *FriendUser) sizeField5() (n int) { + if !x.IsFollow { + return n + } + n += fastpb.SizeBool(5, x.IsFollow) + return n +} + +func (x *FriendUser) sizeField6() (n int) { + if x.Avatar == "" { + return n + } + n += fastpb.SizeString(6, x.Avatar) + return n +} + +func (x *FriendUser) sizeField7() (n int) { + if x.BackgroundImage == "" { + return n + } + n += fastpb.SizeString(7, x.BackgroundImage) + return n +} + +func (x *FriendUser) sizeField8() (n int) { + if x.Signature == "" { + return n + } + n += fastpb.SizeString(8, x.Signature) + return n +} + +func (x *FriendUser) sizeField9() (n int) { + if x.TotalFavorited == 0 { + return n + } + n += fastpb.SizeInt64(9, x.TotalFavorited) + return n +} + +func (x *FriendUser) sizeField10() (n int) { + if x.WorkCount == 0 { + return n + } + n += fastpb.SizeInt64(10, x.WorkCount) + return n +} + +func (x *FriendUser) sizeField11() (n int) { + if x.FavoriteCount == 0 { + return n + } + n += fastpb.SizeInt64(11, x.FavoriteCount) + return n +} + +func (x *FriendUser) sizeField12() (n int) { + if x.Message == "" { + return n + } + n += fastpb.SizeString(12, x.Message) + return n +} + +func (x *FriendUser) sizeField13() (n int) { + if x.MsgType == 0 { + return n + } + n += fastpb.SizeInt64(13, x.MsgType) + return n +} + func (x *DouyinRelationCountRequest) Size() (n int) { if x == nil { return n @@ -987,6 +1380,22 @@ var fieldIDToName_DouyinRelationFriendListResponse = map[int32]string{ 3: "UserList", } +var fieldIDToName_FriendUser = map[int32]string{ + 1: "Id", + 2: "Name", + 3: "FollowCount", + 4: "FollowerCount", + 5: "IsFollow", + 6: "Avatar", + 7: "BackgroundImage", + 8: "Signature", + 9: "TotalFavorited", + 10: "WorkCount", + 11: "FavoriteCount", + 12: "Message", + 13: "MsgType", +} + var fieldIDToName_DouyinRelationCountRequest = map[int32]string{ 1: "UserId", } @@ -998,4 +1407,4 @@ var fieldIDToName_DouyinRelationCountResponse = map[int32]string{ 4: "FollowerCount", } -var _ = entity.File_entity_proto +var _ = user.File_user_proto diff --git a/kitex_gen/relation/relation.pb.go b/kitex_gen/relation/relation.pb.go index 0c054e41..ce19308e 100644 --- a/kitex_gen/relation/relation.pb.go +++ b/kitex_gen/relation/relation.pb.go @@ -8,7 +8,7 @@ package relation import ( context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" + user "github.com/TremblingV5/DouTok/kitex_gen/user" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -90,8 +90,8 @@ type DouyinRelationActionResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 } func (x *DouyinRelationActionResponse) Reset() { @@ -192,9 +192,9 @@ type DouyinRelationFollowListResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserList []*entity.User `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty"` // 用户信息列表 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + UserList []*user.User `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty"` // 用户信息列表 } func (x *DouyinRelationFollowListResponse) Reset() { @@ -243,7 +243,7 @@ func (x *DouyinRelationFollowListResponse) GetStatusMsg() string { return "" } -func (x *DouyinRelationFollowListResponse) GetUserList() []*entity.User { +func (x *DouyinRelationFollowListResponse) GetUserList() []*user.User { if x != nil { return x.UserList } @@ -302,9 +302,9 @@ type DouyinRelationFollowerListResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserList []*entity.User `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty"` // 用户列表 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + UserList []*user.User `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty"` // 用户列表 } func (x *DouyinRelationFollowerListResponse) Reset() { @@ -353,7 +353,7 @@ func (x *DouyinRelationFollowerListResponse) GetStatusMsg() string { return "" } -func (x *DouyinRelationFollowerListResponse) GetUserList() []*entity.User { +func (x *DouyinRelationFollowerListResponse) GetUserList() []*user.User { if x != nil { return x.UserList } @@ -412,9 +412,9 @@ type DouyinRelationFriendListResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserList []*entity.FriendUser `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty"` // 用户列表 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + UserList []*FriendUser `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty"` // 用户列表 } func (x *DouyinRelationFriendListResponse) Reset() { @@ -463,13 +463,156 @@ func (x *DouyinRelationFriendListResponse) GetStatusMsg() string { return "" } -func (x *DouyinRelationFriendListResponse) GetUserList() []*entity.FriendUser { +func (x *DouyinRelationFriendListResponse) GetUserList() []*FriendUser { if x != nil { return x.UserList } return nil } +type FriendUser struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 用户id + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // 用户名称 + FollowCount int64 `protobuf:"varint,3,opt,name=follow_count,json=followCount,proto3" json:"follow_count,omitempty"` // 关注总数 + FollowerCount int64 `protobuf:"varint,4,opt,name=follower_count,json=followerCount,proto3" json:"follower_count,omitempty"` // 粉丝总数 + IsFollow bool `protobuf:"varint,5,opt,name=is_follow,json=isFollow,proto3" json:"is_follow,omitempty"` // true-已关注,false-未关注 + Avatar string `protobuf:"bytes,6,opt,name=avatar,proto3" json:"avatar,omitempty"` // 用户头像Url + BackgroundImage string `protobuf:"bytes,7,opt,name=background_image,json=backgroundImage,proto3" json:"background_image,omitempty"` // 用户个人页顶部大图 + Signature string `protobuf:"bytes,8,opt,name=signature,proto3" json:"signature,omitempty"` // 个人简介 + TotalFavorited int64 `protobuf:"varint,9,opt,name=total_favorited,json=totalFavorited,proto3" json:"total_favorited,omitempty"` // 获赞数量 + WorkCount int64 `protobuf:"varint,10,opt,name=work_count,json=workCount,proto3" json:"work_count,omitempty"` // 作品数量 + FavoriteCount int64 `protobuf:"varint,11,opt,name=favorite_count,json=favoriteCount,proto3" json:"favorite_count,omitempty"` // 点赞数量 + Message string `protobuf:"bytes,12,opt,name=message,proto3" json:"message,omitempty"` // 和该好友的最新聊天消息 + MsgType int64 `protobuf:"varint,13,opt,name=msgType,proto3" json:"msgType,omitempty"` // message消息的类型,0 => 当前请求用户接收的消息, 1 => 当前请求用户发送的消息(用于聊天框显示一条信息) +} + +func (x *FriendUser) Reset() { + *x = FriendUser{} + if protoimpl.UnsafeEnabled { + mi := &file_relation_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendUser) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendUser) ProtoMessage() {} + +func (x *FriendUser) ProtoReflect() protoreflect.Message { + mi := &file_relation_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendUser.ProtoReflect.Descriptor instead. +func (*FriendUser) Descriptor() ([]byte, []int) { + return file_relation_proto_rawDescGZIP(), []int{8} +} + +func (x *FriendUser) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *FriendUser) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *FriendUser) GetFollowCount() int64 { + if x != nil { + return x.FollowCount + } + return 0 +} + +func (x *FriendUser) GetFollowerCount() int64 { + if x != nil { + return x.FollowerCount + } + return 0 +} + +func (x *FriendUser) GetIsFollow() bool { + if x != nil { + return x.IsFollow + } + return false +} + +func (x *FriendUser) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *FriendUser) GetBackgroundImage() string { + if x != nil { + return x.BackgroundImage + } + return "" +} + +func (x *FriendUser) GetSignature() string { + if x != nil { + return x.Signature + } + return "" +} + +func (x *FriendUser) GetTotalFavorited() int64 { + if x != nil { + return x.TotalFavorited + } + return 0 +} + +func (x *FriendUser) GetWorkCount() int64 { + if x != nil { + return x.WorkCount + } + return 0 +} + +func (x *FriendUser) GetFavoriteCount() int64 { + if x != nil { + return x.FavoriteCount + } + return 0 +} + +func (x *FriendUser) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +func (x *FriendUser) GetMsgType() int64 { + if x != nil { + return x.MsgType + } + return 0 +} + type DouyinRelationCountRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -481,7 +624,7 @@ type DouyinRelationCountRequest struct { func (x *DouyinRelationCountRequest) Reset() { *x = DouyinRelationCountRequest{} if protoimpl.UnsafeEnabled { - mi := &file_relation_proto_msgTypes[8] + mi := &file_relation_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -494,7 +637,7 @@ func (x *DouyinRelationCountRequest) String() string { func (*DouyinRelationCountRequest) ProtoMessage() {} func (x *DouyinRelationCountRequest) ProtoReflect() protoreflect.Message { - mi := &file_relation_proto_msgTypes[8] + mi := &file_relation_proto_msgTypes[9] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -507,7 +650,7 @@ func (x *DouyinRelationCountRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use DouyinRelationCountRequest.ProtoReflect.Descriptor instead. func (*DouyinRelationCountRequest) Descriptor() ([]byte, []int) { - return file_relation_proto_rawDescGZIP(), []int{8} + return file_relation_proto_rawDescGZIP(), []int{9} } func (x *DouyinRelationCountRequest) GetUserId() int64 { @@ -531,7 +674,7 @@ type DouyinRelationCountResponse struct { func (x *DouyinRelationCountResponse) Reset() { *x = DouyinRelationCountResponse{} if protoimpl.UnsafeEnabled { - mi := &file_relation_proto_msgTypes[9] + mi := &file_relation_proto_msgTypes[10] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -544,7 +687,7 @@ func (x *DouyinRelationCountResponse) String() string { func (*DouyinRelationCountResponse) ProtoMessage() {} func (x *DouyinRelationCountResponse) ProtoReflect() protoreflect.Message { - mi := &file_relation_proto_msgTypes[9] + mi := &file_relation_proto_msgTypes[10] if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -557,7 +700,7 @@ func (x *DouyinRelationCountResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use DouyinRelationCountResponse.ProtoReflect.Descriptor instead. func (*DouyinRelationCountResponse) Descriptor() ([]byte, []int) { - return file_relation_proto_rawDescGZIP(), []int{9} + return file_relation_proto_rawDescGZIP(), []int{10} } func (x *DouyinRelationCountResponse) GetStatusCode() int32 { @@ -592,110 +735,144 @@ var File_relation_proto protoreflect.FileDescriptor var file_relation_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x12, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x78, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, - 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x63, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, + 0x12, 0x08, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x1a, 0x0a, 0x75, 0x73, 0x65, 0x72, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x78, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, + 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, + 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, + 0x64, 0x12, 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, + 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, + 0x22, 0x61, 0x0a, 0x1f, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, + 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, + 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, + 0x4d, 0x73, 0x67, 0x22, 0x3e, 0x0a, 0x23, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, + 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x6c, 0x69, + 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, - 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, - 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, - 0x70, 0x65, 0x22, 0x61, 0x0a, 0x1f, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, - 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x4d, 0x73, 0x67, 0x22, 0x3e, 0x0a, 0x23, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, - 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, - 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, - 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x91, 0x01, 0x0a, 0x24, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, - 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, - 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, - 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, - 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x29, - 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x0c, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x08, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x40, 0x0a, 0x25, 0x64, 0x6f, 0x75, - 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, - 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x72, 0x49, 0x64, 0x22, 0x8f, 0x01, 0x0a, 0x24, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x6c, + 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, + 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x27, 0x0a, 0x09, + 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x0a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x08, 0x75, 0x73, 0x65, + 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x40, 0x0a, 0x25, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, + 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, + 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x91, 0x01, 0x0a, 0x26, 0x64, 0x6f, 0x75, 0x79, + 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, + 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, + 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, + 0x73, 0x67, 0x12, 0x27, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, + 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, + 0x72, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x3e, 0x0a, 0x23, 0x64, + 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x93, 0x01, 0x0a, 0x26, + 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x99, 0x01, 0x0a, 0x24, + 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, + 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, + 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, + 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x4d, 0x73, 0x67, 0x12, 0x31, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, + 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x52, 0x08, 0x75, + 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x9b, 0x03, 0x0a, 0x0a, 0x46, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x6f, + 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x0b, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x25, 0x0a, + 0x0e, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x43, + 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, + 0x77, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, + 0x77, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x12, 0x29, 0x0a, 0x10, 0x62, 0x61, 0x63, + 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x07, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x0f, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, + 0x6d, 0x61, 0x67, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, + 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, + 0x72, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x66, 0x61, 0x76, 0x6f, + 0x72, 0x69, 0x74, 0x65, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x74, 0x6f, 0x74, + 0x61, 0x6c, 0x46, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x77, + 0x6f, 0x72, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x09, 0x77, 0x6f, 0x72, 0x6b, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x66, 0x61, + 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, + 0x28, 0x03, 0x52, 0x0d, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x75, 0x6e, + 0x74, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x0c, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, + 0x73, 0x67, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x6d, 0x73, + 0x67, 0x54, 0x79, 0x70, 0x65, 0x22, 0x38, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, + 0xaa, 0x01, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, + 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, + 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, + 0x73, 0x67, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, + 0x72, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x66, + 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0xc2, 0x04, 0x0a, + 0x0f, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x65, 0x0a, 0x0e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x41, 0x63, 0x74, 0x69, + 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, + 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x63, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x12, 0x52, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2d, 0x2e, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, + 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x6c, + 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x79, 0x0a, 0x14, + 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, + 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x29, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, - 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x65, 0x6e, 0x74, 0x69, - 0x74, 0x79, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, - 0x74, 0x22, 0x3e, 0x0a, 0x23, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, - 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, - 0x64, 0x22, 0x97, 0x01, 0x0a, 0x24, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, - 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x2f, 0x0a, 0x09, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, - 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x38, 0x0a, 0x1d, 0x64, - 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, - 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, - 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0xaa, 0x01, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, 0x12, 0x52, 0x65, 0x6c, 0x61, 0x74, + 0x69, 0x6f, 0x6e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2d, 0x2e, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, + 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, + 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, + 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x63, 0x0a, 0x0e, + 0x47, 0x65, 0x74, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x27, + 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x6f, 0x6c, 0x6c, - 0x6f, 0x77, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, - 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x66, - 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x0d, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x43, 0x6f, 0x75, - 0x6e, 0x74, 0x32, 0xdd, 0x03, 0x0a, 0x0f, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x65, 0x0a, 0x0e, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x28, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, - 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, - 0x12, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x4c, - 0x69, 0x73, 0x74, 0x12, 0x2d, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, - 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, - 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, - 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, - 0x6c, 0x6c, 0x6f, 0x77, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x12, 0x79, 0x0a, 0x14, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x6f, - 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x2f, 0x2e, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x6c, - 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x5f, - 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x73, 0x0a, - 0x12, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4c, - 0x69, 0x73, 0x74, 0x12, 0x2d, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, - 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, - 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x64, 0x6f, - 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x66, 0x72, - 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, - 0x73, 0x65, 0x42, 0x32, 0x5a, 0x30, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, - 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, + 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, + 0x6f, 0x6b, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, + 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, + 0x65, 0x6e, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -710,7 +887,7 @@ func file_relation_proto_rawDescGZIP() []byte { return file_relation_proto_rawDescData } -var file_relation_proto_msgTypes = make([]protoimpl.MessageInfo, 10) +var file_relation_proto_msgTypes = make([]protoimpl.MessageInfo, 11) var file_relation_proto_goTypes = []interface{}{ (*DouyinRelationActionRequest)(nil), // 0: relation.douyin_relation_action_request (*DouyinRelationActionResponse)(nil), // 1: relation.douyin_relation_action_response @@ -720,25 +897,27 @@ var file_relation_proto_goTypes = []interface{}{ (*DouyinRelationFollowerListResponse)(nil), // 5: relation.douyin_relation_follower_list_response (*DouyinRelationFriendListRequest)(nil), // 6: relation.douyin_relation_friend_list_request (*DouyinRelationFriendListResponse)(nil), // 7: relation.douyin_relation_friend_list_response - (*DouyinRelationCountRequest)(nil), // 8: relation.douyin_relation_count_request - (*DouyinRelationCountResponse)(nil), // 9: relation.douyin_relation_count_response - (*entity.User)(nil), // 10: entity.User - (*entity.FriendUser)(nil), // 11: entity.FriendUser + (*FriendUser)(nil), // 8: relation.FriendUser + (*DouyinRelationCountRequest)(nil), // 9: relation.douyin_relation_count_request + (*DouyinRelationCountResponse)(nil), // 10: relation.douyin_relation_count_response + (*user.User)(nil), // 11: user.User } var file_relation_proto_depIdxs = []int32{ - 10, // 0: relation.douyin_relation_follow_list_response.user_list:type_name -> entity.User - 10, // 1: relation.douyin_relation_follower_list_response.user_list:type_name -> entity.User - 11, // 2: relation.douyin_relation_friend_list_response.user_list:type_name -> entity.FriendUser + 11, // 0: relation.douyin_relation_follow_list_response.user_list:type_name -> user.User + 11, // 1: relation.douyin_relation_follower_list_response.user_list:type_name -> user.User + 8, // 2: relation.douyin_relation_friend_list_response.user_list:type_name -> relation.FriendUser 0, // 3: relation.RelationService.RelationAction:input_type -> relation.douyin_relation_action_request 2, // 4: relation.RelationService.RelationFollowList:input_type -> relation.douyin_relation_follow_list_request 4, // 5: relation.RelationService.RelationFollowerList:input_type -> relation.douyin_relation_follower_list_request 6, // 6: relation.RelationService.RelationFriendList:input_type -> relation.douyin_relation_friend_list_request - 1, // 7: relation.RelationService.RelationAction:output_type -> relation.douyin_relation_action_response - 3, // 8: relation.RelationService.RelationFollowList:output_type -> relation.douyin_relation_follow_list_response - 5, // 9: relation.RelationService.RelationFollowerList:output_type -> relation.douyin_relation_follower_list_response - 7, // 10: relation.RelationService.RelationFriendList:output_type -> relation.douyin_relation_friend_list_response - 7, // [7:11] is the sub-list for method output_type - 3, // [3:7] is the sub-list for method input_type + 9, // 7: relation.RelationService.GetFollowCount:input_type -> relation.douyin_relation_count_request + 1, // 8: relation.RelationService.RelationAction:output_type -> relation.douyin_relation_action_response + 3, // 9: relation.RelationService.RelationFollowList:output_type -> relation.douyin_relation_follow_list_response + 5, // 10: relation.RelationService.RelationFollowerList:output_type -> relation.douyin_relation_follower_list_response + 7, // 11: relation.RelationService.RelationFriendList:output_type -> relation.douyin_relation_friend_list_response + 10, // 12: relation.RelationService.GetFollowCount:output_type -> relation.douyin_relation_count_response + 8, // [8:13] is the sub-list for method output_type + 3, // [3:8] is the sub-list for method input_type 3, // [3:3] is the sub-list for extension type_name 3, // [3:3] is the sub-list for extension extendee 0, // [0:3] is the sub-list for field type_name @@ -847,7 +1026,7 @@ func file_relation_proto_init() { } } file_relation_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DouyinRelationCountRequest); i { + switch v := v.(*FriendUser); i { case 0: return &v.state case 1: @@ -859,6 +1038,18 @@ func file_relation_proto_init() { } } file_relation_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DouyinRelationCountRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_relation_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*DouyinRelationCountResponse); i { case 0: return &v.state @@ -877,7 +1068,7 @@ func file_relation_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_relation_proto_rawDesc, NumEnums: 0, - NumMessages: 10, + NumMessages: 11, NumExtensions: 0, NumServices: 1, }, @@ -900,4 +1091,5 @@ type RelationService interface { RelationFollowList(ctx context.Context, req *DouyinRelationFollowListRequest) (res *DouyinRelationFollowListResponse, err error) RelationFollowerList(ctx context.Context, req *DouyinRelationFollowerListRequest) (res *DouyinRelationFollowerListResponse, err error) RelationFriendList(ctx context.Context, req *DouyinRelationFriendListRequest) (res *DouyinRelationFriendListResponse, err error) + GetFollowCount(ctx context.Context, req *DouyinRelationCountRequest) (res *DouyinRelationCountResponse, err error) } diff --git a/kitex_gen/relation/relationservice/client.go b/kitex_gen/relation/relationservice/client.go index 460ad522..3515709f 100644 --- a/kitex_gen/relation/relationservice/client.go +++ b/kitex_gen/relation/relationservice/client.go @@ -15,6 +15,7 @@ type Client interface { RelationFollowList(ctx context.Context, Req *relation.DouyinRelationFollowListRequest, callOptions ...callopt.Option) (r *relation.DouyinRelationFollowListResponse, err error) RelationFollowerList(ctx context.Context, Req *relation.DouyinRelationFollowerListRequest, callOptions ...callopt.Option) (r *relation.DouyinRelationFollowerListResponse, err error) RelationFriendList(ctx context.Context, Req *relation.DouyinRelationFriendListRequest, callOptions ...callopt.Option) (r *relation.DouyinRelationFriendListResponse, err error) + GetFollowCount(ctx context.Context, Req *relation.DouyinRelationCountRequest, callOptions ...callopt.Option) (r *relation.DouyinRelationCountResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -65,3 +66,8 @@ func (p *kRelationServiceClient) RelationFriendList(ctx context.Context, Req *re ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.RelationFriendList(ctx, Req) } + +func (p *kRelationServiceClient) GetFollowCount(ctx context.Context, Req *relation.DouyinRelationCountRequest, callOptions ...callopt.Option) (r *relation.DouyinRelationCountResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.GetFollowCount(ctx, Req) +} diff --git a/kitex_gen/relation/relationservice/relationservice.go b/kitex_gen/relation/relationservice/relationservice.go index eacb0436..721c6467 100644 --- a/kitex_gen/relation/relationservice/relationservice.go +++ b/kitex_gen/relation/relationservice/relationservice.go @@ -26,6 +26,7 @@ func NewServiceInfo() *kitex.ServiceInfo { "RelationFollowList": kitex.NewMethodInfo(relationFollowListHandler, newRelationFollowListArgs, newRelationFollowListResult, false), "RelationFollowerList": kitex.NewMethodInfo(relationFollowerListHandler, newRelationFollowerListArgs, newRelationFollowerListResult, false), "RelationFriendList": kitex.NewMethodInfo(relationFriendListHandler, newRelationFriendListArgs, newRelationFriendListResult, false), + "GetFollowCount": kitex.NewMethodInfo(getFollowCountHandler, newGetFollowCountArgs, newGetFollowCountResult, false), } extra := map[string]interface{}{ "PackageName": "relation", @@ -621,6 +622,151 @@ func (p *RelationFriendListResult) IsSetSuccess() bool { return p.Success != nil } +func getFollowCountHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(relation.DouyinRelationCountRequest) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(relation.RelationService).GetFollowCount(ctx, req) + if err != nil { + return err + } + if err := st.SendMsg(resp); err != nil { + return err + } + case *GetFollowCountArgs: + success, err := handler.(relation.RelationService).GetFollowCount(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*GetFollowCountResult) + realResult.Success = success + } + return nil +} +func newGetFollowCountArgs() interface{} { + return &GetFollowCountArgs{} +} + +func newGetFollowCountResult() interface{} { + return &GetFollowCountResult{} +} + +type GetFollowCountArgs struct { + Req *relation.DouyinRelationCountRequest +} + +func (p *GetFollowCountArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(relation.DouyinRelationCountRequest) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *GetFollowCountArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *GetFollowCountArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *GetFollowCountArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, fmt.Errorf("No req in GetFollowCountArgs") + } + return proto.Marshal(p.Req) +} + +func (p *GetFollowCountArgs) Unmarshal(in []byte) error { + msg := new(relation.DouyinRelationCountRequest) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var GetFollowCountArgs_Req_DEFAULT *relation.DouyinRelationCountRequest + +func (p *GetFollowCountArgs) GetReq() *relation.DouyinRelationCountRequest { + if !p.IsSetReq() { + return GetFollowCountArgs_Req_DEFAULT + } + return p.Req +} + +func (p *GetFollowCountArgs) IsSetReq() bool { + return p.Req != nil +} + +type GetFollowCountResult struct { + Success *relation.DouyinRelationCountResponse +} + +var GetFollowCountResult_Success_DEFAULT *relation.DouyinRelationCountResponse + +func (p *GetFollowCountResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(relation.DouyinRelationCountResponse) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *GetFollowCountResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *GetFollowCountResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *GetFollowCountResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, fmt.Errorf("No req in GetFollowCountResult") + } + return proto.Marshal(p.Success) +} + +func (p *GetFollowCountResult) Unmarshal(in []byte) error { + msg := new(relation.DouyinRelationCountResponse) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *GetFollowCountResult) GetSuccess() *relation.DouyinRelationCountResponse { + if !p.IsSetSuccess() { + return GetFollowCountResult_Success_DEFAULT + } + return p.Success +} + +func (p *GetFollowCountResult) SetSuccess(x interface{}) { + p.Success = x.(*relation.DouyinRelationCountResponse) +} + +func (p *GetFollowCountResult) IsSetSuccess() bool { + return p.Success != nil +} + type kClient struct { c client.Client } @@ -670,3 +816,13 @@ func (p *kClient) RelationFriendList(ctx context.Context, Req *relation.DouyinRe } return _result.GetSuccess(), nil } + +func (p *kClient) GetFollowCount(ctx context.Context, Req *relation.DouyinRelationCountRequest) (r *relation.DouyinRelationCountResponse, err error) { + var _args GetFollowCountArgs + _args.Req = Req + var _result GetFollowCountResult + if err = p.c.Call(ctx, "GetFollowCount", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/kitex_gen/relationDomain/relationDomain.pb.fast.go b/kitex_gen/relationDomain/relationDomain.pb.fast.go deleted file mode 100644 index c502658b..00000000 --- a/kitex_gen/relationDomain/relationDomain.pb.fast.go +++ /dev/null @@ -1,855 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package relationDomain - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DoutokAddRelationRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddRelationRequest[number], err) -} - -func (x *DoutokAddRelationRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddRelationRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.ToUserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddRelationResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddRelationResponse[number], err) -} - -func (x *DoutokAddRelationResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokAddRelationResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokRmRelationRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokRmRelationRequest[number], err) -} - -func (x *DoutokRmRelationRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokRmRelationRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.ToUserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokRmRelationResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokRmRelationResponse[number], err) -} - -func (x *DoutokRmRelationResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokRmRelationResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokListRelationRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListRelationRequest[number], err) -} - -func (x *DoutokListRelationRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListRelationRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.ActionType, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListRelationResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListRelationResponse[number], err) -} - -func (x *DoutokListRelationResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokListRelationResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokListRelationResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.User - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.UserList = append(x.UserList, &v) - return offset, nil -} - -func (x *DoutokCountRelationRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCountRelationRequest[number], err) -} - -func (x *DoutokCountRelationRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.UserId = append(x.UserId, v) - return offset, err - }) - return offset, err -} - -func (x *DoutokCountRelationRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.ActionType, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokCountRelationResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCountRelationResponse[number], err) -} - -func (x *DoutokCountRelationResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokCountRelationResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokCountRelationResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.Result == nil { - x.Result = make(map[int64]int64) - } - var key int64 - var value int64 - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - value, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }) - if err != nil { - return offset, err - } - x.Result[key] = value - return offset, nil -} - -func (x *DoutokAddRelationRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokAddRelationRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DoutokAddRelationRequest) fastWriteField2(buf []byte) (offset int) { - if x.ToUserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.ToUserId) - return offset -} - -func (x *DoutokAddRelationResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokAddRelationResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokAddRelationResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokRmRelationRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokRmRelationRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DoutokRmRelationRequest) fastWriteField2(buf []byte) (offset int) { - if x.ToUserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.ToUserId) - return offset -} - -func (x *DoutokRmRelationResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokRmRelationResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokRmRelationResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokListRelationRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokListRelationRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DoutokListRelationRequest) fastWriteField2(buf []byte) (offset int) { - if x.ActionType == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.ActionType) - return offset -} - -func (x *DoutokListRelationResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokListRelationResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokListRelationResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokListRelationResponse) fastWriteField3(buf []byte) (offset int) { - if x.UserList == nil { - return offset - } - for i := range x.UserList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.UserList[i]) - } - return offset -} - -func (x *DoutokCountRelationRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokCountRelationRequest) fastWriteField1(buf []byte) (offset int) { - if len(x.UserId) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 1, len(x.UserId), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.UserId[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DoutokCountRelationRequest) fastWriteField2(buf []byte) (offset int) { - if x.ActionType == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.ActionType) - return offset -} - -func (x *DoutokCountRelationResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokCountRelationResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokCountRelationResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokCountRelationResponse) fastWriteField3(buf []byte) (offset int) { - if x.Result == nil { - return offset - } - for k, v := range x.Result { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteInt64(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DoutokAddRelationRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokAddRelationRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DoutokAddRelationRequest) sizeField2() (n int) { - if x.ToUserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.ToUserId) - return n -} - -func (x *DoutokAddRelationResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokAddRelationResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokAddRelationResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokRmRelationRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokRmRelationRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DoutokRmRelationRequest) sizeField2() (n int) { - if x.ToUserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.ToUserId) - return n -} - -func (x *DoutokRmRelationResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokRmRelationResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokRmRelationResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokListRelationRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokListRelationRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DoutokListRelationRequest) sizeField2() (n int) { - if x.ActionType == 0 { - return n - } - n += fastpb.SizeInt64(2, x.ActionType) - return n -} - -func (x *DoutokListRelationResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokListRelationResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokListRelationResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokListRelationResponse) sizeField3() (n int) { - if x.UserList == nil { - return n - } - for i := range x.UserList { - n += fastpb.SizeMessage(3, x.UserList[i]) - } - return n -} - -func (x *DoutokCountRelationRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokCountRelationRequest) sizeField1() (n int) { - if len(x.UserId) == 0 { - return n - } - n += fastpb.SizeListPacked(1, len(x.UserId), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.UserId[numIdxOrVal]) - return n - }) - return n -} - -func (x *DoutokCountRelationRequest) sizeField2() (n int) { - if x.ActionType == 0 { - return n - } - n += fastpb.SizeInt64(2, x.ActionType) - return n -} - -func (x *DoutokCountRelationResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokCountRelationResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokCountRelationResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokCountRelationResponse) sizeField3() (n int) { - if x.Result == nil { - return n - } - for k, v := range x.Result { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeInt64(numIdxOrVal, v) - return n - }) - } - return n -} - -var fieldIDToName_DoutokAddRelationRequest = map[int32]string{ - 1: "UserId", - 2: "ToUserId", -} - -var fieldIDToName_DoutokAddRelationResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", -} - -var fieldIDToName_DoutokRmRelationRequest = map[int32]string{ - 1: "UserId", - 2: "ToUserId", -} - -var fieldIDToName_DoutokRmRelationResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", -} - -var fieldIDToName_DoutokListRelationRequest = map[int32]string{ - 1: "UserId", - 2: "ActionType", -} - -var fieldIDToName_DoutokListRelationResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "UserList", -} - -var fieldIDToName_DoutokCountRelationRequest = map[int32]string{ - 1: "UserId", - 2: "ActionType", -} - -var fieldIDToName_DoutokCountRelationResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "Result", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/relationDomain/relationDomain.pb.go b/kitex_gen/relationDomain/relationDomain.pb.go deleted file mode 100644 index cb314786..00000000 --- a/kitex_gen/relationDomain/relationDomain.pb.go +++ /dev/null @@ -1,755 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 -// source: relationDomain.proto - -package relationDomain - -import ( - context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type DoutokAddRelationRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 用户id - ToUserId int64 `protobuf:"varint,2,opt,name=to_user_id,json=toUserId,proto3" json:"to_user_id,omitempty"` // 对方用户id -} - -func (x *DoutokAddRelationRequest) Reset() { - *x = DoutokAddRelationRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_relationDomain_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddRelationRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddRelationRequest) ProtoMessage() {} - -func (x *DoutokAddRelationRequest) ProtoReflect() protoreflect.Message { - mi := &file_relationDomain_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddRelationRequest.ProtoReflect.Descriptor instead. -func (*DoutokAddRelationRequest) Descriptor() ([]byte, []int) { - return file_relationDomain_proto_rawDescGZIP(), []int{0} -} - -func (x *DoutokAddRelationRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokAddRelationRequest) GetToUserId() int64 { - if x != nil { - return x.ToUserId - } - return 0 -} - -type DoutokAddRelationResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` -} - -func (x *DoutokAddRelationResponse) Reset() { - *x = DoutokAddRelationResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_relationDomain_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddRelationResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddRelationResponse) ProtoMessage() {} - -func (x *DoutokAddRelationResponse) ProtoReflect() protoreflect.Message { - mi := &file_relationDomain_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddRelationResponse.ProtoReflect.Descriptor instead. -func (*DoutokAddRelationResponse) Descriptor() ([]byte, []int) { - return file_relationDomain_proto_rawDescGZIP(), []int{1} -} - -func (x *DoutokAddRelationResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokAddRelationResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -type DoutokRmRelationRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 用户id - ToUserId int64 `protobuf:"varint,2,opt,name=to_user_id,json=toUserId,proto3" json:"to_user_id,omitempty"` // 对方用户id -} - -func (x *DoutokRmRelationRequest) Reset() { - *x = DoutokRmRelationRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_relationDomain_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokRmRelationRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokRmRelationRequest) ProtoMessage() {} - -func (x *DoutokRmRelationRequest) ProtoReflect() protoreflect.Message { - mi := &file_relationDomain_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokRmRelationRequest.ProtoReflect.Descriptor instead. -func (*DoutokRmRelationRequest) Descriptor() ([]byte, []int) { - return file_relationDomain_proto_rawDescGZIP(), []int{2} -} - -func (x *DoutokRmRelationRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokRmRelationRequest) GetToUserId() int64 { - if x != nil { - return x.ToUserId - } - return 0 -} - -type DoutokRmRelationResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` -} - -func (x *DoutokRmRelationResponse) Reset() { - *x = DoutokRmRelationResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_relationDomain_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokRmRelationResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokRmRelationResponse) ProtoMessage() {} - -func (x *DoutokRmRelationResponse) ProtoReflect() protoreflect.Message { - mi := &file_relationDomain_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokRmRelationResponse.ProtoReflect.Descriptor instead. -func (*DoutokRmRelationResponse) Descriptor() ([]byte, []int) { - return file_relationDomain_proto_rawDescGZIP(), []int{3} -} - -func (x *DoutokRmRelationResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokRmRelationResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -type DoutokListRelationRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 用户id - ActionType int64 `protobuf:"varint,2,opt,name=action_type,json=actionType,proto3" json:"action_type,omitempty"` // 请求类型,0对应粉丝列表,1对应关注列表,2对应朋友列表 -} - -func (x *DoutokListRelationRequest) Reset() { - *x = DoutokListRelationRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_relationDomain_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListRelationRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListRelationRequest) ProtoMessage() {} - -func (x *DoutokListRelationRequest) ProtoReflect() protoreflect.Message { - mi := &file_relationDomain_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListRelationRequest.ProtoReflect.Descriptor instead. -func (*DoutokListRelationRequest) Descriptor() ([]byte, []int) { - return file_relationDomain_proto_rawDescGZIP(), []int{4} -} - -func (x *DoutokListRelationRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokListRelationRequest) GetActionType() int64 { - if x != nil { - return x.ActionType - } - return 0 -} - -type DoutokListRelationResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserList []*entity.User `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty"` // 用户列表 -} - -func (x *DoutokListRelationResponse) Reset() { - *x = DoutokListRelationResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_relationDomain_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListRelationResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListRelationResponse) ProtoMessage() {} - -func (x *DoutokListRelationResponse) ProtoReflect() protoreflect.Message { - mi := &file_relationDomain_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListRelationResponse.ProtoReflect.Descriptor instead. -func (*DoutokListRelationResponse) Descriptor() ([]byte, []int) { - return file_relationDomain_proto_rawDescGZIP(), []int{5} -} - -func (x *DoutokListRelationResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokListRelationResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokListRelationResponse) GetUserList() []*entity.User { - if x != nil { - return x.UserList - } - return nil -} - -type DoutokCountRelationRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId []int64 `protobuf:"varint,1,rep,packed,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 用户id - ActionType int64 `protobuf:"varint,2,opt,name=action_type,json=actionType,proto3" json:"action_type,omitempty"` // 请求类型:0对应粉丝数,1对应关注数,2对应朋友数 -} - -func (x *DoutokCountRelationRequest) Reset() { - *x = DoutokCountRelationRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_relationDomain_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCountRelationRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCountRelationRequest) ProtoMessage() {} - -func (x *DoutokCountRelationRequest) ProtoReflect() protoreflect.Message { - mi := &file_relationDomain_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCountRelationRequest.ProtoReflect.Descriptor instead. -func (*DoutokCountRelationRequest) Descriptor() ([]byte, []int) { - return file_relationDomain_proto_rawDescGZIP(), []int{6} -} - -func (x *DoutokCountRelationRequest) GetUserId() []int64 { - if x != nil { - return x.UserId - } - return nil -} - -func (x *DoutokCountRelationRequest) GetActionType() int64 { - if x != nil { - return x.ActionType - } - return 0 -} - -type DoutokCountRelationResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - Result map[int64]int64 `protobuf:"bytes,3,rep,name=result,proto3" json:"result,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` -} - -func (x *DoutokCountRelationResponse) Reset() { - *x = DoutokCountRelationResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_relationDomain_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCountRelationResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCountRelationResponse) ProtoMessage() {} - -func (x *DoutokCountRelationResponse) ProtoReflect() protoreflect.Message { - mi := &file_relationDomain_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCountRelationResponse.ProtoReflect.Descriptor instead. -func (*DoutokCountRelationResponse) Descriptor() ([]byte, []int) { - return file_relationDomain_proto_rawDescGZIP(), []int{7} -} - -func (x *DoutokCountRelationResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokCountRelationResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokCountRelationResponse) GetResult() map[int64]int64 { - if x != nil { - return x.Result - } - return nil -} - -var File_relationDomain_proto protoreflect.FileDescriptor - -var file_relationDomain_proto_rawDesc = []byte{ - 0x0a, 0x14, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x54, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, - 0x64, 0x64, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x0a, - 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, - 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x5e, 0x0a, 0x1c, 0x64, 0x6f, - 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x22, 0x53, 0x0a, 0x1a, 0x64, 0x6f, - 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x72, 0x6d, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, - 0x64, 0x12, 0x1c, 0x0a, 0x0a, 0x74, 0x6f, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x74, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, - 0x5d, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x72, 0x6d, 0x5f, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, - 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, - 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x22, 0x58, - 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, - 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x61, 0x63, - 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x22, 0x8a, 0x01, 0x0a, 0x1d, 0x64, 0x6f, 0x75, - 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, - 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x29, 0x0a, 0x09, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, - 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x08, 0x75, 0x73, 0x65, - 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x59, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, - 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, - 0x1f, 0x0a, 0x0b, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x79, 0x70, 0x65, - 0x22, 0xef, 0x01, 0x0a, 0x1e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, - 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, - 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x4d, 0x73, 0x67, 0x12, 0x52, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x3a, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, - 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, - 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, - 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, - 0x38, 0x01, 0x32, 0xc5, 0x03, 0x0a, 0x15, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x68, 0x0a, 0x0b, - 0x41, 0x64, 0x64, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2b, 0x2e, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, - 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, - 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2c, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, - 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x0a, 0x52, 0x6d, 0x52, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x72, 0x6d, 0x5f, - 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x2b, 0x2e, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x72, 0x6d, 0x5f, 0x72, 0x65, 0x6c, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6b, 0x0a, - 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2c, 0x2e, - 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, - 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, - 0x69, 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2d, 0x2e, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, - 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x6e, 0x0a, 0x0d, 0x43, 0x6f, - 0x75, 0x6e, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x2e, 0x72, 0x65, - 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, - 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, - 0x6f, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2e, 0x2e, 0x72, 0x65, 0x6c, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, - 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x38, 0x5a, 0x36, 0x67, 0x69, - 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, - 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, 0x65, - 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x44, 0x6f, - 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_relationDomain_proto_rawDescOnce sync.Once - file_relationDomain_proto_rawDescData = file_relationDomain_proto_rawDesc -) - -func file_relationDomain_proto_rawDescGZIP() []byte { - file_relationDomain_proto_rawDescOnce.Do(func() { - file_relationDomain_proto_rawDescData = protoimpl.X.CompressGZIP(file_relationDomain_proto_rawDescData) - }) - return file_relationDomain_proto_rawDescData -} - -var file_relationDomain_proto_msgTypes = make([]protoimpl.MessageInfo, 9) -var file_relationDomain_proto_goTypes = []interface{}{ - (*DoutokAddRelationRequest)(nil), // 0: relationDomain.doutok_add_relation_request - (*DoutokAddRelationResponse)(nil), // 1: relationDomain.doutok_add_relation_response - (*DoutokRmRelationRequest)(nil), // 2: relationDomain.doutok_rm_relation_request - (*DoutokRmRelationResponse)(nil), // 3: relationDomain.doutok_rm_relation_response - (*DoutokListRelationRequest)(nil), // 4: relationDomain.doutok_list_relation_request - (*DoutokListRelationResponse)(nil), // 5: relationDomain.doutok_list_relation_response - (*DoutokCountRelationRequest)(nil), // 6: relationDomain.doutok_count_relation_request - (*DoutokCountRelationResponse)(nil), // 7: relationDomain.doutok_count_relation_response - nil, // 8: relationDomain.doutok_count_relation_response.ResultEntry - (*entity.User)(nil), // 9: entity.User -} -var file_relationDomain_proto_depIdxs = []int32{ - 9, // 0: relationDomain.doutok_list_relation_response.user_list:type_name -> entity.User - 8, // 1: relationDomain.doutok_count_relation_response.result:type_name -> relationDomain.doutok_count_relation_response.ResultEntry - 0, // 2: relationDomain.RelationDomainService.AddRelation:input_type -> relationDomain.doutok_add_relation_request - 2, // 3: relationDomain.RelationDomainService.RmRelation:input_type -> relationDomain.doutok_rm_relation_request - 4, // 4: relationDomain.RelationDomainService.ListRelation:input_type -> relationDomain.doutok_list_relation_request - 6, // 5: relationDomain.RelationDomainService.CountRelation:input_type -> relationDomain.doutok_count_relation_request - 1, // 6: relationDomain.RelationDomainService.AddRelation:output_type -> relationDomain.doutok_add_relation_response - 3, // 7: relationDomain.RelationDomainService.RmRelation:output_type -> relationDomain.doutok_rm_relation_response - 5, // 8: relationDomain.RelationDomainService.ListRelation:output_type -> relationDomain.doutok_list_relation_response - 7, // 9: relationDomain.RelationDomainService.CountRelation:output_type -> relationDomain.doutok_count_relation_response - 6, // [6:10] is the sub-list for method output_type - 2, // [2:6] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_relationDomain_proto_init() } -func file_relationDomain_proto_init() { - if File_relationDomain_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_relationDomain_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddRelationRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_relationDomain_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddRelationResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_relationDomain_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokRmRelationRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_relationDomain_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokRmRelationResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_relationDomain_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListRelationRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_relationDomain_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListRelationResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_relationDomain_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCountRelationRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_relationDomain_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCountRelationResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_relationDomain_proto_rawDesc, - NumEnums: 0, - NumMessages: 9, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_relationDomain_proto_goTypes, - DependencyIndexes: file_relationDomain_proto_depIdxs, - MessageInfos: file_relationDomain_proto_msgTypes, - }.Build() - File_relationDomain_proto = out.File - file_relationDomain_proto_rawDesc = nil - file_relationDomain_proto_goTypes = nil - file_relationDomain_proto_depIdxs = nil -} - -var _ context.Context - -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -type RelationDomainService interface { - AddRelation(ctx context.Context, req *DoutokAddRelationRequest) (res *DoutokAddRelationResponse, err error) - RmRelation(ctx context.Context, req *DoutokRmRelationRequest) (res *DoutokRmRelationResponse, err error) - ListRelation(ctx context.Context, req *DoutokListRelationRequest) (res *DoutokListRelationResponse, err error) - CountRelation(ctx context.Context, req *DoutokCountRelationRequest) (res *DoutokCountRelationResponse, err error) -} diff --git a/kitex_gen/relationDomain/relationdomainservice/client.go b/kitex_gen/relationDomain/relationdomainservice/client.go deleted file mode 100644 index ca53ae4b..00000000 --- a/kitex_gen/relationDomain/relationdomainservice/client.go +++ /dev/null @@ -1,67 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package relationdomainservice - -import ( - "context" - relationDomain "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - AddRelation(ctx context.Context, Req *relationDomain.DoutokAddRelationRequest, callOptions ...callopt.Option) (r *relationDomain.DoutokAddRelationResponse, err error) - RmRelation(ctx context.Context, Req *relationDomain.DoutokRmRelationRequest, callOptions ...callopt.Option) (r *relationDomain.DoutokRmRelationResponse, err error) - ListRelation(ctx context.Context, Req *relationDomain.DoutokListRelationRequest, callOptions ...callopt.Option) (r *relationDomain.DoutokListRelationResponse, err error) - CountRelation(ctx context.Context, Req *relationDomain.DoutokCountRelationRequest, callOptions ...callopt.Option) (r *relationDomain.DoutokCountRelationResponse, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfo(), options...) - if err != nil { - return nil, err - } - return &kRelationDomainServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kRelationDomainServiceClient struct { - *kClient -} - -func (p *kRelationDomainServiceClient) AddRelation(ctx context.Context, Req *relationDomain.DoutokAddRelationRequest, callOptions ...callopt.Option) (r *relationDomain.DoutokAddRelationResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.AddRelation(ctx, Req) -} - -func (p *kRelationDomainServiceClient) RmRelation(ctx context.Context, Req *relationDomain.DoutokRmRelationRequest, callOptions ...callopt.Option) (r *relationDomain.DoutokRmRelationResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.RmRelation(ctx, Req) -} - -func (p *kRelationDomainServiceClient) ListRelation(ctx context.Context, Req *relationDomain.DoutokListRelationRequest, callOptions ...callopt.Option) (r *relationDomain.DoutokListRelationResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.ListRelation(ctx, Req) -} - -func (p *kRelationDomainServiceClient) CountRelation(ctx context.Context, Req *relationDomain.DoutokCountRelationRequest, callOptions ...callopt.Option) (r *relationDomain.DoutokCountRelationResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.CountRelation(ctx, Req) -} diff --git a/kitex_gen/relationDomain/relationdomainservice/invoker.go b/kitex_gen/relationDomain/relationdomainservice/invoker.go deleted file mode 100644 index debea501..00000000 --- a/kitex_gen/relationDomain/relationdomainservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package relationdomainservice - -import ( - relationDomain "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler relationDomain.RelationDomainService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/kitex_gen/relationDomain/relationdomainservice/relationdomainservice.go b/kitex_gen/relationDomain/relationdomainservice/relationdomainservice.go deleted file mode 100644 index ab35ae59..00000000 --- a/kitex_gen/relationDomain/relationdomainservice/relationdomainservice.go +++ /dev/null @@ -1,672 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package relationdomainservice - -import ( - "context" - "fmt" - relationDomain "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" -) - -func serviceInfo() *kitex.ServiceInfo { - return relationDomainServiceServiceInfo -} - -var relationDomainServiceServiceInfo = NewServiceInfo() - -func NewServiceInfo() *kitex.ServiceInfo { - serviceName := "RelationDomainService" - handlerType := (*relationDomain.RelationDomainService)(nil) - methods := map[string]kitex.MethodInfo{ - "AddRelation": kitex.NewMethodInfo(addRelationHandler, newAddRelationArgs, newAddRelationResult, false), - "RmRelation": kitex.NewMethodInfo(rmRelationHandler, newRmRelationArgs, newRmRelationResult, false), - "ListRelation": kitex.NewMethodInfo(listRelationHandler, newListRelationArgs, newListRelationResult, false), - "CountRelation": kitex.NewMethodInfo(countRelationHandler, newCountRelationArgs, newCountRelationResult, false), - } - extra := map[string]interface{}{ - "PackageName": "relationDomain", - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", - Extra: extra, - } - return svcInfo -} - -func addRelationHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(relationDomain.DoutokAddRelationRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(relationDomain.RelationDomainService).AddRelation(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *AddRelationArgs: - success, err := handler.(relationDomain.RelationDomainService).AddRelation(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*AddRelationResult) - realResult.Success = success - } - return nil -} -func newAddRelationArgs() interface{} { - return &AddRelationArgs{} -} - -func newAddRelationResult() interface{} { - return &AddRelationResult{} -} - -type AddRelationArgs struct { - Req *relationDomain.DoutokAddRelationRequest -} - -func (p *AddRelationArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(relationDomain.DoutokAddRelationRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *AddRelationArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *AddRelationArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *AddRelationArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in AddRelationArgs") - } - return proto.Marshal(p.Req) -} - -func (p *AddRelationArgs) Unmarshal(in []byte) error { - msg := new(relationDomain.DoutokAddRelationRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var AddRelationArgs_Req_DEFAULT *relationDomain.DoutokAddRelationRequest - -func (p *AddRelationArgs) GetReq() *relationDomain.DoutokAddRelationRequest { - if !p.IsSetReq() { - return AddRelationArgs_Req_DEFAULT - } - return p.Req -} - -func (p *AddRelationArgs) IsSetReq() bool { - return p.Req != nil -} - -type AddRelationResult struct { - Success *relationDomain.DoutokAddRelationResponse -} - -var AddRelationResult_Success_DEFAULT *relationDomain.DoutokAddRelationResponse - -func (p *AddRelationResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(relationDomain.DoutokAddRelationResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *AddRelationResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *AddRelationResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *AddRelationResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in AddRelationResult") - } - return proto.Marshal(p.Success) -} - -func (p *AddRelationResult) Unmarshal(in []byte) error { - msg := new(relationDomain.DoutokAddRelationResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *AddRelationResult) GetSuccess() *relationDomain.DoutokAddRelationResponse { - if !p.IsSetSuccess() { - return AddRelationResult_Success_DEFAULT - } - return p.Success -} - -func (p *AddRelationResult) SetSuccess(x interface{}) { - p.Success = x.(*relationDomain.DoutokAddRelationResponse) -} - -func (p *AddRelationResult) IsSetSuccess() bool { - return p.Success != nil -} - -func rmRelationHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(relationDomain.DoutokRmRelationRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(relationDomain.RelationDomainService).RmRelation(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *RmRelationArgs: - success, err := handler.(relationDomain.RelationDomainService).RmRelation(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*RmRelationResult) - realResult.Success = success - } - return nil -} -func newRmRelationArgs() interface{} { - return &RmRelationArgs{} -} - -func newRmRelationResult() interface{} { - return &RmRelationResult{} -} - -type RmRelationArgs struct { - Req *relationDomain.DoutokRmRelationRequest -} - -func (p *RmRelationArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(relationDomain.DoutokRmRelationRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *RmRelationArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *RmRelationArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *RmRelationArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in RmRelationArgs") - } - return proto.Marshal(p.Req) -} - -func (p *RmRelationArgs) Unmarshal(in []byte) error { - msg := new(relationDomain.DoutokRmRelationRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var RmRelationArgs_Req_DEFAULT *relationDomain.DoutokRmRelationRequest - -func (p *RmRelationArgs) GetReq() *relationDomain.DoutokRmRelationRequest { - if !p.IsSetReq() { - return RmRelationArgs_Req_DEFAULT - } - return p.Req -} - -func (p *RmRelationArgs) IsSetReq() bool { - return p.Req != nil -} - -type RmRelationResult struct { - Success *relationDomain.DoutokRmRelationResponse -} - -var RmRelationResult_Success_DEFAULT *relationDomain.DoutokRmRelationResponse - -func (p *RmRelationResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(relationDomain.DoutokRmRelationResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *RmRelationResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *RmRelationResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *RmRelationResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in RmRelationResult") - } - return proto.Marshal(p.Success) -} - -func (p *RmRelationResult) Unmarshal(in []byte) error { - msg := new(relationDomain.DoutokRmRelationResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *RmRelationResult) GetSuccess() *relationDomain.DoutokRmRelationResponse { - if !p.IsSetSuccess() { - return RmRelationResult_Success_DEFAULT - } - return p.Success -} - -func (p *RmRelationResult) SetSuccess(x interface{}) { - p.Success = x.(*relationDomain.DoutokRmRelationResponse) -} - -func (p *RmRelationResult) IsSetSuccess() bool { - return p.Success != nil -} - -func listRelationHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(relationDomain.DoutokListRelationRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(relationDomain.RelationDomainService).ListRelation(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *ListRelationArgs: - success, err := handler.(relationDomain.RelationDomainService).ListRelation(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*ListRelationResult) - realResult.Success = success - } - return nil -} -func newListRelationArgs() interface{} { - return &ListRelationArgs{} -} - -func newListRelationResult() interface{} { - return &ListRelationResult{} -} - -type ListRelationArgs struct { - Req *relationDomain.DoutokListRelationRequest -} - -func (p *ListRelationArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(relationDomain.DoutokListRelationRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *ListRelationArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *ListRelationArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *ListRelationArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in ListRelationArgs") - } - return proto.Marshal(p.Req) -} - -func (p *ListRelationArgs) Unmarshal(in []byte) error { - msg := new(relationDomain.DoutokListRelationRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var ListRelationArgs_Req_DEFAULT *relationDomain.DoutokListRelationRequest - -func (p *ListRelationArgs) GetReq() *relationDomain.DoutokListRelationRequest { - if !p.IsSetReq() { - return ListRelationArgs_Req_DEFAULT - } - return p.Req -} - -func (p *ListRelationArgs) IsSetReq() bool { - return p.Req != nil -} - -type ListRelationResult struct { - Success *relationDomain.DoutokListRelationResponse -} - -var ListRelationResult_Success_DEFAULT *relationDomain.DoutokListRelationResponse - -func (p *ListRelationResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(relationDomain.DoutokListRelationResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *ListRelationResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *ListRelationResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *ListRelationResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in ListRelationResult") - } - return proto.Marshal(p.Success) -} - -func (p *ListRelationResult) Unmarshal(in []byte) error { - msg := new(relationDomain.DoutokListRelationResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *ListRelationResult) GetSuccess() *relationDomain.DoutokListRelationResponse { - if !p.IsSetSuccess() { - return ListRelationResult_Success_DEFAULT - } - return p.Success -} - -func (p *ListRelationResult) SetSuccess(x interface{}) { - p.Success = x.(*relationDomain.DoutokListRelationResponse) -} - -func (p *ListRelationResult) IsSetSuccess() bool { - return p.Success != nil -} - -func countRelationHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(relationDomain.DoutokCountRelationRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(relationDomain.RelationDomainService).CountRelation(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *CountRelationArgs: - success, err := handler.(relationDomain.RelationDomainService).CountRelation(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*CountRelationResult) - realResult.Success = success - } - return nil -} -func newCountRelationArgs() interface{} { - return &CountRelationArgs{} -} - -func newCountRelationResult() interface{} { - return &CountRelationResult{} -} - -type CountRelationArgs struct { - Req *relationDomain.DoutokCountRelationRequest -} - -func (p *CountRelationArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(relationDomain.DoutokCountRelationRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *CountRelationArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *CountRelationArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *CountRelationArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in CountRelationArgs") - } - return proto.Marshal(p.Req) -} - -func (p *CountRelationArgs) Unmarshal(in []byte) error { - msg := new(relationDomain.DoutokCountRelationRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var CountRelationArgs_Req_DEFAULT *relationDomain.DoutokCountRelationRequest - -func (p *CountRelationArgs) GetReq() *relationDomain.DoutokCountRelationRequest { - if !p.IsSetReq() { - return CountRelationArgs_Req_DEFAULT - } - return p.Req -} - -func (p *CountRelationArgs) IsSetReq() bool { - return p.Req != nil -} - -type CountRelationResult struct { - Success *relationDomain.DoutokCountRelationResponse -} - -var CountRelationResult_Success_DEFAULT *relationDomain.DoutokCountRelationResponse - -func (p *CountRelationResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(relationDomain.DoutokCountRelationResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *CountRelationResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *CountRelationResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *CountRelationResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in CountRelationResult") - } - return proto.Marshal(p.Success) -} - -func (p *CountRelationResult) Unmarshal(in []byte) error { - msg := new(relationDomain.DoutokCountRelationResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *CountRelationResult) GetSuccess() *relationDomain.DoutokCountRelationResponse { - if !p.IsSetSuccess() { - return CountRelationResult_Success_DEFAULT - } - return p.Success -} - -func (p *CountRelationResult) SetSuccess(x interface{}) { - p.Success = x.(*relationDomain.DoutokCountRelationResponse) -} - -func (p *CountRelationResult) IsSetSuccess() bool { - return p.Success != nil -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) AddRelation(ctx context.Context, Req *relationDomain.DoutokAddRelationRequest) (r *relationDomain.DoutokAddRelationResponse, err error) { - var _args AddRelationArgs - _args.Req = Req - var _result AddRelationResult - if err = p.c.Call(ctx, "AddRelation", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) RmRelation(ctx context.Context, Req *relationDomain.DoutokRmRelationRequest) (r *relationDomain.DoutokRmRelationResponse, err error) { - var _args RmRelationArgs - _args.Req = Req - var _result RmRelationResult - if err = p.c.Call(ctx, "RmRelation", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) ListRelation(ctx context.Context, Req *relationDomain.DoutokListRelationRequest) (r *relationDomain.DoutokListRelationResponse, err error) { - var _args ListRelationArgs - _args.Req = Req - var _result ListRelationResult - if err = p.c.Call(ctx, "ListRelation", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) CountRelation(ctx context.Context, Req *relationDomain.DoutokCountRelationRequest) (r *relationDomain.DoutokCountRelationResponse, err error) { - var _args CountRelationArgs - _args.Req = Req - var _result CountRelationResult - if err = p.c.Call(ctx, "CountRelation", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/kitex_gen/relationDomain/relationdomainservice/server.go b/kitex_gen/relationDomain/relationdomainservice/server.go deleted file mode 100644 index 80d986b5..00000000 --- a/kitex_gen/relationDomain/relationdomainservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. -package relationdomainservice - -import ( - relationDomain "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler relationDomain.RelationDomainService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/kitex_gen/user/user.pb.fast.go b/kitex_gen/user/user.pb.fast.go index 51d857c0..e868921a 100644 --- a/kitex_gen/user/user.pb.fast.go +++ b/kitex_gen/user/user.pb.fast.go @@ -4,7 +4,6 @@ package user import ( fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" fastpb "github.com/cloudwego/fastpb" ) @@ -239,7 +238,7 @@ func (x *DouyinUserResponse) fastReadField2(buf []byte, _type int8) (offset int, } func (x *DouyinUserResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.User + var v User offset, err = fastpb.ReadMessage(buf, _type, &v) if err != nil { return offset, err @@ -323,7 +322,7 @@ func (x *DouyinUserListResponse) fastReadField2(buf []byte, _type int8) (offset } func (x *DouyinUserListResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.User + var v User offset, err = fastpb.ReadMessage(buf, _type, &v) if err != nil { return offset, err @@ -332,6 +331,131 @@ func (x *DouyinUserListResponse) fastReadField3(buf []byte, _type int8) (offset return offset, nil } +func (x *User) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { + switch number { + case 1: + offset, err = x.fastReadField1(buf, _type) + if err != nil { + goto ReadFieldError + } + case 2: + offset, err = x.fastReadField2(buf, _type) + if err != nil { + goto ReadFieldError + } + case 3: + offset, err = x.fastReadField3(buf, _type) + if err != nil { + goto ReadFieldError + } + case 4: + offset, err = x.fastReadField4(buf, _type) + if err != nil { + goto ReadFieldError + } + case 5: + offset, err = x.fastReadField5(buf, _type) + if err != nil { + goto ReadFieldError + } + case 6: + offset, err = x.fastReadField6(buf, _type) + if err != nil { + goto ReadFieldError + } + case 7: + offset, err = x.fastReadField7(buf, _type) + if err != nil { + goto ReadFieldError + } + case 8: + offset, err = x.fastReadField8(buf, _type) + if err != nil { + goto ReadFieldError + } + case 9: + offset, err = x.fastReadField9(buf, _type) + if err != nil { + goto ReadFieldError + } + case 10: + offset, err = x.fastReadField10(buf, _type) + if err != nil { + goto ReadFieldError + } + case 11: + offset, err = x.fastReadField11(buf, _type) + if err != nil { + goto ReadFieldError + } + default: + offset, err = fastpb.Skip(buf, _type, number) + if err != nil { + goto SkipFieldError + } + } + return offset, nil +SkipFieldError: + return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) +ReadFieldError: + return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_User[number], err) +} + +func (x *User) fastReadField1(buf []byte, _type int8) (offset int, err error) { + x.Id, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *User) fastReadField2(buf []byte, _type int8) (offset int, err error) { + x.Name, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *User) fastReadField3(buf []byte, _type int8) (offset int, err error) { + x.FollowCount, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *User) fastReadField4(buf []byte, _type int8) (offset int, err error) { + x.FollowerCount, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *User) fastReadField5(buf []byte, _type int8) (offset int, err error) { + x.IsFollow, offset, err = fastpb.ReadBool(buf, _type) + return offset, err +} + +func (x *User) fastReadField6(buf []byte, _type int8) (offset int, err error) { + x.Avatar, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *User) fastReadField7(buf []byte, _type int8) (offset int, err error) { + x.BackgroundImage, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *User) fastReadField8(buf []byte, _type int8) (offset int, err error) { + x.Signature, offset, err = fastpb.ReadString(buf, _type) + return offset, err +} + +func (x *User) fastReadField9(buf []byte, _type int8) (offset int, err error) { + x.TotalFavorited, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *User) fastReadField10(buf []byte, _type int8) (offset int, err error) { + x.WorkCount, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + +func (x *User) fastReadField11(buf []byte, _type int8) (offset int, err error) { + x.FavoriteCount, offset, err = fastpb.ReadInt64(buf, _type) + return offset, err +} + func (x *DouyinUserRegisterRequest) FastWrite(buf []byte) (offset int) { if x == nil { return offset @@ -557,6 +681,112 @@ func (x *DouyinUserListResponse) fastWriteField3(buf []byte) (offset int) { return offset } +func (x *User) FastWrite(buf []byte) (offset int) { + if x == nil { + return offset + } + offset += x.fastWriteField1(buf[offset:]) + offset += x.fastWriteField2(buf[offset:]) + offset += x.fastWriteField3(buf[offset:]) + offset += x.fastWriteField4(buf[offset:]) + offset += x.fastWriteField5(buf[offset:]) + offset += x.fastWriteField6(buf[offset:]) + offset += x.fastWriteField7(buf[offset:]) + offset += x.fastWriteField8(buf[offset:]) + offset += x.fastWriteField9(buf[offset:]) + offset += x.fastWriteField10(buf[offset:]) + offset += x.fastWriteField11(buf[offset:]) + return offset +} + +func (x *User) fastWriteField1(buf []byte) (offset int) { + if x.Id == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 1, x.Id) + return offset +} + +func (x *User) fastWriteField2(buf []byte) (offset int) { + if x.Name == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 2, x.Name) + return offset +} + +func (x *User) fastWriteField3(buf []byte) (offset int) { + if x.FollowCount == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 3, x.FollowCount) + return offset +} + +func (x *User) fastWriteField4(buf []byte) (offset int) { + if x.FollowerCount == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 4, x.FollowerCount) + return offset +} + +func (x *User) fastWriteField5(buf []byte) (offset int) { + if !x.IsFollow { + return offset + } + offset += fastpb.WriteBool(buf[offset:], 5, x.IsFollow) + return offset +} + +func (x *User) fastWriteField6(buf []byte) (offset int) { + if x.Avatar == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 6, x.Avatar) + return offset +} + +func (x *User) fastWriteField7(buf []byte) (offset int) { + if x.BackgroundImage == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 7, x.BackgroundImage) + return offset +} + +func (x *User) fastWriteField8(buf []byte) (offset int) { + if x.Signature == "" { + return offset + } + offset += fastpb.WriteString(buf[offset:], 8, x.Signature) + return offset +} + +func (x *User) fastWriteField9(buf []byte) (offset int) { + if x.TotalFavorited == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 9, x.TotalFavorited) + return offset +} + +func (x *User) fastWriteField10(buf []byte) (offset int) { + if x.WorkCount == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 10, x.WorkCount) + return offset +} + +func (x *User) fastWriteField11(buf []byte) (offset int) { + if x.FavoriteCount == 0 { + return offset + } + offset += fastpb.WriteInt64(buf[offset:], 11, x.FavoriteCount) + return offset +} + func (x *DouyinUserRegisterRequest) Size() (n int) { if x == nil { return n @@ -782,6 +1012,112 @@ func (x *DouyinUserListResponse) sizeField3() (n int) { return n } +func (x *User) Size() (n int) { + if x == nil { + return n + } + n += x.sizeField1() + n += x.sizeField2() + n += x.sizeField3() + n += x.sizeField4() + n += x.sizeField5() + n += x.sizeField6() + n += x.sizeField7() + n += x.sizeField8() + n += x.sizeField9() + n += x.sizeField10() + n += x.sizeField11() + return n +} + +func (x *User) sizeField1() (n int) { + if x.Id == 0 { + return n + } + n += fastpb.SizeInt64(1, x.Id) + return n +} + +func (x *User) sizeField2() (n int) { + if x.Name == "" { + return n + } + n += fastpb.SizeString(2, x.Name) + return n +} + +func (x *User) sizeField3() (n int) { + if x.FollowCount == 0 { + return n + } + n += fastpb.SizeInt64(3, x.FollowCount) + return n +} + +func (x *User) sizeField4() (n int) { + if x.FollowerCount == 0 { + return n + } + n += fastpb.SizeInt64(4, x.FollowerCount) + return n +} + +func (x *User) sizeField5() (n int) { + if !x.IsFollow { + return n + } + n += fastpb.SizeBool(5, x.IsFollow) + return n +} + +func (x *User) sizeField6() (n int) { + if x.Avatar == "" { + return n + } + n += fastpb.SizeString(6, x.Avatar) + return n +} + +func (x *User) sizeField7() (n int) { + if x.BackgroundImage == "" { + return n + } + n += fastpb.SizeString(7, x.BackgroundImage) + return n +} + +func (x *User) sizeField8() (n int) { + if x.Signature == "" { + return n + } + n += fastpb.SizeString(8, x.Signature) + return n +} + +func (x *User) sizeField9() (n int) { + if x.TotalFavorited == 0 { + return n + } + n += fastpb.SizeInt64(9, x.TotalFavorited) + return n +} + +func (x *User) sizeField10() (n int) { + if x.WorkCount == 0 { + return n + } + n += fastpb.SizeInt64(10, x.WorkCount) + return n +} + +func (x *User) sizeField11() (n int) { + if x.FavoriteCount == 0 { + return n + } + n += fastpb.SizeInt64(11, x.FavoriteCount) + return n +} + var fieldIDToName_DouyinUserRegisterRequest = map[int32]string{ 1: "Username", 2: "Password", @@ -824,4 +1160,16 @@ var fieldIDToName_DouyinUserListResponse = map[int32]string{ 3: "UserList", } -var _ = entity.File_entity_proto +var fieldIDToName_User = map[int32]string{ + 1: "Id", + 2: "Name", + 3: "FollowCount", + 4: "FollowerCount", + 5: "IsFollow", + 6: "Avatar", + 7: "BackgroundImage", + 8: "Signature", + 9: "TotalFavorited", + 10: "WorkCount", + 11: "FavoriteCount", +} diff --git a/kitex_gen/user/user.pb.go b/kitex_gen/user/user.pb.go index d7ac0194..304f4cea 100644 --- a/kitex_gen/user/user.pb.go +++ b/kitex_gen/user/user.pb.go @@ -8,7 +8,6 @@ package user import ( context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -82,9 +81,9 @@ type DouyinUserRegisterResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 用户id + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 用户id } func (x *DouyinUserRegisterResponse) Reset() { @@ -200,9 +199,9 @@ type DouyinUserLoginResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 用户id + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 用户id } func (x *DouyinUserLoginResponse) Reset() { @@ -310,9 +309,9 @@ type DouyinUserResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - User *entity.User `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"` // 用户信息 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + User *User `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"` // 用户信息 } func (x *DouyinUserResponse) Reset() { @@ -361,7 +360,7 @@ func (x *DouyinUserResponse) GetStatusMsg() string { return "" } -func (x *DouyinUserResponse) GetUser() *entity.User { +func (x *DouyinUserResponse) GetUser() *User { if x != nil { return x.User } @@ -420,9 +419,9 @@ type DouyinUserListResponse struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserList []*entity.User `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty"` // 用户信息 + StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` // 状态码,0-成功,其他值-失败 + StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` // 返回状态描述 + UserList []*User `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty"` // 用户信息 } func (x *DouyinUserListResponse) Reset() { @@ -471,86 +470,241 @@ func (x *DouyinUserListResponse) GetStatusMsg() string { return "" } -func (x *DouyinUserListResponse) GetUserList() []*entity.User { +func (x *DouyinUserListResponse) GetUserList() []*User { if x != nil { return x.UserList } return nil } +type User struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` // 用户id + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` // 用户名称 + FollowCount int64 `protobuf:"varint,3,opt,name=follow_count,json=followCount,proto3" json:"follow_count,omitempty"` // 关注总数 + FollowerCount int64 `protobuf:"varint,4,opt,name=follower_count,json=followerCount,proto3" json:"follower_count,omitempty"` // 粉丝总数 + IsFollow bool `protobuf:"varint,5,opt,name=is_follow,json=isFollow,proto3" json:"is_follow,omitempty"` // true-已关注,false-未关注 + Avatar string `protobuf:"bytes,6,opt,name=avatar,proto3" json:"avatar,omitempty"` // 用户头像Url + BackgroundImage string `protobuf:"bytes,7,opt,name=background_image,json=backgroundImage,proto3" json:"background_image,omitempty"` // 用户个人页顶部大图 + Signature string `protobuf:"bytes,8,opt,name=signature,proto3" json:"signature,omitempty"` // 个人简介 + TotalFavorited int64 `protobuf:"varint,9,opt,name=total_favorited,json=totalFavorited,proto3" json:"total_favorited,omitempty"` // 获赞数量 + WorkCount int64 `protobuf:"varint,10,opt,name=work_count,json=workCount,proto3" json:"work_count,omitempty"` // 作品数量 + FavoriteCount int64 `protobuf:"varint,11,opt,name=favorite_count,json=favoriteCount,proto3" json:"favorite_count,omitempty"` // 点赞数量 +} + +func (x *User) Reset() { + *x = User{} + if protoimpl.UnsafeEnabled { + mi := &file_user_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *User) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*User) ProtoMessage() {} + +func (x *User) ProtoReflect() protoreflect.Message { + mi := &file_user_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use User.ProtoReflect.Descriptor instead. +func (*User) Descriptor() ([]byte, []int) { + return file_user_proto_rawDescGZIP(), []int{8} +} + +func (x *User) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *User) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *User) GetFollowCount() int64 { + if x != nil { + return x.FollowCount + } + return 0 +} + +func (x *User) GetFollowerCount() int64 { + if x != nil { + return x.FollowerCount + } + return 0 +} + +func (x *User) GetIsFollow() bool { + if x != nil { + return x.IsFollow + } + return false +} + +func (x *User) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *User) GetBackgroundImage() string { + if x != nil { + return x.BackgroundImage + } + return "" +} + +func (x *User) GetSignature() string { + if x != nil { + return x.Signature + } + return "" +} + +func (x *User) GetTotalFavorited() int64 { + if x != nil { + return x.TotalFavorited + } + return 0 +} + +func (x *User) GetWorkCount() int64 { + if x != nil { + return x.WorkCount + } + return 0 +} + +func (x *User) GetFavoriteCount() int64 { + if x != nil { + return x.FavoriteCount + } + return 0 +} + var File_user_proto protoreflect.FileDescriptor var file_user_proto_rawDesc = []byte{ 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, - 0x65, 0x72, 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x56, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, - 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x78, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x79, - 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, - 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, - 0x49, 0x64, 0x22, 0x53, 0x0a, 0x19, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, - 0x72, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, - 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, - 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x75, 0x0a, 0x1a, 0x64, 0x6f, 0x75, 0x79, 0x69, - 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x73, - 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, - 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2e, - 0x0a, 0x13, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x78, - 0x0a, 0x14, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, - 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x20, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x55, 0x73, + 0x65, 0x72, 0x22, 0x56, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, + 0x72, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, + 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x78, 0x0a, 0x1d, 0x64, 0x6f, + 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, + 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, + 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, + 0x65, 0x72, 0x49, 0x64, 0x22, 0x53, 0x0a, 0x19, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x75, 0x0a, 0x1a, 0x64, 0x6f, 0x75, + 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x72, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, + 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, + 0x22, 0x2e, 0x0a, 0x13, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, + 0x22, 0x76, 0x0a, 0x14, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, + 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, + 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, + 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x1e, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x22, 0x37, 0x0a, 0x18, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, - 0x74, 0x22, 0x86, 0x01, 0x0a, 0x19, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, + 0x74, 0x22, 0x84, 0x01, 0x0a, 0x19, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, - 0x29, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x55, 0x73, 0x65, 0x72, - 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x32, 0xf4, 0x01, 0x0a, 0x0b, 0x55, - 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x53, 0x0a, 0x08, 0x52, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x22, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x64, 0x6f, - 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, - 0x65, 0x72, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x75, 0x73, 0x65, - 0x72, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, - 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x4a, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1f, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, - 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x6f, 0x67, 0x69, - 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x75, 0x73, 0x65, 0x72, - 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x6f, 0x67, - 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x0b, 0x47, - 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x49, 0x64, 0x12, 0x19, 0x2e, 0x75, 0x73, 0x65, - 0x72, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x64, 0x6f, 0x75, - 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x42, 0x2e, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, - 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, - 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x75, 0x73, 0x65, - 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x27, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x08, + 0x75, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x22, 0xe1, 0x02, 0x0a, 0x04, 0x55, 0x73, 0x65, + 0x72, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x5f, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x66, 0x6f, 0x6c, + 0x6c, 0x6f, 0x77, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x66, 0x6f, 0x6c, 0x6c, + 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x0d, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, + 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x66, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x18, 0x05, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x46, 0x6f, 0x6c, 0x6c, 0x6f, 0x77, 0x12, 0x16, 0x0a, 0x06, + 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x61, 0x76, + 0x61, 0x74, 0x61, 0x72, 0x12, 0x29, 0x0a, 0x10, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, + 0x6e, 0x64, 0x5f, 0x69, 0x6d, 0x61, 0x67, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, + 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x49, 0x6d, 0x61, 0x67, 0x65, 0x12, + 0x1c, 0x0a, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x61, 0x74, 0x75, 0x72, 0x65, 0x12, 0x27, 0x0a, + 0x0f, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x5f, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x64, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0e, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x46, 0x61, 0x76, + 0x6f, 0x72, 0x69, 0x74, 0x65, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x77, 0x6f, 0x72, 0x6b, 0x5f, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x77, 0x6f, 0x72, 0x6b, + 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x25, 0x0a, 0x0e, 0x66, 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, + 0x65, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x66, + 0x61, 0x76, 0x6f, 0x72, 0x69, 0x74, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x32, 0xc9, 0x02, 0x0a, + 0x0b, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x53, 0x0a, 0x08, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x12, 0x22, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, + 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x67, 0x69, + 0x73, 0x74, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x75, + 0x73, 0x65, 0x72, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x72, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x4a, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x1f, 0x2e, 0x75, 0x73, 0x65, + 0x72, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x6f, + 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x75, 0x73, + 0x65, 0x72, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, + 0x6f, 0x67, 0x69, 0x6e, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, + 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x42, 0x79, 0x49, 0x64, 0x12, 0x19, 0x2e, 0x75, + 0x73, 0x65, 0x72, 0x2e, 0x64, 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x64, + 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x12, 0x53, 0x0a, 0x10, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, + 0x73, 0x74, 0x42, 0x79, 0x49, 0x64, 0x73, 0x12, 0x1e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x64, + 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, + 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x64, + 0x6f, 0x75, 0x79, 0x69, 0x6e, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, + 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x44, 0x5a, 0x42, 0x67, 0x69, 0x74, 0x68, + 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, + 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, + 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -565,7 +719,7 @@ func file_user_proto_rawDescGZIP() []byte { return file_user_proto_rawDescData } -var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 9) var file_user_proto_goTypes = []interface{}{ (*DouyinUserRegisterRequest)(nil), // 0: user.douyin_user_register_request (*DouyinUserRegisterResponse)(nil), // 1: user.douyin_user_register_response @@ -575,19 +729,21 @@ var file_user_proto_goTypes = []interface{}{ (*DouyinUserResponse)(nil), // 5: user.douyin_user_response (*DouyinUserListRequest)(nil), // 6: user.douyin_user_list_request (*DouyinUserListResponse)(nil), // 7: user.douyin_user_list_response - (*entity.User)(nil), // 8: entity.User + (*User)(nil), // 8: user.User } var file_user_proto_depIdxs = []int32{ - 8, // 0: user.douyin_user_response.user:type_name -> entity.User - 8, // 1: user.douyin_user_list_response.user_list:type_name -> entity.User + 8, // 0: user.douyin_user_response.user:type_name -> user.User + 8, // 1: user.douyin_user_list_response.user_list:type_name -> user.User 0, // 2: user.UserService.Register:input_type -> user.douyin_user_register_request 2, // 3: user.UserService.Login:input_type -> user.douyin_user_login_request 4, // 4: user.UserService.GetUserById:input_type -> user.douyin_user_request - 1, // 5: user.UserService.Register:output_type -> user.douyin_user_register_response - 3, // 6: user.UserService.Login:output_type -> user.douyin_user_login_response - 5, // 7: user.UserService.GetUserById:output_type -> user.douyin_user_response - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type + 6, // 5: user.UserService.GetUserListByIds:input_type -> user.douyin_user_list_request + 1, // 6: user.UserService.Register:output_type -> user.douyin_user_register_response + 3, // 7: user.UserService.Login:output_type -> user.douyin_user_login_response + 5, // 8: user.UserService.GetUserById:output_type -> user.douyin_user_response + 7, // 9: user.UserService.GetUserListByIds:output_type -> user.douyin_user_list_response + 6, // [6:10] is the sub-list for method output_type + 2, // [2:6] is the sub-list for method input_type 2, // [2:2] is the sub-list for extension type_name 2, // [2:2] is the sub-list for extension extendee 0, // [0:2] is the sub-list for field type_name @@ -695,6 +851,18 @@ func file_user_proto_init() { return nil } } + file_user_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*User); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -702,7 +870,7 @@ func file_user_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_user_proto_rawDesc, NumEnums: 0, - NumMessages: 8, + NumMessages: 9, NumExtensions: 0, NumServices: 1, }, @@ -724,4 +892,5 @@ type UserService interface { Register(ctx context.Context, req *DouyinUserRegisterRequest) (res *DouyinUserRegisterResponse, err error) Login(ctx context.Context, req *DouyinUserLoginRequest) (res *DouyinUserLoginResponse, err error) GetUserById(ctx context.Context, req *DouyinUserRequest) (res *DouyinUserResponse, err error) + GetUserListByIds(ctx context.Context, req *DouyinUserListRequest) (res *DouyinUserListResponse, err error) } diff --git a/kitex_gen/user/userservice/client.go b/kitex_gen/user/userservice/client.go index 0d2b6ec6..f74d2d7e 100644 --- a/kitex_gen/user/userservice/client.go +++ b/kitex_gen/user/userservice/client.go @@ -14,6 +14,7 @@ type Client interface { Register(ctx context.Context, Req *user.DouyinUserRegisterRequest, callOptions ...callopt.Option) (r *user.DouyinUserRegisterResponse, err error) Login(ctx context.Context, Req *user.DouyinUserLoginRequest, callOptions ...callopt.Option) (r *user.DouyinUserLoginResponse, err error) GetUserById(ctx context.Context, Req *user.DouyinUserRequest, callOptions ...callopt.Option) (r *user.DouyinUserResponse, err error) + GetUserListByIds(ctx context.Context, Req *user.DouyinUserListRequest, callOptions ...callopt.Option) (r *user.DouyinUserListResponse, err error) } // NewClient creates a client for the service defined in IDL. @@ -59,3 +60,8 @@ func (p *kUserServiceClient) GetUserById(ctx context.Context, Req *user.DouyinUs ctx = client.NewCtxWithCallOptions(ctx, callOptions) return p.kClient.GetUserById(ctx, Req) } + +func (p *kUserServiceClient) GetUserListByIds(ctx context.Context, Req *user.DouyinUserListRequest, callOptions ...callopt.Option) (r *user.DouyinUserListResponse, err error) { + ctx = client.NewCtxWithCallOptions(ctx, callOptions) + return p.kClient.GetUserListByIds(ctx, Req) +} diff --git a/kitex_gen/user/userservice/userservice.go b/kitex_gen/user/userservice/userservice.go index 04e3c92f..1ebf6720 100644 --- a/kitex_gen/user/userservice/userservice.go +++ b/kitex_gen/user/userservice/userservice.go @@ -22,9 +22,10 @@ func NewServiceInfo() *kitex.ServiceInfo { serviceName := "UserService" handlerType := (*user.UserService)(nil) methods := map[string]kitex.MethodInfo{ - "Register": kitex.NewMethodInfo(registerHandler, newRegisterArgs, newRegisterResult, false), - "Login": kitex.NewMethodInfo(loginHandler, newLoginArgs, newLoginResult, false), - "GetUserById": kitex.NewMethodInfo(getUserByIdHandler, newGetUserByIdArgs, newGetUserByIdResult, false), + "Register": kitex.NewMethodInfo(registerHandler, newRegisterArgs, newRegisterResult, false), + "Login": kitex.NewMethodInfo(loginHandler, newLoginArgs, newLoginResult, false), + "GetUserById": kitex.NewMethodInfo(getUserByIdHandler, newGetUserByIdArgs, newGetUserByIdResult, false), + "GetUserListByIds": kitex.NewMethodInfo(getUserListByIdsHandler, newGetUserListByIdsArgs, newGetUserListByIdsResult, false), } extra := map[string]interface{}{ "PackageName": "user", @@ -475,6 +476,151 @@ func (p *GetUserByIdResult) IsSetSuccess() bool { return p.Success != nil } +func getUserListByIdsHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { + switch s := arg.(type) { + case *streaming.Args: + st := s.Stream + req := new(user.DouyinUserListRequest) + if err := st.RecvMsg(req); err != nil { + return err + } + resp, err := handler.(user.UserService).GetUserListByIds(ctx, req) + if err != nil { + return err + } + if err := st.SendMsg(resp); err != nil { + return err + } + case *GetUserListByIdsArgs: + success, err := handler.(user.UserService).GetUserListByIds(ctx, s.Req) + if err != nil { + return err + } + realResult := result.(*GetUserListByIdsResult) + realResult.Success = success + } + return nil +} +func newGetUserListByIdsArgs() interface{} { + return &GetUserListByIdsArgs{} +} + +func newGetUserListByIdsResult() interface{} { + return &GetUserListByIdsResult{} +} + +type GetUserListByIdsArgs struct { + Req *user.DouyinUserListRequest +} + +func (p *GetUserListByIdsArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetReq() { + p.Req = new(user.DouyinUserListRequest) + } + return p.Req.FastRead(buf, _type, number) +} + +func (p *GetUserListByIdsArgs) FastWrite(buf []byte) (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.FastWrite(buf) +} + +func (p *GetUserListByIdsArgs) Size() (n int) { + if !p.IsSetReq() { + return 0 + } + return p.Req.Size() +} + +func (p *GetUserListByIdsArgs) Marshal(out []byte) ([]byte, error) { + if !p.IsSetReq() { + return out, fmt.Errorf("No req in GetUserListByIdsArgs") + } + return proto.Marshal(p.Req) +} + +func (p *GetUserListByIdsArgs) Unmarshal(in []byte) error { + msg := new(user.DouyinUserListRequest) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Req = msg + return nil +} + +var GetUserListByIdsArgs_Req_DEFAULT *user.DouyinUserListRequest + +func (p *GetUserListByIdsArgs) GetReq() *user.DouyinUserListRequest { + if !p.IsSetReq() { + return GetUserListByIdsArgs_Req_DEFAULT + } + return p.Req +} + +func (p *GetUserListByIdsArgs) IsSetReq() bool { + return p.Req != nil +} + +type GetUserListByIdsResult struct { + Success *user.DouyinUserListResponse +} + +var GetUserListByIdsResult_Success_DEFAULT *user.DouyinUserListResponse + +func (p *GetUserListByIdsResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { + if !p.IsSetSuccess() { + p.Success = new(user.DouyinUserListResponse) + } + return p.Success.FastRead(buf, _type, number) +} + +func (p *GetUserListByIdsResult) FastWrite(buf []byte) (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.FastWrite(buf) +} + +func (p *GetUserListByIdsResult) Size() (n int) { + if !p.IsSetSuccess() { + return 0 + } + return p.Success.Size() +} + +func (p *GetUserListByIdsResult) Marshal(out []byte) ([]byte, error) { + if !p.IsSetSuccess() { + return out, fmt.Errorf("No req in GetUserListByIdsResult") + } + return proto.Marshal(p.Success) +} + +func (p *GetUserListByIdsResult) Unmarshal(in []byte) error { + msg := new(user.DouyinUserListResponse) + if err := proto.Unmarshal(in, msg); err != nil { + return err + } + p.Success = msg + return nil +} + +func (p *GetUserListByIdsResult) GetSuccess() *user.DouyinUserListResponse { + if !p.IsSetSuccess() { + return GetUserListByIdsResult_Success_DEFAULT + } + return p.Success +} + +func (p *GetUserListByIdsResult) SetSuccess(x interface{}) { + p.Success = x.(*user.DouyinUserListResponse) +} + +func (p *GetUserListByIdsResult) IsSetSuccess() bool { + return p.Success != nil +} + type kClient struct { c client.Client } @@ -514,3 +660,13 @@ func (p *kClient) GetUserById(ctx context.Context, Req *user.DouyinUserRequest) } return _result.GetSuccess(), nil } + +func (p *kClient) GetUserListByIds(ctx context.Context, Req *user.DouyinUserListRequest) (r *user.DouyinUserListResponse, err error) { + var _args GetUserListByIdsArgs + _args.Req = Req + var _result GetUserListByIdsResult + if err = p.c.Call(ctx, "GetUserListByIds", &_args, &_result); err != nil { + return + } + return _result.GetSuccess(), nil +} diff --git a/kitex_gen/userDomain/userDomain.pb.fast.go b/kitex_gen/userDomain/userDomain.pb.fast.go deleted file mode 100644 index 3f54defe..00000000 --- a/kitex_gen/userDomain/userDomain.pb.fast.go +++ /dev/null @@ -1,671 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package userDomain - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DoutokAddUserRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddUserRequest[number], err) -} - -func (x *DoutokAddUserRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.Username, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokAddUserRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.Password, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokAddUserResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddUserResponse[number], err) -} - -func (x *DoutokAddUserResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokAddUserResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokAddUserResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokCheckUserRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCheckUserRequest[number], err) -} - -func (x *DoutokCheckUserRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.Username, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokCheckUserRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.Password, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokCheckUserResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCheckUserResponse[number], err) -} - -func (x *DoutokCheckUserResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokCheckUserResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokCheckUserResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokGetUserInfoRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokGetUserInfoRequest[number], err) -} - -func (x *DoutokGetUserInfoRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.UserId = append(x.UserId, v) - return offset, err - }) - return offset, err -} - -func (x *DoutokGetUserInfoResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokGetUserInfoResponse[number], err) -} - -func (x *DoutokGetUserInfoResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokGetUserInfoResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokGetUserInfoResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.UserList == nil { - x.UserList = make(map[int64]*entity.User) - } - var key int64 - var value *entity.User - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - var v entity.User - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - value = &v - return offset, nil - }) - if err != nil { - return offset, err - } - x.UserList[key] = value - return offset, nil -} - -func (x *DoutokAddUserRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokAddUserRequest) fastWriteField1(buf []byte) (offset int) { - if x.Username == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 1, x.Username) - return offset -} - -func (x *DoutokAddUserRequest) fastWriteField2(buf []byte) (offset int) { - if x.Password == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.Password) - return offset -} - -func (x *DoutokAddUserResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokAddUserResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokAddUserResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokAddUserResponse) fastWriteField3(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 3, x.UserId) - return offset -} - -func (x *DoutokCheckUserRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokCheckUserRequest) fastWriteField1(buf []byte) (offset int) { - if x.Username == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 1, x.Username) - return offset -} - -func (x *DoutokCheckUserRequest) fastWriteField2(buf []byte) (offset int) { - if x.Password == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.Password) - return offset -} - -func (x *DoutokCheckUserResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokCheckUserResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokCheckUserResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokCheckUserResponse) fastWriteField3(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 3, x.UserId) - return offset -} - -func (x *DoutokGetUserInfoRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DoutokGetUserInfoRequest) fastWriteField1(buf []byte) (offset int) { - if len(x.UserId) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 1, len(x.UserId), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.UserId[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DoutokGetUserInfoResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokGetUserInfoResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokGetUserInfoResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokGetUserInfoResponse) fastWriteField3(buf []byte) (offset int) { - if x.UserList == nil { - return offset - } - for k, v := range x.UserList { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteMessage(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DoutokAddUserRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokAddUserRequest) sizeField1() (n int) { - if x.Username == "" { - return n - } - n += fastpb.SizeString(1, x.Username) - return n -} - -func (x *DoutokAddUserRequest) sizeField2() (n int) { - if x.Password == "" { - return n - } - n += fastpb.SizeString(2, x.Password) - return n -} - -func (x *DoutokAddUserResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokAddUserResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokAddUserResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokAddUserResponse) sizeField3() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(3, x.UserId) - return n -} - -func (x *DoutokCheckUserRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokCheckUserRequest) sizeField1() (n int) { - if x.Username == "" { - return n - } - n += fastpb.SizeString(1, x.Username) - return n -} - -func (x *DoutokCheckUserRequest) sizeField2() (n int) { - if x.Password == "" { - return n - } - n += fastpb.SizeString(2, x.Password) - return n -} - -func (x *DoutokCheckUserResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokCheckUserResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokCheckUserResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokCheckUserResponse) sizeField3() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(3, x.UserId) - return n -} - -func (x *DoutokGetUserInfoRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DoutokGetUserInfoRequest) sizeField1() (n int) { - if len(x.UserId) == 0 { - return n - } - n += fastpb.SizeListPacked(1, len(x.UserId), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.UserId[numIdxOrVal]) - return n - }) - return n -} - -func (x *DoutokGetUserInfoResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokGetUserInfoResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokGetUserInfoResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokGetUserInfoResponse) sizeField3() (n int) { - if x.UserList == nil { - return n - } - for k, v := range x.UserList { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeMessage(numIdxOrVal, v) - return n - }) - } - return n -} - -var fieldIDToName_DoutokAddUserRequest = map[int32]string{ - 1: "Username", - 2: "Password", -} - -var fieldIDToName_DoutokAddUserResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "UserId", -} - -var fieldIDToName_DoutokCheckUserRequest = map[int32]string{ - 1: "Username", - 2: "Password", -} - -var fieldIDToName_DoutokCheckUserResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "UserId", -} - -var fieldIDToName_DoutokGetUserInfoRequest = map[int32]string{ - 1: "UserId", -} - -var fieldIDToName_DoutokGetUserInfoResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "UserList", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/userDomain/userDomain.pb.go b/kitex_gen/userDomain/userDomain.pb.go deleted file mode 100644 index 9da921ba..00000000 --- a/kitex_gen/userDomain/userDomain.pb.go +++ /dev/null @@ -1,593 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 -// source: userDomain.proto - -package userDomain - -import ( - context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type DoutokAddUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` -} - -func (x *DoutokAddUserRequest) Reset() { - *x = DoutokAddUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_userDomain_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddUserRequest) ProtoMessage() {} - -func (x *DoutokAddUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_userDomain_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddUserRequest.ProtoReflect.Descriptor instead. -func (*DoutokAddUserRequest) Descriptor() ([]byte, []int) { - return file_userDomain_proto_rawDescGZIP(), []int{0} -} - -func (x *DoutokAddUserRequest) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *DoutokAddUserRequest) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -type DoutokAddUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` -} - -func (x *DoutokAddUserResponse) Reset() { - *x = DoutokAddUserResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_userDomain_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddUserResponse) ProtoMessage() {} - -func (x *DoutokAddUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_userDomain_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddUserResponse.ProtoReflect.Descriptor instead. -func (*DoutokAddUserResponse) Descriptor() ([]byte, []int) { - return file_userDomain_proto_rawDescGZIP(), []int{1} -} - -func (x *DoutokAddUserResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokAddUserResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokAddUserResponse) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type DoutokCheckUserRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` - Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` -} - -func (x *DoutokCheckUserRequest) Reset() { - *x = DoutokCheckUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_userDomain_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCheckUserRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCheckUserRequest) ProtoMessage() {} - -func (x *DoutokCheckUserRequest) ProtoReflect() protoreflect.Message { - mi := &file_userDomain_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCheckUserRequest.ProtoReflect.Descriptor instead. -func (*DoutokCheckUserRequest) Descriptor() ([]byte, []int) { - return file_userDomain_proto_rawDescGZIP(), []int{2} -} - -func (x *DoutokCheckUserRequest) GetUsername() string { - if x != nil { - return x.Username - } - return "" -} - -func (x *DoutokCheckUserRequest) GetPassword() string { - if x != nil { - return x.Password - } - return "" -} - -type DoutokCheckUserResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` -} - -func (x *DoutokCheckUserResponse) Reset() { - *x = DoutokCheckUserResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_userDomain_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCheckUserResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCheckUserResponse) ProtoMessage() {} - -func (x *DoutokCheckUserResponse) ProtoReflect() protoreflect.Message { - mi := &file_userDomain_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCheckUserResponse.ProtoReflect.Descriptor instead. -func (*DoutokCheckUserResponse) Descriptor() ([]byte, []int) { - return file_userDomain_proto_rawDescGZIP(), []int{3} -} - -func (x *DoutokCheckUserResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokCheckUserResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokCheckUserResponse) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type DoutokGetUserInfoRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId []int64 `protobuf:"varint,1,rep,packed,name=user_id,json=userId,proto3" json:"user_id,omitempty"` -} - -func (x *DoutokGetUserInfoRequest) Reset() { - *x = DoutokGetUserInfoRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_userDomain_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokGetUserInfoRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokGetUserInfoRequest) ProtoMessage() {} - -func (x *DoutokGetUserInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_userDomain_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokGetUserInfoRequest.ProtoReflect.Descriptor instead. -func (*DoutokGetUserInfoRequest) Descriptor() ([]byte, []int) { - return file_userDomain_proto_rawDescGZIP(), []int{4} -} - -func (x *DoutokGetUserInfoRequest) GetUserId() []int64 { - if x != nil { - return x.UserId - } - return nil -} - -type DoutokGetUserInfoResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - UserList map[int64]*entity.User `protobuf:"bytes,3,rep,name=user_list,json=userList,proto3" json:"user_list,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (x *DoutokGetUserInfoResponse) Reset() { - *x = DoutokGetUserInfoResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_userDomain_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokGetUserInfoResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokGetUserInfoResponse) ProtoMessage() {} - -func (x *DoutokGetUserInfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_userDomain_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokGetUserInfoResponse.ProtoReflect.Descriptor instead. -func (*DoutokGetUserInfoResponse) Descriptor() ([]byte, []int) { - return file_userDomain_proto_rawDescGZIP(), []int{5} -} - -func (x *DoutokGetUserInfoResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokGetUserInfoResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokGetUserInfoResponse) GetUserList() map[int64]*entity.User { - if x != nil { - return x.UserList - } - return nil -} - -var File_userDomain_proto protoreflect.FileDescriptor - -var file_userDomain_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x1a, 0x0c, - 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x51, 0x0a, 0x17, - 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, - 0x73, 0x0a, 0x18, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, - 0x65, 0x72, 0x49, 0x64, 0x22, 0x53, 0x0a, 0x19, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, - 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, - 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x70, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x22, 0x75, 0x0a, 0x1a, 0x64, 0x6f, 0x75, - 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, - 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, - 0x22, 0x37, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x67, 0x65, 0x74, 0x5f, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, - 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x80, 0x02, 0x0a, 0x1d, 0x64, 0x6f, - 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x67, 0x65, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x6e, - 0x66, 0x6f, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, - 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x54, 0x0a, 0x09, 0x75, - 0x73, 0x65, 0x72, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x37, - 0x2e, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, - 0x6f, 0x6b, 0x5f, 0x67, 0x65, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, - 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, - 0x73, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, - 0x74, 0x1a, 0x49, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x73, 0x74, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x22, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x55, 0x73, 0x65, - 0x72, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x32, 0xa9, 0x02, 0x0a, - 0x11, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, - 0x63, 0x65, 0x12, 0x54, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x55, 0x73, 0x65, 0x72, 0x12, 0x23, 0x2e, - 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, - 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x24, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x09, 0x43, 0x68, 0x65, 0x63, - 0x6b, 0x55, 0x73, 0x65, 0x72, 0x12, 0x25, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, - 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, - 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x75, - 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, - 0x5f, 0x63, 0x68, 0x65, 0x63, 0x6b, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x28, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x67, 0x65, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, - 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, - 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, - 0x6b, 0x5f, 0x67, 0x65, 0x74, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x34, 0x5a, 0x32, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, - 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, - 0x67, 0x65, 0x6e, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_userDomain_proto_rawDescOnce sync.Once - file_userDomain_proto_rawDescData = file_userDomain_proto_rawDesc -) - -func file_userDomain_proto_rawDescGZIP() []byte { - file_userDomain_proto_rawDescOnce.Do(func() { - file_userDomain_proto_rawDescData = protoimpl.X.CompressGZIP(file_userDomain_proto_rawDescData) - }) - return file_userDomain_proto_rawDescData -} - -var file_userDomain_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_userDomain_proto_goTypes = []interface{}{ - (*DoutokAddUserRequest)(nil), // 0: userDomain.doutok_add_user_request - (*DoutokAddUserResponse)(nil), // 1: userDomain.doutok_add_user_response - (*DoutokCheckUserRequest)(nil), // 2: userDomain.doutok_check_user_request - (*DoutokCheckUserResponse)(nil), // 3: userDomain.doutok_check_user_response - (*DoutokGetUserInfoRequest)(nil), // 4: userDomain.doutok_get_user_info_request - (*DoutokGetUserInfoResponse)(nil), // 5: userDomain.doutok_get_user_info_response - nil, // 6: userDomain.doutok_get_user_info_response.UserListEntry - (*entity.User)(nil), // 7: entity.User -} -var file_userDomain_proto_depIdxs = []int32{ - 6, // 0: userDomain.doutok_get_user_info_response.user_list:type_name -> userDomain.doutok_get_user_info_response.UserListEntry - 7, // 1: userDomain.doutok_get_user_info_response.UserListEntry.value:type_name -> entity.User - 0, // 2: userDomain.UserDomainService.AddUser:input_type -> userDomain.doutok_add_user_request - 2, // 3: userDomain.UserDomainService.CheckUser:input_type -> userDomain.doutok_check_user_request - 4, // 4: userDomain.UserDomainService.GetUserInfo:input_type -> userDomain.doutok_get_user_info_request - 1, // 5: userDomain.UserDomainService.AddUser:output_type -> userDomain.doutok_add_user_response - 3, // 6: userDomain.UserDomainService.CheckUser:output_type -> userDomain.doutok_check_user_response - 5, // 7: userDomain.UserDomainService.GetUserInfo:output_type -> userDomain.doutok_get_user_info_response - 5, // [5:8] is the sub-list for method output_type - 2, // [2:5] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_userDomain_proto_init() } -func file_userDomain_proto_init() { - if File_userDomain_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_userDomain_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_userDomain_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddUserResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_userDomain_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCheckUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_userDomain_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCheckUserResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_userDomain_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokGetUserInfoRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_userDomain_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokGetUserInfoResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_userDomain_proto_rawDesc, - NumEnums: 0, - NumMessages: 7, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_userDomain_proto_goTypes, - DependencyIndexes: file_userDomain_proto_depIdxs, - MessageInfos: file_userDomain_proto_msgTypes, - }.Build() - File_userDomain_proto = out.File - file_userDomain_proto_rawDesc = nil - file_userDomain_proto_goTypes = nil - file_userDomain_proto_depIdxs = nil -} - -var _ context.Context - -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -type UserDomainService interface { - AddUser(ctx context.Context, req *DoutokAddUserRequest) (res *DoutokAddUserResponse, err error) - CheckUser(ctx context.Context, req *DoutokCheckUserRequest) (res *DoutokCheckUserResponse, err error) - GetUserInfo(ctx context.Context, req *DoutokGetUserInfoRequest) (res *DoutokGetUserInfoResponse, err error) -} diff --git a/kitex_gen/userDomain/userdomainservice/client.go b/kitex_gen/userDomain/userdomainservice/client.go deleted file mode 100644 index fa554c3e..00000000 --- a/kitex_gen/userDomain/userdomainservice/client.go +++ /dev/null @@ -1,61 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package userdomainservice - -import ( - "context" - userDomain "github.com/TremblingV5/DouTok/kitex_gen/userDomain" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - AddUser(ctx context.Context, Req *userDomain.DoutokAddUserRequest, callOptions ...callopt.Option) (r *userDomain.DoutokAddUserResponse, err error) - CheckUser(ctx context.Context, Req *userDomain.DoutokCheckUserRequest, callOptions ...callopt.Option) (r *userDomain.DoutokCheckUserResponse, err error) - GetUserInfo(ctx context.Context, Req *userDomain.DoutokGetUserInfoRequest, callOptions ...callopt.Option) (r *userDomain.DoutokGetUserInfoResponse, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfo(), options...) - if err != nil { - return nil, err - } - return &kUserDomainServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kUserDomainServiceClient struct { - *kClient -} - -func (p *kUserDomainServiceClient) AddUser(ctx context.Context, Req *userDomain.DoutokAddUserRequest, callOptions ...callopt.Option) (r *userDomain.DoutokAddUserResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.AddUser(ctx, Req) -} - -func (p *kUserDomainServiceClient) CheckUser(ctx context.Context, Req *userDomain.DoutokCheckUserRequest, callOptions ...callopt.Option) (r *userDomain.DoutokCheckUserResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.CheckUser(ctx, Req) -} - -func (p *kUserDomainServiceClient) GetUserInfo(ctx context.Context, Req *userDomain.DoutokGetUserInfoRequest, callOptions ...callopt.Option) (r *userDomain.DoutokGetUserInfoResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.GetUserInfo(ctx, Req) -} diff --git a/kitex_gen/userDomain/userdomainservice/invoker.go b/kitex_gen/userDomain/userdomainservice/invoker.go deleted file mode 100644 index 5fcd7070..00000000 --- a/kitex_gen/userDomain/userdomainservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package userdomainservice - -import ( - userDomain "github.com/TremblingV5/DouTok/kitex_gen/userDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler userDomain.UserDomainService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/kitex_gen/userDomain/userdomainservice/server.go b/kitex_gen/userDomain/userdomainservice/server.go deleted file mode 100644 index e57d3128..00000000 --- a/kitex_gen/userDomain/userdomainservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. -package userdomainservice - -import ( - userDomain "github.com/TremblingV5/DouTok/kitex_gen/userDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler userDomain.UserDomainService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/kitex_gen/userDomain/userdomainservice/userdomainservice.go b/kitex_gen/userDomain/userdomainservice/userdomainservice.go deleted file mode 100644 index 628d610d..00000000 --- a/kitex_gen/userDomain/userdomainservice/userdomainservice.go +++ /dev/null @@ -1,516 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package userdomainservice - -import ( - "context" - "fmt" - userDomain "github.com/TremblingV5/DouTok/kitex_gen/userDomain" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" -) - -func serviceInfo() *kitex.ServiceInfo { - return userDomainServiceServiceInfo -} - -var userDomainServiceServiceInfo = NewServiceInfo() - -func NewServiceInfo() *kitex.ServiceInfo { - serviceName := "UserDomainService" - handlerType := (*userDomain.UserDomainService)(nil) - methods := map[string]kitex.MethodInfo{ - "AddUser": kitex.NewMethodInfo(addUserHandler, newAddUserArgs, newAddUserResult, false), - "CheckUser": kitex.NewMethodInfo(checkUserHandler, newCheckUserArgs, newCheckUserResult, false), - "GetUserInfo": kitex.NewMethodInfo(getUserInfoHandler, newGetUserInfoArgs, newGetUserInfoResult, false), - } - extra := map[string]interface{}{ - "PackageName": "userDomain", - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", - Extra: extra, - } - return svcInfo -} - -func addUserHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(userDomain.DoutokAddUserRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(userDomain.UserDomainService).AddUser(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *AddUserArgs: - success, err := handler.(userDomain.UserDomainService).AddUser(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*AddUserResult) - realResult.Success = success - } - return nil -} -func newAddUserArgs() interface{} { - return &AddUserArgs{} -} - -func newAddUserResult() interface{} { - return &AddUserResult{} -} - -type AddUserArgs struct { - Req *userDomain.DoutokAddUserRequest -} - -func (p *AddUserArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(userDomain.DoutokAddUserRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *AddUserArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *AddUserArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *AddUserArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in AddUserArgs") - } - return proto.Marshal(p.Req) -} - -func (p *AddUserArgs) Unmarshal(in []byte) error { - msg := new(userDomain.DoutokAddUserRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var AddUserArgs_Req_DEFAULT *userDomain.DoutokAddUserRequest - -func (p *AddUserArgs) GetReq() *userDomain.DoutokAddUserRequest { - if !p.IsSetReq() { - return AddUserArgs_Req_DEFAULT - } - return p.Req -} - -func (p *AddUserArgs) IsSetReq() bool { - return p.Req != nil -} - -type AddUserResult struct { - Success *userDomain.DoutokAddUserResponse -} - -var AddUserResult_Success_DEFAULT *userDomain.DoutokAddUserResponse - -func (p *AddUserResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(userDomain.DoutokAddUserResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *AddUserResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *AddUserResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *AddUserResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in AddUserResult") - } - return proto.Marshal(p.Success) -} - -func (p *AddUserResult) Unmarshal(in []byte) error { - msg := new(userDomain.DoutokAddUserResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *AddUserResult) GetSuccess() *userDomain.DoutokAddUserResponse { - if !p.IsSetSuccess() { - return AddUserResult_Success_DEFAULT - } - return p.Success -} - -func (p *AddUserResult) SetSuccess(x interface{}) { - p.Success = x.(*userDomain.DoutokAddUserResponse) -} - -func (p *AddUserResult) IsSetSuccess() bool { - return p.Success != nil -} - -func checkUserHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(userDomain.DoutokCheckUserRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(userDomain.UserDomainService).CheckUser(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *CheckUserArgs: - success, err := handler.(userDomain.UserDomainService).CheckUser(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*CheckUserResult) - realResult.Success = success - } - return nil -} -func newCheckUserArgs() interface{} { - return &CheckUserArgs{} -} - -func newCheckUserResult() interface{} { - return &CheckUserResult{} -} - -type CheckUserArgs struct { - Req *userDomain.DoutokCheckUserRequest -} - -func (p *CheckUserArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(userDomain.DoutokCheckUserRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *CheckUserArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *CheckUserArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *CheckUserArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in CheckUserArgs") - } - return proto.Marshal(p.Req) -} - -func (p *CheckUserArgs) Unmarshal(in []byte) error { - msg := new(userDomain.DoutokCheckUserRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var CheckUserArgs_Req_DEFAULT *userDomain.DoutokCheckUserRequest - -func (p *CheckUserArgs) GetReq() *userDomain.DoutokCheckUserRequest { - if !p.IsSetReq() { - return CheckUserArgs_Req_DEFAULT - } - return p.Req -} - -func (p *CheckUserArgs) IsSetReq() bool { - return p.Req != nil -} - -type CheckUserResult struct { - Success *userDomain.DoutokCheckUserResponse -} - -var CheckUserResult_Success_DEFAULT *userDomain.DoutokCheckUserResponse - -func (p *CheckUserResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(userDomain.DoutokCheckUserResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *CheckUserResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *CheckUserResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *CheckUserResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in CheckUserResult") - } - return proto.Marshal(p.Success) -} - -func (p *CheckUserResult) Unmarshal(in []byte) error { - msg := new(userDomain.DoutokCheckUserResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *CheckUserResult) GetSuccess() *userDomain.DoutokCheckUserResponse { - if !p.IsSetSuccess() { - return CheckUserResult_Success_DEFAULT - } - return p.Success -} - -func (p *CheckUserResult) SetSuccess(x interface{}) { - p.Success = x.(*userDomain.DoutokCheckUserResponse) -} - -func (p *CheckUserResult) IsSetSuccess() bool { - return p.Success != nil -} - -func getUserInfoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(userDomain.DoutokGetUserInfoRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(userDomain.UserDomainService).GetUserInfo(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *GetUserInfoArgs: - success, err := handler.(userDomain.UserDomainService).GetUserInfo(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*GetUserInfoResult) - realResult.Success = success - } - return nil -} -func newGetUserInfoArgs() interface{} { - return &GetUserInfoArgs{} -} - -func newGetUserInfoResult() interface{} { - return &GetUserInfoResult{} -} - -type GetUserInfoArgs struct { - Req *userDomain.DoutokGetUserInfoRequest -} - -func (p *GetUserInfoArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(userDomain.DoutokGetUserInfoRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *GetUserInfoArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *GetUserInfoArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *GetUserInfoArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in GetUserInfoArgs") - } - return proto.Marshal(p.Req) -} - -func (p *GetUserInfoArgs) Unmarshal(in []byte) error { - msg := new(userDomain.DoutokGetUserInfoRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var GetUserInfoArgs_Req_DEFAULT *userDomain.DoutokGetUserInfoRequest - -func (p *GetUserInfoArgs) GetReq() *userDomain.DoutokGetUserInfoRequest { - if !p.IsSetReq() { - return GetUserInfoArgs_Req_DEFAULT - } - return p.Req -} - -func (p *GetUserInfoArgs) IsSetReq() bool { - return p.Req != nil -} - -type GetUserInfoResult struct { - Success *userDomain.DoutokGetUserInfoResponse -} - -var GetUserInfoResult_Success_DEFAULT *userDomain.DoutokGetUserInfoResponse - -func (p *GetUserInfoResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(userDomain.DoutokGetUserInfoResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *GetUserInfoResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *GetUserInfoResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *GetUserInfoResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in GetUserInfoResult") - } - return proto.Marshal(p.Success) -} - -func (p *GetUserInfoResult) Unmarshal(in []byte) error { - msg := new(userDomain.DoutokGetUserInfoResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *GetUserInfoResult) GetSuccess() *userDomain.DoutokGetUserInfoResponse { - if !p.IsSetSuccess() { - return GetUserInfoResult_Success_DEFAULT - } - return p.Success -} - -func (p *GetUserInfoResult) SetSuccess(x interface{}) { - p.Success = x.(*userDomain.DoutokGetUserInfoResponse) -} - -func (p *GetUserInfoResult) IsSetSuccess() bool { - return p.Success != nil -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) AddUser(ctx context.Context, Req *userDomain.DoutokAddUserRequest) (r *userDomain.DoutokAddUserResponse, err error) { - var _args AddUserArgs - _args.Req = Req - var _result AddUserResult - if err = p.c.Call(ctx, "AddUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) CheckUser(ctx context.Context, Req *userDomain.DoutokCheckUserRequest) (r *userDomain.DoutokCheckUserResponse, err error) { - var _args CheckUserArgs - _args.Req = Req - var _result CheckUserResult - if err = p.c.Call(ctx, "CheckUser", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) GetUserInfo(ctx context.Context, Req *userDomain.DoutokGetUserInfoRequest) (r *userDomain.DoutokGetUserInfoResponse, err error) { - var _args GetUserInfoArgs - _args.Req = Req - var _result GetUserInfoResult - if err = p.c.Call(ctx, "GetUserInfo", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/kitex_gen/videoDomain/videoDomain.pb.fast.go b/kitex_gen/videoDomain/videoDomain.pb.fast.go deleted file mode 100644 index 367016d1..00000000 --- a/kitex_gen/videoDomain/videoDomain.pb.fast.go +++ /dev/null @@ -1,983 +0,0 @@ -// Code generated by Fastpb v0.0.2. DO NOT EDIT. - -package videoDomain - -import ( - fmt "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - fastpb "github.com/cloudwego/fastpb" -) - -var ( - _ = fmt.Errorf - _ = fastpb.Skip -) - -func (x *DoutokGetFeedRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokGetFeedRequest[number], err) -} - -func (x *DoutokGetFeedRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.LatestTime, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokGetFeedRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokGetFeedResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - case 4: - offset, err = x.fastReadField4(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokGetFeedResponse[number], err) -} - -func (x *DoutokGetFeedResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokGetFeedResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokGetFeedResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Video - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.VideoList = append(x.VideoList, &v) - return offset, nil -} - -func (x *DoutokGetFeedResponse) fastReadField4(buf []byte, _type int8) (offset int, err error) { - x.NextTime, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddPublishRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - case 4: - offset, err = x.fastReadField4(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddPublishRequest[number], err) -} - -func (x *DoutokAddPublishRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.Data, offset, err = fastpb.ReadBytes(buf, _type) - return offset, err -} - -func (x *DoutokAddPublishRequest) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.Title, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokAddPublishRequest) fastReadField3(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokAddPublishRequest) fastReadField4(buf []byte, _type int8) (offset int, err error) { - x.Name, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokAddPublishResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokAddPublishResponse[number], err) -} - -func (x *DoutokAddPublishResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokAddPublishResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokListPublishRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListPublishRequest[number], err) -} - -func (x *DoutokListPublishRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.UserId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokListPublishResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokListPublishResponse[number], err) -} - -func (x *DoutokListPublishResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokListPublishResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokListPublishResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - var v entity.Video - offset, err = fastpb.ReadMessage(buf, _type, &v) - if err != nil { - return offset, err - } - x.VideoList = append(x.VideoList, &v) - return offset, nil -} - -func (x *DoutokCountPublishRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCountPublishRequest[number], err) -} - -func (x *DoutokCountPublishRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - offset, err = fastpb.ReadList(buf, _type, - func(buf []byte, _type int8) (n int, err error) { - var v int64 - v, offset, err = fastpb.ReadInt64(buf, _type) - if err != nil { - return offset, err - } - x.UserId = append(x.UserId, v) - return offset, err - }) - return offset, err -} - -func (x *DoutokCountPublishResponse) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - case 2: - offset, err = x.fastReadField2(buf, _type) - if err != nil { - goto ReadFieldError - } - case 3: - offset, err = x.fastReadField3(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokCountPublishResponse[number], err) -} - -func (x *DoutokCountPublishResponse) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.StatusCode, offset, err = fastpb.ReadInt32(buf, _type) - return offset, err -} - -func (x *DoutokCountPublishResponse) fastReadField2(buf []byte, _type int8) (offset int, err error) { - x.StatusMsg, offset, err = fastpb.ReadString(buf, _type) - return offset, err -} - -func (x *DoutokCountPublishResponse) fastReadField3(buf []byte, _type int8) (offset int, err error) { - if x.Result == nil { - x.Result = make(map[int64]int64) - } - var key int64 - var value int64 - offset, err = fastpb.ReadMapEntry(buf, _type, - func(buf []byte, _type int8) (offset int, err error) { - key, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }, - func(buf []byte, _type int8) (offset int, err error) { - value, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err - }) - if err != nil { - return offset, err - } - x.Result[key] = value - return offset, nil -} - -func (x *DoutokGetVideoInfoRequest) FastRead(buf []byte, _type int8, number int32) (offset int, err error) { - switch number { - case 1: - offset, err = x.fastReadField1(buf, _type) - if err != nil { - goto ReadFieldError - } - default: - offset, err = fastpb.Skip(buf, _type, number) - if err != nil { - goto SkipFieldError - } - } - return offset, nil -SkipFieldError: - return offset, fmt.Errorf("%T cannot parse invalid wire-format data, error: %s", x, err) -ReadFieldError: - return offset, fmt.Errorf("%T read field %d '%s' error: %s", x, number, fieldIDToName_DoutokGetVideoInfoRequest[number], err) -} - -func (x *DoutokGetVideoInfoRequest) fastReadField1(buf []byte, _type int8) (offset int, err error) { - x.VideoId, offset, err = fastpb.ReadInt64(buf, _type) - return offset, err -} - -func (x *DoutokGetFeedRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokGetFeedRequest) fastWriteField1(buf []byte) (offset int) { - if x.LatestTime == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.LatestTime) - return offset -} - -func (x *DoutokGetFeedRequest) fastWriteField2(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 2, x.UserId) - return offset -} - -func (x *DoutokGetFeedResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - offset += x.fastWriteField4(buf[offset:]) - return offset -} - -func (x *DoutokGetFeedResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokGetFeedResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokGetFeedResponse) fastWriteField3(buf []byte) (offset int) { - if x.VideoList == nil { - return offset - } - for i := range x.VideoList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.VideoList[i]) - } - return offset -} - -func (x *DoutokGetFeedResponse) fastWriteField4(buf []byte) (offset int) { - if x.NextTime == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 4, x.NextTime) - return offset -} - -func (x *DoutokAddPublishRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - offset += x.fastWriteField4(buf[offset:]) - return offset -} - -func (x *DoutokAddPublishRequest) fastWriteField1(buf []byte) (offset int) { - if len(x.Data) == 0 { - return offset - } - offset += fastpb.WriteBytes(buf[offset:], 1, x.Data) - return offset -} - -func (x *DoutokAddPublishRequest) fastWriteField2(buf []byte) (offset int) { - if x.Title == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.Title) - return offset -} - -func (x *DoutokAddPublishRequest) fastWriteField3(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 3, x.UserId) - return offset -} - -func (x *DoutokAddPublishRequest) fastWriteField4(buf []byte) (offset int) { - if x.Name == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 4, x.Name) - return offset -} - -func (x *DoutokAddPublishResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - return offset -} - -func (x *DoutokAddPublishResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokAddPublishResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokListPublishRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DoutokListPublishRequest) fastWriteField1(buf []byte) (offset int) { - if x.UserId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.UserId) - return offset -} - -func (x *DoutokListPublishResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokListPublishResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokListPublishResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokListPublishResponse) fastWriteField3(buf []byte) (offset int) { - if x.VideoList == nil { - return offset - } - for i := range x.VideoList { - offset += fastpb.WriteMessage(buf[offset:], 3, x.VideoList[i]) - } - return offset -} - -func (x *DoutokCountPublishRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DoutokCountPublishRequest) fastWriteField1(buf []byte) (offset int) { - if len(x.UserId) == 0 { - return offset - } - offset += fastpb.WriteListPacked(buf[offset:], 1, len(x.UserId), - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, x.UserId[numIdxOrVal]) - return offset - }) - return offset -} - -func (x *DoutokCountPublishResponse) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - offset += x.fastWriteField2(buf[offset:]) - offset += x.fastWriteField3(buf[offset:]) - return offset -} - -func (x *DoutokCountPublishResponse) fastWriteField1(buf []byte) (offset int) { - if x.StatusCode == 0 { - return offset - } - offset += fastpb.WriteInt32(buf[offset:], 1, x.StatusCode) - return offset -} - -func (x *DoutokCountPublishResponse) fastWriteField2(buf []byte) (offset int) { - if x.StatusMsg == "" { - return offset - } - offset += fastpb.WriteString(buf[offset:], 2, x.StatusMsg) - return offset -} - -func (x *DoutokCountPublishResponse) fastWriteField3(buf []byte) (offset int) { - if x.Result == nil { - return offset - } - for k, v := range x.Result { - offset += fastpb.WriteMapEntry(buf[offset:], 3, - func(buf []byte, numTagOrKey, numIdxOrVal int32) int { - offset := 0 - offset += fastpb.WriteInt64(buf[offset:], numTagOrKey, k) - offset += fastpb.WriteInt64(buf[offset:], numIdxOrVal, v) - return offset - }) - } - return offset -} - -func (x *DoutokGetVideoInfoRequest) FastWrite(buf []byte) (offset int) { - if x == nil { - return offset - } - offset += x.fastWriteField1(buf[offset:]) - return offset -} - -func (x *DoutokGetVideoInfoRequest) fastWriteField1(buf []byte) (offset int) { - if x.VideoId == 0 { - return offset - } - offset += fastpb.WriteInt64(buf[offset:], 1, x.VideoId) - return offset -} - -func (x *DoutokGetFeedRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokGetFeedRequest) sizeField1() (n int) { - if x.LatestTime == 0 { - return n - } - n += fastpb.SizeInt64(1, x.LatestTime) - return n -} - -func (x *DoutokGetFeedRequest) sizeField2() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(2, x.UserId) - return n -} - -func (x *DoutokGetFeedResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - n += x.sizeField4() - return n -} - -func (x *DoutokGetFeedResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokGetFeedResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokGetFeedResponse) sizeField3() (n int) { - if x.VideoList == nil { - return n - } - for i := range x.VideoList { - n += fastpb.SizeMessage(3, x.VideoList[i]) - } - return n -} - -func (x *DoutokGetFeedResponse) sizeField4() (n int) { - if x.NextTime == 0 { - return n - } - n += fastpb.SizeInt64(4, x.NextTime) - return n -} - -func (x *DoutokAddPublishRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - n += x.sizeField4() - return n -} - -func (x *DoutokAddPublishRequest) sizeField1() (n int) { - if len(x.Data) == 0 { - return n - } - n += fastpb.SizeBytes(1, x.Data) - return n -} - -func (x *DoutokAddPublishRequest) sizeField2() (n int) { - if x.Title == "" { - return n - } - n += fastpb.SizeString(2, x.Title) - return n -} - -func (x *DoutokAddPublishRequest) sizeField3() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(3, x.UserId) - return n -} - -func (x *DoutokAddPublishRequest) sizeField4() (n int) { - if x.Name == "" { - return n - } - n += fastpb.SizeString(4, x.Name) - return n -} - -func (x *DoutokAddPublishResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - return n -} - -func (x *DoutokAddPublishResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokAddPublishResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokListPublishRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DoutokListPublishRequest) sizeField1() (n int) { - if x.UserId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.UserId) - return n -} - -func (x *DoutokListPublishResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokListPublishResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokListPublishResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokListPublishResponse) sizeField3() (n int) { - if x.VideoList == nil { - return n - } - for i := range x.VideoList { - n += fastpb.SizeMessage(3, x.VideoList[i]) - } - return n -} - -func (x *DoutokCountPublishRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DoutokCountPublishRequest) sizeField1() (n int) { - if len(x.UserId) == 0 { - return n - } - n += fastpb.SizeListPacked(1, len(x.UserId), - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, x.UserId[numIdxOrVal]) - return n - }) - return n -} - -func (x *DoutokCountPublishResponse) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - n += x.sizeField2() - n += x.sizeField3() - return n -} - -func (x *DoutokCountPublishResponse) sizeField1() (n int) { - if x.StatusCode == 0 { - return n - } - n += fastpb.SizeInt32(1, x.StatusCode) - return n -} - -func (x *DoutokCountPublishResponse) sizeField2() (n int) { - if x.StatusMsg == "" { - return n - } - n += fastpb.SizeString(2, x.StatusMsg) - return n -} - -func (x *DoutokCountPublishResponse) sizeField3() (n int) { - if x.Result == nil { - return n - } - for k, v := range x.Result { - n += fastpb.SizeMapEntry(3, - func(numTagOrKey, numIdxOrVal int32) int { - n := 0 - n += fastpb.SizeInt64(numTagOrKey, k) - n += fastpb.SizeInt64(numIdxOrVal, v) - return n - }) - } - return n -} - -func (x *DoutokGetVideoInfoRequest) Size() (n int) { - if x == nil { - return n - } - n += x.sizeField1() - return n -} - -func (x *DoutokGetVideoInfoRequest) sizeField1() (n int) { - if x.VideoId == 0 { - return n - } - n += fastpb.SizeInt64(1, x.VideoId) - return n -} - -var fieldIDToName_DoutokGetFeedRequest = map[int32]string{ - 1: "LatestTime", - 2: "UserId", -} - -var fieldIDToName_DoutokGetFeedResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "VideoList", - 4: "NextTime", -} - -var fieldIDToName_DoutokAddPublishRequest = map[int32]string{ - 1: "Data", - 2: "Title", - 3: "UserId", - 4: "Name", -} - -var fieldIDToName_DoutokAddPublishResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", -} - -var fieldIDToName_DoutokListPublishRequest = map[int32]string{ - 1: "UserId", -} - -var fieldIDToName_DoutokListPublishResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "VideoList", -} - -var fieldIDToName_DoutokCountPublishRequest = map[int32]string{ - 1: "UserId", -} - -var fieldIDToName_DoutokCountPublishResponse = map[int32]string{ - 1: "StatusCode", - 2: "StatusMsg", - 3: "Result", -} - -var fieldIDToName_DoutokGetVideoInfoRequest = map[int32]string{ - 1: "VideoId", -} - -var _ = entity.File_entity_proto diff --git a/kitex_gen/videoDomain/videoDomain.pb.go b/kitex_gen/videoDomain/videoDomain.pb.go deleted file mode 100644 index 97b53ce3..00000000 --- a/kitex_gen/videoDomain/videoDomain.pb.go +++ /dev/null @@ -1,842 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.12.4 -// source: videoDomain.proto - -package videoDomain - -import ( - context "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type DoutokGetFeedRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - LatestTime int64 `protobuf:"varint,1,opt,name=latest_time,json=latestTime,proto3" json:"latest_time,omitempty"` // 可选参数,限制返回视频的最新投稿时间戳,精确到秒,不填表示当前时间 - UserId int64 `protobuf:"varint,2,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // 请求feed流的用户id,若没有则置为0 -} - -func (x *DoutokGetFeedRequest) Reset() { - *x = DoutokGetFeedRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_videoDomain_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokGetFeedRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokGetFeedRequest) ProtoMessage() {} - -func (x *DoutokGetFeedRequest) ProtoReflect() protoreflect.Message { - mi := &file_videoDomain_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokGetFeedRequest.ProtoReflect.Descriptor instead. -func (*DoutokGetFeedRequest) Descriptor() ([]byte, []int) { - return file_videoDomain_proto_rawDescGZIP(), []int{0} -} - -func (x *DoutokGetFeedRequest) GetLatestTime() int64 { - if x != nil { - return x.LatestTime - } - return 0 -} - -func (x *DoutokGetFeedRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type DoutokGetFeedResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - VideoList []*entity.Video `protobuf:"bytes,3,rep,name=video_list,json=videoList,proto3" json:"video_list,omitempty"` - NextTime int64 `protobuf:"varint,4,opt,name=next_time,json=nextTime,proto3" json:"next_time,omitempty"` -} - -func (x *DoutokGetFeedResponse) Reset() { - *x = DoutokGetFeedResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_videoDomain_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokGetFeedResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokGetFeedResponse) ProtoMessage() {} - -func (x *DoutokGetFeedResponse) ProtoReflect() protoreflect.Message { - mi := &file_videoDomain_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokGetFeedResponse.ProtoReflect.Descriptor instead. -func (*DoutokGetFeedResponse) Descriptor() ([]byte, []int) { - return file_videoDomain_proto_rawDescGZIP(), []int{1} -} - -func (x *DoutokGetFeedResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokGetFeedResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokGetFeedResponse) GetVideoList() []*entity.Video { - if x != nil { - return x.VideoList - } - return nil -} - -func (x *DoutokGetFeedResponse) GetNextTime() int64 { - if x != nil { - return x.NextTime - } - return 0 -} - -type DoutokAddPublishRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` - Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"` - UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` - Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *DoutokAddPublishRequest) Reset() { - *x = DoutokAddPublishRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_videoDomain_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddPublishRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddPublishRequest) ProtoMessage() {} - -func (x *DoutokAddPublishRequest) ProtoReflect() protoreflect.Message { - mi := &file_videoDomain_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddPublishRequest.ProtoReflect.Descriptor instead. -func (*DoutokAddPublishRequest) Descriptor() ([]byte, []int) { - return file_videoDomain_proto_rawDescGZIP(), []int{2} -} - -func (x *DoutokAddPublishRequest) GetData() []byte { - if x != nil { - return x.Data - } - return nil -} - -func (x *DoutokAddPublishRequest) GetTitle() string { - if x != nil { - return x.Title - } - return "" -} - -func (x *DoutokAddPublishRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -func (x *DoutokAddPublishRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -type DoutokAddPublishResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` -} - -func (x *DoutokAddPublishResponse) Reset() { - *x = DoutokAddPublishResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_videoDomain_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokAddPublishResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokAddPublishResponse) ProtoMessage() {} - -func (x *DoutokAddPublishResponse) ProtoReflect() protoreflect.Message { - mi := &file_videoDomain_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokAddPublishResponse.ProtoReflect.Descriptor instead. -func (*DoutokAddPublishResponse) Descriptor() ([]byte, []int) { - return file_videoDomain_proto_rawDescGZIP(), []int{3} -} - -func (x *DoutokAddPublishResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokAddPublishResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -type DoutokListPublishRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` -} - -func (x *DoutokListPublishRequest) Reset() { - *x = DoutokListPublishRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_videoDomain_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListPublishRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListPublishRequest) ProtoMessage() {} - -func (x *DoutokListPublishRequest) ProtoReflect() protoreflect.Message { - mi := &file_videoDomain_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListPublishRequest.ProtoReflect.Descriptor instead. -func (*DoutokListPublishRequest) Descriptor() ([]byte, []int) { - return file_videoDomain_proto_rawDescGZIP(), []int{4} -} - -func (x *DoutokListPublishRequest) GetUserId() int64 { - if x != nil { - return x.UserId - } - return 0 -} - -type DoutokListPublishResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - VideoList []*entity.Video `protobuf:"bytes,3,rep,name=video_list,json=videoList,proto3" json:"video_list,omitempty"` -} - -func (x *DoutokListPublishResponse) Reset() { - *x = DoutokListPublishResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_videoDomain_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokListPublishResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokListPublishResponse) ProtoMessage() {} - -func (x *DoutokListPublishResponse) ProtoReflect() protoreflect.Message { - mi := &file_videoDomain_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokListPublishResponse.ProtoReflect.Descriptor instead. -func (*DoutokListPublishResponse) Descriptor() ([]byte, []int) { - return file_videoDomain_proto_rawDescGZIP(), []int{5} -} - -func (x *DoutokListPublishResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokListPublishResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokListPublishResponse) GetVideoList() []*entity.Video { - if x != nil { - return x.VideoList - } - return nil -} - -type DoutokCountPublishRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId []int64 `protobuf:"varint,1,rep,packed,name=user_id,json=userId,proto3" json:"user_id,omitempty"` -} - -func (x *DoutokCountPublishRequest) Reset() { - *x = DoutokCountPublishRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_videoDomain_proto_msgTypes[6] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCountPublishRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCountPublishRequest) ProtoMessage() {} - -func (x *DoutokCountPublishRequest) ProtoReflect() protoreflect.Message { - mi := &file_videoDomain_proto_msgTypes[6] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCountPublishRequest.ProtoReflect.Descriptor instead. -func (*DoutokCountPublishRequest) Descriptor() ([]byte, []int) { - return file_videoDomain_proto_rawDescGZIP(), []int{6} -} - -func (x *DoutokCountPublishRequest) GetUserId() []int64 { - if x != nil { - return x.UserId - } - return nil -} - -type DoutokCountPublishResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - StatusCode int32 `protobuf:"varint,1,opt,name=status_code,json=statusCode,proto3" json:"status_code,omitempty"` - StatusMsg string `protobuf:"bytes,2,opt,name=status_msg,json=statusMsg,proto3" json:"status_msg,omitempty"` - Result map[int64]int64 `protobuf:"bytes,3,rep,name=result,proto3" json:"result,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` -} - -func (x *DoutokCountPublishResponse) Reset() { - *x = DoutokCountPublishResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_videoDomain_proto_msgTypes[7] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokCountPublishResponse) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokCountPublishResponse) ProtoMessage() {} - -func (x *DoutokCountPublishResponse) ProtoReflect() protoreflect.Message { - mi := &file_videoDomain_proto_msgTypes[7] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokCountPublishResponse.ProtoReflect.Descriptor instead. -func (*DoutokCountPublishResponse) Descriptor() ([]byte, []int) { - return file_videoDomain_proto_rawDescGZIP(), []int{7} -} - -func (x *DoutokCountPublishResponse) GetStatusCode() int32 { - if x != nil { - return x.StatusCode - } - return 0 -} - -func (x *DoutokCountPublishResponse) GetStatusMsg() string { - if x != nil { - return x.StatusMsg - } - return "" -} - -func (x *DoutokCountPublishResponse) GetResult() map[int64]int64 { - if x != nil { - return x.Result - } - return nil -} - -type DoutokGetVideoInfoRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - VideoId int64 `protobuf:"varint,1,opt,name=video_id,json=videoId,proto3" json:"video_id,omitempty"` -} - -func (x *DoutokGetVideoInfoRequest) Reset() { - *x = DoutokGetVideoInfoRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_videoDomain_proto_msgTypes[8] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DoutokGetVideoInfoRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DoutokGetVideoInfoRequest) ProtoMessage() {} - -func (x *DoutokGetVideoInfoRequest) ProtoReflect() protoreflect.Message { - mi := &file_videoDomain_proto_msgTypes[8] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DoutokGetVideoInfoRequest.ProtoReflect.Descriptor instead. -func (*DoutokGetVideoInfoRequest) Descriptor() ([]byte, []int) { - return file_videoDomain_proto_rawDescGZIP(), []int{8} -} - -func (x *DoutokGetVideoInfoRequest) GetVideoId() int64 { - if x != nil { - return x.VideoId - } - return 0 -} - -var File_videoDomain_proto protoreflect.FileDescriptor - -var file_videoDomain_proto_rawDesc = []byte{ - 0x0a, 0x11, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x12, 0x0b, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, - 0x1a, 0x0c, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x53, - 0x0a, 0x17, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x67, 0x65, 0x74, 0x5f, 0x66, 0x65, 0x65, - 0x64, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x6c, 0x61, 0x74, - 0x65, 0x73, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, - 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, - 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x22, 0xa5, 0x01, 0x0a, 0x18, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x67, - 0x65, 0x74, 0x5f, 0x66, 0x65, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, - 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, - 0x12, 0x2c, 0x0a, 0x0a, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, - 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x69, - 0x64, 0x65, 0x6f, 0x52, 0x09, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1b, - 0x0a, 0x09, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x73, 0x0a, 0x1a, 0x64, - 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, - 0x68, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, - 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, - 0x74, 0x6c, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x5d, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, - 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x22, - 0x36, 0x0a, 0x1b, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, - 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x8c, 0x01, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x74, - 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, - 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, - 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, - 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, 0x67, 0x12, 0x2c, 0x0a, 0x0a, 0x76, 0x69, 0x64, 0x65, - 0x6f, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x65, - 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x52, 0x09, 0x76, 0x69, 0x64, - 0x65, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x22, 0x37, 0x0a, 0x1c, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, - 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x72, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, - 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x03, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, - 0xea, 0x01, 0x0a, 0x1d, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, - 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x63, 0x6f, 0x64, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x43, 0x6f, - 0x64, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x5f, 0x6d, 0x73, 0x67, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x4d, 0x73, - 0x67, 0x12, 0x4e, 0x0a, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x18, 0x03, 0x20, 0x03, 0x28, - 0x0b, 0x32, 0x36, 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x70, 0x75, 0x62, - 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x52, 0x65, - 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x72, 0x65, 0x73, 0x75, 0x6c, - 0x74, 0x1a, 0x39, 0x0a, 0x0b, 0x52, 0x65, 0x73, 0x75, 0x6c, 0x74, 0x45, 0x6e, 0x74, 0x72, 0x79, - 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x03, 0x6b, - 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x3a, 0x0a, 0x1d, - 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x67, 0x65, 0x74, 0x5f, 0x76, 0x69, 0x64, 0x65, 0x6f, - 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, - 0x08, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, - 0x07, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x49, 0x64, 0x32, 0xe3, 0x03, 0x0a, 0x12, 0x56, 0x69, 0x64, - 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x56, 0x0a, 0x07, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x64, 0x12, 0x24, 0x2e, 0x76, 0x69, 0x64, - 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, - 0x67, 0x65, 0x74, 0x5f, 0x66, 0x65, 0x65, 0x64, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x1a, 0x25, 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, - 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x67, 0x65, 0x74, 0x5f, 0x66, 0x65, 0x65, 0x64, 0x5f, 0x72, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5f, 0x0a, 0x0a, 0x41, 0x64, 0x64, 0x50, 0x75, - 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12, 0x27, 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x6d, - 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x70, - 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x28, - 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, - 0x74, 0x6f, 0x6b, 0x5f, 0x61, 0x64, 0x64, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, - 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x62, 0x0a, 0x0b, 0x4c, 0x69, 0x73, 0x74, - 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12, 0x28, 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, - 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x1a, 0x29, 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, - 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, - 0x69, 0x73, 0x68, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x65, 0x0a, 0x0c, - 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x12, 0x29, 0x2e, 0x76, - 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, - 0x6b, 0x5f, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, - 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2a, 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x63, 0x6f, 0x75, - 0x6e, 0x74, 0x5f, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x49, - 0x6e, 0x66, 0x6f, 0x12, 0x2a, 0x2e, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, 0x6f, 0x6d, 0x61, 0x69, - 0x6e, 0x2e, 0x64, 0x6f, 0x75, 0x74, 0x6f, 0x6b, 0x5f, 0x67, 0x65, 0x74, 0x5f, 0x76, 0x69, 0x64, - 0x65, 0x6f, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x0d, 0x2e, 0x65, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x56, 0x69, 0x64, 0x65, 0x6f, 0x42, 0x35, - 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x72, 0x65, - 0x6d, 0x62, 0x6c, 0x69, 0x6e, 0x67, 0x56, 0x35, 0x2f, 0x44, 0x6f, 0x75, 0x54, 0x6f, 0x6b, 0x2f, - 0x6b, 0x69, 0x74, 0x65, 0x78, 0x5f, 0x67, 0x65, 0x6e, 0x2f, 0x76, 0x69, 0x64, 0x65, 0x6f, 0x44, - 0x6f, 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_videoDomain_proto_rawDescOnce sync.Once - file_videoDomain_proto_rawDescData = file_videoDomain_proto_rawDesc -) - -func file_videoDomain_proto_rawDescGZIP() []byte { - file_videoDomain_proto_rawDescOnce.Do(func() { - file_videoDomain_proto_rawDescData = protoimpl.X.CompressGZIP(file_videoDomain_proto_rawDescData) - }) - return file_videoDomain_proto_rawDescData -} - -var file_videoDomain_proto_msgTypes = make([]protoimpl.MessageInfo, 10) -var file_videoDomain_proto_goTypes = []interface{}{ - (*DoutokGetFeedRequest)(nil), // 0: videoDomain.doutok_get_feed_request - (*DoutokGetFeedResponse)(nil), // 1: videoDomain.doutok_get_feed_response - (*DoutokAddPublishRequest)(nil), // 2: videoDomain.doutok_add_publish_request - (*DoutokAddPublishResponse)(nil), // 3: videoDomain.doutok_add_publish_response - (*DoutokListPublishRequest)(nil), // 4: videoDomain.doutok_list_publish_request - (*DoutokListPublishResponse)(nil), // 5: videoDomain.doutok_list_publish_response - (*DoutokCountPublishRequest)(nil), // 6: videoDomain.doutok_count_publish_request - (*DoutokCountPublishResponse)(nil), // 7: videoDomain.doutok_count_publish_response - (*DoutokGetVideoInfoRequest)(nil), // 8: videoDomain.doutok_get_video_info_request - nil, // 9: videoDomain.doutok_count_publish_response.ResultEntry - (*entity.Video)(nil), // 10: entity.Video -} -var file_videoDomain_proto_depIdxs = []int32{ - 10, // 0: videoDomain.doutok_get_feed_response.video_list:type_name -> entity.Video - 10, // 1: videoDomain.doutok_list_publish_response.video_list:type_name -> entity.Video - 9, // 2: videoDomain.doutok_count_publish_response.result:type_name -> videoDomain.doutok_count_publish_response.ResultEntry - 0, // 3: videoDomain.VideoDomainService.GetFeed:input_type -> videoDomain.doutok_get_feed_request - 2, // 4: videoDomain.VideoDomainService.AddPublish:input_type -> videoDomain.doutok_add_publish_request - 4, // 5: videoDomain.VideoDomainService.ListPublish:input_type -> videoDomain.doutok_list_publish_request - 6, // 6: videoDomain.VideoDomainService.CountPublish:input_type -> videoDomain.doutok_count_publish_request - 8, // 7: videoDomain.VideoDomainService.GetVideoInfo:input_type -> videoDomain.doutok_get_video_info_request - 1, // 8: videoDomain.VideoDomainService.GetFeed:output_type -> videoDomain.doutok_get_feed_response - 3, // 9: videoDomain.VideoDomainService.AddPublish:output_type -> videoDomain.doutok_add_publish_response - 5, // 10: videoDomain.VideoDomainService.ListPublish:output_type -> videoDomain.doutok_list_publish_response - 7, // 11: videoDomain.VideoDomainService.CountPublish:output_type -> videoDomain.doutok_count_publish_response - 10, // 12: videoDomain.VideoDomainService.GetVideoInfo:output_type -> entity.Video - 8, // [8:13] is the sub-list for method output_type - 3, // [3:8] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name -} - -func init() { file_videoDomain_proto_init() } -func file_videoDomain_proto_init() { - if File_videoDomain_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_videoDomain_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokGetFeedRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_videoDomain_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokGetFeedResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_videoDomain_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddPublishRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_videoDomain_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokAddPublishResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_videoDomain_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListPublishRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_videoDomain_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokListPublishResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_videoDomain_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCountPublishRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_videoDomain_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokCountPublishResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_videoDomain_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DoutokGetVideoInfoRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_videoDomain_proto_rawDesc, - NumEnums: 0, - NumMessages: 10, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_videoDomain_proto_goTypes, - DependencyIndexes: file_videoDomain_proto_depIdxs, - MessageInfos: file_videoDomain_proto_msgTypes, - }.Build() - File_videoDomain_proto = out.File - file_videoDomain_proto_rawDesc = nil - file_videoDomain_proto_goTypes = nil - file_videoDomain_proto_depIdxs = nil -} - -var _ context.Context - -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -type VideoDomainService interface { - GetFeed(ctx context.Context, req *DoutokGetFeedRequest) (res *DoutokGetFeedResponse, err error) - AddPublish(ctx context.Context, req *DoutokAddPublishRequest) (res *DoutokAddPublishResponse, err error) - ListPublish(ctx context.Context, req *DoutokListPublishRequest) (res *DoutokListPublishResponse, err error) - CountPublish(ctx context.Context, req *DoutokCountPublishRequest) (res *DoutokCountPublishResponse, err error) - GetVideoInfo(ctx context.Context, req *DoutokGetVideoInfoRequest) (res *entity.Video, err error) -} diff --git a/kitex_gen/videoDomain/videodomainservice/client.go b/kitex_gen/videoDomain/videodomainservice/client.go deleted file mode 100644 index 90929f03..00000000 --- a/kitex_gen/videoDomain/videodomainservice/client.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package videodomainservice - -import ( - "context" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - videoDomain "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - client "github.com/cloudwego/kitex/client" - callopt "github.com/cloudwego/kitex/client/callopt" -) - -// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework. -type Client interface { - GetFeed(ctx context.Context, Req *videoDomain.DoutokGetFeedRequest, callOptions ...callopt.Option) (r *videoDomain.DoutokGetFeedResponse, err error) - AddPublish(ctx context.Context, Req *videoDomain.DoutokAddPublishRequest, callOptions ...callopt.Option) (r *videoDomain.DoutokAddPublishResponse, err error) - ListPublish(ctx context.Context, Req *videoDomain.DoutokListPublishRequest, callOptions ...callopt.Option) (r *videoDomain.DoutokListPublishResponse, err error) - CountPublish(ctx context.Context, Req *videoDomain.DoutokCountPublishRequest, callOptions ...callopt.Option) (r *videoDomain.DoutokCountPublishResponse, err error) - GetVideoInfo(ctx context.Context, Req *videoDomain.DoutokGetVideoInfoRequest, callOptions ...callopt.Option) (r *entity.Video, err error) -} - -// NewClient creates a client for the service defined in IDL. -func NewClient(destService string, opts ...client.Option) (Client, error) { - var options []client.Option - options = append(options, client.WithDestService(destService)) - - options = append(options, opts...) - - kc, err := client.NewClient(serviceInfo(), options...) - if err != nil { - return nil, err - } - return &kVideoDomainServiceClient{ - kClient: newServiceClient(kc), - }, nil -} - -// MustNewClient creates a client for the service defined in IDL. It panics if any error occurs. -func MustNewClient(destService string, opts ...client.Option) Client { - kc, err := NewClient(destService, opts...) - if err != nil { - panic(err) - } - return kc -} - -type kVideoDomainServiceClient struct { - *kClient -} - -func (p *kVideoDomainServiceClient) GetFeed(ctx context.Context, Req *videoDomain.DoutokGetFeedRequest, callOptions ...callopt.Option) (r *videoDomain.DoutokGetFeedResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.GetFeed(ctx, Req) -} - -func (p *kVideoDomainServiceClient) AddPublish(ctx context.Context, Req *videoDomain.DoutokAddPublishRequest, callOptions ...callopt.Option) (r *videoDomain.DoutokAddPublishResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.AddPublish(ctx, Req) -} - -func (p *kVideoDomainServiceClient) ListPublish(ctx context.Context, Req *videoDomain.DoutokListPublishRequest, callOptions ...callopt.Option) (r *videoDomain.DoutokListPublishResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.ListPublish(ctx, Req) -} - -func (p *kVideoDomainServiceClient) CountPublish(ctx context.Context, Req *videoDomain.DoutokCountPublishRequest, callOptions ...callopt.Option) (r *videoDomain.DoutokCountPublishResponse, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.CountPublish(ctx, Req) -} - -func (p *kVideoDomainServiceClient) GetVideoInfo(ctx context.Context, Req *videoDomain.DoutokGetVideoInfoRequest, callOptions ...callopt.Option) (r *entity.Video, err error) { - ctx = client.NewCtxWithCallOptions(ctx, callOptions) - return p.kClient.GetVideoInfo(ctx, Req) -} diff --git a/kitex_gen/videoDomain/videodomainservice/invoker.go b/kitex_gen/videoDomain/videodomainservice/invoker.go deleted file mode 100644 index 5ff87d51..00000000 --- a/kitex_gen/videoDomain/videodomainservice/invoker.go +++ /dev/null @@ -1,24 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package videodomainservice - -import ( - videoDomain "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewInvoker creates a server.Invoker with the given handler and options. -func NewInvoker(handler videoDomain.VideoDomainService, opts ...server.Option) server.Invoker { - var options []server.Option - - options = append(options, opts...) - - s := server.NewInvoker(options...) - if err := s.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - if err := s.Init(); err != nil { - panic(err) - } - return s -} diff --git a/kitex_gen/videoDomain/videodomainservice/server.go b/kitex_gen/videoDomain/videodomainservice/server.go deleted file mode 100644 index 777a994d..00000000 --- a/kitex_gen/videoDomain/videodomainservice/server.go +++ /dev/null @@ -1,20 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. -package videodomainservice - -import ( - videoDomain "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - server "github.com/cloudwego/kitex/server" -) - -// NewServer creates a server.Server with the given handler and options. -func NewServer(handler videoDomain.VideoDomainService, opts ...server.Option) server.Server { - var options []server.Option - - options = append(options, opts...) - - svr := server.NewServer(options...) - if err := svr.RegisterService(serviceInfo(), handler); err != nil { - panic(err) - } - return svr -} diff --git a/kitex_gen/videoDomain/videodomainservice/videodomainservice.go b/kitex_gen/videoDomain/videodomainservice/videodomainservice.go deleted file mode 100644 index ba759681..00000000 --- a/kitex_gen/videoDomain/videodomainservice/videodomainservice.go +++ /dev/null @@ -1,829 +0,0 @@ -// Code generated by Kitex v0.4.4. DO NOT EDIT. - -package videodomainservice - -import ( - "context" - "fmt" - entity "github.com/TremblingV5/DouTok/kitex_gen/entity" - videoDomain "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - client "github.com/cloudwego/kitex/client" - kitex "github.com/cloudwego/kitex/pkg/serviceinfo" - streaming "github.com/cloudwego/kitex/pkg/streaming" - proto "google.golang.org/protobuf/proto" -) - -func serviceInfo() *kitex.ServiceInfo { - return videoDomainServiceServiceInfo -} - -var videoDomainServiceServiceInfo = NewServiceInfo() - -func NewServiceInfo() *kitex.ServiceInfo { - serviceName := "VideoDomainService" - handlerType := (*videoDomain.VideoDomainService)(nil) - methods := map[string]kitex.MethodInfo{ - "GetFeed": kitex.NewMethodInfo(getFeedHandler, newGetFeedArgs, newGetFeedResult, false), - "AddPublish": kitex.NewMethodInfo(addPublishHandler, newAddPublishArgs, newAddPublishResult, false), - "ListPublish": kitex.NewMethodInfo(listPublishHandler, newListPublishArgs, newListPublishResult, false), - "CountPublish": kitex.NewMethodInfo(countPublishHandler, newCountPublishArgs, newCountPublishResult, false), - "GetVideoInfo": kitex.NewMethodInfo(getVideoInfoHandler, newGetVideoInfoArgs, newGetVideoInfoResult, false), - } - extra := map[string]interface{}{ - "PackageName": "videoDomain", - } - svcInfo := &kitex.ServiceInfo{ - ServiceName: serviceName, - HandlerType: handlerType, - Methods: methods, - PayloadCodec: kitex.Protobuf, - KiteXGenVersion: "v0.4.4", - Extra: extra, - } - return svcInfo -} - -func getFeedHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(videoDomain.DoutokGetFeedRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(videoDomain.VideoDomainService).GetFeed(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *GetFeedArgs: - success, err := handler.(videoDomain.VideoDomainService).GetFeed(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*GetFeedResult) - realResult.Success = success - } - return nil -} -func newGetFeedArgs() interface{} { - return &GetFeedArgs{} -} - -func newGetFeedResult() interface{} { - return &GetFeedResult{} -} - -type GetFeedArgs struct { - Req *videoDomain.DoutokGetFeedRequest -} - -func (p *GetFeedArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(videoDomain.DoutokGetFeedRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *GetFeedArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *GetFeedArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *GetFeedArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in GetFeedArgs") - } - return proto.Marshal(p.Req) -} - -func (p *GetFeedArgs) Unmarshal(in []byte) error { - msg := new(videoDomain.DoutokGetFeedRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var GetFeedArgs_Req_DEFAULT *videoDomain.DoutokGetFeedRequest - -func (p *GetFeedArgs) GetReq() *videoDomain.DoutokGetFeedRequest { - if !p.IsSetReq() { - return GetFeedArgs_Req_DEFAULT - } - return p.Req -} - -func (p *GetFeedArgs) IsSetReq() bool { - return p.Req != nil -} - -type GetFeedResult struct { - Success *videoDomain.DoutokGetFeedResponse -} - -var GetFeedResult_Success_DEFAULT *videoDomain.DoutokGetFeedResponse - -func (p *GetFeedResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(videoDomain.DoutokGetFeedResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *GetFeedResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *GetFeedResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *GetFeedResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in GetFeedResult") - } - return proto.Marshal(p.Success) -} - -func (p *GetFeedResult) Unmarshal(in []byte) error { - msg := new(videoDomain.DoutokGetFeedResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *GetFeedResult) GetSuccess() *videoDomain.DoutokGetFeedResponse { - if !p.IsSetSuccess() { - return GetFeedResult_Success_DEFAULT - } - return p.Success -} - -func (p *GetFeedResult) SetSuccess(x interface{}) { - p.Success = x.(*videoDomain.DoutokGetFeedResponse) -} - -func (p *GetFeedResult) IsSetSuccess() bool { - return p.Success != nil -} - -func addPublishHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(videoDomain.DoutokAddPublishRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(videoDomain.VideoDomainService).AddPublish(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *AddPublishArgs: - success, err := handler.(videoDomain.VideoDomainService).AddPublish(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*AddPublishResult) - realResult.Success = success - } - return nil -} -func newAddPublishArgs() interface{} { - return &AddPublishArgs{} -} - -func newAddPublishResult() interface{} { - return &AddPublishResult{} -} - -type AddPublishArgs struct { - Req *videoDomain.DoutokAddPublishRequest -} - -func (p *AddPublishArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(videoDomain.DoutokAddPublishRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *AddPublishArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *AddPublishArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *AddPublishArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in AddPublishArgs") - } - return proto.Marshal(p.Req) -} - -func (p *AddPublishArgs) Unmarshal(in []byte) error { - msg := new(videoDomain.DoutokAddPublishRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var AddPublishArgs_Req_DEFAULT *videoDomain.DoutokAddPublishRequest - -func (p *AddPublishArgs) GetReq() *videoDomain.DoutokAddPublishRequest { - if !p.IsSetReq() { - return AddPublishArgs_Req_DEFAULT - } - return p.Req -} - -func (p *AddPublishArgs) IsSetReq() bool { - return p.Req != nil -} - -type AddPublishResult struct { - Success *videoDomain.DoutokAddPublishResponse -} - -var AddPublishResult_Success_DEFAULT *videoDomain.DoutokAddPublishResponse - -func (p *AddPublishResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(videoDomain.DoutokAddPublishResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *AddPublishResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *AddPublishResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *AddPublishResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in AddPublishResult") - } - return proto.Marshal(p.Success) -} - -func (p *AddPublishResult) Unmarshal(in []byte) error { - msg := new(videoDomain.DoutokAddPublishResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *AddPublishResult) GetSuccess() *videoDomain.DoutokAddPublishResponse { - if !p.IsSetSuccess() { - return AddPublishResult_Success_DEFAULT - } - return p.Success -} - -func (p *AddPublishResult) SetSuccess(x interface{}) { - p.Success = x.(*videoDomain.DoutokAddPublishResponse) -} - -func (p *AddPublishResult) IsSetSuccess() bool { - return p.Success != nil -} - -func listPublishHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(videoDomain.DoutokListPublishRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(videoDomain.VideoDomainService).ListPublish(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *ListPublishArgs: - success, err := handler.(videoDomain.VideoDomainService).ListPublish(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*ListPublishResult) - realResult.Success = success - } - return nil -} -func newListPublishArgs() interface{} { - return &ListPublishArgs{} -} - -func newListPublishResult() interface{} { - return &ListPublishResult{} -} - -type ListPublishArgs struct { - Req *videoDomain.DoutokListPublishRequest -} - -func (p *ListPublishArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(videoDomain.DoutokListPublishRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *ListPublishArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *ListPublishArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *ListPublishArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in ListPublishArgs") - } - return proto.Marshal(p.Req) -} - -func (p *ListPublishArgs) Unmarshal(in []byte) error { - msg := new(videoDomain.DoutokListPublishRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var ListPublishArgs_Req_DEFAULT *videoDomain.DoutokListPublishRequest - -func (p *ListPublishArgs) GetReq() *videoDomain.DoutokListPublishRequest { - if !p.IsSetReq() { - return ListPublishArgs_Req_DEFAULT - } - return p.Req -} - -func (p *ListPublishArgs) IsSetReq() bool { - return p.Req != nil -} - -type ListPublishResult struct { - Success *videoDomain.DoutokListPublishResponse -} - -var ListPublishResult_Success_DEFAULT *videoDomain.DoutokListPublishResponse - -func (p *ListPublishResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(videoDomain.DoutokListPublishResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *ListPublishResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *ListPublishResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *ListPublishResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in ListPublishResult") - } - return proto.Marshal(p.Success) -} - -func (p *ListPublishResult) Unmarshal(in []byte) error { - msg := new(videoDomain.DoutokListPublishResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *ListPublishResult) GetSuccess() *videoDomain.DoutokListPublishResponse { - if !p.IsSetSuccess() { - return ListPublishResult_Success_DEFAULT - } - return p.Success -} - -func (p *ListPublishResult) SetSuccess(x interface{}) { - p.Success = x.(*videoDomain.DoutokListPublishResponse) -} - -func (p *ListPublishResult) IsSetSuccess() bool { - return p.Success != nil -} - -func countPublishHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(videoDomain.DoutokCountPublishRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(videoDomain.VideoDomainService).CountPublish(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *CountPublishArgs: - success, err := handler.(videoDomain.VideoDomainService).CountPublish(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*CountPublishResult) - realResult.Success = success - } - return nil -} -func newCountPublishArgs() interface{} { - return &CountPublishArgs{} -} - -func newCountPublishResult() interface{} { - return &CountPublishResult{} -} - -type CountPublishArgs struct { - Req *videoDomain.DoutokCountPublishRequest -} - -func (p *CountPublishArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(videoDomain.DoutokCountPublishRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *CountPublishArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *CountPublishArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *CountPublishArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in CountPublishArgs") - } - return proto.Marshal(p.Req) -} - -func (p *CountPublishArgs) Unmarshal(in []byte) error { - msg := new(videoDomain.DoutokCountPublishRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var CountPublishArgs_Req_DEFAULT *videoDomain.DoutokCountPublishRequest - -func (p *CountPublishArgs) GetReq() *videoDomain.DoutokCountPublishRequest { - if !p.IsSetReq() { - return CountPublishArgs_Req_DEFAULT - } - return p.Req -} - -func (p *CountPublishArgs) IsSetReq() bool { - return p.Req != nil -} - -type CountPublishResult struct { - Success *videoDomain.DoutokCountPublishResponse -} - -var CountPublishResult_Success_DEFAULT *videoDomain.DoutokCountPublishResponse - -func (p *CountPublishResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(videoDomain.DoutokCountPublishResponse) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *CountPublishResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *CountPublishResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *CountPublishResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in CountPublishResult") - } - return proto.Marshal(p.Success) -} - -func (p *CountPublishResult) Unmarshal(in []byte) error { - msg := new(videoDomain.DoutokCountPublishResponse) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *CountPublishResult) GetSuccess() *videoDomain.DoutokCountPublishResponse { - if !p.IsSetSuccess() { - return CountPublishResult_Success_DEFAULT - } - return p.Success -} - -func (p *CountPublishResult) SetSuccess(x interface{}) { - p.Success = x.(*videoDomain.DoutokCountPublishResponse) -} - -func (p *CountPublishResult) IsSetSuccess() bool { - return p.Success != nil -} - -func getVideoInfoHandler(ctx context.Context, handler interface{}, arg, result interface{}) error { - switch s := arg.(type) { - case *streaming.Args: - st := s.Stream - req := new(videoDomain.DoutokGetVideoInfoRequest) - if err := st.RecvMsg(req); err != nil { - return err - } - resp, err := handler.(videoDomain.VideoDomainService).GetVideoInfo(ctx, req) - if err != nil { - return err - } - if err := st.SendMsg(resp); err != nil { - return err - } - case *GetVideoInfoArgs: - success, err := handler.(videoDomain.VideoDomainService).GetVideoInfo(ctx, s.Req) - if err != nil { - return err - } - realResult := result.(*GetVideoInfoResult) - realResult.Success = success - } - return nil -} -func newGetVideoInfoArgs() interface{} { - return &GetVideoInfoArgs{} -} - -func newGetVideoInfoResult() interface{} { - return &GetVideoInfoResult{} -} - -type GetVideoInfoArgs struct { - Req *videoDomain.DoutokGetVideoInfoRequest -} - -func (p *GetVideoInfoArgs) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetReq() { - p.Req = new(videoDomain.DoutokGetVideoInfoRequest) - } - return p.Req.FastRead(buf, _type, number) -} - -func (p *GetVideoInfoArgs) FastWrite(buf []byte) (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.FastWrite(buf) -} - -func (p *GetVideoInfoArgs) Size() (n int) { - if !p.IsSetReq() { - return 0 - } - return p.Req.Size() -} - -func (p *GetVideoInfoArgs) Marshal(out []byte) ([]byte, error) { - if !p.IsSetReq() { - return out, fmt.Errorf("No req in GetVideoInfoArgs") - } - return proto.Marshal(p.Req) -} - -func (p *GetVideoInfoArgs) Unmarshal(in []byte) error { - msg := new(videoDomain.DoutokGetVideoInfoRequest) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Req = msg - return nil -} - -var GetVideoInfoArgs_Req_DEFAULT *videoDomain.DoutokGetVideoInfoRequest - -func (p *GetVideoInfoArgs) GetReq() *videoDomain.DoutokGetVideoInfoRequest { - if !p.IsSetReq() { - return GetVideoInfoArgs_Req_DEFAULT - } - return p.Req -} - -func (p *GetVideoInfoArgs) IsSetReq() bool { - return p.Req != nil -} - -type GetVideoInfoResult struct { - Success *entity.Video -} - -var GetVideoInfoResult_Success_DEFAULT *entity.Video - -func (p *GetVideoInfoResult) FastRead(buf []byte, _type int8, number int32) (n int, err error) { - if !p.IsSetSuccess() { - p.Success = new(entity.Video) - } - return p.Success.FastRead(buf, _type, number) -} - -func (p *GetVideoInfoResult) FastWrite(buf []byte) (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.FastWrite(buf) -} - -func (p *GetVideoInfoResult) Size() (n int) { - if !p.IsSetSuccess() { - return 0 - } - return p.Success.Size() -} - -func (p *GetVideoInfoResult) Marshal(out []byte) ([]byte, error) { - if !p.IsSetSuccess() { - return out, fmt.Errorf("No req in GetVideoInfoResult") - } - return proto.Marshal(p.Success) -} - -func (p *GetVideoInfoResult) Unmarshal(in []byte) error { - msg := new(entity.Video) - if err := proto.Unmarshal(in, msg); err != nil { - return err - } - p.Success = msg - return nil -} - -func (p *GetVideoInfoResult) GetSuccess() *entity.Video { - if !p.IsSetSuccess() { - return GetVideoInfoResult_Success_DEFAULT - } - return p.Success -} - -func (p *GetVideoInfoResult) SetSuccess(x interface{}) { - p.Success = x.(*entity.Video) -} - -func (p *GetVideoInfoResult) IsSetSuccess() bool { - return p.Success != nil -} - -type kClient struct { - c client.Client -} - -func newServiceClient(c client.Client) *kClient { - return &kClient{ - c: c, - } -} - -func (p *kClient) GetFeed(ctx context.Context, Req *videoDomain.DoutokGetFeedRequest) (r *videoDomain.DoutokGetFeedResponse, err error) { - var _args GetFeedArgs - _args.Req = Req - var _result GetFeedResult - if err = p.c.Call(ctx, "GetFeed", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) AddPublish(ctx context.Context, Req *videoDomain.DoutokAddPublishRequest) (r *videoDomain.DoutokAddPublishResponse, err error) { - var _args AddPublishArgs - _args.Req = Req - var _result AddPublishResult - if err = p.c.Call(ctx, "AddPublish", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) ListPublish(ctx context.Context, Req *videoDomain.DoutokListPublishRequest) (r *videoDomain.DoutokListPublishResponse, err error) { - var _args ListPublishArgs - _args.Req = Req - var _result ListPublishResult - if err = p.c.Call(ctx, "ListPublish", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) CountPublish(ctx context.Context, Req *videoDomain.DoutokCountPublishRequest) (r *videoDomain.DoutokCountPublishResponse, err error) { - var _args CountPublishArgs - _args.Req = Req - var _result CountPublishResult - if err = p.c.Call(ctx, "CountPublish", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} - -func (p *kClient) GetVideoInfo(ctx context.Context, Req *videoDomain.DoutokGetVideoInfoRequest) (r *entity.Video, err error) { - var _args GetVideoInfoArgs - _args.Req = Req - var _result GetVideoInfoResult - if err = p.c.Call(ctx, "GetVideoInfo", &_args, &_result); err != nil { - return - } - return _result.GetSuccess(), nil -} diff --git a/pkg/dtviper/config.go b/pkg/dtviper/config.go index 112db92c..d2104ea9 100644 --- a/pkg/dtviper/config.go +++ b/pkg/dtviper/config.go @@ -139,7 +139,7 @@ func (v *Config) ZapLogConfig() []byte { } // ConfigInit initializes the configuration -func ConfigInit(envPrefix string, cfgName string, searchPaths ...string) *Config { +func ConfigInit(envPrefix string, cfgName string) Config { pflag.Parse() v := viper.New() @@ -149,9 +149,7 @@ func ConfigInit(envPrefix string, cfgName string, searchPaths ...string) *Config viper.BindPFlags 自动绑定了所有命令行参数,如果只需要其中一部分,可以用viper.BingPflag选择性绑定,如 viper.BindPFlag("global.source", pflag.Lookup("global.source")) */ - if err := viper.BindPFlags(pflag.CommandLine); err != nil { - panic(err) - } + viper.BindPFlags(pflag.CommandLine) config.SetDefaultValue() // read from env @@ -181,23 +179,20 @@ func ConfigInit(envPrefix string, cfgName string, searchPaths ...string) *Config } else { /* 尝试搜索若干默认路径,先后顺序如下: - - /etc/doutok/config/userConfig. - - ~/.doutok/userConfig. + - /etc/tiktok/config/userConfig. + - ~/.tiktok/userConfig. - ./userConfig. 其中 是 viper所支持的文件类型,如yml,json等 */ viper.SetConfigName(cfgName) // name of config file (without extension) - viper.AddConfigPath("/etc/doutok/config") - viper.AddConfigPath("$HOME/.doutok/") + viper.AddConfigPath("/etc/tiktok/config") + viper.AddConfigPath("$HOME/.tiktok/") viper.AddConfigPath("./config") viper.AddConfigPath("../../config") viper.AddConfigPath("../../../config") viper.AddConfigPath("../../../../config") - for _, searchPath := range searchPaths { - viper.AddConfigPath(filepath.Clean(searchPath)) - } } if isRemoteConfig { @@ -206,10 +201,7 @@ func ConfigInit(envPrefix string, cfgName string, searchPaths ...string) *Config } klog.Infof("Using Remote Config: '%s'", configVar) - if err := viper.WatchRemoteConfig(); err != nil { - klog.Errorf("unable to read remote config: %v", err) - } - + viper.WatchRemoteConfig() // 另启动一个协程来监测远程配置文件 go config.WatchRemoteConf() @@ -217,7 +209,6 @@ func ConfigInit(envPrefix string, cfgName string, searchPaths ...string) *Config if err := viper.ReadInConfig(); err != nil { klog.Fatalf("error reading config: %s", err) } - klog.Infof("Using configuration file '%s'", viper.ConfigFileUsed()) viper.WatchConfig() @@ -229,5 +220,5 @@ func ConfigInit(envPrefix string, cfgName string, searchPaths ...string) *Config } - return &config + return config } diff --git a/pkg/errno/errno.go b/pkg/errno/errno.go index be9520bc..f086c928 100644 --- a/pkg/errno/errno.go +++ b/pkg/errno/errno.go @@ -19,21 +19,16 @@ const ( ) type ErrNo struct { - ErrCode int - ErrMsg string - NameCode int - NodeCode int + ErrCode int + ErrMsg string } func (e ErrNo) Error() string { return fmt.Sprintf("err_code=%d, err_msg=%s", e.ErrCode, e.ErrMsg) } -func New(code int, msg string) ErrNo { - return ErrNo{ - ErrCode: code, - ErrMsg: msg, - } +func NewErrNo(code int, msg string) ErrNo { + return ErrNo{code, msg} } func (e ErrNo) WithMessage(msg string) ErrNo { @@ -42,16 +37,16 @@ func (e ErrNo) WithMessage(msg string) ErrNo { } var ( - Success = New(SuccessCode, "Success") - ServiceErr = New(ServiceErrCode, "Service is unable to start successfully") - ParamErr = New(ParamErrCode, "Wrong Parameter has been given") - UserAlreadyExistErr = New(UserAlreadyExistErrCode, "User already exists") - AuthorizationFailedErr = New(AuthorizationFailedErrCode, "Authorization failed") - BadRequest = New(BadRequestErrCode, "Request Failed") - ErrBind = New(ErrBindErrCode, "Error occurred while binding the request body to the struct") - InternalErr = New(InternalErrCode, "Internal server error") - RedisSetErr = New(RedisSetErrorCode, "Set data to redis error") - RedisGetErr = New(RedisGetErrorCode, "Get data from redis error") + Success = NewErrNo(SuccessCode, "Success") + ServiceErr = NewErrNo(ServiceErrCode, "Service is unable to start successfully") + ParamErr = NewErrNo(ParamErrCode, "Wrong Parameter has been given") + UserAlreadyExistErr = NewErrNo(UserAlreadyExistErrCode, "User already exists") + AuthorizationFailedErr = NewErrNo(AuthorizationFailedErrCode, "Authorization failed") + BadRequest = NewErrNo(BadRequestErrCode, "Request Failed") + ErrBind = NewErrNo(ErrBindErrCode, "Error occurred while binding the request body to the struct") + InternalErr = NewErrNo(InternalErrCode, "Internal server error") + RedisSetErr = NewErrNo(RedisSetErrorCode, "Set data to redis error") + RedisGetErr = NewErrNo(RedisGetErrorCode, "Get data from redis error") ) // ConvertErr convert error to Errno diff --git a/pkg/hbaseHandle/init.go b/pkg/hbaseHandle/init.go new file mode 100644 index 00000000..859a3ed5 --- /dev/null +++ b/pkg/hbaseHandle/init.go @@ -0,0 +1,10 @@ +package hbaseHandle + +import "github.com/tsuna/gohbase" + +func InitHB(host string) HBaseClient { + c := gohbase.NewClient(host) + return HBaseClient{ + Client: c, + } +} diff --git a/pkg/hbaseHandle/init_test.go b/pkg/hbaseHandle/init_test.go new file mode 100644 index 00000000..40ea7b27 --- /dev/null +++ b/pkg/hbaseHandle/init_test.go @@ -0,0 +1,19 @@ +package hbaseHandle + +import ( + "fmt" + "testing" + + "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/pkg/configurator" +) + +func TestInitHB(t *testing.T) { + var config configStruct.HBaseConfig + configurator.InitConfig( + &config, "hbase.yaml", + ) + + client := InitHB(config.Host) + fmt.Println(client) +} diff --git a/pkg/hbaseHandle/put.go b/pkg/hbaseHandle/put.go index 762061f0..9ac19c56 100644 --- a/pkg/hbaseHandle/put.go +++ b/pkg/hbaseHandle/put.go @@ -2,6 +2,7 @@ package hbaseHandle import ( "context" + "github.com/tsuna/gohbase/hrpc" ) diff --git a/pkg/hbaseHandle/put_test.go b/pkg/hbaseHandle/put_test.go new file mode 100644 index 00000000..e3570457 --- /dev/null +++ b/pkg/hbaseHandle/put_test.go @@ -0,0 +1,28 @@ +package hbaseHandle + +import ( + "testing" + + "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/pkg/configurator" + "github.com/sirupsen/logrus" +) + +func TestPut(t *testing.T) { + logrus.SetLevel(logrus.DebugLevel) + var config configStruct.HBaseConfig + configurator.InitConfig( + &config, "hbase.yaml", + ) + + client := InitHB(config.Host) + + values := map[string]map[string][]byte{ + "d": { + "title": []byte("test video"), + "time": []byte("1998"), + }, + } + + client.Put("test", "00030005", values) +} diff --git a/pkg/hbaseHandle/scan_test.go b/pkg/hbaseHandle/scan_test.go new file mode 100644 index 00000000..7259b385 --- /dev/null +++ b/pkg/hbaseHandle/scan_test.go @@ -0,0 +1,74 @@ +package hbaseHandle + +import ( + "fmt" + "testing" + + "github.com/TremblingV5/DouTok/config/configStruct" + "github.com/TremblingV5/DouTok/pkg/configurator" +) + +func TestScan(t *testing.T) { + var config configStruct.HBaseConfig + configurator.InitConfig( + &config, "hbase.yaml", + ) + + client := InitHB(config.Host) + + res, _ := client.Scan("test") + + for k, v := range res { + fmt.Println(k) + fmt.Println(v) + } +} + +func TestScanRange(t *testing.T) { + var config configStruct.HBaseConfig + configurator.InitConfig( + &config, "hbase.yaml", + ) + + client := InitHB(config.Host) + + res, _ := client.ScanRange("test", "0000", "0003") + + for k, v := range res { + fmt.Println(k) + fmt.Println(v) + } +} + +func TestScanByRowKeyPrefix(t *testing.T) { + var config configStruct.HBaseConfig + configurator.InitConfig( + &config, "hbase.yaml", + ) + + client := InitHB(config.Host) + + res, _ := client.Scan("test", GetFilterByRowKeyPrefix("0003")...) + + for k, v := range res { + fmt.Println(k) + fmt.Println(v) + } +} + +// TODO: 待修改,无法使用 +func TestScanByRowKeyRange(t *testing.T) { + var config configStruct.HBaseConfig + configurator.InitConfig( + &config, "hbase.yaml", + ) + + client := InitHB(config.Host) + + res, _ := client.Scan("test", GetFilterByRowKeyRange(100, "00010003", "00030003")...) + + for k, v := range res { + fmt.Println(k) + fmt.Println(v) + } +} diff --git a/pkg/initHelper/comment.go b/pkg/initHelper/comment.go index 6a294b8e..bd8947ed 100644 --- a/pkg/initHelper/comment.go +++ b/pkg/initHelper/comment.go @@ -14,7 +14,7 @@ type CommentClient struct { func InitCommentRPCClient() *CommentClient { config := dtviper.ConfigInit("DOUTOK_COMMENT", "comment") - c, err := commentservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) + c, err := commentservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(&config)...) if err != nil { panic(err) } diff --git a/pkg/initHelper/commentDomain.go b/pkg/initHelper/commentDomain.go deleted file mode 100644 index 77a80030..00000000 --- a/pkg/initHelper/commentDomain.go +++ /dev/null @@ -1,66 +0,0 @@ -package initHelper - -import ( - "context" - "errors" - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain" - "github.com/TremblingV5/DouTok/kitex_gen/commentDomain/commentdomainservice" - "github.com/TremblingV5/DouTok/pkg/dtviper" -) - -type CommentDomainClient struct { - client commentdomainservice.Client -} - -func InitCommentDomainRPCClient() *CommentDomainClient { - config := dtviper.ConfigInit("DOUTOK_COMMENTDOMAIN", "commentDomain") - c, err := commentdomainservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) - if err != nil { - panic(err) - } - return &CommentDomainClient{client: c} -} - -func (c *CommentDomainClient) AddComment(ctx context.Context, req *commentDomain.DoutokAddCommentReq) (*commentDomain.DoutokAddCommentResp, error) { - resp, err := c.client.AddComment(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *CommentDomainClient) RmComment(ctx context.Context, req *commentDomain.DoutokRmCommentReq) (*commentDomain.DoutokAddCommentResp, error) { - resp, err := c.client.RmComment(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *CommentDomainClient) ListComment(ctx context.Context, req *commentDomain.DoutokListCommentReq) (*commentDomain.DoutokListCommentResp, error) { - resp, err := c.client.ListComment(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *CommentDomainClient) CountComment(ctx context.Context, req *commentDomain.DoutokCountCommentReq) (*commentDomain.DoutokCountCommentResp, error) { - resp, err := c.client.CountComment(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} diff --git a/pkg/initHelper/favorite.go b/pkg/initHelper/favorite.go index 560196e1..6a27ece5 100644 --- a/pkg/initHelper/favorite.go +++ b/pkg/initHelper/favorite.go @@ -15,7 +15,7 @@ type FavoriteClient struct { func InitFavoriteRPCClient() *FavoriteClient { config := dtviper.ConfigInit("DOUTOK_FAVORITE", "favorite") - c, err := favoriteservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) + c, err := favoriteservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(&config)...) if err != nil { panic(err) } diff --git a/pkg/initHelper/favoriteDomain.go b/pkg/initHelper/favoriteDomain.go deleted file mode 100644 index c11ed998..00000000 --- a/pkg/initHelper/favoriteDomain.go +++ /dev/null @@ -1,78 +0,0 @@ -package initHelper - -import ( - "context" - "errors" - - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain" - "github.com/TremblingV5/DouTok/kitex_gen/favoriteDomain/favoritedomainservice" - "github.com/TremblingV5/DouTok/pkg/dtviper" -) - -type FavoriteDomainClient struct { - client favoritedomainservice.Client -} - -func InitFavoriteDomainRPCClient() *FavoriteDomainClient { - config := dtviper.ConfigInit("DOUTOK_FAVORITEDOMAIN", "favoriteDomain") - c, err := favoritedomainservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) - if err != nil { - panic(err) - } - return &FavoriteDomainClient{client: c} -} - -func (c *FavoriteDomainClient) AddFavorite(ctx context.Context, req *favoriteDomain.DoutokAddFavRequest) (*favoriteDomain.DoutokAddFavResponse, error) { - resp, err := c.client.AddFavorite(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *FavoriteDomainClient) RmFavorite(ctx context.Context, req *favoriteDomain.DoutokRmFavRequest) (*favoriteDomain.DoutokRmFavResponse, error) { - resp, err := c.client.RmFavorite(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *FavoriteDomainClient) ListFavorite(ctx context.Context, req *favoriteDomain.DoutokListFavRequest) (*favoriteDomain.DoutokListFavResponse, error) { - resp, err := c.client.ListFavorite(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *FavoriteDomainClient) IsFavorite(ctx context.Context, req *favoriteDomain.DoutokIsFavRequest) (*favoriteDomain.DoutokIsFavResponse, error) { - resp, err := c.client.IsFavorite(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *FavoriteDomainClient) CountFavorite(ctx context.Context, req *favoriteDomain.DoutokCountFavRequest) (*favoriteDomain.DoutokCountFavResponse, error) { - resp, err := c.client.CountFavorite(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} diff --git a/pkg/initHelper/feed.go b/pkg/initHelper/feed.go index a71a2940..511b24dd 100644 --- a/pkg/initHelper/feed.go +++ b/pkg/initHelper/feed.go @@ -16,7 +16,7 @@ type FeedClient struct { func InitFeedRPCClient() *FeedClient { config := dtviper.ConfigInit("DOUTOK_FEED", "feed") - c, err := feedservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) + c, err := feedservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(&config)...) if err != nil { panic(err) } @@ -35,9 +35,9 @@ func (c *FeedClient) GetUserFeed(ctx context.Context, req *feed.DouyinFeedReques } func (c *FeedClient) GetVideoById(ctx context.Context, req *feed.VideoIdRequest) (*entity.Video, error) { - resp, err := c.client.GetVideoById(ctx, req) + _, err := c.client.GetVideoById(ctx, req) if err != nil { return nil, err } - return resp, nil + return nil, nil } diff --git a/pkg/initHelper/message.go b/pkg/initHelper/message.go index dbb62de1..20dae132 100644 --- a/pkg/initHelper/message.go +++ b/pkg/initHelper/message.go @@ -15,7 +15,7 @@ type MessageClient struct { func InitMessageRPCClient() *MessageClient { config := dtviper.ConfigInit("DOUTOK_MESSAGE", "message") - c, err := messageservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) + c, err := messageservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(&config)...) if err != nil { panic(err) } diff --git a/pkg/initHelper/messageDomain.go b/pkg/initHelper/messageDomain.go deleted file mode 100644 index 3c4e43fb..00000000 --- a/pkg/initHelper/messageDomain.go +++ /dev/null @@ -1,45 +0,0 @@ -package initHelper - -import ( - "context" - "errors" - - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain" - "github.com/TremblingV5/DouTok/kitex_gen/messageDomain/messagedomainservice" - "github.com/TremblingV5/DouTok/pkg/dtviper" -) - -type MessageDomainClient struct { - client messagedomainservice.Client -} - -func InitMessageDomainRPCClient() *MessageDomainClient { - config := dtviper.ConfigInit("DOUTOK_MESSAGEDOMAIN", "messageDomain") - c, err := messagedomainservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) - if err != nil { - panic(err) - } - return &MessageDomainClient{client: c} -} - -func (c *MessageDomainClient) AddMessage(ctx context.Context, req *messageDomain.DoutokAddMessageRequest) (*messageDomain.DoutokAddMessageResponse, error) { - resp, err := c.client.AddMessage(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *MessageDomainClient) ListMessage(ctx context.Context, req *messageDomain.DoutokListMessageRequest) (*messageDomain.DoutokListMessageResponse, error) { - resp, err := c.client.ListMessage(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} diff --git a/pkg/initHelper/publish.go b/pkg/initHelper/publish.go index 75a488b7..1af549cb 100644 --- a/pkg/initHelper/publish.go +++ b/pkg/initHelper/publish.go @@ -15,7 +15,7 @@ type PublishClient struct { func InitPublishRPCClient() *PublishClient { config := dtviper.ConfigInit("DOUTOK_PUBLISH", "publish") - c, err := publishservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) + c, err := publishservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(&config)...) if err != nil { panic(err) } diff --git a/pkg/initHelper/relation.go b/pkg/initHelper/relation.go index a5f6e54d..af664039 100644 --- a/pkg/initHelper/relation.go +++ b/pkg/initHelper/relation.go @@ -15,7 +15,7 @@ type RelationClient struct { func InitRelationRPCClient() *RelationClient { config := dtviper.ConfigInit("DOUTOK_RELATION", "relation") - c, err := relationservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) + c, err := relationservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(&config)...) if err != nil { panic(err) } diff --git a/pkg/initHelper/relationDomain.go b/pkg/initHelper/relationDomain.go deleted file mode 100644 index fbc29157..00000000 --- a/pkg/initHelper/relationDomain.go +++ /dev/null @@ -1,67 +0,0 @@ -package initHelper - -import ( - "context" - "errors" - - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain" - "github.com/TremblingV5/DouTok/kitex_gen/relationDomain/relationdomainservice" - "github.com/TremblingV5/DouTok/pkg/dtviper" -) - -type RelationDomainClient struct { - client relationdomainservice.Client -} - -func InitRelationDomainRPCClient() *RelationDomainClient { - config := dtviper.ConfigInit("DOUTOK_RELATIONDOMAIN", "relationDomain") - c, err := relationdomainservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) - if err != nil { - panic(err) - } - return &RelationDomainClient{client: c} -} - -func (c *RelationDomainClient) AddRelation(ctx context.Context, req *relationDomain.DoutokAddRelationRequest) (*relationDomain.DoutokAddRelationResponse, error) { - resp, err := c.client.AddRelation(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *RelationDomainClient) ListRelation(ctx context.Context, req *relationDomain.DoutokListRelationRequest) (*relationDomain.DoutokListRelationResponse, error) { - resp, err := c.client.ListRelation(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *RelationDomainClient) RmRelation(ctx context.Context, req *relationDomain.DoutokRmRelationRequest) (*relationDomain.DoutokRmRelationResponse, error) { - resp, err := c.client.RmRelation(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *RelationDomainClient) CountRelation(ctx context.Context, req *relationDomain.DoutokCountRelationRequest) (*relationDomain.DoutokCountRelationResponse, error) { - resp, err := c.client.CountRelation(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} diff --git a/pkg/initHelper/rpc_client.go b/pkg/initHelper/rpc_client.go index 35930e27..84b5fc97 100644 --- a/pkg/initHelper/rpc_client.go +++ b/pkg/initHelper/rpc_client.go @@ -4,17 +4,15 @@ import ( "github.com/TremblingV5/DouTok/pkg/dtviper" "github.com/TremblingV5/DouTok/pkg/middleware" "github.com/cloudwego/kitex/client" - "github.com/cloudwego/kitex/pkg/remote/trans/gonet" "github.com/cloudwego/kitex/pkg/retry" "github.com/cloudwego/kitex/pkg/rpcinfo" "github.com/kitex-contrib/obs-opentelemetry/tracing" etcd "github.com/kitex-contrib/registry-etcd" - "runtime" "time" ) /* -返回初始化RPC客户端所需要的一些配置,减少这部分代码的重复 + 返回初始化RPC客户端所需要的一些配置,减少这部分代码的重复 */ func InitRPCClientArgs(config *dtviper.Config) []client.Option { addr := config.Viper.GetString("Etcd.Address") + ":" + config.Viper.GetString("Etcd.Port") @@ -22,21 +20,16 @@ func InitRPCClientArgs(config *dtviper.Config) []client.Option { if err != nil { panic(err) } - options := []client.Option{ + + return []client.Option{ client.WithSuite(tracing.NewClientSuite()), client.WithMiddleware(middleware.CommonMiddleware), client.WithInstanceMW(middleware.ClientMiddleware), + client.WithMuxConnection(1), // mux client.WithRPCTimeout(30 * time.Second), // rpc timeout client.WithConnectTimeout(30000 * time.Millisecond), // conn timeout client.WithFailureRetry(retry.NewFailurePolicy()), // retry client.WithResolver(registry), client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: config.Viper.GetString("Server.Name")}), } - if runtime.GOOS == "windows" { - options = append(options, client.WithTransHandlerFactory(gonet.NewCliTransHandlerFactory())) - } else { - options = append(options, client.WithMuxConnection(1)) // mux - } - - return options } diff --git a/pkg/initHelper/rpc_server.go b/pkg/initHelper/rpc_server.go new file mode 100644 index 00000000..ba907fef --- /dev/null +++ b/pkg/initHelper/rpc_server.go @@ -0,0 +1,51 @@ +package initHelper + +import ( + "context" + "fmt" + "github.com/TremblingV5/DouTok/pkg/dtviper" + "github.com/TremblingV5/DouTok/pkg/middleware" + "github.com/cloudwego/kitex/pkg/limit" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" + "net" +) + +/* + 返回初始化RPC客户端所需要的一些配置,减少这部分代码的重复 +*/ +func InitRPCServerArgs(config *dtviper.Config) ([]server.Option, func()) { + addr := config.Viper.GetString("Etcd.Address") + ":" + config.Viper.GetString("Etcd.Port") + + registry, err := etcd.NewEtcdRegistry([]string{addr}) + if err != nil { + panic(err) + } + + serverAddr, err := net.ResolveTCPAddr("tcp", config.Viper.GetString("Server.Address")+":"+config.Viper.GetString("Server.Port")) + if err != nil { + panic(err) + } + + p := provider.NewOpenTelemetryProvider( + provider.WithServiceName(config.Viper.GetString("Server.Name")), + provider.WithExportEndpoint(fmt.Sprintf("%s:%s", config.Viper.GetString("Otel.Host"), config.Viper.GetString("Otel.Port"))), + provider.WithInsecure(), + ) + + return []server.Option{ + server.WithServiceAddr(serverAddr), + server.WithMiddleware(middleware.CommonMiddleware), + server.WithMiddleware(middleware.ServerMiddleware), + server.WithRegistry(registry), + server.WithLimit(&limit.Option{MaxConnections: 1000, MaxQPS: 100}), // limit + server.WithMuxTransport(), + server.WithSuite(tracing.NewServerSuite()), + server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: config.Viper.GetString("Server.Name")}), + }, func() { + p.Shutdown(context.Background()) + } +} diff --git a/pkg/initHelper/user.go b/pkg/initHelper/user.go index 873a0d82..bc3eb75b 100644 --- a/pkg/initHelper/user.go +++ b/pkg/initHelper/user.go @@ -15,7 +15,7 @@ type UserClient struct { func InitUserRPCClient() *UserClient { config := dtviper.ConfigInit("DOUTOK_USER", "user") - c, err := userservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) + c, err := userservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(&config)...) if err != nil { panic(err) } diff --git a/pkg/initHelper/userDomain.go b/pkg/initHelper/userDomain.go deleted file mode 100644 index 1bb8e497..00000000 --- a/pkg/initHelper/userDomain.go +++ /dev/null @@ -1,55 +0,0 @@ -package initHelper - -import ( - "context" - "errors" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain" - "github.com/TremblingV5/DouTok/kitex_gen/userDomain/userdomainservice" - "github.com/TremblingV5/DouTok/pkg/dtviper" -) - -type UserDomainClient struct { - client userdomainservice.Client -} - -func InitUserDomainRPCClient() *UserDomainClient { - config := dtviper.ConfigInit("DOUTOK_USERDOMAIN", "userDomain") - c, err := userdomainservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) - if err != nil { - panic(err) - } - return &UserDomainClient{client: c} -} - -func (c *UserDomainClient) AddUser(ctx context.Context, req *userDomain.DoutokAddUserRequest) (*userDomain.DoutokAddUserResponse, error) { - resp, err := c.client.AddUser(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *UserDomainClient) CheckUser(ctx context.Context, req *userDomain.DoutokCheckUserRequest) (*userDomain.DoutokCheckUserResponse, error) { - resp, err := c.client.CheckUser(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *UserDomainClient) GetUserInfo(ctx context.Context, req *userDomain.DoutokGetUserInfoRequest) (*userDomain.DoutokGetUserInfoResponse, error) { - resp, err := c.client.GetUserInfo(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} diff --git a/pkg/initHelper/videoDomain.go b/pkg/initHelper/videoDomain.go deleted file mode 100644 index 77144b95..00000000 --- a/pkg/initHelper/videoDomain.go +++ /dev/null @@ -1,76 +0,0 @@ -package initHelper - -import ( - "context" - "errors" - - "github.com/TremblingV5/DouTok/kitex_gen/entity" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain" - "github.com/TremblingV5/DouTok/kitex_gen/videoDomain/videodomainservice" - "github.com/TremblingV5/DouTok/pkg/dtviper" -) - -type VideoDomainClient struct { - client videodomainservice.Client -} - -func InitVideoDomainRPCClient() *VideoDomainClient { - config := dtviper.ConfigInit("DOUTOK_VIDEODOMAIN", "videoDomain") - c, err := videodomainservice.NewClient(config.Viper.GetString("Server.Name"), InitRPCClientArgs(config)...) - if err != nil { - panic(err) - } - return &VideoDomainClient{client: c} -} - -func (c *VideoDomainClient) GetFeed(ctx context.Context, req *videoDomain.DoutokGetFeedRequest) (*videoDomain.DoutokGetFeedResponse, error) { - resp, err := c.client.GetFeed(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *VideoDomainClient) AddPublish(ctx context.Context, req *videoDomain.DoutokAddPublishRequest) (*videoDomain.DoutokAddPublishResponse, error) { - resp, err := c.client.AddPublish(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *VideoDomainClient) ListPublish(ctx context.Context, req *videoDomain.DoutokListPublishRequest) (*videoDomain.DoutokListPublishResponse, error) { - resp, err := c.client.ListPublish(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *VideoDomainClient) CountPublish(ctx context.Context, req *videoDomain.DoutokCountPublishRequest) (*videoDomain.DoutokCountPublishResponse, error) { - resp, err := c.client.CountPublish(ctx, req) - if err != nil { - return nil, err - } - if resp.StatusCode != 0 { - return nil, errors.New(resp.StatusMsg) - } - return resp, nil -} - -func (c *VideoDomainClient) GetVideoInfo(ctx context.Context, req *videoDomain.DoutokGetVideoInfoRequest) (*entity.Video, error) { - resp, err := c.client.GetVideoInfo(ctx, req) - if err != nil { - return nil, err - } - return resp, nil -} diff --git a/proto/api.proto b/proto/api.proto deleted file mode 100644 index 8bec7241..00000000 --- a/proto/api.proto +++ /dev/null @@ -1,318 +0,0 @@ -syntax = "proto3"; - -package api; - -option go_package = "api.yaml"; - -import "hz.proto"; - -// user -message DouyinUserRegisterRequest { - string username = 1[(api.vd) = "len($) < 32"]; // 注册用户名,最长32个字符 - string password = 2[(api.vd) = "len($) < 32"]; // 密码,最长32个字符 -} - -message DouyinUserRegisterResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - int64 user_id = 3; // 用户id - string token = 4; // 用户鉴权token -} - -message DouyinUserLoginRequest { - string username = 1[(api.vd) = "len($) < 32"]; // 登陆用户名,最长32个字符 - string password = 2[(api.vd) = "len($) < 32"]; // 密码,最长32个字符 -} - -message DouyinUserLoginResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - int64 user_id = 3; // 用户id - string token = 4; // 用户鉴权token -} - -message DouyinUserRequest { - int64 user_id = 1; // 用户id - string token = 2; // 用户鉴权token -} - -message DouyinUserResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - User user = 3; // 用户信息 -} - -message User { - int64 id = 1; // 用户id - string name = 2; // 用户名称 - int64 follow_count = 3; // 关注总数 - int64 follower_count = 4; // 粉丝总数 - bool is_follow = 5; // true-已关注,false-未关注 - string avatar = 6; // 用户头像Url - string background_image = 7; // 用户个人页顶部大图 - string signature = 8; // 个人简介 - int64 total_favorited = 9; // 获赞数量 - int64 work_count = 10; // 作品数量 - int64 favorite_count = 11; // 点赞数量 -} - -service UserService{ - rpc Register (DouyinUserRegisterRequest) returns (DouyinUserRegisterResponse){ - option (api.post) = "/douyin/user/register"; - } - rpc Login (DouyinUserLoginRequest) returns (DouyinUserLoginResponse){ - option (api.post) = "/douyin/user/login"; - } - rpc GetUserById (DouyinUserRequest) returns (DouyinUserResponse){ - option (api.get) = "/douyin/user"; - } -} - -// relation -message DouyinRelationActionRequest { - string token = 1; // 用户鉴权token - int64 to_user_id = 2; // 对方用户id - int32 action_type = 3; // 1-关注,2-取消关注 -} - -message DouyinRelationActionResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 -} - -message DouyinRelationFollowListRequest { - int64 user_id = 1; // 用户id - string token = 2; // 用户鉴权token -} - -message DouyinRelationFollowListResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - repeated User user_list = 3; // 用户信息列表 -} - -message DouyinRelationFollowerListRequest { - int64 user_id = 1; // 用户id - string token = 2; // 用户鉴权token -} - -message DouyinRelationFollowerListResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - repeated User user_list = 3; // 用户列表 -} - -message DouyinRelationFriendListRequest { - int64 user_id = 1; // 用户id - string token = 2; // 用户鉴权token -} - -message DouyinRelationFriendListResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - repeated FriendUser user_list = 3; // 用户列表 -} - -message FriendUser { - User user = 1; // 评论用户信息 - string message = 2; // 和该好友的最新聊天消息 - int64 msgType = 3; // message消息的类型,0 => 当前请求用户接收的消息, 1 => 当前请求用户发送的消息(用于聊天框显示一条信息) -} - -service RelationService{ - rpc RelationAction(DouyinRelationActionRequest) returns (DouyinRelationActionResponse){ - option (api.post) = "/douyin/relation/action"; - } //关注或取消关注 - rpc RelationFollowList(DouyinRelationFollowListRequest) returns (DouyinRelationFollowListResponse){ - option (api.get) = "/douyin/relation/follow/list"; - } //获取已关注用户的列表 - rpc RelationFollowerList(DouyinRelationFollowerListRequest) returns (DouyinRelationFollowerListResponse){ - option (api.get) = "/douyin/relation/follower/list"; - } //获取粉丝用户列表 - rpc RelationFriendList(DouyinRelationFriendListRequest) returns (DouyinRelationFriendListResponse){ - option (api.get) = "/douyin/relation/friend/list"; - } //获取好友列表 -} - -// feed -message DouyinFeedRequest { - int64 latest_time = 1; // 可选参数,限制返回视频的最新投稿时间戳,精确到秒,不填表示当前时间 - string token = 2; // 可选参数,登录用户设置 -} - -// 例如当前请求的latest_time为9:00,那么返回的视频列表时间戳为[8:55,7:40, 6:30, 6:00] -// 所有这些视频中,最早发布的是 6:00的视频,那么6:00作为下一次请求时的latest_time -// 那么下次请求返回的视频时间戳就会小于6:00 -message DouyinFeedResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - repeated Video video_list = 3; // 视频列表 - int64 next_time = 4; // 本次返回的视频中,发布最早的时间,作为下次请求时的latest_time -} - -message Video { - int64 id = 1; // 视频唯一标识 - User author = 2; // 视频作者信息 - string play_url = 3; // 视频播放地址 - string cover_url = 4; // 视频封面地址 - int64 favorite_count = 5; // 视频的点赞总数 - int64 comment_count = 6; // 视频的评论总数 - bool is_favorite = 7; // true-已点赞,false-未点赞 - string title = 8; // 视频标题 -} - -service FeedService{ - rpc GetUserFeed (DouyinFeedRequest) returns (DouyinFeedResponse){ - option (api.get) = "/douyin/feed"; - } //返回一个视频列表 -} - -// publish -message DouyinPublishActionRequest { - string token = 1; // 用户鉴权token - bytes data = 2; // 视频数据 - string title = 3; // 视频标题 -} - -message DouyinPublishActionResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 -} - -message DouyinPublishListRequest { - int64 user_id = 1; // 用户id - string token = 2; // 用户鉴权token -} - -message DouyinPublishListResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - repeated Video video_list = 3; // 用户发布的视频列表 -} - -service PublishService{ - rpc PublishAction(DouyinPublishActionRequest) returns (DouyinPublishActionResponse){ - option (api.post) = "/douyin/publish/action"; - } //发布视频操作 - rpc PublishList(DouyinPublishListRequest) returns (DouyinPublishListResponse){ - option (api.get) = "/douyin/publish/list"; - } // 获取用户已发布视频的列表 -} - -// message -message DouyinMessageChatRequest { - string token = 1; // 用户鉴权token - int64 to_user_id = 2; // 对方用户id - int64 pre_msg_time = 3; // 上次最新消息的时间 -} - -message DouyinMessageChatResponse { - int32 status_code = 1; // 状态码,0-成功,其他-失败 - string status_msg = 2; // 返回状态描述 - repeated Message message_list = 3; // 消息列表 -} - -message Message { - int64 id = 1; // 消息id - int64 to_user_id = 2; // 该消息接收者的id - int64 from_user_id =3; // 该消息发送者的id - string content = 4; // 消息内容 - string create_time = 5; // 消息创建时间 -} - -message DouyinMessageActionRequest { - string token = 1; // 用户鉴权token - int64 to_user_id = 2; // 对方用户id - int32 action_type = 3; // 1-发送消息 - string content = 4; // 消息内容 -} - -message DouyinMessageActionResponse { - int32 status_code = 1; // 状态码,0-成功,其他-失败 - string status_msg = 2; // 返回状态描述 -} - -service MessageService { - rpc MessageChat(DouyinMessageChatRequest) returns (DouyinMessageChatResponse){ - option (api.get) = "/douyin/message/chat"; - } // 聊天记录 - rpc MessageAction(DouyinMessageActionRequest) returns (DouyinMessageActionResponse){ - option (api.post) = "/douyin/message/action"; - } // 消息操作 -} - -// favorite -message DouyinFavoriteActionRequest { - string token = 1; // 用户鉴权token - int64 video_id = 2; // 视频id - int32 action_type = 3; // 1-点赞,2-取消点赞 -} - -message DouyinFavoriteActionResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 -} - -message DouyinFavoriteListRequest { - int64 user_id = 1; // 用户id - string token = 2; // 用户鉴权token -} - -message DouyinFavoriteListResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - repeated Video video_list = 3; // 用户点赞视频列表 -} - -service FavoriteService{ - rpc FavoriteAction(DouyinFavoriteActionRequest) returns (DouyinFavoriteActionResponse){ - option (api.post) = "/douyin/favorite/action"; - } //点赞或取消点赞 - rpc FavoriteList(DouyinFavoriteListRequest) returns (DouyinFavoriteListResponse){ - option (api.get) = "/douyin/favorite/list"; - } // 返回点赞视频列表 -} - -// comment -message DouyinCommentActionRequest { - string token = 1; // 用户鉴权token - int64 video_id = 2; // 视频id - int32 action_type = 3; // 1-发布评论,2-删除评论 - string comment_text = 4; // 用户填写的评论内容,在action_type=1的时候使用 - int64 comment_id = 5; // 要删除的评论id,在action_type=2的时候使用 -} - -message DouyinCommentActionResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - Comment comment = 3; // 评论成功返回评论内容,不需要重新拉取整个列表 -} - -message DouyinCommentListRequest { - string token = 1; // 用户鉴权token - int64 video_id = 2; // 视频id -} - -message DouyinCommentListResponse { - int32 status_code = 1; // 状态码,0-成功,其他值-失败 - string status_msg = 2; // 返回状态描述 - repeated Comment comment_list = 3; // 评论列表 -} - -message Comment { - int64 id = 1; // 视频评论id - User user =2; // 评论用户信息 - string content = 3; // 评论内容 - string create_date = 4; // 评论发布日期,格式 mm-dd - int64 like_count = 5; // 该评论点赞数 - int64 tease_count = 6; // 该评论diss数 -} - -service CommentService{ - rpc CommentAction(DouyinCommentActionRequest) returns (DouyinCommentActionResponse){ - option (api.post) = "/douyin/comment/action"; - } //评论操作 - rpc CommentList(DouyinCommentListRequest) returns (DouyinCommentListResponse){ - option (api.get) = "/douyin/comment/list"; - } //返回评论列表 -} \ No newline at end of file diff --git a/proto/comment.proto b/proto/comment.proto deleted file mode 100644 index cc3a0b0d..00000000 --- a/proto/comment.proto +++ /dev/null @@ -1,45 +0,0 @@ -syntax = "proto3"; -package comment; -option go_package = "comment"; - -import "entity.proto"; - -message douyin_comment_action_request { - int64 user_id = 1; // 用户id - int64 video_id = 2; // 视频id - int32 action_type = 3; // 1-发布评论,2-删除评论 - string comment_text = 4; // 用户填写的评论内容,在action_type=1的时候使用 - int64 comment_id = 5; // 要删除的评论id,在action_type=2的时候使用 -} - -message douyin_comment_action_response { - int32 status_code = 1; - string status_msg = 2; - entity.Comment comment = 3; // 评论成功返回评论内容,不需要重新拉取整个列表 -} - -message douyin_comment_list_request { - int64 video_id = 1; // 视频id -} - -message douyin_comment_list_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Comment comment_list = 3; // 评论列表 -} - -message douyin_comment_count_request { - repeated int64 video_id_list = 1; // 视频id所组成的列表 -} - -message douyin_comment_count_response { - int32 status_code = 1; - string status_msg = 2; - map result = 3; // key为视频的id,value为该视频的评论数 -} - -service CommentService{ - rpc CommentAction(douyin_comment_action_request) returns (douyin_comment_action_response); //评论操作 - rpc CommentList(douyin_comment_list_request) returns (douyin_comment_list_response); //返回评论列表 - // rpc CommentCount(douyin_comment_count_request) returns (douyin_comment_count_response); // 返回一个视频列表中各自的评论数量 -} \ No newline at end of file diff --git a/proto/commentDomain.proto b/proto/commentDomain.proto deleted file mode 100644 index 2e240b51..00000000 --- a/proto/commentDomain.proto +++ /dev/null @@ -1,51 +0,0 @@ -syntax = "proto3"; -package commentDomain; -option go_package = "commentDomain"; - -import "entity.proto"; - -message doutok_add_comment_req { - int64 video_id = 1; - int64 user_id = 2; - string comment_text = 3; -} - -message doutok_add_comment_resp { - int32 status_code = 1; - string status_msg = 2; - entity.Comment comment = 3; -} - -message doutok_rm_comment_req { - int64 user_id = 1; - int64 video_id = 2; - int64 comment_id = 3; -} - -message doutok_list_comment_req { - int64 video_id = 1; - int64 user_id = 2; -} - -message doutok_list_comment_resp { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Comment comment_list = 3; -} - -message doutok_count_comment_req { - repeated int64 video_id_list = 1; -} - -message doutok_count_comment_resp { - int32 status_code = 1; - string status_msg = 2; - map comment_count = 3; -} - -service CommentDomainService { - rpc AddComment(doutok_add_comment_req) returns (doutok_add_comment_resp); - rpc RmComment(doutok_rm_comment_req) returns (doutok_add_comment_resp); - rpc ListComment(doutok_list_comment_req) returns (doutok_list_comment_resp); - rpc CountComment(doutok_count_comment_req) returns (doutok_count_comment_resp); -} diff --git a/proto/favorite.proto b/proto/favorite.proto deleted file mode 100644 index f9f857b9..00000000 --- a/proto/favorite.proto +++ /dev/null @@ -1,54 +0,0 @@ -syntax = "proto3"; -package favorite; -option go_package = "favorite"; - -import "entity.proto"; - -message douyin_favorite_action_request { - int64 user_id = 1; // 用户id - int64 video_id = 2; // 视频id - int32 action_type = 3; // 1-点赞,2-取消点赞 -} - -message douyin_favorite_action_response { - int32 status_code = 1; - string status_msg = 2; -} - -message douyin_favorite_list_request { - int64 user_id = 1; // 用户id -} - -message douyin_favorite_list_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Video video_list = 3; // 用户点赞视频列表 -} - -message douyin_is_favorite_request { - int64 user_id = 1; // 要判断的主要用户 - repeated int64 video_id_list = 2; // 要判断的视频列表 -} - -message douyin_is_favorite_response { - int32 status_code = 1; - string status_msg = 2; - map result = 3; // key为视频id,value为是否存在喜欢关系 -} - -message douyin_favorite_count_request { - repeated int64 video_id_list = 1; // 视频id所组成的列表 -} - -message douyin_favorite_count_response { - int32 status_code = 1; - string status_msg = 2; - map result = 3; // key为视频的id,value为该视频的点赞数 -} - -service FavoriteService{ - rpc FavoriteAction(douyin_favorite_action_request) returns (douyin_favorite_action_response); //点赞或取消点赞 - rpc FavoriteList(douyin_favorite_list_request) returns (douyin_favorite_list_response); // 返回点赞视频列表 - // rpc IsFavorite(douyin_is_favorite_request) returns (douyin_is_favorite_response); // 判断用户对视频是否有喜欢关系 - // rpc FavoriteCount(douyin_favorite_count_request) returns (douyin_favorite_count_response); // 返回一个视频列表中每个视频的点赞数 -} \ No newline at end of file diff --git a/proto/favoriteDomain.proto b/proto/favoriteDomain.proto deleted file mode 100644 index ec6874f6..00000000 --- a/proto/favoriteDomain.proto +++ /dev/null @@ -1,64 +0,0 @@ -syntax = "proto3"; -package favoriteDomain; -option go_package = "favoriteDomain"; - -import "entity.proto"; - -message doutok_add_fav_request { - int64 user_id = 1; - int64 video_id = 2; -} - -message doutok_add_fav_response { - int32 status_code = 1; - string status_msg = 2; -} - -message doutok_rm_fav_request { - int64 user_id = 1; - int64 video_id = 2; -} - -message doutok_rm_fav_response { - int32 status_code = 1; - string status_msg = 2; -} - -message doutok_list_fav_request { - int64 user_id = 1; -} - -message doutok_list_fav_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Video video_list = 3; -} - -message doutok_is_fav_request { - int64 user_id = 1; - repeated int64 video_id = 2; -} - -message doutok_is_fav_response { - int32 status_code = 1; - string status_msg = 2; - map is_fav = 3; -} - -message doutok_count_fav_request { - repeated int64 user_id_list = 1; -} - -message doutok_count_fav_response { - int32 status_code = 1; - string status_msg = 2; - map count_fav = 3; -} - -service FavoriteDomainService { - rpc AddFavorite(doutok_add_fav_request) returns (doutok_add_fav_response); - rpc RmFavorite(doutok_rm_fav_request) returns (doutok_rm_fav_response); - rpc ListFavorite(doutok_list_fav_request) returns (doutok_list_fav_response); - rpc IsFavorite(doutok_is_fav_request) returns (doutok_is_fav_response); - rpc CountFavorite(doutok_count_fav_request) returns (doutok_count_fav_response); -} diff --git a/proto/feed.proto b/proto/feed.proto deleted file mode 100644 index ea53796e..00000000 --- a/proto/feed.proto +++ /dev/null @@ -1,30 +0,0 @@ -syntax = "proto3"; -package feed; -option go_package = "feed"; - -import "entity.proto"; - -message douyin_feed_request { - int64 latest_time = 1; // 可选参数,限制返回视频的最新投稿时间戳,精确到秒,不填表示当前时间 - int64 user_id = 2; // 请求feed流的用户id,若没有则置为0 -} - -// 例如当前请求的latest_time为9:00,那么返回的视频列表时间戳为[8:55,7:40, 6:30, 6:00] -// 所有这些视频中,最早发布的是 6:00的视频,那么6:00作为下一次请求时的latest_time -// 那么下次请求返回的视频时间戳就会小于6:00 -message douyin_feed_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Video video_list = 3; // 视频列表 - int64 next_time = 4; // 本次返回的视频中,发布最早的时间,作为下次请求时的latest_time -} - -message video_id_request{ - int64 video_id = 1 ; - int64 search_id = 2 ; -} - -service FeedService{ - rpc GetUserFeed (douyin_feed_request) returns (douyin_feed_response); //返回一个视频列表 - rpc GetVideoById (video_id_request) returns (entity.Video); // 根据视频id返回一个视频 -} \ No newline at end of file diff --git a/proto/hz.proto b/proto/hz.proto deleted file mode 100644 index 69cb465b..00000000 --- a/proto/hz.proto +++ /dev/null @@ -1,43 +0,0 @@ -syntax = "proto2"; - -package api; - -import "google/protobuf/descriptor.proto"; - -option go_package = "/api.yaml"; - -extend google.protobuf.FieldOptions { - optional string raw_body = 50101; - optional string query = 50102; - optional string header = 50103; - optional string cookie = 50104; - optional string body = 50105; - optional string path = 50106; - optional string vd = 50107; - optional string form = 50108; - optional string go_tag = 51001; - optional string js_conv = 50109; -} - -extend google.protobuf.MethodOptions { - optional string get = 50201; - optional string post = 50202; - optional string put = 50203; - optional string delete = 50204; - optional string patch = 50205; - optional string options = 50206; - optional string head = 50207; - optional string any = 50208; - optional string gen_path = 50301; - optional string api_version = 50302; - optional string tag = 50303; - optional string name = 50304; - optional string api_level = 50305; - optional string serializer = 50306; - optional string param = 50307; - optional string baseurl = 50308; -} - -extend google.protobuf.EnumValueOptions { - optional int32 http_code = 50401; -} diff --git a/proto/message.proto b/proto/message.proto deleted file mode 100644 index 155e2752..00000000 --- a/proto/message.proto +++ /dev/null @@ -1,46 +0,0 @@ -syntax = "proto3"; -package message; -option go_package = "message"; - -import "entity.proto"; - -message douyin_message_chat_request { - int64 to_user_id = 1; // 对方用户id - int64 user_id = 2; // 发出动作的user id - int64 pre_msg_time = 3; // 上次最新消息的时间 -} - -message douyin_message_chat_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Message message_list = 3; // 消息列表 -} - -message douyin_message_action_request { - int64 to_user_id = 1; // 对方用户id - int64 user_id = 2; // 发消息的user id - int32 action_type = 3; // 1-发送消息 - string content = 4; // 消息内容 -} - -message douyin_message_action_response { - int32 status_code = 1; - string status_msg = 2; -} - -message douyin_friend_list_message_request { - int64 user_id = 1; // 要判断的主要用户 - repeated int64 friend_id_list = 2; // 要判断的好友id列表 -} - -message douyin_friend_list_message_response { - int32 status_code = 1; - string status_msg = 2; - map result = 3; // key 为好友id,value 为和该好友的最新聊天消息 -} - -service MessageService { - rpc MessageChat(douyin_message_chat_request) returns (douyin_message_chat_response); // 聊天记录 - rpc MessageAction(douyin_message_action_request) returns (douyin_message_action_response); // 消息操作 - rpc MessageFriendList(douyin_friend_list_message_request) returns (douyin_friend_list_message_response); // 最新消息 -} diff --git a/proto/messageDomain.proto b/proto/messageDomain.proto deleted file mode 100644 index c5bd6f6d..00000000 --- a/proto/messageDomain.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; -package messageDomain; -option go_package = "messageDomain"; - -import "entity.proto"; - -message doutok_add_message_request { - int64 to_user_id = 1; // 对方用户id - int64 user_id = 2; // 发消息的user id - int32 action_type = 3; // 1-发送消息 - string content = 4; // 消息内容 -} - -message doutok_add_message_response { - int32 status_code = 1; - string status_msg = 2; -} - -message doutok_list_message_request { - int64 to_user_id = 1; // 对方用户id - int64 user_id = 2; // 发出动作的user id - int64 pre_msg_time = 3; // 上次最新消息的时间 -} - -message doutok_list_message_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Message message = 3; -} - -service MessageDomainService { - rpc AddMessage(doutok_add_message_request) returns (doutok_add_message_response); - rpc ListMessage(doutok_list_message_request) returns (doutok_list_message_response); -} diff --git a/proto/publish.proto b/proto/publish.proto deleted file mode 100644 index a9e2a324..00000000 --- a/proto/publish.proto +++ /dev/null @@ -1,32 +0,0 @@ -syntax = "proto3"; -package publish; -option go_package = "publish"; - -import "entity.proto"; - -message douyin_publish_action_request { - bytes data = 1; // 视频数据 - string title = 2; // 视频标题 - int64 user_id = 3; // 发布视频的user id - string name = 4; // 发布视频的user name -} - -message douyin_publish_action_response { - int32 status_code = 1; - string status_msg = 2; -} - -message douyin_publish_list_request { - int64 user_id = 1; // 用户id -} - -message douyin_publish_list_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Video video_list = 3; // 用户发布的视频列表 -} - -service PublishService{ - rpc PublishAction(douyin_publish_action_request) returns (douyin_publish_action_response); //发布视频操作 - rpc PublishList(douyin_publish_list_request) returns (douyin_publish_list_response);// 获取用户已发布视频的列表 -} \ No newline at end of file diff --git a/proto/relation.proto b/proto/relation.proto deleted file mode 100644 index d4e6211a..00000000 --- a/proto/relation.proto +++ /dev/null @@ -1,65 +0,0 @@ -syntax = "proto3"; -package relation; -option go_package = "relation"; - -import "entity.proto"; - -message douyin_relation_action_request { - int64 user_id = 1; // 用户id - int64 to_user_id = 2; // 对方用户id - int32 action_type = 3; // 1-关注,2-取消关注 -} - -message douyin_relation_action_response { - int32 status_code = 1; - string status_msg = 2; -} - -message douyin_relation_follow_list_request { - int64 user_id = 1; // 用户id -} - -message douyin_relation_follow_list_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.User user_list = 3; // 用户信息列表 -} - -message douyin_relation_follower_list_request { - int64 user_id = 1; // 用户id -} - -message douyin_relation_follower_list_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.User user_list = 3; // 用户列表 -} - -message douyin_relation_friend_list_request { - int64 user_id = 1; // 用户id -} - -message douyin_relation_friend_list_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.FriendUser user_list = 3; // 用户列表 -} - -message douyin_relation_count_request { - int64 user_id = 1; -} - -message douyin_relation_count_response { - int32 status_code = 1; - string status_msg = 2; - int64 follow_count = 3; // 关注数 - int64 follower_count = 4; // 粉丝数 -} - -service RelationService{ - rpc RelationAction(douyin_relation_action_request) returns (douyin_relation_action_response); //关注或取消关注 - rpc RelationFollowList(douyin_relation_follow_list_request) returns (douyin_relation_follow_list_response); //获取已关注用户的列表 - rpc RelationFollowerList(douyin_relation_follower_list_request) returns (douyin_relation_follower_list_response); //获取粉丝用户列表 - rpc RelationFriendList(douyin_relation_friend_list_request) returns (douyin_relation_friend_list_response); //获取粉丝用户列表 - // rpc GetFollowCount(douyin_relation_count_request) returns (douyin_relation_count_response); // 查询一个user的关注数和粉丝数 -} \ No newline at end of file diff --git a/proto/relationDomain.proto b/proto/relationDomain.proto deleted file mode 100644 index d06d215c..00000000 --- a/proto/relationDomain.proto +++ /dev/null @@ -1,54 +0,0 @@ -syntax = "proto3"; -package relationDomain; -option go_package = "relationDomain"; - -import "entity.proto"; - -message doutok_add_relation_request { - int64 user_id = 1; // 用户id - int64 to_user_id = 2; // 对方用户id -} - -message doutok_add_relation_response { - int32 status_code = 1; - string status_msg = 2; -} - -message doutok_rm_relation_request { - int64 user_id = 1; // 用户id - int64 to_user_id = 2; // 对方用户id -} - -message doutok_rm_relation_response { - int32 status_code = 1; - string status_msg = 2; -} - -message doutok_list_relation_request { - int64 user_id = 1; // 用户id - int64 action_type = 2; // 请求类型,0对应粉丝列表,1对应关注列表,2对应朋友列表 -} - -message doutok_list_relation_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.User user_list = 3; // 用户列表 -} - -message doutok_count_relation_request { - repeated int64 user_id = 1; // 用户id - int64 action_type = 2; // 请求类型:0对应粉丝数,1对应关注数,2对应朋友数 -} - -message doutok_count_relation_response { - int32 status_code = 1; - string status_msg = 2; - map result = 3; -} - -service RelationDomainService { - rpc AddRelation(doutok_add_relation_request) returns (doutok_add_relation_response); - rpc RmRelation(doutok_rm_relation_request) returns (doutok_rm_relation_response); - rpc ListRelation(doutok_list_relation_request) returns (doutok_list_relation_response); - rpc CountRelation(doutok_count_relation_request) returns (doutok_count_relation_response); -} diff --git a/proto/user.proto b/proto/user.proto deleted file mode 100644 index 2b22d36d..00000000 --- a/proto/user.proto +++ /dev/null @@ -1,54 +0,0 @@ -syntax = "proto3"; -package user; -option go_package = "user"; - -import "entity.proto"; - -message douyin_user_register_request { - string username = 1; // 注册用户名,最长32个字符 - string password = 2; // 密码,最长32个字符 -} - -message douyin_user_register_response { - int32 status_code = 1; - string status_msg = 2; - int64 user_id = 3; // 用户id -} - -message douyin_user_login_request { - string username = 1; // 登陆用户名,最长32个字符 - string password = 2; // 密码,最长32个字符 -} - -message douyin_user_login_response { - int32 status_code = 1; - string status_msg = 2; - int64 user_id = 3; // 用户id -} - -message douyin_user_request { - int64 user_id = 1; // 用户id -} - -message douyin_user_response { - int32 status_code = 1; - string status_msg = 2; - entity.User user = 3; // 用户信息 -} - -message douyin_user_list_request { - repeated int64 user_list = 1; // 用户列表 -} - -message douyin_user_list_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.User user_list = 3; // 用户信息 -} - -service UserService{ - rpc Register (douyin_user_register_request) returns (douyin_user_register_response); - rpc Login (douyin_user_login_request) returns (douyin_user_login_response); - rpc GetUserById (douyin_user_request) returns (douyin_user_response); - // rpc GetUserListByIds (douyin_user_list_request) returns (douyin_user_list_response); -} diff --git a/proto/userDomain.proto b/proto/userDomain.proto deleted file mode 100644 index fa49d70a..00000000 --- a/proto/userDomain.proto +++ /dev/null @@ -1,43 +0,0 @@ -syntax = "proto3"; -package userDomain; -option go_package = "userDomain"; - -import "entity.proto"; - -message doutok_add_user_request { - string username = 1; - string password = 2; -} - -message doutok_add_user_response { - int32 status_code = 1; - string status_msg = 2; - int64 user_id = 3; -} - -message doutok_check_user_request { - string username = 1; - string password = 2; -} - -message doutok_check_user_response { - int32 status_code = 1; - string status_msg = 2; - int64 user_id = 3; -} - -message doutok_get_user_info_request { - repeated int64 user_id = 1; -} - -message doutok_get_user_info_response { - int32 status_code = 1; - string status_msg = 2; - map user_list = 3; -} - -service UserDomainService { - rpc AddUser(doutok_add_user_request) returns (doutok_add_user_response); - rpc CheckUser(doutok_check_user_request) returns (doutok_check_user_response); - rpc GetUserInfo(doutok_get_user_info_request) returns (doutok_get_user_info_response); -} diff --git a/proto/videoDomain.proto b/proto/videoDomain.proto deleted file mode 100644 index 1944fbd1..00000000 --- a/proto/videoDomain.proto +++ /dev/null @@ -1,61 +0,0 @@ -syntax = "proto3"; -package videoDomain; -option go_package = "videoDomain"; - -import "entity.proto"; - -message doutok_get_feed_request { - int64 latest_time = 1; // 可选参数,限制返回视频的最新投稿时间戳,精确到秒,不填表示当前时间 - int64 user_id = 2; // 请求feed流的用户id,若没有则置为0 -} - -message doutok_get_feed_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Video video_list = 3; - int64 next_time = 4; -} - -message doutok_add_publish_request { - bytes data = 1; - string title = 2; - int64 user_id = 3; - string name = 4; -} - -message doutok_add_publish_response { - int32 status_code = 1; - string status_msg = 2; -} - -message doutok_list_publish_request { - int64 user_id = 1; -} - -message doutok_list_publish_response { - int32 status_code = 1; - string status_msg = 2; - repeated entity.Video video_list = 3; -} - -message doutok_count_publish_request { - repeated int64 user_id = 1; -} - -message doutok_count_publish_response { - int32 status_code = 1; - string status_msg = 2; - map result = 3; -} - -message doutok_get_video_info_request { - int64 video_id = 1; -} - -service VideoDomainService { - rpc GetFeed(doutok_get_feed_request) returns (doutok_get_feed_response); - rpc AddPublish(doutok_add_publish_request) returns (doutok_add_publish_response); - rpc ListPublish(doutok_list_publish_request) returns (doutok_list_publish_response); - rpc CountPublish(doutok_count_publish_request) returns (doutok_count_publish_response); - rpc GetVideoInfo(doutok_get_video_info_request) returns (entity.Video); -}