38 lines
1015 B
Go
38 lines
1015 B
Go
package hpc
|
|
|
|
import (
|
|
"context"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc"
|
|
"gitlink.org.cn/JointCloud/pcm-coordinator/internal/types"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type OverViewLogic struct {
|
|
logx.Logger
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
}
|
|
|
|
func NewOverViewLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OverViewLogic {
|
|
return &OverViewLogic{
|
|
Logger: logx.WithContext(ctx),
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
}
|
|
}
|
|
|
|
func (l *OverViewLogic) OverView(req *types.HpcOverViewReq) (resp *types.HpcOverViewResp, err error) {
|
|
|
|
var overView types.HPCOverView
|
|
tx := l.svcCtx.DbEngin.Raw("SELECT count( DISTINCT a.id ) as adapter_count,count( DISTINCT label ) as stack_count,count( c.id ) as cluster_count,(select count(*) from task_hpc) as task_count FROM t_cluster c JOIN t_adapter a ON c.adapter_id = a.id AND a.type = 2 ").Scan(&overView)
|
|
|
|
println(tx)
|
|
resp = &types.HpcOverViewResp{
|
|
Code: 200,
|
|
Msg: "success",
|
|
Data: overView,
|
|
}
|
|
return resp, nil
|
|
}
|