优化结构体定义
This commit is contained in:
48
common.go
48
common.go
@ -33,7 +33,55 @@ func GetUriPathParamList(uriPath string) []*define.ParamConfig {
|
||||
Type: consts.DataTypeString.String(),
|
||||
Title: param,
|
||||
Description: param,
|
||||
IsRequired: true,
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// GetParamType 将文档配置的数据类型转换为归一化处理后的数据类型
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 11:52 2024/12/24
|
||||
func GetParamType(docParamType string, formatType string) consts.DataType {
|
||||
docParamType = strings.ToLower(docParamType)
|
||||
formatType = strings.ToLower(formatType)
|
||||
if len(formatType) == 0 {
|
||||
formatType = docParamType
|
||||
}
|
||||
switch docParamType {
|
||||
case "integer":
|
||||
if formatType == "int64" {
|
||||
return consts.DataTypeInt
|
||||
}
|
||||
return consts.DataTypeUint
|
||||
case "string":
|
||||
return consts.DataTypeString
|
||||
default:
|
||||
return consts.DataTypeAny
|
||||
}
|
||||
}
|
||||
|
||||
// GetParamLocation 获取参数位置
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 12:02 2024/12/24
|
||||
func GetParamLocation(docParamLocation string) consts.RequestDataLocation {
|
||||
docParamLocation = strings.ToLower(docParamLocation)
|
||||
switch docParamLocation {
|
||||
case "query":
|
||||
return consts.RequestDataLocationQuery
|
||||
case "header":
|
||||
return consts.RequestDataLocationHeader
|
||||
case "cookie":
|
||||
return consts.RequestDataLocationCookie
|
||||
case "body":
|
||||
return consts.RequestDataLocationBody
|
||||
case "path":
|
||||
return consts.RequestDataLocationUriPath
|
||||
default:
|
||||
return consts.RequestDataLocationQuery
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user