Commit f1308ddd authored by johnnyjoy's avatar johnnyjoy

refactor: update part of resource identifier

parent cda18a37
......@@ -116,8 +116,8 @@ service MemoService {
}
// DeleteMemoReaction deletes a reaction for a memo.
rpc DeleteMemoReaction(DeleteMemoReactionRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {delete: "/api/v1/reactions/{reaction_id}"};
option (google.api.method_signature) = "reaction_id";
option (google.api.http) = {delete: "/api/v1/reactions/{id}"};
option (google.api.method_signature) = "id";
}
}
......@@ -336,5 +336,7 @@ message UpsertMemoReactionRequest {
}
message DeleteMemoReactionRequest {
int32 reaction_id = 1;
// The id of the reaction.
// Refer to the `Reaction.id`.
int32 id = 1;
}
......@@ -11,6 +11,8 @@ message Reaction {
// Format: users/{user}
string creator = 2;
// The content identifier.
// For memo, it should be the `Memo.name`.
string content_id = 3;
string reaction_type = 4;
......
This diff is collapsed.
......@@ -703,13 +703,13 @@ func request_MemoService_DeleteMemoReaction_0(ctx context.Context, marshaler run
metadata runtime.ServerMetadata
err error
)
val, ok := pathParams["reaction_id"]
val, ok := pathParams["id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reaction_id")
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
}
protoReq.ReactionId, err = runtime.Int32(val)
protoReq.Id, err = runtime.Int32(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reaction_id", err)
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
}
msg, err := client.DeleteMemoReaction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
......@@ -721,13 +721,13 @@ func local_request_MemoService_DeleteMemoReaction_0(ctx context.Context, marshal
metadata runtime.ServerMetadata
err error
)
val, ok := pathParams["reaction_id"]
val, ok := pathParams["id"]
if !ok {
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reaction_id")
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id")
}
protoReq.ReactionId, err = runtime.Int32(val)
protoReq.Id, err = runtime.Int32(val)
if err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reaction_id", err)
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err)
}
msg, err := server.DeleteMemoReaction(ctx, &protoReq)
return msg, metadata, err
......@@ -1065,7 +1065,7 @@ func RegisterMemoServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MemoService/DeleteMemoReaction", runtime.WithHTTPPathPattern("/api/v1/reactions/{reaction_id}"))
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/memos.api.v1.MemoService/DeleteMemoReaction", runtime.WithHTTPPathPattern("/api/v1/reactions/{id}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
......@@ -1395,7 +1395,7 @@ func RegisterMemoServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MemoService/DeleteMemoReaction", runtime.WithHTTPPathPattern("/api/v1/reactions/{reaction_id}"))
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/memos.api.v1.MemoService/DeleteMemoReaction", runtime.WithHTTPPathPattern("/api/v1/reactions/{id}"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
......@@ -1428,7 +1428,7 @@ var (
pattern_MemoService_ListMemoComments_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "memos", "name", "comments"}, ""))
pattern_MemoService_ListMemoReactions_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "memos", "name", "reactions"}, ""))
pattern_MemoService_UpsertMemoReaction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 2, 5, 3, 2, 4}, []string{"api", "v1", "memos", "name", "reactions"}, ""))
pattern_MemoService_DeleteMemoReaction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "reactions", "reaction_id"}, ""))
pattern_MemoService_DeleteMemoReaction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"api", "v1", "reactions", "id"}, ""))
)
var (
......
......@@ -25,7 +25,9 @@ type Reaction struct {
Id int32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
// The name of the creator.
// Format: users/{user}
Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"`
Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"`
// The content identifier.
// For memo, it should be the `Memo.name`.
ContentId string `protobuf:"bytes,3,opt,name=content_id,json=contentId,proto3" json:"content_id,omitempty"`
ReactionType string `protobuf:"bytes,4,opt,name=reaction_type,json=reactionType,proto3" json:"reaction_type,omitempty"`
unknownFields protoimpl.UnknownFields
......
......@@ -367,7 +367,7 @@ paths:
type: string
tags:
- MemoService
/api/v1/reactions/{reactionId}:
/api/v1/reactions/{id}:
delete:
summary: DeleteMemoReaction deletes a reaction for a memo.
operationId: MemoService_DeleteMemoReaction
......@@ -382,7 +382,10 @@ paths:
schema:
$ref: '#/definitions/googlerpcStatus'
parameters:
- name: reactionId
- name: id
description: |-
The id of the reaction.
Refer to the `Reaction.id`.
in: path
required: true
type: integer
......@@ -2911,6 +2914,9 @@ definitions:
Format: users/{user}
contentId:
type: string
description: |-
The content identifier.
For memo, it should be the `Memo.name`.
reactionType:
type: string
v1ReferencedContentNode:
......
......@@ -56,7 +56,7 @@ func (s *APIV1Service) UpsertMemoReaction(ctx context.Context, request *v1pb.Ups
func (s *APIV1Service) DeleteMemoReaction(ctx context.Context, request *v1pb.DeleteMemoReactionRequest) (*emptypb.Empty, error) {
if err := s.Store.DeleteReaction(ctx, &store.DeleteReaction{
ID: request.ReactionId,
ID: request.Id,
}); err != nil {
return nil, status.Errorf(codes.Internal, "failed to delete reaction")
}
......
......@@ -41,7 +41,7 @@ const ReactionSelector = (props: Props) => {
(reaction) => reaction.reactionType === reactionType && reaction.creator === currentUser.name,
);
for (const reaction of reactions) {
await memoServiceClient.deleteMemoReaction({ reactionId: reaction.id });
await memoServiceClient.deleteMemoReaction({ id: reaction.id });
}
} else {
await memoServiceClient.upsertMemoReaction({
......
......@@ -55,7 +55,7 @@ const ReactionView = (props: Props) => {
(reaction) => reaction.reactionType === reactionType && reaction.creator === currentUser.name,
);
for (const reaction of reactions) {
await memoServiceClient.deleteMemoReaction({ reactionId: reaction.id });
await memoServiceClient.deleteMemoReaction({ id: reaction.id });
}
}
} catch (error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment