mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
fix: add json tag for service response (#6)
This commit is contained in:
parent
3a09ec94e8
commit
8640cbbf42
@ -33,10 +33,10 @@ func listService(c *gin.Context) (*model.ServiceResponse, error) {
|
||||
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
|
||||
authorized := isMember // TODO || isViewPasswordVerfied
|
||||
for k, service := range stats {
|
||||
if !service.Service.EnableShowInService {
|
||||
delete(stats, k)
|
||||
}
|
||||
if !authorized {
|
||||
if !service.Service.EnableShowInService {
|
||||
delete(stats, k)
|
||||
}
|
||||
service.Service = &model.Service{Name: service.Service.Name}
|
||||
stats[k] = service
|
||||
}
|
||||
|
@ -21,14 +21,14 @@ type ServiceForm struct {
|
||||
}
|
||||
|
||||
type ServiceResponseItem struct {
|
||||
Service *Service
|
||||
CurrentUp uint64
|
||||
CurrentDown uint64
|
||||
TotalUp uint64
|
||||
TotalDown uint64
|
||||
Delay *[30]float32
|
||||
Up *[30]int
|
||||
Down *[30]int
|
||||
Service *Service `json:"service,omitempty"`
|
||||
CurrentUp uint64 `json:"current_up"`
|
||||
CurrentDown uint64 `json:"current_down"`
|
||||
TotalUp uint64 `json:"total_up"`
|
||||
TotalDown uint64 `json:"total_down"`
|
||||
Delay *[30]float32 `json:"delay,omitempty"`
|
||||
Up *[30]int `json:"up,omitempty"`
|
||||
Down *[30]int `json:"down,omitempty"`
|
||||
}
|
||||
|
||||
func (r ServiceResponseItem) TotalUptime() float32 {
|
||||
@ -39,17 +39,17 @@ func (r ServiceResponseItem) TotalUptime() float32 {
|
||||
}
|
||||
|
||||
type CycleTransferStats struct {
|
||||
Name string
|
||||
From time.Time
|
||||
To time.Time
|
||||
Max uint64
|
||||
Min uint64
|
||||
ServerName map[uint64]string
|
||||
Transfer map[uint64]uint64
|
||||
NextUpdate map[uint64]time.Time
|
||||
Name string `json:"name"`
|
||||
From time.Time `json:"from"`
|
||||
To time.Time `json:"to"`
|
||||
Max uint64 `json:"max"`
|
||||
Min uint64 `json:"min"`
|
||||
ServerName map[uint64]string `json:"server_name,omitempty"`
|
||||
Transfer map[uint64]uint64 `json:"transfer,omitempty"`
|
||||
NextUpdate map[uint64]time.Time `json:"next_update,omitempty"`
|
||||
}
|
||||
|
||||
type ServiceResponse struct {
|
||||
Services map[uint64]ServiceResponseItem
|
||||
CycleTransferStats map[uint64]CycleTransferStats
|
||||
Services map[uint64]ServiceResponseItem `json:"services,omitempty"`
|
||||
CycleTransferStats map[uint64]CycleTransferStats `json:"cycle_transfer_stats,omitempty"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user