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:
37
backend/api/base.go
Normal file
37
backend/api/base.go
Normal 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,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user