dashboard/services/uniss/common.go

48 lines
981 B
Go

package uniss
import (
"dashboard/dao/dadis/unisd"
"dashboard/models"
"fmt"
)
type commonService struct {
rpcClients *rpcClients
}
func newcommonService(http *httpHandle) *commonService {
res := new(commonService)
http.pushHandle(string(models.UNIS_HTTP_ID_CONFIG_ADD), res.stationConfig)
return res
}
func (c *commonService) stationConfig(reqest *models.UnisHttpRequest) (*models.UnisHttpResponse, error) {
req := reqest.Msg.(*models.StationConfigParams)
fmt.Println(req)
var addres []*rpcIdAddres
for _, sc := range req.StationConfig.Screens {
add := new(rpcIdAddres)
add.host = sc.NodeIP
add.id = sc.NodeID
addres = append(addres, add)
}
c.rpcClients.flushRpcClients(addres)
fmt.Println(c.rpcClients.getConfig(addres[0].id, models.UnisRpcRequest{Id: "zhangshuo"}))
res := &models.UnisHttpResponse{
Code: int(models.CodeSuccess),
Msg: "config ok",
}
unisd.UnisDataSet(string(unisd.DadisKey_UnisStationInfo), req, 0)
return res, nil
}