Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
[个人资料更新]
Browse files Browse the repository at this point in the history
  • Loading branch information
Thxzzzzz committed May 28, 2019
1 parent 8a5dda7 commit b1e77ba
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 73 deletions.
27 changes: 8 additions & 19 deletions controllers/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ func (c *UserControllers) OptionsUploadImage() {
c.ResponseSuccessJson(nil)
}

// @Title 上传图片
// @Description 上传图片
// @Param form body forms.UserUpdateForm true "图片文件"
// @Title 更新个人资料
// @Description 更新个人资料
// @Param form body models.User true "图片文件"
// @Accept form
// @Success 200
// @Failure 400
Expand All @@ -303,31 +303,20 @@ func (c *UserControllers) UpdateInfo() {
return
}

form := forms.UserFormWithRole{}
form := models.User{}
err = json.Unmarshal(c.Ctx.Input.RequestBody, &form)
if err != nil {
c.ResponseErrJson(err)
return
}
// 如果不是超级管理员,那只能更新自己的信息
if user.RoleId != enums.Role_SuperAdmin && user.ID != form.ID {
c.ResponseErrJson(&resultError.UserRoleVerifyError)
return
}

//因为 User 屏蔽了 password 的 json 解析,所以这里要转一下
newUser := models.User{}
err = utils.CopyStruct(form, &newUser)
if err != nil {
c.ResponseErrJson(err)
return
}
// 只能更新自己的信息
form.ID = user.ID

// 更新信息
err = models.UpdateUser(&newUser)
err = models.UpdateUser(&form)
if err != nil {
c.ResponseErrJson(err)
return
}
c.ResponseSuccessJson(newUser)
c.ResponseSuccessJson(form)
}
2 changes: 1 addition & 1 deletion lastupdate.tmp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"C:\\GoPath\\src\\funding\\controllers":1558774708766893500,"C:\\GoPath\\src\\funding\\managerControllers":1558787616388088000}
{"C:\\GoPath\\src\\funding\\controllers":1559004157544869600,"C:\\GoPath\\src\\funding\\managerControllers":1559004157561296300}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ func init() {
Filters: nil,
Params: nil})

beego.GlobalControllerRouter["funding/managerControllers:ManagerOrderController"] = append(beego.GlobalControllerRouter["funding/managerControllers:ManagerOrderController"],
beego.ControllerComments{
Method: "ComplaintOrders",
Router: `/complaintOrders`,
AllowHTTPMethods: []string{"get"},
MethodParams: param.Make(),
Filters: nil,
Params: nil})

beego.GlobalControllerRouter["funding/managerControllers:ManagerOrderController"] = append(beego.GlobalControllerRouter["funding/managerControllers:ManagerOrderController"],
beego.ControllerComments{
Method: "OrderDelete",
Expand Down
34 changes: 3 additions & 31 deletions swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1798,8 +1798,8 @@
"tags": [
"user"
],
"description": "上传图片",
"operationId": "UserControllers.上传图片",
"description": "更新个人资料",
"operationId": "UserControllers.更新个人资料",
"consumes": [
"multipart/form-data"
],
Expand All @@ -1810,7 +1810,7 @@
"description": "图片文件",
"required": true,
"schema": {
"$ref": "#/definitions/forms.UserUpdateForm"
"$ref": "#/definitions/models.User"
}
}
],
Expand Down Expand Up @@ -2217,34 +2217,6 @@
}
}
},
"forms.UserUpdateForm": {
"title": "UserUpdateForm",
"type": "object",
"properties": {
"email": {
"type": "string"
},
"icon_url": {
"type": "string"
},
"id": {
"type": "integer",
"format": "int64"
},
"nickname": {
"type": "string"
},
"password": {
"type": "string"
},
"phone": {
"type": "string"
},
"username": {
"type": "string"
}
}
},
"models.Address": {
"title": "Address",
"type": "object",
Expand Down
25 changes: 3 additions & 22 deletions swagger/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1178,8 +1178,8 @@ paths:
post:
tags:
- user
description: 上传图片
operationId: UserControllers.上传图片
description: 更新个人资料
operationId: UserControllers.更新个人资料
consumes:
- multipart/form-data
parameters:
Expand All @@ -1188,7 +1188,7 @@ paths:
description: 图片文件
required: true
schema:
$ref: '#/definitions/forms.UserUpdateForm'
$ref: '#/definitions/models.User'
responses:
"200":
description: ""
Expand Down Expand Up @@ -1462,25 +1462,6 @@ definitions:
format: int64
username:
type: string
forms.UserUpdateForm:
title: UserUpdateForm
type: object
properties:
email:
type: string
icon_url:
type: string
id:
type: integer
format: int64
nickname:
type: string
password:
type: string
phone:
type: string
username:
type: string
models.Address:
title: Address
type: object
Expand Down

0 comments on commit b1e77ba

Please sign in to comment.