Commit 6ba1547f authored by honghuiliu's avatar honghuiliu 💬

日常提交

parent b8cbf386
package web package web
import ( import (
"fmt"
"gitee.com/zjlsliupei/ghelp" "gitee.com/zjlsliupei/ghelp"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/request" "github.com/flipped-aurora/gin-vue-admin/server/request"
...@@ -30,10 +29,23 @@ func GetToiletList(c *gin.Context) { ...@@ -30,10 +29,23 @@ func GetToiletList(c *gin.Context) {
func GetToiletDetail(c *gin.Context) { func GetToiletDetail(c *gin.Context) {
var arg request.GetId var arg request.GetId
_ = c.ShouldBindJSON(&arg) _ = c.ShouldBindJSON(&arg)
fmt.Println(c.ShouldBindJSON(&arg))
if data, err := toiletService.GetToiletDetail(arg); err != nil { if data, err := toiletService.GetToiletDetail(arg); err != nil {
response.FailWithMessage(err.Error(), c) response.FailWithMessage(err.Error(), c)
} else { } else {
response.OkWithData(data, c) 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) { ...@@ -17,6 +17,7 @@ func InitWebRouter(router *gin.Engine) {
{ {
toilet.POST("/toiletList", web.GetToiletList) toilet.POST("/toiletList", web.GetToiletList)
toilet.POST("/getToiletDetail", web.GetToiletDetail) toilet.POST("/getToiletDetail", web.GetToiletDetail)
toilet.POST("/getMonitorInfo", web.GetMonitorInfo)
} }
patrol := webRouter.Group("patrol") patrol := webRouter.Group("patrol")
{ {
......
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"github.com/flipped-aurora/gin-vue-admin/server/global" "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/model/admin"
"github.com/flipped-aurora/gin-vue-admin/server/request" "github.com/flipped-aurora/gin-vue-admin/server/request"
"github.com/flipped-aurora/gin-vue-admin/server/utils"
) )
type ToiletService struct { type ToiletService struct {
...@@ -33,3 +34,21 @@ func (l *ToiletService) GetToiletDetail(toilet request.GetId) (admin.QshToilet, ...@@ -33,3 +34,21 @@ func (l *ToiletService) GetToiletDetail(toilet request.GetId) (admin.QshToilet,
} }
return toiletInfo, nil 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