[FIX] fix bug

This commit is contained in:
zhoujunhao 2018-07-12 16:20:11 +08:00
parent c211d813bd
commit 88054c6f96

View File

@ -501,22 +501,24 @@ func (t *TenantStruct) UpdateTenant(w http.ResponseWriter, r *http.Request) {
//Get all apps and status //Get all apps and status
func (t *TenantStruct) ServicesCount(w http.ResponseWriter, r *http.Request) { func (t *TenantStruct) ServicesCount(w http.ResponseWriter, r *http.Request) {
ServicesInfoList := make([]*api_model.StatusList,0,300) allStatus := t.StatusCli.GetAllStatus()
ServiceList,err := db.GetManager().TenantServiceDao().GetAllServicesID() var closed int = 0
if err!= nil{ var running int = 0
httputil.ReturnError(r, w, 500, fmt.Sprintf("select service error, %v", err)) var abnormal int = 0
return for _, v := range allStatus {
} switch v {
for _,v :=range ServiceList{ case "closed":
statusList, err := handler.GetServiceManager().GetStatus(v.ServiceID) closed += 1
if err != nil { case "running":
httputil.ReturnError(r, w, 500, fmt.Sprintf("get service list error,%v", err)) running += 1
return case "abnormal":
abnormal += 1
} }
ServicesInfoList = append(ServicesInfoList, statusList)
} }
httputil.ReturnSuccess(r, w, ServicesInfoList) serviceCount := map[string]int{"total":len(allStatus),"running":running,"closed":closed,"abnormal":abnormal}
httputil.ReturnSuccess(r, w, serviceCount)
} }
//ServicesInfo GetServiceInfo //ServicesInfo GetServiceInfo