1
0
mirror of https://github.com/fumiama/paper-manager.git synced 2026-06-13 05:03:16 +08:00

初步完成step1前端设计

This commit is contained in:
源文雨
2023-04-24 00:59:06 +08:00
parent ff831f2f7a
commit aabd25ea19
10 changed files with 326 additions and 77 deletions

View File

@@ -4,6 +4,7 @@ import (
"container/heap"
"encoding/json"
"math"
"net/http"
"strconv"
"github.com/fumiama/paper-manager/backend/global"
@@ -95,3 +96,22 @@ func parseFileQuestions(qb []byte, istemp bool) ([]question, []duplication, floa
return qs, ds, sum / float64(cnt), nil
}
func init() {
apimap["/api/getMajors"] = &apihandler{"GET", func(w http.ResponseWriter, r *http.Request) {
user := usertokens.Get(r.Header.Get("Authorization"))
if user == nil {
writeresult(w, codeError, nil, errInvalidToken.Error(), typeError)
return
}
majs := global.FileDB.GetMajors()
type majret struct {
Name string
}
majrets := make([]majret, len(majs))
for i, s := range majs {
majrets[i].Name = s
}
writeresult(w, codeSuccess, &majrets, messageOk, typeSuccess)
}}
}