diff --git a/app/config/term.go b/app/config/term.go index b637e8a..ed9a178 100644 --- a/app/config/term.go +++ b/app/config/term.go @@ -3,8 +3,10 @@ package config const termYearKey = "termYearKey" const termKey = "termKey" const termStartDate = "termStartDate" +const scoreTermYearKey = "scoreTermYearKey" +const scoreTermKey = "scoreTermKey" -func SetTermInfo(yearValue, termValue, termStartDateValue string) error { +func SetTermInfo(yearValue, termValue, termStartDateValue, scoreYearValue, scoreTermValue string) error { err := setConfig(termYearKey, yearValue) if err != nil { return err @@ -14,11 +16,19 @@ func SetTermInfo(yearValue, termValue, termStartDateValue string) error { return err } err = setConfig(termStartDate, termStartDateValue) + if err != nil { + return err + } + err = setConfig(scoreTermYearKey, scoreYearValue) + if err != nil { + return err + } + err = setConfig(scoreTermKey, scoreTermValue) return err } -func GetTermInfo() (string, string, string) { - return getConfig(termYearKey), getConfig(termKey), getConfig(termStartDate) +func GetTermInfo() (string, string, string, string, string) { + return getConfig(termYearKey), getConfig(termKey), getConfig(termStartDate), getConfig(scoreTermYearKey), getConfig(scoreTermKey) } func IsSetTermInfo() bool { diff --git a/app/controllers/adminController/init.go b/app/controllers/adminController/init.go index e86995b..eeb8a07 100644 --- a/app/controllers/adminController/init.go +++ b/app/controllers/adminController/init.go @@ -12,6 +12,8 @@ type termInfoForm struct { YearValue string `json:"yearValue"` TermValue string `json:"termValue"` TermStartDateValue string `json:"termStartDateValue"` + ScoreYearValue string `json:"scoreYearValue"` + ScoreTermValue string `json:"scoreTermValue"` } type encryptForm struct { @@ -65,7 +67,7 @@ func SetTermInfo(c *gin.Context) { return } - err = config.SetTermInfo(postForm.YearValue, postForm.TermValue, postForm.TermStartDateValue) + err = config.SetTermInfo(postForm.YearValue, postForm.TermValue, postForm.TermStartDateValue, postForm.ScoreYearValue, postForm.ScoreTermValue) if err != nil { _ = c.AbortWithError(200, apiException.ServerError) return diff --git a/app/controllers/systemController/controlInfo.go b/app/controllers/systemController/controlInfo.go index b4ec0cb..56224ae 100644 --- a/app/controllers/systemController/controlInfo.go +++ b/app/controllers/systemController/controlInfo.go @@ -8,7 +8,7 @@ import ( ) func Info(c *gin.Context) { - year, term, startTimeString := config.GetTermInfo() + year, term, startTimeString, scoreYear, scoreTerm := config.GetTermInfo() startTime, _ := time.Parse("2006-01-02", startTimeString) // 学期开始的时间 currentTime := time.Now() schoolBusUrl := config.GetSchoolBusUrl() @@ -23,8 +23,9 @@ func Info(c *gin.Context) { "termStartDate": startTimeString, "termYear": year, "term": term, + "scoreYear": scoreYear, + "scoreTerm": scoreTerm, "week": week, - "score": "下", //TODO 特殊时期过去后删除 "schoolBusUrl": schoolBusUrl, })