dashboard/services/uniss/common.go
2025-06-04 17:07:17 +08:00

64 lines
1.4 KiB
Go

package uniss
import (
"dashboard/dao/dadis/unisd"
"dashboard/models"
"fmt"
"net/http"
)
type commonService struct {
comm *communicateService
}
func newcommonService(comm *communicateService) *commonService {
res := new(commonService)
res.comm = comm
res.comm.httpServerHandler.Put(string(models.UNIS_HTTP_ID_CONFIG_ADD), res.stationConfig)
return res
}
func (c *commonService) stationConfig(reqest *models.UnisHttpRequest, respons *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.comm.rpcClientStub.flushRpcClients(addres)
fmt.Println(c.comm.rpcClientStub.getConfig(addres[0].id, models.UnisRpcRequest{Id: "zhangshuo"}))
// res := &models.UnisHttpResponse{
// Code: int(models.CodeSuccess),
// Msg: "config ok",
// }
respons.SetResParam(int(models.CodeSuccess), "config ok", nil)
unisd.UnisDataSet(unisd.DadisKey_UnisStationInfo.KeyWithChannel(0), req, 0)
c.comm.httpClientHandler.curl(http.MethodGet,
models.UNIS_HTTP_CLIENT_URL_SOURCE_LIST.URI("192.168.177.7", 8080),
nil,
func(msg *models.UnisHttpClientRequest) error {
fmt.Println(msg.Url)
if err, ok := msg.Msg.(error); ok {
fmt.Println(err)
}
return nil
})
return nil
}