Migrating to sqlc

This commit is contained in:
2025-08-04 22:31:29 +01:00
parent f6152188e5
commit b194818c93
25 changed files with 629 additions and 202 deletions
+6 -5
View File
@@ -1,6 +1,7 @@
package pages
import (
"database/sql"
"expenses/expenses"
"encoding/json"
@@ -31,19 +32,19 @@ func categoriesGlobalPage(c *gin.Context) {
}
func categoryPage(c *gin.Context) {
categoryID, err := strconv.Atoi(c.Param("id"))
categoryID, err := strconv.ParseInt(c.Param("id"), 10, 16)
if err != nil {
NotFoundView(c, "No such category")
return
}
category, err := expenses.GetCategory(categoryID)
if err != nil {
ServerErrorView(c, "The server too makes mistakes")
if err == sql.ErrNoRows {
NotFoundView(c, fmt.Sprintf("Could not find category `%d`", categoryID))
return
}
if category.CategoryID == -1 {
NotFoundView(c, fmt.Sprintf("Could not find category `%d`", categoryID))
if err != nil {
ServerErrorView(c, "The server too makes mistakes")
return
}