From 05cfaa8e37ef6c99f8c541db6de3af492c9f0f32 Mon Sep 17 00:00:00 2001 From: taolx0 Date: Tue, 7 Nov 2023 14:30:17 +0800 Subject: [PATCH] feat:support sort by field --- sqle/api/controller/v1/sql_manage.go | 8 ++ sqle/docs/docs.go | 136 +++++++++++++++++++++++++++ sqle/docs/swagger.json | 136 +++++++++++++++++++++++++++ sqle/docs/swagger.yaml | 90 ++++++++++++++++++ 4 files changed, 370 insertions(+) diff --git a/sqle/api/controller/v1/sql_manage.go b/sqle/api/controller/v1/sql_manage.go index a609cd4a8e..fe2a33386a 100644 --- a/sqle/api/controller/v1/sql_manage.go +++ b/sqle/api/controller/v1/sql_manage.go @@ -16,6 +16,8 @@ type GetSqlManageListReq struct { FilterStatus *string `query:"filter_status" json:"filter_status,omitempty"` FilterDbType *string `query:"filter_db_type" json:"filter_db_type,omitempty"` FilterRuleName *string `query:"filter_rule_name" json:"filter_rule_name,omitempty"` + SortField *string `query:"sort_field" json:"sort_field,omitempty" valid:"omitempty,oneof=first_appear_time last_appear_time appear_count" enums:"first_appear_time,last_appear_time,appear_count"` + SortOrder *string `query:"sort_order" json:"sort_order,omitempty" valid:"omitempty,oneof=asc desc" enums:"asc,desc"` PageIndex uint32 `query:"page_index" valid:"required" json:"page_index"` PageSize uint32 `query:"page_size" valid:"required" json:"page_size"` } @@ -74,6 +76,8 @@ type Source struct { // @Param filter_status query string false "status" Enums(unhandled,solved,ignored,manual_audited) // @Param filter_rule_name query string false "rule name" // @Param filter_db_type query string false "db type" +// @Param sort_field query string false "sort field" Enums(first_appear_time,last_appear_time,appear_count) +// @Param sort_order query string false "sort order" Enums(asc,desc) // @Param page_index query uint32 true "page index" // @Param page_size query uint32 true "size of per page" // @Success 200 {object} v1.GetSqlManageListResp @@ -114,6 +118,8 @@ type ExportSqlManagesReq struct { FilterStatus *string `query:"filter_status" json:"filter_status,omitempty"` FilterDbType *string `query:"filter_db_type" json:"filter_db_type,omitempty"` FilterRuleName *string `query:"filter_rule_name" json:"filter_rule_name,omitempty"` + SortField *string `query:"sort_field" json:"sort_field,omitempty" valid:"omitempty,oneof=first_appear_time last_appear_time appear_count" enums:"first_appear_time,last_appear_time,appear_count"` + SortOrder *string `query:"sort_order" json:"sort_order,omitempty" valid:"omitempty,oneof=asc desc" enums:"asc,desc"` } // ExportSqlManagesV1 @@ -133,6 +139,8 @@ type ExportSqlManagesReq struct { // @Param filter_status query string false "status" Enums(unhandled,solved,ignored,manual_audited) // @Param filter_db_type query string false "db type" // @Param filter_rule_name query string false "rule name" +// @Param sort_field query string false "sort field" Enums(first_appear_time,last_appear_time,appear_count) +// @Param sort_order query string false "sort order" Enums(asc,desc) // @Success 200 {file} file "export sql manage" // @Router /v1/projects/{project_name}/sql_manages/exports [get] func ExportSqlManagesV1(c echo.Context) error { diff --git a/sqle/docs/docs.go b/sqle/docs/docs.go index e60eaf4a62..a7ee6061c1 100644 --- a/sqle/docs/docs.go +++ b/sqle/docs/docs.go @@ -131,6 +131,67 @@ var doc = `{ } } }, + "/v1/company_notice": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get company notice info", + "tags": [ + "companyNotice" + ], + "summary": "获取企业公告", + "operationId": "getCompanyNotice", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetCompanyNoticeResp" + } + } + } + }, + "patch": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "update company notice info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "companyNotice" + ], + "summary": "更新企业公告", + "operationId": "updateCompanyNotice", + "parameters": [ + { + "description": "company notice", + "name": "companyNotice", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.UpdateCompanyNoticeReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, "/v1/configurations/ding_talk": { "get": { "security": [ @@ -4757,6 +4818,27 @@ var doc = `{ "name": "filter_db_type", "in": "query" }, + { + "enum": [ + "first_appear_time", + "last_appear_time", + "appear_count" + ], + "type": "string", + "description": "sort field", + "name": "sort_field", + "in": "query" + }, + { + "enum": [ + "asc", + "desc" + ], + "type": "string", + "description": "sort order", + "name": "sort_order", + "in": "query" + }, { "type": "integer", "description": "page index", @@ -4919,6 +5001,27 @@ var doc = `{ "description": "rule name", "name": "filter_rule_name", "in": "query" + }, + { + "enum": [ + "first_appear_time", + "last_appear_time", + "appear_count" + ], + "type": "string", + "description": "sort field", + "name": "sort_field", + "in": "query" + }, + { + "enum": [ + "asc", + "desc" + ], + "type": "string", + "description": "sort order", + "name": "sort_order", + "in": "query" } ], "responses": { @@ -10648,6 +10751,14 @@ var doc = `{ } } }, + "v1.CompanyNotice": { + "type": "object", + "properties": { + "notice_str": { + "type": "string" + } + } + }, "v1.CreateAuditPlanReqV1": { "type": "object", "properties": { @@ -11614,6 +11725,23 @@ var doc = `{ } } }, + "v1.GetCompanyNoticeResp": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "object", + "$ref": "#/definitions/v1.CompanyNotice" + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.GetCustomRuleResV1": { "type": "object", "properties": { @@ -15354,6 +15482,14 @@ var doc = `{ } } }, + "v1.UpdateCompanyNoticeReq": { + "type": "object", + "properties": { + "notice_str": { + "type": "string" + } + } + }, "v1.UpdateCurrentUserPasswordReqV1": { "type": "object", "properties": { diff --git a/sqle/docs/swagger.json b/sqle/docs/swagger.json index 9b6867a905..37d04a87e6 100644 --- a/sqle/docs/swagger.json +++ b/sqle/docs/swagger.json @@ -115,6 +115,67 @@ } } }, + "/v1/company_notice": { + "get": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "get company notice info", + "tags": [ + "companyNotice" + ], + "summary": "获取企业公告", + "operationId": "getCompanyNotice", + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/v1.GetCompanyNoticeResp" + } + } + } + }, + "patch": { + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "update company notice info", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "companyNotice" + ], + "summary": "更新企业公告", + "operationId": "updateCompanyNotice", + "parameters": [ + { + "description": "company notice", + "name": "companyNotice", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/v1.UpdateCompanyNoticeReq" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/controller.BaseRes" + } + } + } + } + }, "/v1/configurations/ding_talk": { "get": { "security": [ @@ -4741,6 +4802,27 @@ "name": "filter_db_type", "in": "query" }, + { + "enum": [ + "first_appear_time", + "last_appear_time", + "appear_count" + ], + "type": "string", + "description": "sort field", + "name": "sort_field", + "in": "query" + }, + { + "enum": [ + "asc", + "desc" + ], + "type": "string", + "description": "sort order", + "name": "sort_order", + "in": "query" + }, { "type": "integer", "description": "page index", @@ -4903,6 +4985,27 @@ "description": "rule name", "name": "filter_rule_name", "in": "query" + }, + { + "enum": [ + "first_appear_time", + "last_appear_time", + "appear_count" + ], + "type": "string", + "description": "sort field", + "name": "sort_field", + "in": "query" + }, + { + "enum": [ + "asc", + "desc" + ], + "type": "string", + "description": "sort order", + "name": "sort_order", + "in": "query" } ], "responses": { @@ -10632,6 +10735,14 @@ } } }, + "v1.CompanyNotice": { + "type": "object", + "properties": { + "notice_str": { + "type": "string" + } + } + }, "v1.CreateAuditPlanReqV1": { "type": "object", "properties": { @@ -11598,6 +11709,23 @@ } } }, + "v1.GetCompanyNoticeResp": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "example": 0 + }, + "data": { + "type": "object", + "$ref": "#/definitions/v1.CompanyNotice" + }, + "message": { + "type": "string", + "example": "ok" + } + } + }, "v1.GetCustomRuleResV1": { "type": "object", "properties": { @@ -15338,6 +15466,14 @@ } } }, + "v1.UpdateCompanyNoticeReq": { + "type": "object", + "properties": { + "notice_str": { + "type": "string" + } + } + }, "v1.UpdateCurrentUserPasswordReqV1": { "type": "object", "properties": { diff --git a/sqle/docs/swagger.yaml b/sqle/docs/swagger.yaml index 7760d88f12..08a68b66f1 100644 --- a/sqle/docs/swagger.yaml +++ b/sqle/docs/swagger.yaml @@ -459,6 +459,11 @@ definitions: new_rule_template_name: type: string type: object + v1.CompanyNotice: + properties: + notice_str: + type: string + type: object v1.CreateAuditPlanReqV1: properties: audit_plan_cron: @@ -1129,6 +1134,18 @@ definitions: total_nums: type: integer type: object + v1.GetCompanyNoticeResp: + properties: + code: + example: 0 + type: integer + data: + $ref: '#/definitions/v1.CompanyNotice' + type: object + message: + example: ok + type: string + type: object v1.GetCustomRuleResV1: properties: code: @@ -3672,6 +3689,11 @@ definitions: example: create table type: string type: object + v1.UpdateCompanyNoticeReq: + properties: + notice_str: + type: string + type: object v1.UpdateCurrentUserPasswordReqV1: properties: new_password: @@ -5075,6 +5097,44 @@ paths: summary: 获取 sqle 基本信息 tags: - global + /v1/company_notice: + get: + description: get company notice info + operationId: getCompanyNotice + responses: + "200": + description: OK + schema: + $ref: '#/definitions/v1.GetCompanyNoticeResp' + security: + - ApiKeyAuth: [] + summary: 获取企业公告 + tags: + - companyNotice + patch: + consumes: + - application/json + description: update company notice info + operationId: updateCompanyNotice + parameters: + - description: company notice + in: body + name: companyNotice + required: true + schema: + $ref: '#/definitions/v1.UpdateCompanyNoticeReq' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/controller.BaseRes' + security: + - ApiKeyAuth: [] + summary: 更新企业公告 + tags: + - companyNotice /v1/configurations/ding_talk: get: description: get dingTalk configuration @@ -8046,6 +8106,21 @@ paths: in: query name: filter_db_type type: string + - description: sort field + enum: + - first_appear_time + - last_appear_time + - appear_count + in: query + name: sort_field + type: string + - description: sort order + enum: + - asc + - desc + in: query + name: sort_order + type: string - description: page index in: query name: page_index @@ -8155,6 +8230,21 @@ paths: in: query name: filter_rule_name type: string + - description: sort field + enum: + - first_appear_time + - last_appear_time + - appear_count + in: query + name: sort_field + type: string + - description: sort order + enum: + - asc + - desc + in: query + name: sort_order + type: string responses: "200": description: export sql manage