Update userController.go
This commit is contained in:
parent
42fa4d23e0
commit
6e90d0d3eb
1 changed files with 4 additions and 8 deletions
|
@ -98,13 +98,6 @@ func UpdateUser(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if len(uploadedFiles) == 0 {
|
||||
c.JSON(http.StatusBadRequest, gin.H{
|
||||
"error": "No files were uploaded.",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
files, err := uploadFiles(c, uploadedFiles)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
|
@ -116,7 +109,10 @@ func UpdateUser(c *gin.Context) {
|
|||
currentUserId := c.GetString("userId")
|
||||
id, _ := uuid.Parse(currentUserId)
|
||||
|
||||
if len(uploadedFiles) == 1 {
|
||||
initializers.DB.Model(&files[0]).Update("user_id", id.String())
|
||||
return
|
||||
}
|
||||
|
||||
var user models.User
|
||||
result := initializers.DB.Preload("Avatar").First(&user, "id = ?", id)
|
||||
|
|
Loading…
Add table
Reference in a new issue