fix:增加大屏数据代码到2.0分支
This commit is contained in:
parent
e89c7df2b8
commit
f55f041fef
|
@ -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
|
||||
}
|
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue