Skip to content

Commit

Permalink
成绩查询时间和学年学期时间分离
Browse files Browse the repository at this point in the history
Signed-off-by: cbluebird <[email protected]>
  • Loading branch information
cbluebird committed Aug 26, 2023
1 parent a2b42bb commit 5044a61
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
16 changes: 13 additions & 3 deletions app/config/term.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/adminController/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/systemController/controlInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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,
})

Expand Down

0 comments on commit 5044a61

Please sign in to comment.