package storage import ( "context" "gitlink.org.cn/JointCloud/pcm-coordinator/pkg/utils/httputils" "k8s.io/apimachinery/pkg/util/json" "strings" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/svc" "gitlink.org.cn/JointCloud/pcm-coordinator/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type DailyPowerScreenLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewDailyPowerScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DailyPowerScreenLogic { return &DailyPowerScreenLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx, } } func (l *DailyPowerScreenLogic) DailyPowerScreen() (resp *types.DailyPowerScreenResp, err error) { resp = &types.DailyPowerScreenResp{} statusCode, body, err := httputils.HttpClientWithScreen(httputils.GET, "https://grampus.openi.org.cn/openapi/v1/sharescreen/computepower/dailytrend", strings.NewReader(``)) if statusCode == 200 { json.Unmarshal(body, &resp.Chart) println(resp) } else if statusCode != 200 { return nil, err } return resp, nil }