Bläddra i källkod

增加更新用户头像接口

zhou.xiaoning 2 år sedan
förälder
incheckning
9bd29408d6
7 ändrade filer med 184 tillägg och 8 borttagningar
  1. 4 4
      controllers/guangzuan/tradeService.go
  2. 43 4
      controllers/user/user.go
  3. 46 0
      docs/docs.go
  4. 46 0
      docs/swagger.json
  5. 29 0
      docs/swagger.yaml
  6. 14 0
      models/account.go
  7. 2 0
      routers/router.go

+ 4 - 4
controllers/guangzuan/tradeService.go

@@ -18,8 +18,8 @@ import (
 // @Security Group
 // @Param    userid   query    int    true  "用户ID"
 // @Param    executestatus query    int false "执行状态 - 1:未生效 2:进行中 3:已结束"
-// @Param    page          query    int false "页码"
-// @Param    pagesize      query    int false "每页条数"
+// @Param    page     query    int    false "页码"
+// @Param    pagesize query    int    false "每页条数"
 // @Success  200           {array}  models.GzcjjcorderM
 // @Failure  500     {object} app.Response
 // @Router   /Guangzuan/QueryGZCJJCOrder [get]
@@ -39,8 +39,8 @@ func QueryGZCJJCOrder(c *gin.Context) {
 // @Security Group
 // @Param    userid        query    int true  "用户ID"
 // @Param    orderid  query    string false "单据ID"
-// @Param    page     query    int    false "页码"
-// @Param    pagesize query    int    false "每页条数"
+// @Param    page          query    int false "页码"
+// @Param    pagesize      query    int false "每页条数"
 // @Success  200      {array}  models.GzcjjcorderdetailM
 // @Failure  500           {object} app.Response
 // @Router   /Guangzuan/QueryGZCJJCOrderDetail [get]

+ 43 - 4
controllers/user/user.go

@@ -579,12 +579,12 @@ type UpdateUserAccountStatusReq struct {
 
 // UpdateUserAccountStatus 更新用户状态
 // @Summary  更新用户状态
-// @Produce json
+// @Produce  json
 // @Security ApiKeyAuth
-// @Param    userID        query    int true "用户ID"
+// @Param    userID  query    int    true "用户ID"
 // @Param    accountStatus query    int true "账户状态 -  4:正常 6:注销(停用)"
-// @Success  200           {object} app.Response
-// @Failure  500           {object} app.Response
+// @Success  200     {object} app.Response
+// @Failure  500     {object} app.Response
 // @Router   /User/UpdateUserAccountStatus [post]
 // @Tags     用户信息
 func UpdateUserAccountStatus(c *gin.Context) {
@@ -609,3 +609,42 @@ func UpdateUserAccountStatus(c *gin.Context) {
 	logger.GetLogger().Debugln("UpdateUserAccountStatus successed: %v", "ok")
 	appG.Response(http.StatusOK, e.SUCCESS, "ok")
 }
+
+// UpdateUserHeadUrlReq 更新用户头像请求参数
+type UpdateUserHeadUrlReq struct {
+	UserID  int    `form:"userID" binding:"required"`
+	Headurl string `form:"headurl" binding:"required"`
+}
+
+// UpdateUserHeadUrl 更新用户头像
+// @Summary  更新用户头像
+// @Produce json
+// @Security ApiKeyAuth
+// @Param    userID        query    int true "用户ID"
+// @Param    headurl query    string true "头像地址"
+// @Success  200           {object} app.Response
+// @Failure  500           {object} app.Response
+// @Router   /User/UpdateUserHeadUrl [post]
+// @Tags     用户信息
+func UpdateUserHeadUrl(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req UpdateUserHeadUrlReq
+	if err := appG.C.ShouldBind(&req); err != nil {
+		logger.GetLogger().Errorf("UpdateUserHeadUrlReq failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	if err := models.UpdateUserHeadUrl(req.UserID, req.Headurl); err != nil {
+		// 执行失败
+		logger.GetLogger().Errorf("UpdateUserHeadUrl failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 执行成功
+	logger.GetLogger().Debugln("UpdateUserHeadUrl successed: %v", "ok")
+	appG.Response(http.StatusOK, e.SUCCESS, "ok")
+}

+ 46 - 0
docs/docs.go

@@ -16510,6 +16510,52 @@ const docTemplate = `{
                 }
             }
         },
+        "/User/UpdateUserHeadUrl": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "用户信息"
+                ],
+                "summary": "更新用户头像",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userID",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "头像地址",
+                        "name": "headurl",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WRTrade/GetAllDeliveryGoods": {
             "get": {
                 "security": [

+ 46 - 0
docs/swagger.json

@@ -16501,6 +16501,52 @@
                 }
             }
         },
+        "/User/UpdateUserHeadUrl": {
+            "post": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "用户信息"
+                ],
+                "summary": "更新用户头像",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "用户ID",
+                        "name": "userID",
+                        "in": "query",
+                        "required": true
+                    },
+                    {
+                        "type": "string",
+                        "description": "头像地址",
+                        "name": "headurl",
+                        "in": "query",
+                        "required": true
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/WRTrade/GetAllDeliveryGoods": {
             "get": {
                 "security": [

+ 29 - 0
docs/swagger.yaml

@@ -36347,6 +36347,35 @@ paths:
       summary: 更新用户状态
       tags:
       - 用户信息
+  /User/UpdateUserHeadUrl:
+    post:
+      parameters:
+      - description: 用户ID
+        in: query
+        name: userID
+        required: true
+        type: integer
+      - description: 头像地址
+        in: query
+        name: headurl
+        required: true
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/app.Response'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 更新用户头像
+      tags:
+      - 用户信息
   /WRTrade/GetAllDeliveryGoods:
     get:
       produces:

+ 14 - 0
models/account.go

@@ -1228,3 +1228,17 @@ func (r *RelatedTaAccount) GetDataEx() (interface{}, error) {
 	}
 	return sData, err
 }
+
+// UpdateUserHeadUrl 更新用户头像地址
+func UpdateUserHeadUrl(userID int, headurl string) error {
+	engine := db.GetEngine()
+
+	userinfo := Userinfo{Headurl: headurl}
+	if _, err := engine.Table("USERINFO").
+		Where("USERID = ?", userID).
+		Update(&userinfo); err != nil {
+		return err
+	}
+
+	return nil
+}

+ 2 - 0
routers/router.go

@@ -97,6 +97,8 @@ func InitRouter() *gin.Engine {
 		userR.Use(token.Auth()).POST("/UpdateUserAccountStatus", user.UpdateUserAccountStatus)
 		// 账户登录后信息查询
 		userR.Use(token.Auth()).GET("/LoginQuery", user.LoginQuery)
+
+		userR.Use(token.Auth()).POST("/UpdateUserHeadUrl", user.UpdateUserHeadUrl)
 	}
 	// ************************ 资金账户 ************************
 	taAccountR := apiR.Group("TaAccount")