fix init table
This commit is contained in:
parent
84811e426c
commit
e8561a060c
14
code.go
14
code.go
@ -38,7 +38,7 @@ func InitCodeTableWithMessage(table map[interface{}]map[string]string, convertDe
|
||||
c := Code{
|
||||
Value: code,
|
||||
Message: message,
|
||||
Reason: make(map[string][]*CodeReason),
|
||||
Reason: make([]*CodeReason, 0),
|
||||
}
|
||||
|
||||
codeTable[code] = c
|
||||
@ -63,13 +63,19 @@ func InitCodeTableWithCodeList(list []Code, convertDefaultSuccessCode interface{
|
||||
codeList = list
|
||||
for _, itemCode := range list {
|
||||
if nil == itemCode.Reason {
|
||||
itemCode.Reason = make(map[string][]*CodeReason)
|
||||
itemCode.Reason = make([]*CodeReason, 0)
|
||||
}
|
||||
|
||||
for lang, _ := range itemCode.Message {
|
||||
if _, exist := itemCode.Reason[lang]; !exist {
|
||||
itemCode.Reason[lang] = make([]*CodeReason, 0)
|
||||
for _, itemReason := range itemCode.Reason {
|
||||
if _, exist := itemReason.Reason[lang]; !exist {
|
||||
continue
|
||||
}
|
||||
if _, exist := itemReason.Solution[lang]; !exist {
|
||||
itemReason.Solution[lang] = make([]string, 0)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
codeTable[itemCode.Value] = itemCode
|
||||
|
Loading…
Reference in New Issue
Block a user