Преглед изворни кода

增加“客户信息查询”接口

zhou.xiaoning пре 5 година
родитељ
комит
127d6d0c12
6 измењених фајлова са 335 додато и 0 уклоњено
  1. 98 0
      controllers/erms3/customer.go
  2. 82 0
      docs/docs.go
  3. 82 0
      docs/swagger.json
  4. 54 0
      docs/swagger.yaml
  5. 17 0
      models/account.go
  6. 2 0
      routers/router.go

+ 98 - 0
controllers/erms3/customer.go

@@ -154,3 +154,101 @@ func QueryUserInfoApplies(c *gin.Context) {
 		appG.Response(http.StatusOK, e.SUCCESS, rsp)
 	}
 }
+
+// QueryUserInfosReq 客户信息查询请求参数
+type QueryUserInfosReq struct {
+	app.PageInfo
+	UserName string `form:"userName"`
+}
+
+// QueryUserInfosRsp 客户信息查询返回模型
+type QueryUserInfosRsp struct {
+	Userid       int64  `json:"userid"  xorm:"'USERID'" binding:"required"` // 用户ID
+	Userinfotype int32  `json:"userinfotype"  xorm:"'USERINFOTYPE'"`        // 用户信息类型 - 1:个人  2:企业
+	Customername string `json:"customername"  xorm:"'CUSTOMERNAME'"`        // 客户名称(企业名称)
+	Userstatus   int32  `json:"userstatus"  xorm:"'USERSTATUS'"`            // 用户状态 - 1:正常 2:注销
+	Biznature    int32  `json:"biznature"  xorm:"'BIZNATURE'"`              // 企业性质( 企业) - 1:国有控股企业 2:集体控股企业 3:私人控股企业 4:港澳台商控股企业 5:外商控股企业 6:其它
+	Contactname  string `json:"contactname"  xorm:"'CONTACTNAME'"`          // 联系人
+}
+
+// QueryUserInfos 客户信息查询
+// @Summary 客户信息查询
+// @Produce json
+// @Security ApiKeyAuth
+// @Param page query int false "页码"
+// @Param pagesize query int false "每页条数"
+// @Param userName query string false "客户名称,支持模糊查询"
+// @Success 200 {object} QueryUserInfosRsp
+// @Failure 500 {object} app.Response
+// @Router /Erms3/QueryUserInfos [get]
+// @Tags 风险管理v3
+func QueryUserInfos(c *gin.Context) {
+	appG := app.Gin{C: c}
+
+	// 获取请求参数
+	var req QueryUserInfosReq
+	err := appG.C.ShouldBindQuery(&req)
+	if err != nil {
+		logger.GetLogger().Errorf("QueryUserInfos failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.INVALID_PARAMS, nil)
+		return
+	}
+
+	// 获取客户信息
+	userInfos, err := models.GetUserInfos(req.UserName)
+	if err != nil {
+		// 查询失败
+		logger.GetLogger().Errorf("QueryUserInfos failed: %s", err.Error())
+		appG.Response(http.StatusBadRequest, e.ERROR_QUERY_FAIL, nil)
+		return
+	}
+
+	// 排序
+	sort.Slice(userInfos, func(i int, j int) bool {
+		return userInfos[i].Createtime.After(userInfos[j].Createtime)
+	})
+
+	// 分页
+	total := len(userInfos)
+	if req.PageSize > 0 {
+		rstByPage := make([]models.Userinfo, 0)
+		// 开始上标
+		start := req.Page * req.PageSize
+		// 结束下标
+		end := start + req.PageSize
+
+		if start <= len(userInfos) {
+			// 判断结束下标是否越界
+			if end > len(userInfos) {
+				end = len(userInfos)
+			}
+			rstByPage = userInfos[start:end]
+		} else {
+			rstByPage = userInfos[0:0]
+		}
+
+		userInfos = rstByPage
+	}
+
+	// 转换返回模型
+	rsp := make([]QueryUserInfosRsp, 0)
+	for _, v := range userInfos {
+		rsp = append(rsp, QueryUserInfosRsp{
+			Userid:       v.Userid,
+			Userinfotype: v.Userinfotype,
+			Customername: v.Customername,
+			Userstatus:   v.Userstatus,
+			Biznature:    v.Biznature,
+			Contactname:  v.Contactname,
+		})
+	}
+
+	// 查询成功返回
+	if req.PageSize > 0 {
+		logger.GetLogger().Debugln("QueryUserInfos successed: %v", rsp)
+		appG.ResponseByPage(http.StatusOK, e.SUCCESS, rsp, app.PageInfo{Page: req.Page, PageSize: req.PageSize, Total: total})
+	} else {
+		logger.GetLogger().Debugln("QueryUserInfos successed: %v", rsp)
+		appG.Response(http.StatusOK, e.SUCCESS, rsp)
+	}
+}

+ 82 - 0
docs/docs.go

@@ -1079,6 +1079,56 @@ var doc = `{
                 }
             }
         },
+        "/Erms3/QueryUserInfos": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "客户信息查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "客户名称,支持模糊查询",
+                        "name": "userName",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/erms3.QueryUserInfosRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/GetHsbyMyCount": {
             "get": {
                 "security": [
@@ -5279,6 +5329,38 @@ var doc = `{
                 }
             }
         },
