更新枚举类型定义

This commit is contained in:
白茶清欢 2024-11-25 16:15:57 +08:00
parent f919222003
commit cacc6b3caf
5 changed files with 174 additions and 66 deletions

View File

@ -7,13 +7,41 @@
// Date : 2023-08-11 10:59 // Date : 2023-08-11 10:59
package consts package consts
type FileType string
func (ft FileType) String() string {
return string(ft)
}
func (ft FileType) MarshalJSON() ([]byte, error) {
return []byte(ft.String()), nil
}
func (ft FileType) IsValid() bool {
supportFileTypeList := []FileType{
FileTypeJson,
FileTypeIni,
FileTypeYml,
FileTypeYaml,
FileTypeToml,
FileTypeXml,
FileTypeTxt,
}
for _, fileType := range supportFileTypeList {
if fileType == ft {
return true
}
}
return false
}
const ( const (
FileTypeJson = "json" // json格式文件 FileTypeJson FileType = "json" // json格式文件
FileTypeIni = "ini" // ini格式文件 FileTypeIni FileType = "ini" // ini格式文件
FileTypeYml = "yml" // yml 格式文件 FileTypeYml FileType = "yml" // yml 格式文件
FileTypeYaml = "yaml" // yaml格式文件 FileTypeYaml FileType = "yaml" // yaml格式文件
FileTypeToml = "toml" // toml格式文件 FileTypeToml FileType = "toml" // toml格式文件
FileTypeXml = "xml" // xml格式文件 FileTypeXml FileType = "xml" // xml格式文件
FileTypeTxt = "txt" // txt格式文件 FileTypeTxt FileType = "txt" // txt格式文件
FileTypeUnknown = "unknown" // 未知格式 FileTypeUnknown FileType = "unknown" // 未知格式
) )

View File

@ -7,10 +7,20 @@
// Date : 2024-01-04 20:28 // Date : 2024-01-04 20:28
package consts package consts
type HttpHeader string
func (hh HttpHeader) String() string {
return string(hh)
}
func (hh HttpHeader) MarshalJSON() ([]byte, error) {
return []byte(hh.String()), nil
}
const ( const (
HeaderKeyAccessControlAllowOrigin = "Access-Control-Allow-Origin" // 标识允许哪个域的请求 HeaderKeyAccessControlAllowOrigin HttpHeader = "Access-Control-Allow-Origin" // 标识允许哪个域的请求
HeaderKeyAccessControlAllowHeaders = "Access-Control-Allow-Headers" // 标识允许的请求header HeaderKeyAccessControlAllowHeaders HttpHeader = "Access-Control-Allow-Headers" // 标识允许的请求header
HeaderKeyAccessControlAllowMethods = "Access-Control-Allow-Methods" // 标识允许的请求方法 HeaderKeyAccessControlAllowMethods HttpHeader = "Access-Control-Allow-Methods" // 标识允许的请求方法
HeaderKeyAccessControlExposeHeaders = "Access-Control-Expose-Headers" // 允许浏览器端能够获取相应的header值 HeaderKeyAccessControlExposeHeaders HttpHeader = "Access-Control-Expose-Headers" // 允许浏览器端能够获取相应的header值
HeaderKeyAccessControlMaxAge = "Access-Control-Max-Age" // 控制发送预检请求options的频率单位 : 秒 HeaderKeyAccessControlMaxAge HttpHeader = "Access-Control-Max-Age" // 控制发送预检请求options的频率单位 : 秒
) )

View File

