按照code列表初始化异常码表
This commit is contained in:
parent
a038f90ed8
commit
292fcf0839
23
code.go
23
code.go
@ -26,12 +26,12 @@ func init() {
|
|||||||
codeTable = make(map[interface{}]Code)
|
codeTable = make(map[interface{}]Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitCodeTable 初始化码表, 同时只指定代表业务成功的状态码以及使用的语言
|
// InitCodeTableWithMessage 初始化码表, 同时只指定代表业务成功的状态码以及使用的语言
|
||||||
//
|
//
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
//
|
//
|
||||||
// Date : 20:55 2022/6/25
|
// Date : 20:55 2022/6/25
|
||||||
func InitCodeTable(table map[interface{}]map[string]string, convertDefaultSuccessCode interface{}, convertDefaultLanguage string) {
|
func InitCodeTableWithMessage(table map[interface{}]map[string]string, convertDefaultSuccessCode interface{}, convertDefaultLanguage string) {
|
||||||
for code, message := range table {
|
for code, message := range table {
|
||||||
codeTable[code] = Code{
|
codeTable[code] = Code{
|
||||||
Value: code,
|
Value: code,
|
||||||
@ -50,6 +50,25 @@ func InitCodeTable(table map[interface{}]map[string]string, convertDefaultSucces
|
|||||||
defaultLanguage = convertDefaultLanguage
|
defaultLanguage = convertDefaultLanguage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InitCodeTableWithCodeList 按照code列表初始化
|
||||||
|
//
|
||||||
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
|
//
|
||||||
|
// Date : 16:19 2023/6/9
|
||||||
|
func InitCodeTableWithCodeList(list []Code, convertDefaultSuccessCode interface{}, convertDefaultLanguage string) {
|
||||||
|
for _, itemCode := range list {
|
||||||
|
codeTable[itemCode.Value] = itemCode
|
||||||
|
}
|
||||||
|
if nil == convertDefaultSuccessCode {
|
||||||
|
convertDefaultSuccessCode = 0
|
||||||
|
}
|
||||||
|
if len(convertDefaultLanguage) == 0 {
|
||||||
|
convertDefaultLanguage = defaultLanguage
|
||||||
|
}
|
||||||
|
defaultSuccessCode = convertDefaultSuccessCode
|
||||||
|
defaultLanguage = convertDefaultLanguage
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// messageWithCode 自动在message文案后追加状态码
|
// messageWithCode 自动在message文案后追加状态码
|
||||||
messageWithCode = true
|
messageWithCode = true
|
||||||
|
Loading…
Reference in New Issue
Block a user