+        "erms3.QueryUserInfosRsp": {
+            "type": "object",
+            "required": [
+                "userid"
+            ],
+            "properties": {
+                "biznature": {
+                    "description": "企业性质( 企业) - 1:国有控股企业 2:集体控股企业 3:私人控股企业 4:港澳台商控股企业 5:外商控股企业 6:其它",
+                    "type": "integer"
+                },
+                "contactname": {
+                    "description": "联系人",
+                    "type": "string"
+                },
+                "customername": {
+                    "description": "客户名称(企业名称)",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "userinfotype": {
+                    "description": "用户信息类型 - 1:个人  2:企业",
+                    "type": "integer"
+                },
+                "userstatus": {
+                    "description": "用户状态 - 1:正常 2:注销",
+                    "type": "integer"
+                }
+            }
+        },
         "erms3.SoptContractDetail": {
             "type": "object",
             "required": [

+ 82 - 0
docs/swagger.json

@@ -1063,6 +1063,56 @@
                 }
             }
         },
+        "/Erms3/QueryUserInfos": {
+            "get": {
+                "security": [
+                    {
+                        "ApiKeyAuth": []
+                    }
+                ],
+                "produces": [
+                    "application/json"
+                ],
+                "tags": [
+                    "风险管理v3"
+                ],
+                "summary": "客户信息查询",
+                "parameters": [
+                    {
+                        "type": "integer",
+                        "description": "页码",
+                        "name": "page",
+                        "in": "query"
+                    },
+                    {
+                        "type": "integer",
+                        "description": "每页条数",
+                        "name": "pagesize",
+                        "in": "query"
+                    },
+                    {
+                        "type": "string",
+                        "description": "客户名称,支持模糊查询",
+                        "name": "userName",
+                        "in": "query"
+                    }
+                ],
+                "responses": {
+                    "200": {
+                        "description": "OK",
+                        "schema": {
+                            "$ref": "#/definitions/erms3.QueryUserInfosRsp"
+                        }
+                    },
+                    "500": {
+                        "description": "Internal Server Error",
+                        "schema": {
+                            "$ref": "#/definitions/app.Response"
+                        }
+                    }
+                }
+            }
+        },
         "/HSBY/GetHsbyMyCount": {
             "get": {
                 "security": [
@@ -5263,6 +5313,38 @@
                 }
             }
         },