@ -7,14 +7,64 @@
// Date : 2024-06-24 15:46 // Date : 2024-06-24 15:46
package consts package consts
type LogLevel string
func (ll LogLevel) String() string {
return string(ll)
}
func (ll LogLevel) MarshalJSON() ([]byte, error) {
return []byte(ll.String()), nil
}
func (ll LogLevel) IsValid() bool {
levelList := []LogLevel{
LogLevelDebug,
LogLevelInfo,
LogLevelWarn,
LogLevelError,
LogLevelPanic,
}
for _, level := range levelList {
if level == ll {
return true
}
}
return false
}
const ( const (
LogLevelDebug = "DEBUG" LogLevelDebug LogLevel = "DEBUG"
LogLevelInfo = "INFO" LogLevelInfo LogLevel = "INFO"
LogLevelWarn = "WARN" LogLevelWarn LogLevel = "WARN"
LogLevelError = "ERROR" LogLevelError LogLevel = "ERROR"
LogLevelPanic = "PANIC" LogLevelPanic LogLevel = "PANIC"
) )
type LogSplit string
func (ls LogSplit) String() string {
return string(ls)
}
func (ls LogSplit) MarshalJSON() ([]byte, error) {
return []byte(ls.String()), nil
}
func (ls LogSplit) IsValid() bool {
supportSplitList := []LogSplit{
LogSplitHour,
LogSplitDay,
LogSplitMonth,
LogSplitYear,
}
for _, supportSplit := range supportSplitList {
if supportSplit == ls {
return true
}
}
return false
}
const ( const (
LogSplitHour = "HOUR" LogSplitHour = "HOUR"
LogSplitDay = "DAY" LogSplitDay = "DAY"

View File

@ -7,29 +7,39 @@
// Date : 2024-10-08 16:32 // Date : 2024-10-08 16:32
package consts package consts
type RedisCmd string
func (rc RedisCmd) String() string {
return string(rc)
}
func (rc RedisCmd) MarshalJSON() ([]byte, error) {
return []byte(rc.String()), nil
}
const ( const (
RedisCommandExists = "EXISTS" RedisCommandExists RedisCmd = "EXISTS"
RedisCommandTTL = "TTL" RedisCommandTTL RedisCmd = "TTL"
RedisCommandSet = "SET" RedisCommandSet RedisCmd = "SET"
RedisCommandDel = "DEL" RedisCommandDel RedisCmd = "DEL"
RedisCommandGet = "GET" RedisCommandGet RedisCmd = "GET"
RedisCommandHget = "HGET" RedisCommandHget RedisCmd = "HGET"
RedisCommandHset = "HSET" RedisCommandHset RedisCmd = "HSET"
RedisCommandHdel = "HDEL" RedisCommandHdel RedisCmd = "HDEL"
RedisCommandMGet = "MGET" RedisCommandMGet RedisCmd = "MGET"
RedisCommandMSet = "MSET" RedisCommandMSet RedisCmd = "MSET"
RedisCommandLpush = "LPUSH" RedisCommandLpush RedisCmd = "LPUSH"
RedisCommandLpop = "LPOP" RedisCommandLpop RedisCmd = "LPOP"
RedisCommandRpush = "RPUSH" RedisCommandRpush RedisCmd = "RPUSH"
RedisCommandRpop = "RPOP" RedisCommandRpop RedisCmd = "RPOP"
RedisCommandSadd = "SADD" RedisCommandSadd RedisCmd = "SADD"
RedisCommandSunionstore = "SUNIONSTORE" RedisCommandSunionstore RedisCmd = "SUNIONSTORE"
RedisCommandZadd = "ZADD" RedisCommandZadd RedisCmd = "ZADD"
RedisCommandZincrby = "ZINCRBY" RedisCommandZincrby RedisCmd = "ZINCRBY"
RedisCommandPsubScribe = "PSUBSCRIBE" RedisCommandPsubScribe RedisCmd = "PSUBSCRIBE"
RedisCommandPubsub = "PUBSUB" RedisCommandPubsub RedisCmd = "PUBSUB"
RedisCommandPublish = "PUBLISH" RedisCommandPublish RedisCmd = "PUBLISH"
RedisCommandPunsubScribe = "PUNSUBSCRIBE" RedisCommandPunsubScribe RedisCmd = "PUNSUBSCRIBE"
RedisCommandSubscribe = "SUBSCRIBE" RedisCommandSubscribe RedisCmd = "SUBSCRIBE"
RedisCommandUnsubscribe = "UNSUBSCRIBE" RedisCommandUnsubscribe RedisCmd = "UNSUBSCRIBE"
) )

View File

@ -7,32 +7,42 @@
// Date : 2024-01-01 14:33 // Date : 2024-01-01 14:33
package consts package consts
type HttpScheme string
func (hs HttpScheme) String() string {
return string(hs)
}
func (hs HttpScheme) MarshalJSON() ([]byte, error) {
return []byte(hs.String()), nil
}
const ( const (
SchemeHTTP = "http" SchemeHTTP HttpScheme = "http"
SchemeHTTPS = "https" SchemeHTTPS HttpScheme = "https"
SchemeWs = "ws" SchemeWs HttpScheme = "ws"
SchemeWss = "wss" SchemeWss HttpScheme = "wss"
SchemeSms = "sms" // SchemeSms 短信 SchemeSms HttpScheme = "sms" // SchemeSms 短信
SchemeTel = "tel" // SchemeTel 电话 SchemeTel HttpScheme = "tel" // SchemeTel 电话
SchemeMobileNotes = "mobilenotes" // SchemeMobileNotes 备忘录 SchemeMobileNotes HttpScheme = "mobilenotes" // SchemeMobileNotes 备忘录
SchemeMessage = "MESSAGE" // SchemeMessage E-MAIL SchemeMessage HttpScheme = "MESSAGE" // SchemeMessage E-MAIL
SchemeAliPay = "alipay" // SchemeAliPay 支付宝 SchemeAliPay HttpScheme = "alipay" // SchemeAliPay 支付宝
SchemeDingTalk = "dingtalk" // SchemeDingTalk 钉钉 SchemeDingTalk HttpScheme = "dingtalk" // SchemeDingTalk 钉钉
SchemeWeChat = "wechat" // SchemeWeChat 微信 SchemeWeChat HttpScheme = "wechat" // SchemeWeChat 微信
SchemeWeiXin = "weixin" // SchemeWeiXin 微信 SchemeWeiXin HttpScheme = "weixin" // SchemeWeiXin 微信
SchemeTCP = "tcp" SchemeTCP HttpScheme = "tcp"
SchemeUDP = "udp" SchemeUDP HttpScheme = "udp"
SchemeUnix = "unix" SchemeUnix HttpScheme = "unix"
SchemeKCP = "kcp" SchemeKCP HttpScheme = "kcp"
SchemeQuic = "quic" SchemeQuic HttpScheme = "quic"
SchemeGRPC = "grpc" SchemeGRPC HttpScheme = "grpc"
SchemeMQTT = "mqtt" SchemeMQTT HttpScheme = "mqtt"
SchemeMQTT5 = "mqtt5" SchemeMQTT5 HttpScheme = "mqtt5"
SchemeMQTTN = "mqttn" SchemeMQTTN HttpScheme = "mqttn"
SchemeMQTTv3 = "mqttv3" SchemeMQTTv3 HttpScheme = "mqttv3"
SchemeMQTTv4 = "mqttv4" SchemeMQTTv4 HttpScheme = "mqttv4"
SchemeMQTTv5 = "mqttv5" SchemeMQTTv5 HttpScheme = "mqttv5"
) )