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)
|
_, isMember := c.Get(model.CtxKeyAuthorizedUser)
|
||||||
authorized := isMember // TODO || isViewPasswordVerfied
|
authorized := isMember // TODO || isViewPasswordVerfied
|
||||||
for k, service := range stats {
|
for k, service := range stats {
|
||||||
if !service.Service.EnableShowInService {
|
|
||||||
delete(stats, k)
|
|
||||||
}
|
|
||||||
if !authorized {
|
if !authorized {
|
||||||
|
if !service.Service.EnableShowInService {
|
||||||
|
delete(stats, k)
|
||||||
|
}
|
||||||
service.Service = &model.Service{Name: service.Service.Name}
|
service.Service = &model.Service{Name: service.Service.Name}
|
||||||
stats[k] = service
|
stats[k] = service
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,14 @@ type ServiceForm struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ServiceResponseItem struct {
|
type ServiceResponseItem struct {
|
||||||
Service *Service
|
Service *Service `json:"service,omitempty"`
|
||||||
CurrentUp uint64
|
CurrentUp uint64 `json:"current_up"`
|
||||||
CurrentDown uint64
|
CurrentDown uint64 `json:"current_down"`
|
||||||
TotalUp uint64
|
TotalUp uint64 `json:"total_up"`
|
||||||
TotalDown uint64
|
TotalDown uint64 `json:"total_down"`
|
||||||
Delay *[30]float32
|
Delay *[30]float32 `json:"delay,omitempty"`
|
||||||
Up *[30]int
|
Up *[30]int `json:"up,omitempty"`
|
||||||
Down *[30]int
|
Down *[30]int `json:"down,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r ServiceResponseItem) TotalUptime() float32 {
|
func (r ServiceResponseItem) TotalUptime() float32 {
|
||||||
@ -39,17 +39,17 @@ func (r ServiceResponseItem) TotalUptime() float32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CycleTransferStats struct {
|
type CycleTransferStats struct {
|
||||||
Name string
|
Name string `json:"name"`
|
||||||
From time.Time
|
From time.Time `json:"from"`
|
||||||
To time.Time
|
To time.Time `json:"to"`
|
||||||
Max uint64
|
Max uint64 `json:"max"`
|
||||||
Min uint64
|
Min uint64 `json:"min"`
|
||||||
ServerName map[uint64]string
|
ServerName map[uint64]string `json:"server_name,omitempty"`
|
||||||
Transfer map[uint64]uint64
|
Transfer map[uint64]uint64 `json:"transfer,omitempty"`
|
||||||
NextUpdate map[uint64]time.Time
|
NextUpdate map[uint64]time.Time `json:"next_update,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServiceResponse struct {
|
type ServiceResponse struct {
|
||||||
Services map[uint64]ServiceResponseItem
|
Services map[uint64]ServiceResponseItem `json:"services,omitempty"`
|
||||||
CycleTransferStats map[uint64]CycleTransferStats
|
CycleTransferStats map[uint64]CycleTransferStats `json:"cycle_transfer_stats,omitempty"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user