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 +}