新增单词管理后台,分类有单词时禁止删除,支持 Docker 一键部署
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"github.com/fish/language/backend/internal/services"
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
@@ -30,6 +31,9 @@ func MapError(err error) (status int, code int, message string) {
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return http.StatusNotFound, 10001, "resource not found"
|
||||
}
|
||||
if errors.Is(err, services.ErrCategoryNotEmpty) {
|
||||
return http.StatusConflict, 10005, "category has words and cannot be deleted"
|
||||
}
|
||||
return http.StatusInternalServerError, 10000, "internal server error"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user