Skip to content

Commit

Permalink
Optimize timeline code conditional judgement
Browse files Browse the repository at this point in the history
  • Loading branch information
guanguans committed Apr 29, 2022
1 parent ab49904 commit 93b4b12
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions data/address_code_timeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ var provinceAddressCodeTimelinePluck = map[string]func() map[int][]map[string]st
}

func GetAddressCodeTimeline(code int) ([]map[string]string, bool) {
codeStr := cast.ToString(code)
if len(codeStr) < 2 {
return nil, false
if code < 110000 || code > 830000 {
return []map[string]string{}, false
}

f, ok := provinceAddressCodeTimelinePluck[codeStr[:2]]
f, ok := provinceAddressCodeTimelinePluck[cast.ToString(code)[:2]]
if !ok {
timeline, ok := getAddressCodeTimelineAdditional()[code]
return timeline, ok
Expand Down

0 comments on commit 93b4b12

Please sign in to comment.