ch logika
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

This commit is contained in:
guwandyk committed 2026-09-18 11:53:37 +05:00
1 parent e0d03730de
commit d3e188affe
28 files changed
+405 -656

No files matched your search

+10
View File
@@ -110,6 +110,7 @@ func (h *handler) getByID(c *gin.Context) {
// @Param body body CreateCurrencyDTO true "Currency rate payload"
// @Success 201 {object} CurrencyDTO
// @Failure 400 {object} appresult.AppError
// @Failure 409 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
// @Router /currencies [post]
func (h *handler) create(c *gin.Context) {
@@ -122,6 +123,10 @@ func (h *handler) create(c *gin.Context) {
dto.CreatedBy = currentUserID(c)
item, err := h.repository.Create(c.Request.Context(), dto)
if errors.Is(err, ErrDuplicate) {
c.JSON(http.StatusConflict, appresult.ErrDuplicate)
return
}
if err != nil {
h.logger.Errorf("create currency failed: %v", err)
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)
@@ -143,6 +148,7 @@ func (h *handler) create(c *gin.Context) {
// @Success 200 {object} CurrencyDTO
// @Failure 400 {object} appresult.AppError
// @Failure 404 {object} appresult.AppError
// @Failure 409 {object} appresult.AppError
// @Failure 500 {object} appresult.AppError
// @Router /currencies/{id} [put]
func (h *handler) update(c *gin.Context) {
@@ -165,6 +171,10 @@ func (h *handler) update(c *gin.Context) {
c.JSON(http.StatusNotFound, appresult.ErrNotFound)
return
}
if errors.Is(err, ErrDuplicate) {
c.JSON(http.StatusConflict, appresult.ErrDuplicate)
return
}
if err != nil {
h.logger.Errorf("update currency failed: %v", err)
c.JSON(http.StatusInternalServerError, appresult.ErrInternalServer)