+        "erms3.QueryUserInfosRsp": {
+            "type": "object",
+            "required": [
+                "userid"
+            ],
+            "properties": {
+                "biznature": {
+                    "description": "企业性质( 企业) - 1:国有控股企业 2:集体控股企业 3:私人控股企业 4:港澳台商控股企业 5:外商控股企业 6:其它",
+                    "type": "integer"
+                },
+                "contactname": {
+                    "description": "联系人",
+                    "type": "string"
+                },
+                "customername": {
+                    "description": "客户名称(企业名称)",
+                    "type": "string"
+                },
+                "userid": {
+                    "description": "用户ID",
+                    "type": "integer"
+                },
+                "userinfotype": {
+                    "description": "用户信息类型 - 1:个人  2:企业",
+                    "type": "integer"
+                },
+                "userstatus": {
+                    "description": "用户状态 - 1:正常 2:注销",
+                    "type": "integer"
+                }
+            }
+        },
         "erms3.SoptContractDetail": {
             "type": "object",
             "required": [

+ 54 - 0
docs/swagger.yaml

@@ -1666,6 +1666,29 @@ definitions:
     required:
     - userid
     type: object
+  erms3.QueryUserInfosRsp:
+    properties:
+      biznature:
+        description: 企业性质( 企业) - 1:国有控股企业 2:集体控股企业 3:私人控股企业 4:港澳台商控股企业 5:外商控股企业 6:其它
+        type: integer
+      contactname:
+        description: 联系人
+        type: string
+      customername:
+        description: 客户名称(企业名称)
+        type: string
+      userid:
+        description: 用户ID
+        type: integer
+      userinfotype:
+        description: 用户信息类型 - 1:个人  2:企业
+        type: integer
+      userstatus:
+        description: 用户状态 - 1:正常 2:注销
+        type: integer
+    required:
+    - userid
+    type: object
   erms3.SoptContractDetail:
     properties:
       deliverygoodsdesc:
@@ -5205,6 +5228,37 @@ paths:
       summary: 客户申请信息查询
       tags:
       - 风险管理v3
+  /Erms3/QueryUserInfos:
+    get:
+      parameters:
+      - description: 页码
+        in: query
+        name: page
+        type: integer
+      - description: 每页条数
+        in: query
+        name: pagesize
+        type: integer
+      - description: 客户名称,支持模糊查询
+        in: query
+        name: userName
+        type: string
+      produces:
+      - application/json
+      responses:
+        "200":
+          description: OK
+          schema:
+            $ref: '#/definitions/erms3.QueryUserInfosRsp'
+        "500":
+          description: Internal Server Error
+          schema:
+            $ref: '#/definitions/app.Response'
+      security:
+      - ApiKeyAuth: []
+      summary: 客户信息查询
+      tags:
+      - 风险管理v3
   /HSBY/GetHsbyMyCount:
     get:
       description: 说明: 不包括已完成的数量。

+ 17 - 0
models/account.go

@@ -671,3 +671,20 @@ func GetWSKHUserInfos(userName string) ([]Wskhuserinfo, error) {
 
 	return userInfos, nil
 }
+
+// GetUserInfos 获取用户信息
+// 输入 userName string 客户名称,支持模糊查询
+func GetUserInfos(userName string) ([]Userinfo, error) {
+	engine := db.GetEngine()
+
+	userInfos := make([]Userinfo, 0)
+	session := engine.Table("USERINFO")
+	if len(userName) > 0 {
+		session = session.Where(fmt.Sprintf("CUSTOMERNAME like '%%%s%%'", userName))
+	}
+	if err := session.Find(&userInfos); err != nil {
+		return nil, err
+	}
+
+	return userInfos, nil
+}

+ 2 - 0
routers/router.go

@@ -188,6 +188,8 @@ func InitRouter() *gin.Engine {
 		erms3R.POST("/AddUserInfoApply", erms3.AddUserInfoApply)
 		// 客户申请信息查询
 		erms3R.GET("/QueryUserInfoApplies", erms3.QueryUserInfoApplies)
+		// 客户信息查询
+		erms3R.GET("/QueryUserInfos", erms3.QueryUserInfos)
 	}
 	// ************************ 定制【尚志大宗】 ************************
 	szdzR := apiR.Group("SZDZ")