add GetComments and update proto

This commit is contained in:
2023-08-14 14:27:29 +03:00
parent 85d1191dd9
commit 37e92e8473
16 changed files with 850 additions and 142 deletions

View File

@@ -117,6 +117,13 @@ func (h *Handler) GetModule(ctx context.Context, req *pb.GetModuleReq, rsp *pb.G
logger := h.svc.Logger()
logger.Debug(ctx, "Start GetModule")
err := req.Validate()
if err != nil {
logger.Error(ctx, err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
modules, err := h.store.GetModule(ctx, req)
if err != nil {
logger.Error(ctx, err)
@@ -130,6 +137,30 @@ func (h *Handler) GetModule(ctx context.Context, req *pb.GetModuleReq, rsp *pb.G
return nil
}
func (h *Handler) GetComments(ctx context.Context, req *pb.GetCommentsReq, rsp *pb.GetCommentsRsp) error {
logger := h.svc.Logger()
logger.Debug(ctx, "Start GetModule")
err := req.Validate()
if err != nil {
logger.Error(ctx, err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
comments, err := h.store.GetComment(ctx, req)
if err != nil {
logger.Error(ctx, err)
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
return httpsrv.SetError(NewInternalError(err))
}
rsp.Comments = comments.Decode()
logger.Debug(ctx, "Success finish getModule")
return nil
}
func NewHandler(svc micro.Service, client cligit.Client) *Handler {
h := &Handler{
svc: svc,