Skip to content

Commit

Permalink
Merge pull request #16 from Toktik-Team/feat-comment-service
Browse files Browse the repository at this point in the history
  • Loading branch information
nicognaW authored Feb 14, 2023
2 parents be6772d + d541154 commit 261a99d
Show file tree
Hide file tree
Showing 24 changed files with 3,217 additions and 4 deletions.
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

0 comments on commit 261a99d

Please sign in to comment.