Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Comment service #16

Merged
merged 9 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions constant/biz/comment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package biz

import httpStatus "github.com/cloudwego/hertz/pkg/protocol/consts"

const (
InvalidCommentActionType = 400001
VideoNotFound = 400002
ActorIDNotMatch = 403001
UnableToCreateComment = 500001
UnableToDeleteComment = 500002
UnableToQueryVideo = 500003
UnableToQueryComment = 500004
UnableToQueryUser = 500005
)

var (
UnauthorizedError = GWError{HTTPStatusCode: httpStatus.StatusUnauthorized, StatusCode: 400003, StatusMsg: "Unauthorized"}

BadRequestError = GWError{HTTPStatusCode: httpStatus.StatusBadRequest, StatusCode: 400004, StatusMsg: "Bad request"}

InternalServerError = GWError{HTTPStatusCode: httpStatus.StatusInternalServerError, StatusCode: 500006, StatusMsg: "Internal server error"}
)
1 change: 1 addition & 0 deletions constant/biz/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ var (
OkStatusMsg = "OK"

BadRequestStatusMsg = "Unable to finish request, please check your parameters. If you think this is a bug, please contact us."
ForbiddenStatusMsg = "You are not allowed to access this resource."
InternalServerErrorStatusMsg = "The server had an error while processing your request. Sorry about that!"
)
3 changes: 3 additions & 0 deletions constant/config/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ const FeedServiceAddr = ":40129"

const UserServiceName = "toktik-user"
const UserServiceAddr = ":40130"

const CommentServiceName = "toktik-comment-api"
const CommentServiceAddr = ":40131"
52 changes: 52 additions & 0 deletions idl/comment.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
syntax = "proto3";
package douyin.comment;
option go_package = "douyin/comment";

import "user.proto";

message Comment {
uint32 id = 1;
user.User user = 2;
string content = 3;
string create_date = 4;
}

enum ActionCommentType {
ACTION_COMMENT_TYPE_UNSPECIFIED = 0; // Only for protobuf compatibility
ACTION_COMMENT_TYPE_ADD = 1;
ACTION_COMMENT_TYPE_DELETE = 2;
}

message ActionCommentRequest {
uint32 actor_id = 1;
uint32 video_id = 2;
ActionCommentType action_type = 3;
oneof action {
string comment_text = 4;
uint32 comment_id = 5;
}
}

message ActionCommentResponse {
uint32 status_code = 1;
optional string status_msg = 2;
optional Comment comment = 3;
}


message ListCommentRequest {
uint32 actor_id = 1;
uint32 video_id = 2;
}

message ListCommentResponse {
uint32 status_code = 1;
optional string status_msg = 2;
repeated Comment comment_list = 3;
}


service CommentService {
rpc ActionComment(ActionCommentRequest) returns (ActionCommentResponse);
rpc ListComment(ListCommentRequest) returns (ListCommentResponse);
}
Loading