From f55f041feff88cd80e53458a8837ed551f41b4e1 Mon Sep 17 00:00:00 2001 From: qiwang <1364512070@qq.com> Date: Tue, 25 Apr 2023 17:25:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=A2=9E=E5=8A=A0=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BB=A3=E7=A0=81=E5=88=B02.0=E5=88=86?= =?UTF-8?q?=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/dailypowerscreenlogic.go | 54 +++++++++++++++++++ .../percentercomputerpowerscreenlogic.go | 54 +++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/dailypowerscreenlogic.go create mode 100644 adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/percentercomputerpowerscreenlogic.go diff --git a/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/dailypowerscreenlogic.go b/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/dailypowerscreenlogic.go new file mode 100644 index 00000000..96a1b7f9 --- /dev/null +++ b/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/dailypowerscreenlogic.go @@ -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 +} diff --git a/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/percentercomputerpowerscreenlogic.go b/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/percentercomputerpowerscreenlogic.go new file mode 100644 index 00000000..edc385af --- /dev/null +++ b/adaptor/PCM-STORAGE/PCM-CEPH/rpc/internal/logic/percentercomputerpowerscreenlogic.go @@ -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 +}