optimize doc of measurement recommend api
This commit is contained in:
parent
54128bedac
commit
458f7afdbf
49
docs/docs.go
49
docs/docs.go
|
|
@ -23,8 +23,8 @@ const docTemplate = `{
|
||||||
"host": "{{.Host}}",
|
"host": "{{.Host}}",
|
||||||
"basePath": "{{.BasePath}}",
|
"basePath": "{{.BasePath}}",
|
||||||
"paths": {
|
"paths": {
|
||||||
"/api/v1/recommend/measurement": {
|
"/measurement/recommend": {
|
||||||
"post": {
|
"get": {
|
||||||
"description": "根据用户输入的字符串,从 Redis 中查询可能的测量点或结构路径,并提供推荐列表。",
|
"description": "根据用户输入的字符串,从 Redis 中查询可能的测量点或结构路径,并提供推荐列表。",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
|
|
@ -33,12 +33,12 @@ const docTemplate = `{
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Recommend"
|
"Measurement Recommend"
|
||||||
],
|
],
|
||||||
"summary": "测量点推荐(搜索框自动补全)",
|
"summary": "测量点推荐(搜索框自动补全)",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "查询输入参数,例如 'trans' 或 'grid_key.'",
|
"description": "查询输入参数,例如 'trans' 或 'transformfeeder1_220.'",
|
||||||
"name": "request",
|
"name": "request",
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
|
|
@ -49,7 +49,25 @@ const docTemplate = `{
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "请求或查询失败。**注意**:HTTP 状态码始终为 200,但内部 Code 为 400 (参数错误) 或 500 (内部错误)。",
|
"description": "返回推荐列表成功",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/network.SuccessResponse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"payload": {
|
||||||
|
"$ref": "#/definitions/network.MeasurementRecommendPayload"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "返回推荐列表失败",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/network.FailureResponse"
|
"$ref": "#/definitions/network.FailureResponse"
|
||||||
}
|
}
|
||||||
|
|
@ -109,13 +127,7 @@ const docTemplate = `{
|
||||||
"example": "failed to get recommend data from redis"
|
"example": "failed to get recommend data from redis"
|
||||||
},
|
},
|
||||||
"payload": {
|
"payload": {
|
||||||
"type": "object",
|
"type": "object"
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"example": {
|
|
||||||
"key": "value"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -128,7 +140,7 @@ const docTemplate = `{
|
||||||
},
|
},
|
||||||
"offset": {
|
"offset": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"example": 20
|
"example": 21
|
||||||
},
|
},
|
||||||
"recommended_list": {
|
"recommended_list": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|
@ -137,7 +149,8 @@ const docTemplate = `{
|
||||||
},
|
},
|
||||||
"example": [
|
"example": [
|
||||||
"[\"I_A_rms\"",
|
"[\"I_A_rms\"",
|
||||||
" \"I_B_rms\"]"
|
" \"I_B_rms\"",
|
||||||
|
"\"I_C_rms\"]"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -163,13 +176,7 @@ const docTemplate = `{
|
||||||
"example": "success"
|
"example": "success"
|
||||||
},
|
},
|
||||||
"payload": {
|
"payload": {
|
||||||
"type": "object",
|
"type": "object"
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"example": {
|
|
||||||
"key": "value"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
"host": "localhost:8080",
|
"host": "localhost:8080",
|
||||||
"basePath": "/api/v1",
|
"basePath": "/api/v1",
|
||||||
"paths": {
|
"paths": {
|
||||||
"/api/v1/recommend/measurement": {
|
"/measurement/recommend": {
|
||||||
"post": {
|
"get": {
|
||||||
"description": "根据用户输入的字符串,从 Redis 中查询可能的测量点或结构路径,并提供推荐列表。",
|
"description": "根据用户输入的字符串,从 Redis 中查询可能的测量点或结构路径,并提供推荐列表。",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
|
|
@ -27,12 +27,12 @@
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Recommend"
|
"Measurement Recommend"
|
||||||
],
|
],
|
||||||
"summary": "测量点推荐(搜索框自动补全)",
|
"summary": "测量点推荐(搜索框自动补全)",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
{
|
{
|
||||||
"description": "查询输入参数,例如 'trans' 或 'grid_key.'",
|
"description": "查询输入参数,例如 'trans' 或 'transformfeeder1_220.'",
|
||||||
"name": "request",
|
"name": "request",
|
||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
|
|
@ -43,7 +43,25 @@
|
||||||
],
|
],
|
||||||
"responses": {
|
"responses": {
|
||||||
"200": {
|
"200": {
|
||||||
"description": "请求或查询失败。**注意**:HTTP 状态码始终为 200,但内部 Code 为 400 (参数错误) 或 500 (内部错误)。",
|
"description": "返回推荐列表成功",
|
||||||
|
"schema": {
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"$ref": "#/definitions/network.SuccessResponse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"payload": {
|
||||||
|
"$ref": "#/definitions/network.MeasurementRecommendPayload"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "返回推荐列表失败",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/network.FailureResponse"
|
"$ref": "#/definitions/network.FailureResponse"
|
||||||
}
|
}
|
||||||
|
|
@ -103,13 +121,7 @@
|
||||||
"example": "failed to get recommend data from redis"
|
"example": "failed to get recommend data from redis"
|
||||||
},
|
},
|
||||||
"payload": {
|
"payload": {
|
||||||
"type": "object",
|
"type": "object"
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"example": {
|
|
||||||
"key": "value"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -122,7 +134,7 @@
|
||||||
},
|
},
|
||||||
"offset": {
|
"offset": {
|
||||||
"type": "integer",
|
"type": "integer",
|
||||||
"example": 20
|
"example": 21
|
||||||
},
|
},
|
||||||
"recommended_list": {
|
"recommended_list": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
|
@ -131,7 +143,8 @@
|
||||||
},
|
},
|
||||||
"example": [
|
"example": [
|
||||||
"[\"I_A_rms\"",
|
"[\"I_A_rms\"",
|
||||||
" \"I_B_rms\"]"
|
" \"I_B_rms\"",
|
||||||
|
"\"I_C_rms\"]"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -157,13 +170,7 @@
|
||||||
"example": "success"
|
"example": "success"
|
||||||
},
|
},
|
||||||
"payload": {
|
"payload": {
|
||||||
"type": "object",
|
"type": "object"
|
||||||
"additionalProperties": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"example": {
|
|
||||||
"key": "value"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,6 @@ definitions:
|
||||||
example: failed to get recommend data from redis
|
example: failed to get recommend data from redis
|
||||||
type: string
|
type: string
|
||||||
payload:
|
payload:
|
||||||
additionalProperties:
|
|
||||||
type: string
|
|
||||||
example:
|
|
||||||
key: value
|
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
network.MeasurementRecommendPayload:
|
network.MeasurementRecommendPayload:
|
||||||
|
|
@ -21,12 +17,13 @@ definitions:
|
||||||
example: transformfeeder1_220.
|
example: transformfeeder1_220.
|
||||||
type: string
|
type: string
|
||||||
offset:
|
offset:
|
||||||
example: 20
|
example: 21
|
||||||
type: integer
|
type: integer
|
||||||
recommended_list:
|
recommended_list:
|
||||||
example:
|
example:
|
||||||
- '["I_A_rms"'
|
- '["I_A_rms"'
|
||||||
- ' "I_B_rms"]'
|
- ' "I_B_rms"'
|
||||||
|
- '"I_C_rms"]'
|
||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
type: array
|
type: array
|
||||||
|
|
@ -46,10 +43,6 @@ definitions:
|
||||||
example: success
|
example: success
|
||||||
type: string
|
type: string
|
||||||
payload:
|
payload:
|
||||||
additionalProperties:
|
|
||||||
type: string
|
|
||||||
example:
|
|
||||||
key: value
|
|
||||||
type: object
|
type: object
|
||||||
type: object
|
type: object
|
||||||
host: localhost:8080
|
host: localhost:8080
|
||||||
|
|
@ -65,13 +58,13 @@ info:
|
||||||
title: ModelRT 实时模型服务 API 文档
|
title: ModelRT 实时模型服务 API 文档
|
||||||
version: "1.0"
|
version: "1.0"
|
||||||
paths:
|
paths:
|
||||||
/api/v1/recommend/measurement:
|
/measurement/recommend:
|
||||||
post:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
description: 根据用户输入的字符串,从 Redis 中查询可能的测量点或结构路径,并提供推荐列表。
|
description: 根据用户输入的字符串,从 Redis 中查询可能的测量点或结构路径,并提供推荐列表。
|
||||||
parameters:
|
parameters:
|
||||||
- description: 查询输入参数,例如 'trans' 或 'grid_key.'
|
- description: 查询输入参数,例如 'trans' 或 'transformfeeder1_220.'
|
||||||
in: body
|
in: body
|
||||||
name: request
|
name: request
|
||||||
required: true
|
required: true
|
||||||
|
|
@ -81,13 +74,21 @@ paths:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: 请求或查询失败。**注意**:HTTP 状态码始终为 200,但内部 Code 为 400 (参数错误) 或 500
|
description: 返回推荐列表成功
|
||||||
(内部错误)。
|
schema:
|
||||||
|
allOf:
|
||||||
|
- $ref: '#/definitions/network.SuccessResponse'
|
||||||
|
- properties:
|
||||||
|
payload:
|
||||||
|
$ref: '#/definitions/network.MeasurementRecommendPayload'
|
||||||
|
type: object
|
||||||
|
"400":
|
||||||
|
description: 返回推荐列表失败
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/network.FailureResponse'
|
$ref: '#/definitions/network.FailureResponse'
|
||||||
summary: 测量点推荐(搜索框自动补全)
|
summary: 测量点推荐(搜索框自动补全)
|
||||||
tags:
|
tags:
|
||||||
- Recommend
|
- Measurement Recommend
|
||||||
/model/diagram_load/{page_id}:
|
/model/diagram_load/{page_id}:
|
||||||
get:
|
get:
|
||||||
consumes:
|
consumes:
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,35 @@ import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MeasurementRecommendHandler define measurement recommend API
|
|
||||||
// MeasurementRecommendHandler define measurement recommend API
|
// MeasurementRecommendHandler define measurement recommend API
|
||||||
// @Summary 测量点推荐(搜索框自动补全)
|
// @Summary 测量点推荐(搜索框自动补全)
|
||||||
// @Description 根据用户输入的字符串,从 Redis 中查询可能的测量点或结构路径,并提供推荐列表。
|
// @Description 根据用户输入的字符串,从 Redis 中查询可能的测量点或结构路径,并提供推荐列表。
|
||||||
// @Tags Recommend
|
// @Tags Measurement Recommend
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param request body network.MeasurementRecommendRequest true "查询输入参数,例如 'trans' 或 'grid_key.'"
|
// @Param request body network.MeasurementRecommendRequest true "查询输入参数,例如 'trans' 或 'transformfeeder1_220.'"
|
||||||
// @Success 200 {object} network.SuccessResponse{payload=network.MeasurementRecommendPayload} "成功返回推荐列表"
|
// @Success 200 {object} network.SuccessResponse{payload=network.MeasurementRecommendPayload} "返回推荐列表成功"
|
||||||
// @Failure 200 {object} network.FailureResponse "请求或查询失败。**注意**:HTTP 状态码始终为 200,但内部 Code 为 400 (参数错误) 或 500 (内部错误)。"
|
//
|
||||||
// @Router /api/v1/recommend/measurement [post]
|
// @Example 200 {
|
||||||
|
// "code": 200,
|
||||||
|
// "msg": "success",
|
||||||
|
// "payload": {
|
||||||
|
// "input": "transformfeeder1_220.",
|
||||||
|
// "offset": 21,
|
||||||
|
// "recommended_list": [
|
||||||
|
// "I_A_rms",
|
||||||
|
// "I_B_rms",
|
||||||
|
// "I_C_rms",
|
||||||
|
// ]
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Failure 400 {object} network.FailureResponse "返回推荐列表失败"
|
||||||
|
// @Example 400 {
|
||||||
|
// "code": 400,
|
||||||
|
// "msg": "failed to get recommend data from redis",
|
||||||
|
// }
|
||||||
|
// @Router /measurement/recommend [get]
|
||||||
func MeasurementRecommendHandler(c *gin.Context) {
|
func MeasurementRecommendHandler(c *gin.Context) {
|
||||||
var request network.MeasurementRecommendRequest
|
var request network.MeasurementRecommendRequest
|
||||||
|
|
||||||
|
|
@ -84,10 +102,15 @@ func MeasurementRecommendHandler(c *gin.Context) {
|
||||||
c.JSON(http.StatusOK, network.SuccessResponse{
|
c.JSON(http.StatusOK, network.SuccessResponse{
|
||||||
Code: http.StatusOK,
|
Code: http.StatusOK,
|
||||||
Msg: "success",
|
Msg: "success",
|
||||||
PayLoad: map[string]any{
|
// PayLoad: map[string]any{
|
||||||
"input": request.Input,
|
// "input": request.Input,
|
||||||
"offset": finalOffset,
|
// "offset": finalOffset,
|
||||||
"recommended_list": resultRecommends,
|
// "recommended_list": resultRecommends,
|
||||||
|
// },
|
||||||
|
PayLoad: &network.MeasurementRecommendPayload{
|
||||||
|
Input: request.Input,
|
||||||
|
Offset: finalOffset,
|
||||||
|
RecommendedList: resultRecommends,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,22 @@ package network
|
||||||
|
|
||||||
// FailureResponse define struct of standard failure API response format
|
// FailureResponse define struct of standard failure API response format
|
||||||
type FailureResponse struct {
|
type FailureResponse struct {
|
||||||
Code int `json:"code" example:"500"`
|
Code int `json:"code" example:"500"`
|
||||||
Msg string `json:"msg" example:"failed to get recommend data from redis"`
|
Msg string `json:"msg" example:"failed to get recommend data from redis"`
|
||||||
PayLoad map[string]interface{} `json:"payload" swaggertype:"object,string" example:"key:value"`
|
PayLoad any `json:"payload" swaggertype:"object"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// SuccessResponse define struct of standard successful API response format
|
// SuccessResponse define struct of standard successful API response format
|
||||||
type SuccessResponse struct {
|
type SuccessResponse struct {
|
||||||
Code int `json:"code" example:"200"`
|
Code int `json:"code" example:"200"`
|
||||||
Msg string `json:"msg" example:"success"`
|
Msg string `json:"msg" example:"success"`
|
||||||
PayLoad map[string]interface{} `json:"payload" swaggertype:"object,string" example:"key:value"`
|
PayLoad any `json:"payload" swaggertype:"object"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MeasurementRecommendPayload define struct of represents the data payload for the successful recommendation response.
|
// MeasurementRecommendPayload define struct of represents the data payload for the successful recommendation response.
|
||||||
type MeasurementRecommendPayload struct {
|
type MeasurementRecommendPayload struct {
|
||||||
Input string `json:"input" example:"transformfeeder1_220."`
|
Input string `json:"input" example:"transformfeeder1_220."`
|
||||||
Offset int `json:"offset" example:"20"`
|
Offset int `json:"offset" example:"21"`
|
||||||
RecommendedList []string `json:"recommended_list" example:"[\"I_A_rms\", \"I_B_rms\"]"`
|
RecommendedList []string `json:"recommended_list" example:"[\"I_A_rms\", \"I_B_rms\",\"I_C_rms\"]"`
|
||||||
|
// RecommendedList []string `json:"recommended_list"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue