应用列表中展示子表中的副本数量

Former-commit-id: 8388d26ea87ae143f542e9c3660b5ea1aa3f56a3
This commit is contained in:
zhouqunjie 2023-11-25 16:37:50 +08:00
parent 68c82f7807
commit 405c972314
3 changed files with 27 additions and 11 deletions

View File

@ -577,6 +577,10 @@ type (
TotalCount int64 `json:"totalCount"` // 任务总数 TotalCount int64 `json:"totalCount"` // 任务总数
Apps []App `json:"apps"` //应用列表 Apps []App `json:"apps"` //应用列表
} }
Replica {
ClusterName string `json:"clusterName"`
Replica int32 `json:"replica"`
}
App { App {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
@ -589,6 +593,7 @@ type (
ParticipantName string `json:"participantName"` ParticipantName string `json:"participantName"`
Storage string `json:"storage"` Storage string `json:"storage"`
CreateTime string `json:"createTime"` CreateTime string `json:"createTime"`
Replicas []Replica `json:"replicas"`
} }
) )

View File

@ -49,6 +49,10 @@ func (l *AppListLogic) AppList(req *types.AppListReq) (resp *types.AppListResp,
resp = &types.AppListResp{} resp = &types.AppListResp{}
l.svcCtx.DbEngin.Raw("SELECT t.*,phy.name as p_name,phy.id as p_id FROM task t LEFT JOIN cloud c ON c.task_id = t.id join sc_participant_phy_info phy on c.participant_id = phy.id WHERE c.kind in ('Deployment', 'StatefulSet', 'Ingress', 'Service') AND t.`ns_id` = ? AND t.`deleted_at` IS NULL ORDER BY t.created_time Desc", req.Namespace).Scan(&tasks) l.svcCtx.DbEngin.Raw("SELECT t.*,phy.name as p_name,phy.id as p_id FROM task t LEFT JOIN cloud c ON c.task_id = t.id join sc_participant_phy_info phy on c.participant_id = phy.id WHERE c.kind in ('Deployment', 'StatefulSet', 'Ingress', 'Service') AND t.`ns_id` = ? AND t.`deleted_at` IS NULL ORDER BY t.created_time Desc", req.Namespace).Scan(&tasks)
for _, task := range tasks { for _, task := range tasks {
var replicas []types.Replica
l.svcCtx.DbEngin.Raw("SELECT sc_participant_phy_info.name,replica FROM cloud left join sc_participant_phy_info on cloud.participant_id = sc_participant_phy_info.id WHERE task_id =?", task.Id).Scan(&replicas)
resp.Apps = append(resp.Apps, types.App{ resp.Apps = append(resp.Apps, types.App{
Id: task.Id, Id: task.Id,
Name: task.Name, Name: task.Name,
@ -58,6 +62,7 @@ func (l *AppListLogic) AppList(req *types.AppListReq) (resp *types.AppListResp,
CreateTime: task.CommitTime.Format("2006-01-02 15:04:05"), CreateTime: task.CommitTime.Format("2006-01-02 15:04:05"),
ParticipantId: task.PId, ParticipantId: task.PId,
ParticipantName: task.PName, ParticipantName: task.PName,
Replicas: replicas,
}) })
} }
return return

View File

@ -541,18 +541,24 @@ type AppListResp struct {
Apps []App `json:"apps"` //应用列表 Apps []App `json:"apps"` //应用列表
} }
type Replica struct {
ClusterName string `json:"clusterName"`
Replica int32 `json:"replica"`
}
type App struct { type App struct {
Id int64 `json:"id"` Id int64 `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Status string `json:"status"` Status string `json:"status"`
TaskType string `json:"taskType"` TaskType string `json:"taskType"`
StartTime string `json:"startTime"` StartTime string `json:"startTime"`
EndTime string `json:"endTime"` EndTime string `json:"endTime"`
ParticipantStatus string `json:"participantStatus"` ParticipantStatus string `json:"participantStatus"`
ParticipantId int64 `json:"participantId"` ParticipantId int64 `json:"participantId"`
ParticipantName string `json:"participantName"` ParticipantName string `json:"participantName"`
Storage string `json:"storage"` Storage string `json:"storage"`
CreateTime string `json:"createTime"` CreateTime string `json:"createTime"`
Replicas []Replica `json:"replicas"`
} }
type AppDetailReq struct { type AppDetailReq struct {