add GetComments and update proto
This commit is contained in:
@@ -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,
|
||||
|
Reference in New Issue
Block a user