Commit 1794765e authored by mahui's avatar mahui

Merge remote-tracking branch 'origin/master'

parents 4f62df50 aa7ffa0d
package web
import (
"fmt"
"gitee.com/zjlsliupei/ghelp"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/request"
......@@ -30,10 +29,23 @@ func GetToiletList(c *gin.Context) {
func GetToiletDetail(c *gin.Context) {
var arg request.GetId
_ = c.ShouldBindJSON(&arg)
fmt.Println(c.ShouldBindJSON(&arg))
if data, err := toiletService.GetToiletDetail(arg); err != nil {
response.FailWithMessage(err.Error(), c)
} else {
response.OkWithData(data, c)
}
}
func GetMonitorInfo(c *gin.Context) {
var arg request.GetId
_ = c.ShouldBindJSON(&arg)
accessToken, cameraUrl, err := toiletService.GetMonitorInfo(arg)
if err != nil {
response.FailWithMessage(err.Error(), c)
return
}
response.OkWithData(ghelp.MAP{
"access_token": accessToken,
"camera_url": cameraUrl,
}, c)
}
......@@ -17,6 +17,7 @@ func InitWebRouter(router *gin.Engine) {
{
toilet.POST("/toiletList", web.GetToiletList)
toilet.POST("/getToiletDetail", web.GetToiletDetail)
toilet.POST("/getMonitorInfo", web.GetMonitorInfo)
}
patrol := webRouter.Group("patrol")
{
......
......@@ -4,6 +4,7 @@ import (
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/admin"
"github.com/flipped-aurora/gin-vue-admin/server/request"
"github.com/flipped-aurora/gin-vue-admin/server/utils"
)
type ToiletService struct {
......@@ -33,3 +34,21 @@ func (l *ToiletService) GetToiletDetail(toilet request.GetId) (admin.QshToilet,
}
return toiletInfo, nil
}
//GetMonitorInfo 获取设备信息
func (l *ToiletService) GetMonitorInfo(toilet request.GetId) (string, string, error) {
var toiletInfo admin.QshToilet
err := global.GVA_DB.Model(toiletInfo).Where("id = ?", toilet.ID).First(&toiletInfo).Error
if err != nil {
return "", "", err
}
accessToken, err := utils.GetYinShiAccessToken(toiletInfo.MonitorAc)
if err != nil {
return "", "", err
}
cameraUrl := utils.GetCameraUrl(toiletInfo.MonitorId)
return accessToken, cameraUrl, nil
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment