feat(api): add return for all user templates

BREAKING: Template api will return different variables in template
object
This commit is contained in:
Leons Aleksandrovs
2025-07-10 20:36:37 +03:00
parent 9f99f6a4a9
commit e35bf46dac
4 changed files with 36 additions and 16 deletions
+16 -1
View File
@@ -34,7 +34,7 @@ func Create(c *gin.Context) {
// Get user id
user, err := jwt.GetUser(c)
if err != nil {
res.Error(c, err.Error(), http.StatusInternalServerError)
res.NeedsToLogin(c)
return
}
@@ -61,6 +61,21 @@ func Create(c *gin.Context) {
}
func Get(c *gin.Context) {
// Get user from context
user, err := jwt.GetUser(c)
if err != nil {
res.NeedsToLogin(c)
return
}
// Get all user templates
templates, err := template.Get("user_id = $1", user.Id)
if err != nil {
res.Error(c, err.Error(), http.StatusInternalServerError)
return
}
res.Success(c, templates)
}
func Update(c *gin.Context) {