NumToShortID num to string
(id int64)
| 30 | |
| 31 | // NumToShortID num to string |
| 32 | func NumToShortID(id int64) string { |
| 33 | sid := strconv.FormatInt(id, 10) |
| 34 | if len(sid) < 17 { |
| 35 | return "" |
| 36 | } |
| 37 | sTypeCode := sid[1:4] |
| 38 | sid = sid[4:int32(len(sid))] |
| 39 | id, err := strconv.ParseInt(sid, 10, 64) |
| 40 | if err != nil { |
| 41 | return "" |
| 42 | } |
| 43 | typeCode, err := strconv.ParseInt(sTypeCode, 10, 64) |
| 44 | if err != nil { |
| 45 | return "" |
| 46 | } |
| 47 | code := utils.EnShortID(id, salt) |
| 48 | tcode := utils.EnShortID(typeCode, salt) |
| 49 | return tcode + code |
| 50 | } |
| 51 | |
| 52 | // ShortIDToNum string to num |
| 53 | func ShortIDToNum(code string) int64 { |