update for latest micro changes

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-03-25 22:54:25 +03:00
parent ec5c6c591d
commit c362702c40
17 changed files with 1106 additions and 1043 deletions

View File

@@ -17,18 +17,18 @@ func (h *Handler) CommentCreate(ctx context.Context, req *pb.CommentCreateReq, r
err := req.Validate()
if err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "validation error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
var com *models.Comment
if com, err = h.store.CommentCreate(ctx, req); err != nil {
logger.Error(ctx, err)
if errors.Is(err, sql.ErrNoRows) {
httpsrv.SetRspCode(ctx, http.StatusNotFound)
return httpsrv.SetError(NewNotFoundError(err))
}
logger.Error(ctx, "comment create error", err)
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
return httpsrv.SetError(NewInternalError(err))
}

View File

@@ -16,17 +16,18 @@ func (h *Handler) CommentDelete(ctx context.Context, req *pb.CommentDeleteReq, r
err := req.Validate()
if err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "validate error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
if err = h.store.CommentDelete(ctx, req); err != nil {
logger.Error(ctx, err)
if errors.Is(err, sql.ErrNoRows) {
httpsrv.SetRspCode(ctx, http.StatusNotFound)
return httpsrv.SetError(NewNotFoundError(err))
}
logger.Error(ctx, "comment delete error", err)
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
return httpsrv.SetError(NewInternalError(err))
}

View File

@@ -15,14 +15,14 @@ func (h *Handler) CommentList(ctx context.Context, req *pb.CommentListReq, rsp *
err := req.Validate()
if err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "validate error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
comments, err := h.store.CommentList(ctx, req)
if err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "comment list error", err)
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
return httpsrv.SetError(NewInternalError(err))
}

View File

@@ -15,14 +15,14 @@ func (h *Handler) ModuleList(ctx context.Context, req *pb.ModuleListReq, rsp *pb
err := req.Validate()
if err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "validate error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
modules, err := h.store.ModuleList(ctx, req)
if err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "module list error", err)
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
return httpsrv.SetError(NewInternalError(err))
}

View File

@@ -14,14 +14,14 @@ func (h *Handler) PackageCreate(ctx context.Context, req *pb.PackageCreateReq, r
logger.Debug(ctx, "PackagesCreate handler start")
if err := req.Validate(); err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "validate error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
pkg, err := h.store.PackageCreate(ctx, req)
if err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "package create error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}

View File

@@ -13,13 +13,13 @@ func (h *Handler) PackageDelete(ctx context.Context, req *pb.PackageDeleteReq, r
logger.Debug(ctx, "Start UpdatePackage")
if err := req.Validate(); err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "validate error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
if err := h.store.PackageDelete(ctx, req); err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "package delete error", err)
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
return httpsrv.SetError(NewInternalError(err))
}

View File

@@ -14,14 +14,14 @@ func (h *Handler) PackageLookup(ctx context.Context, req *pb.PackageLookupReq, r
logger.Debug(ctx, "Start PackagesLookup")
if err := req.Validate(); err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "validate error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
pkg, err := h.store.PackageLookup(ctx, req)
if err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "package lookup", err)
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
return httpsrv.SetError(NewInternalError(err))
}

View File

@@ -14,14 +14,14 @@ func (h *Handler) PackageUpdate(ctx context.Context, req *pb.PackageUpdateReq, r
logger.Debug(ctx, "Start UpdatePackage")
if err := req.Validate(); err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "validate error", err)
httpsrv.SetRspCode(ctx, http.StatusBadRequest)
return httpsrv.SetError(NewValidationError(err))
}
pkg, err := h.store.PackageUpdate(ctx, req)
if err != nil {
logger.Error(ctx, err)
logger.Error(ctx, "package update error", err)
httpsrv.SetRspCode(ctx, http.StatusInternalServerError)
return httpsrv.SetError(NewInternalError(err))
}