修复设备重启请求id获取不到
This commit is contained in:
parent
ca49391c2b
commit
00c23de1ca
|
|
@ -68,7 +68,6 @@ func UpdateDevice(c *gin.Context) {
|
|||
var req DeviceUpdateReq
|
||||
user_id, _ := c.Get("id")
|
||||
if err := c.ShouldBindJSON(&req); err == nil {
|
||||
fmt.Println("req:", req)
|
||||
res := service.UpdateDevice(req.DeviceName, req.DeviceIP, req.DeviceStatus, req.DeviceInfo, req.DeviceType, req.DeviceLocation, req.ID, int(user_id.(float64)))
|
||||
if res {
|
||||
c.JSON(200, gin.H{
|
||||
|
|
@ -137,13 +136,18 @@ func GetDeviceList(c *gin.Context) {
|
|||
c.JSON(200, gin.H{
|
||||
"code": 0,
|
||||
"message": "success",
|
||||
"data": devices,
|
||||
"data": devices,
|
||||
})
|
||||
}
|
||||
|
||||
func RestartDevice(c *gin.Context) {
|
||||
user_id, _ := c.Get("id")
|
||||
device_id := c.GetInt("device_id")
|
||||
var req DeviceDelReq
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
c.JSON(200, gin.H{"code": 1, "message": "failed"})
|
||||
return
|
||||
}
|
||||
device_id := req.ID
|
||||
device := service.GetDevice(device_id, int(user_id.(float64)))
|
||||
if device.ID != 0 {
|
||||
if device.DeviceIP != "" {
|
||||
|
|
|
|||
Loading…
Reference in New Issue