1
0
mirror of https://github.com/fumiama/paper-manager.git synced 2026-06-09 02:01:31 +08:00

finish backend login

This commit is contained in:
源文雨
2023-03-17 18:29:02 +08:00
parent 5889f0e30a
commit cd571e9e25
12 changed files with 844 additions and 279 deletions

37
backend/api/base.go Normal file
View File

@@ -0,0 +1,37 @@
package api
import (
"encoding/json"
"io"
)
const (
codeError = -1
codeSuccess = 0
codeTimeout = 401
)
const (
typeSuccess = "success"
typeError = "error"
)
const (
messageOk = "ok"
)
type base struct {
Code int `json:"code"`
Message string `json:"message"`
Result any `json:"result"`
Type string `json:"type"`
}
func writeresult(w io.Writer, c int, r any, m, t string) error {
return json.NewEncoder(w).Encode(&base{
Code: c,
Result: r,
Message: m,
Type: t,
})
}