From 4c48e3ef4e3a0dacee71f04ece0151d900143cef Mon Sep 17 00:00:00 2001 From: luziqi Date: Thu, 17 Aug 2023 16:08:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E6=9B=B4=E5=A4=9A?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs.go | 55 ++++++++++++++++++++++++++++++++++++++++++++++- docs/swagger.json | 55 ++++++++++++++++++++++++++++++++++++++++++++++- docs/swagger.yaml | 37 ++++++++++++++++++++++++++++++- monkey/task.go | 31 ++++++++++++++++++++++++-- 4 files changed, 173 insertions(+), 5 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 8c35967..3a232c1 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -375,6 +375,35 @@ const docTemplate = `{ } } }, + "/api/device/v2/list": { + "get": { + "description": "获取设备列表,可选筛选系统平台", + "consumes": [ + "application/x-www-form-urlencoded" + ], + "tags": [ + "设备相关 /api/device/v2/" + ], + "summary": "获取设备列表", + "parameters": [ + { + "type": "string", + "description": "系统平台,不传查全部", + "name": "pf", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "返回设备列表", + "schema": { + "$ref": "#/definitions/models.Response" + } + } + } + } + }, "/api/device/v2/update_ip": { "post": { "description": "更新设备IP", @@ -953,16 +982,40 @@ const docTemplate = `{ "in": "query" }, { - "type": "integer", + "type": "string", "description": "项目名称", "name": "project", "in": "query" }, + { + "type": "string", + "description": "产品名称", + "name": "product", + "in": "query" + }, + { + "type": "string", + "description": "版本号,模糊匹配", + "name": "version", + "in": "query" + }, + { + "type": "string", + "description": "系统平台:ios/adr", + "name": "pf", + "in": "query" + }, { "type": "integer", "description": "传1筛选有异常的任务", "name": "has_error", "in": "query" + }, + { + "type": "string", + "description": "任务状态(大写)", + "name": "status", + "in": "query" } ], "responses": { diff --git a/docs/swagger.json b/docs/swagger.json index f6ebd74..7a55be3 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -363,6 +363,35 @@ } } }, + "/api/device/v2/list": { + "get": { + "description": "获取设备列表,可选筛选系统平台", + "consumes": [ + "application/x-www-form-urlencoded" + ], + "tags": [ + "设备相关 /api/device/v2/" + ], + "summary": "获取设备列表", + "parameters": [ + { + "type": "string", + "description": "系统平台,不传查全部", + "name": "pf", + "in": "query", + "required": true + } + ], + "responses": { + "200": { + "description": "返回设备列表", + "schema": { + "$ref": "#/definitions/models.Response" + } + } + } + } + }, "/api/device/v2/update_ip": { "post": { "description": "更新设备IP", @@ -941,16 +970,40 @@ "in": "query" }, { - "type": "integer", + "type": "string", "description": "项目名称", "name": "project", "in": "query" }, + { + "type": "string", + "description": "产品名称", + "name": "product", + "in": "query" + }, + { + "type": "string", + "description": "版本号,模糊匹配", + "name": "version", + "in": "query" + }, + { + "type": "string", + "description": "系统平台:ios/adr", + "name": "pf", + "in": "query" + }, { "type": "integer", "description": "传1筛选有异常的任务", "name": "has_error", "in": "query" + }, + { + "type": "string", + "description": "任务状态(大写)", + "name": "status", + "in": "query" } ], "responses": { diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 642cefd..630dacd 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -282,6 +282,25 @@ paths: summary: 查询设备 tags: - 设备相关 /api/device/v2/ + /api/device/v2/list: + get: + consumes: + - application/x-www-form-urlencoded + description: 获取设备列表,可选筛选系统平台 + parameters: + - description: 系统平台,不传查全部 + in: query + name: pf + required: true + type: string + responses: + "200": + description: 返回设备列表 + schema: + $ref: '#/definitions/models.Response' + summary: 获取设备列表 + tags: + - 设备相关 /api/device/v2/ /api/device/v2/update_ip: post: consumes: @@ -665,11 +684,27 @@ paths: - description: 项目名称 in: query name: project - type: integer + type: string + - description: 产品名称 + in: query + name: product + type: string + - description: 版本号,模糊匹配 + in: query + name: version + type: string + - description: 系统平台:ios/adr + in: query + name: pf + type: string - description: 传1筛选有异常的任务 in: query name: has_error type: integer + - description: 任务状态(大写) + in: query + name: status + type: string responses: "200": description: 返回更新后的任务信息 diff --git a/monkey/task.go b/monkey/task.go index fd40f2f..5729a38 100644 --- a/monkey/task.go +++ b/monkey/task.go @@ -194,8 +194,12 @@ func UpdateTaskCrashCount(c *gin.Context) { // @accept x-www-form-urlencoded // @Param page_size query int false "每页大小,默认为10" // @Param page_index query int false "第几页,默认为第一页" -// @Param project query int false "项目名称" +// @Param project query string false "项目名称" +// @Param product query string false "产品名称" +// @Param version query string false "版本号,模糊匹配" +// @Param pf query string false "系统平台:ios/adr" // @Param has_error query int false "传1筛选有异常的任务" +// @Param status query string false "任务状态(大写)" // @Success 200 {object} models.Response "返回更新后的任务信息" // @Router /api/monkey/v1/tasks [get] func GetTasks(c *gin.Context) { @@ -215,9 +219,18 @@ func GetTasks(c *gin.Context) { } p.Size = pageSize + // param-项目 project := c.DefaultQuery("project", "") - + // param-系统平台 + pf := c.DefaultQuery("pf", "") + if pf != "" && pf != "adr" && pf != "ios" { + c.JSON(http.StatusOK, rsp.Error("参数pf异常")) + return + } + // param-是否有异常 has_error := cast.ToInt(c.DefaultQuery("has_error", "0")) + // param-任务状态 + status := c.DefaultQuery("status", "") db, err := dbsql.GetConn(dbsql.DSN) if err != nil { @@ -230,12 +243,26 @@ func GetTasks(c *gin.Context) { db = db.Model(&models.MonkeyTask{}) var lenght int64 + // 参数判断 if project != "" { db = db.Where("project = ?", project) } + if c.Query("product") != "" { + db = db.Where("product = ?", c.Query("product")) + } + if c.Query("version") != "" { + db = db.Where("version LIKE ?", "%"+c.Query("version")+"%") + } + if pf != "" { + db = db.Where("platform = ?", pf) + } if has_error == 1 { db = db.Where("crash_count > 0") } + if status != "" { + db = db.Where("status = ?", status) + } + db = db.Where("is_del = 0").Count(&lenght) db = dbsql.SetPageQuery(db, pageIndex, pageSize) db.Order("id desc").Find(&list)