fix: change avatar upload response to JSON object with URL;
feat: add UrlDto for standardized URL responses; refactor: update avatar upload endpoint to return UrlDto; docs: regenerate Swagger; chore: add comments for untested profile controller methods
This commit is contained in:
@@ -89,6 +89,7 @@ func NewProfileController(_log *zap.Logger, _ps services.ProfileService) Control
|
||||
}
|
||||
}
|
||||
|
||||
// XXX: untested
|
||||
// @Summary Get your profile
|
||||
// @Tags Profile
|
||||
// @Accept json
|
||||
@@ -107,6 +108,7 @@ func (ctrl *ProfileController) getMyProfile(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// XXX: untested
|
||||
// @Summary Get profile by username
|
||||
// @Tags Profile
|
||||
// @Accept json
|
||||
@@ -142,6 +144,7 @@ func (ctrl *ProfileController) getProfileByUsername(c *gin.Context) {
|
||||
panic("Not implemented")
|
||||
}
|
||||
|
||||
// XXX: untested
|
||||
// @Summary Get your profile settings
|
||||
// @Tags Profile
|
||||
// @Accept json
|
||||
@@ -160,6 +163,7 @@ func (ctrl *ProfileController) getProfileSettings(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// XXX: untested
|
||||
// @Summary Update your profile
|
||||
// @Tags Profile
|
||||
// @Accept json
|
||||
@@ -181,6 +185,7 @@ func (ctrl *ProfileController) updateProfile(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// XXX: untested
|
||||
// @Summary Update your profile's settings
|
||||
// @Tags Profile
|
||||
// @Accept json
|
||||
@@ -202,13 +207,14 @@ func (ctrl *ProfileController) updateProfileSettings(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// XXX: untested
|
||||
// @Summary Upload an avatar
|
||||
// @Tags Profile
|
||||
// @Accept mpfd
|
||||
// @Produce plain
|
||||
// @Produce json
|
||||
// @Security JWT
|
||||
// @Param file formData file true "Avatar image file"
|
||||
// @Success 200 {object} string "Uploaded image url"
|
||||
// @Success 200 {object} dto.UrlDto "Uploaded image url"
|
||||
// @Router /profile/avatar [post]
|
||||
func (ctrl *ProfileController) uploadAvatar(c *gin.Context) {
|
||||
cinfo := GetClientInfo(c)
|
||||
@@ -228,5 +234,5 @@ func (ctrl *ProfileController) uploadAvatar(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.String(http.StatusOK, link)
|
||||
c.JSON(http.StatusOK, dto.UrlDto{Url: link})
|
||||
}
|
||||
|
||||
22
backend/internal/dto/general.go
Normal file
22
backend/internal/dto/general.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2025 Nikolai Papin
|
||||
//
|
||||
// This file is part of Easywish
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
|
||||
// the GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package dto
|
||||
|
||||
type UrlDto struct {
|
||||
Url string `json:"url" binding:"required"`
|
||||
}
|
||||
Reference in New Issue
Block a user