package core

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 GetScreenChartLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetScreenChartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetScreenChartLogic {
	return &GetScreenChartLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetScreenChartLogic) GetScreenChart() (resp *types.ScreenChartResp, err error) {
	resp = &types.ScreenChartResp{}
	l.svcCtx.DbEngin.Raw("select cpu_avg from screen_chart").Scan(&resp.CpuAvg)
	l.svcCtx.DbEngin.Raw("select cpu_load from screen_chart").Scan(&resp.CpuLoad)
	l.svcCtx.DbEngin.Raw("select memory_avg from screen_chart").Scan(&resp.MemoryAvg)
	l.svcCtx.DbEngin.Raw("select memory_load from screen_chart").Scan(&resp.MemoryLoad)
	return
}
