Skip to content

Commit

Permalink
Optimize get timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
guanguans committed Apr 29, 2022
1 parent ab1345d commit 7429f1a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ func generatorBirthdayCode(addressCode string, address string, birthday string)
day := datePipeHandle(datePad(substr(birthday, 6, 8), "day"), "day")

addressCodeInt := cast.ToInt(addressCode)
if _, ok := data.AddressCodeTimeline[addressCodeInt]; ok {
timeLine := data.AddressCodeTimeline[addressCodeInt]
if timeLine, ok := data.AddressCodeTimeline[addressCodeInt]; ok {
for _, val := range timeLine {
if val["address"] == address {
if val["start_year"] != "" {
Expand Down
4 changes: 2 additions & 2 deletions helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func getAddressInfo(addressCode string, birthdayCode string, strict bool) map[st
func getAddress(addressCode string, birthdayCode string, strict bool) string {
address := ""
addressCodeInt := cast.ToInt(addressCode)
if _, ok := data.AddressCodeTimeline[addressCodeInt]; !ok {
timeline, ok := data.AddressCodeTimeline[addressCodeInt]
if !ok {
// 修复 \d\d\d\d01、\d\d\d\d02、\d\d\d\d11 和 \d\d\d\d20 的历史遗留问题
// 以上四种地址码,现实身份证真实存在,但民政部历年公布的官方地址码中可能没有查询到
// 如:440401 450111 等
Expand All @@ -66,7 +67,6 @@ func getAddress(addressCode string, birthdayCode string, strict bool) string {
return address
}

timeline := data.AddressCodeTimeline[addressCodeInt]
year := cast.ToInt(substr(birthdayCode, 0, 4))
startYear := "0001"
endYear := "9999"
Expand Down

0 comments on commit 7429f1a

Please sign in to comment.