fix:增加大屏数据代码到2.0分支

This commit is contained in:
qiwang 2023-04-25 17:25:42 +08:00
parent e89c7df2b8
commit f55f041fef
2 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package logic
import (
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/config"
"PCM/common/tool"
"context"
"fmt"
"k8s.io/apimachinery/pkg/util/json"
"strings"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/ceph"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type DailyPowerScreenLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewDailyPowerScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DailyPowerScreenLogic {
return &DailyPowerScreenLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *DailyPowerScreenLogic) DailyPowerScreen(in *ceph.DailyPowerScreenReq) (*ceph.DailyPowerScreenResp, error) {
// todo: add your logic here and delete this line
var resp ceph.DailyPowerScreenResp
screenConfig := config.Cfg
screenUrl := screenConfig.ScreenConfig.ScreenUrl
statusCode, body, err := tool.HttpClientWithScreen(tool.GET, screenUrl+"computepower/dailytrend", strings.NewReader(``))
if err != nil {
return nil, err
}
if statusCode == 200 {
err := json.Unmarshal(body, &resp)
if err != nil {
fmt.Println(err)
}
fmt.Println(body)
resp.Code = 200
resp.Msg = "Success"
} else if statusCode != 200 {
json.Unmarshal(body, &resp)
resp.Code = 400
resp.Msg = "Failure"
}
return &resp, nil
}

View File

@ -0,0 +1,54 @@
package logic
import (
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/config"
"PCM/common/tool"
"context"
"fmt"
"k8s.io/apimachinery/pkg/util/json"
"strings"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/ceph"
"PCM/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type PerCenterComputerPowerScreenLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewPerCenterComputerPowerScreenLogic(ctx context.Context, svcCtx *svc.ServiceContext) *PerCenterComputerPowerScreenLogic {
return &PerCenterComputerPowerScreenLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
func (l *PerCenterComputerPowerScreenLogic) PerCenterComputerPowerScreen(in *ceph.PerCenterComputerPowersReq) (*ceph.PerCenterComputerPowersResp, error) {
// todo: add your logic here and delete this line
var resp ceph.PerCenterComputerPowersResp
screenConfig := config.Cfg
screenUrl := screenConfig.ScreenConfig.ScreenUrl
statusCode, body, err := tool.HttpClientWithScreen(tool.GET, screenUrl+"computepower/percenter", strings.NewReader(``))
if err != nil {
return nil, err
}
if statusCode == 200 {
err := json.Unmarshal(body, &resp)
if err != nil {
fmt.Println(err)
}
fmt.Println(body)
resp.Code = 200
resp.Msg = "Success"
} else if statusCode != 200 {
json.Unmarshal(body, &resp)
resp.Code = 400
resp.Msg = "Failure"
}
return &resp, nil
}