File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -65,9 +65,9 @@ func ExtractIDFromLoginData(data *model.LoginData) string {
6565// 研究生:id直接是stuId,以 00000 为前缀(可能是 9 或 10 位)
6666// 本科生:identifier 末尾为学号,按入学年份判断是 9 位还是 10 位
6767// 2026年开始本科生学号由9位变到10位
68- // 本科生identifier规则:yyyymmdd + hhmmss + 学号,长度不定
69- // 比如2026年8月5日 ,开头就是202685,12月17日就是20261217
70- // 时间也是一样,24小时制,当日1时50分07秒就是1507 ,10时0分0秒就是1000,12时37分59秒就是123759
68+ // 本科生identifier规则:请求时间 yyyymmdd + hhmmss + 学号,长度不定
69+ // 比如请求时间在2026年8月5日 ,开头就是202685,12月17日就是20261217
70+ // 时间也是一样,24小时制,当日1时50分7秒就是1507 ,10时0分0秒就是1000,12时37分59秒就是123759
7171func ExtractIDFromIdentifier (id string ) string {
7272 if len (id ) < constants .StudentIDLength {
7373 return ""
Original file line number Diff line number Diff line change @@ -43,8 +43,8 @@ func TestExtractIDFromIdentifier(t *testing.T) {
4343 },
4444 {
4545 name : "本科生-10位学号" ,
46- id : "202685148141026012345 " ,
47- want : "1026012345 " ,
46+ id : "202685148140102612345 " ,
47+ want : "0102612345 " ,
4848 },
4949 {
5050 name : "过短" ,
Original file line number Diff line number Diff line change @@ -26,5 +26,5 @@ const (
2626 // 2026年(含)起入学的新生学号由9位变为10位。
2727 // 学号第3-4位为入学年份(如 22/25/26),年份 >= StudentIDYearThreshold 时为10位新学号。
2828 StudentIDLengthNew = 10
29- StudentIDYearThreshold = "26"
29+ StudentIDYearThreshold = 26
3030)
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ limitations under the License.
1717package utils
1818
1919import (
20+ "strconv"
2021 "strings"
2122
2223 "github.com/west2-online/fzuhelper-server/pkg/constants"
@@ -47,7 +48,8 @@ func RemoveUndergraduatePrefix(id string) string {
4748 // 先取后9位,其第3-4位为入学年份
4849 last9 := id [len (id )- constants .StudentIDLength :]
4950 // 年份 >= 26(2026年起入学)为10位新学号,取后10位
50- if len (id ) >= constants .StudentIDLengthNew && last9 [2 :4 ] >= constants .StudentIDYearThreshold {
51+ year , err := strconv .Atoi (last9 [2 :4 ])
52+ if err == nil && len (id ) >= constants .StudentIDLengthNew && year >= constants .StudentIDYearThreshold {
5153 return id [len (id )- constants .StudentIDLengthNew :]
5254 }
5355 return last9
You can’t perform that action at this time.
0 commit comments