2021-04-17 11:36:37 -04:00
|
|
|
package model
|
|
|
|
|
2024-10-19 12:09:16 -04:00
|
|
|
const (
|
|
|
|
ApiErrorUnauthorized = 10001
|
|
|
|
)
|
|
|
|
|
2021-04-17 11:36:37 -04:00
|
|
|
type ServiceItemResponse struct {
|
2021-09-02 11:45:21 -04:00
|
|
|
Monitor *Monitor
|
2021-04-17 11:36:37 -04:00
|
|
|
CurrentUp uint64
|
|
|
|
CurrentDown uint64
|
2022-05-01 22:33:21 -04:00
|
|
|
TotalUp uint64
|
|
|
|
TotalDown uint64
|
2021-04-17 11:36:37 -04:00
|
|
|
Delay *[30]float32
|
|
|
|
Up *[30]int
|
|
|
|
Down *[30]int
|
|
|
|
}
|
2022-05-01 12:45:03 -04:00
|
|
|
|
2022-05-01 22:33:21 -04:00
|
|
|
func (r ServiceItemResponse) TotalUptime() float32 {
|
|
|
|
if r.TotalUp+r.TotalDown == 0 {
|
2022-05-01 12:45:03 -04:00
|
|
|
return 0
|
|
|
|
}
|
2022-05-01 22:33:21 -04:00
|
|
|
return float32(r.TotalUp) / (float32(r.TotalUp + r.TotalDown)) * 100
|
2022-05-01 12:45:03 -04:00
|
|
|
}
|
2024-10-19 12:09:16 -04:00
|
|
|
|
|
|
|
type LoginRequest struct {
|
2024-10-20 02:05:43 -04:00
|
|
|
Username string `json:"username,omitempty"`
|
|
|
|
Password string `json:"password,omitempty"`
|
2024-10-19 12:09:16 -04:00
|
|
|
}
|
|
|
|
|
2024-10-20 02:05:43 -04:00
|
|
|
type CommonResponse[T any] struct {
|
|
|
|
Success bool `json:"success,omitempty"`
|
|
|
|
Data T `json:"data,omitempty"`
|
|
|
|
Error string `json:"error,omitempty"`
|
2024-10-19 12:09:16 -04:00
|
|
|
}
|
|
|
|
|
2024-10-20 02:05:43 -04:00
|
|
|
type LoginResponse struct {
|
|
|
|
Token string `json:"token,omitempty"`
|
|
|
|
Expire string `json:"expire,omitempty"`
|
2024-10-19 12:09:16 -04:00
|
|
|
}
|