优化枚举值定义
This commit is contained in:
78
request.go
78
request.go
@ -7,33 +7,79 @@
|
||||
// Date : 2024-04-22 11:04
|
||||
package consts
|
||||
|
||||
import "git.zhangdeman.cn/zhangdeman/consts/enums"
|
||||
// RequestDataLocation 请求数据所在位置
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:40 2024/11/25
|
||||
type RequestDataLocation string
|
||||
|
||||
func (rdl RequestDataLocation) String() string {
|
||||
return string(rdl)
|
||||
}
|
||||
|
||||
func (rdl RequestDataLocation) MarshalJSON() ([]byte, error) {
|
||||
return []byte(rdl.String()), nil
|
||||
}
|
||||
|
||||
func (rdl RequestDataLocation) IsValid() bool {
|
||||
for _, item := range RequestDataLocationList {
|
||||
if item.Value == rdl {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ResponseDataLocation 响应数据所在位置
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 14:41 2024/11/25
|
||||
type ResponseDataLocation string
|
||||
|
||||
func (rdl ResponseDataLocation) String() string {
|
||||
return string(rdl)
|
||||
}
|
||||
|
||||
func (rdl ResponseDataLocation) MarshalJSON() ([]byte, error) {
|
||||
return []byte(rdl.String()), nil
|
||||
}
|
||||
|
||||
func (rdl ResponseDataLocation) IsValid() bool {
|
||||
for _, item := range ResponseDataLocationList {
|
||||
if item.Value == rdl {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
const (
|
||||
RequestDataLocationHeader enums.RequestDataLocation = "HEADER" // header
|
||||
RequestDataLocationCookie enums.RequestDataLocation = "COOKIE" // cookie
|
||||
RequestDataLocationBody enums.RequestDataLocation = "BODY" // body
|
||||
RequestDataLocationQuery enums.RequestDataLocation = "QUERY" // query
|
||||
RequestDataLocationUriPath enums.RequestDataLocation = "URI_PATH" // uri路由一部分
|
||||
RequestDataLocationStatic enums.RequestDataLocation = "STATIC" // 静态配置的参数
|
||||
RequestDataLocationCustomConfig enums.RequestDataLocation = "CUSTOM_CONFIG" // 针对接口的一些自定义配置规则
|
||||
RequestDataLocationHeader RequestDataLocation = "HEADER" // header
|
||||
RequestDataLocationCookie RequestDataLocation = "COOKIE" // cookie
|
||||
RequestDataLocationBody RequestDataLocation = "BODY" // body
|
||||
RequestDataLocationQuery RequestDataLocation = "QUERY" // query
|
||||
RequestDataLocationUriPath RequestDataLocation = "URI_PATH" // uri路由一部分
|
||||
RequestDataLocationStatic RequestDataLocation = "STATIC" // 静态配置的参数
|
||||
RequestDataLocationCustomConfig RequestDataLocation = "CUSTOM_CONFIG" // 针对接口的一些自定义配置规则
|
||||
)
|
||||
|
||||
const (
|
||||
ResponseDataLocationHeader enums.ResponseDataLocation = "HEADER" // header
|
||||
ResponseDataLocationCookie enums.ResponseDataLocation = "COOKIE" // cookie
|
||||
ResponseDataLocationBody enums.ResponseDataLocation = "BODY" // body
|
||||
ResponseDataLocationExtension enums.ResponseDataLocation = "EXTENSION" // 扩展信息
|
||||
ResponseDataLocationHeader ResponseDataLocation = "HEADER" // header
|
||||
ResponseDataLocationCookie ResponseDataLocation = "COOKIE" // cookie
|
||||
ResponseDataLocationBody ResponseDataLocation = "BODY" // body
|
||||
ResponseDataLocationExtension ResponseDataLocation = "EXTENSION" // 扩展信息
|
||||
)
|
||||
|
||||
type RequestDataLocationDesc struct {
|
||||
Value enums.RequestDataLocation `json:"value"` // 数据位置
|
||||
Description string `json:"description"` // 数据位置描述
|
||||
Value RequestDataLocation `json:"value"` // 数据位置
|
||||
Description string `json:"description"` // 数据位置描述
|
||||
}
|
||||
|
||||
type ResponseDataLocationDesc struct {
|
||||
Value enums.ResponseDataLocation `json:"value"` // 数据位置
|
||||
Description string `json:"description"` // 数据位置描述
|
||||
Value ResponseDataLocation `json:"value"` // 数据位置
|
||||
Description string `json:"description"` // 数据位置描述
|
||||
}
|
||||
|
||||
var (
|
||||
|
Reference in New Issue
Block a user