Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qsh-wc
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
honghuiliu
qsh-wc
Commits
e31bbace
Commit
e31bbace
authored
Sep 23, 2022
by
honghuiliu
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
日常提交
parent
793f8753
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
5 deletions
+103
-5
data.go
server/api/v1/web/data.go
+38
-1
dataRequest.go
server/request/dataRequest.go
+16
-0
web.go
server/router/web.go
+5
-0
dataService.go
server/service/web/dataService.go
+44
-4
No files found.
server/api/v1/web/data.go
View file @
e31bbace
package
web
package
web
import
"github.com/gin-gonic/gin"
import
(
"gitee.com/zjlsliupei/ghelp"
"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/service/web"
"github.com/gin-gonic/gin"
)
var
DataService
=
new
(
web
.
DataService
)
func
DataIn
(
c
*
gin
.
Context
)
{
func
DataIn
(
c
*
gin
.
Context
)
{
}
}
//GetYewei 获取液位数据
func
GetYewei
(
c
*
gin
.
Context
)
{
var
arg
request
.
GetYewei
_
=
c
.
ShouldBindJSON
(
&
arg
)
data
,
err
:=
DataService
.
GetYewei
(
arg
)
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
return
}
response
.
OkWithData
(
data
,
c
)
}
//GetHistoryDataList 获取历史数据列表
func
GetHistoryDataList
(
c
*
gin
.
Context
)
{
var
arg
request
.
GetHistoryDataList
_
=
c
.
ShouldBindJSON
(
&
arg
)
list
,
total
,
err
:=
DataService
.
GetHistoryDataList
(
arg
)
if
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
return
}
response
.
OkWithData
(
ghelp
.
MAP
{
"list"
:
list
,
"total"
:
total
,
},
c
)
}
server/request/dataRequest.go
0 → 100644
View file @
e31bbace
package
request
import
"github.com/flipped-aurora/gin-vue-admin/server/utils"
type
GetYewei
struct
{
ToiletID
int
`json:"toilet_id"`
YeweiDeviceID
string
`json:"yewei_device_id"`
}
type
GetHistoryDataList
struct
{
utils
.
PageInfo
TypeName
string
`json:"type_name"`
StartTime
string
`json:"start_time"`
EndTime
string
`json:"end_time"`
ToiletID
int
`json:"toilet_id"`
}
server/router/web.go
View file @
e31bbace
...
@@ -27,4 +27,9 @@ func InitWebRouter(router *gin.Engine) {
...
@@ -27,4 +27,9 @@ func InitWebRouter(router *gin.Engine) {
{
{
oss
.
POST
(
"getOssConfig"
,
web
.
GetOssConfig
)
oss
.
POST
(
"getOssConfig"
,
web
.
GetOssConfig
)
}
}
data
:=
webRouter
.
Group
(
"data"
)
{
data
.
POST
(
"getHistoryDataList"
,
web
.
GetHistoryDataList
)
data
.
POST
(
"getYewei"
,
web
.
GetYewei
)
}
}
}
server/service/web/dataService.go
View file @
e31bbace
...
@@ -4,12 +4,14 @@ import (
...
@@ -4,12 +4,14 @@ import (
"errors"
"errors"
"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/server"
"github.com/flipped-aurora/gin-vue-admin/server/server"
)
)
type
DataService
struct
{
type
DataService
struct
{
}
}
//DataInYeWei 接受液位数据
func
(
s
*
DataService
)
DataInYeWei
(
arg
server
.
YeWeiData
)
error
{
func
(
s
*
DataService
)
DataInYeWei
(
arg
server
.
YeWeiData
)
error
{
//先查询设备绑定厕所
//先查询设备绑定厕所
var
toiletInfo
admin
.
QshToilet
var
toiletInfo
admin
.
QshToilet
...
@@ -18,9 +20,47 @@ func (s *DataService) DataInYeWei(arg server.YeWeiData) error {
...
@@ -18,9 +20,47 @@ func (s *DataService) DataInYeWei(arg server.YeWeiData) error {
return
errors
.
New
(
"设备ID未绑定公厕信息!"
)
return
errors
.
New
(
"设备ID未绑定公厕信息!"
)
}
}
return
global
.
GVA_DB
.
Create
(
&
admin
.
QshMonitorData
{
return
global
.
GVA_DB
.
Create
(
&
admin
.
QshMonitorData
{
ToiletId
:
int
(
toiletInfo
.
ID
),
ToiletId
:
int
(
toiletInfo
.
ID
),
TypeName
:
"液位"
,
RawDeviceId
:
arg
.
DeviceId
,
Value
:
arg
.
YeWei
,
TypeName
:
"液位"
,
Unit
:
"m"
,
Value
:
arg
.
YeWei
,
Unit
:
"m"
,
})
.
Error
})
.
Error
}
}
//GetYewei 获取液位
func
(
s
*
DataService
)
GetYewei
(
arg
request
.
GetYewei
)
(
admin
.
QshMonitorData
,
error
)
{
var
data
admin
.
QshMonitorData
err
:=
global
.
GVA_DB
.
Model
(
admin
.
QshMonitorData
{})
.
Where
(
"toilet_id = ?"
,
arg
.
ToiletID
)
.
Where
(
"type_name = ?"
,
"液位"
)
.
Last
(
&
data
)
.
Error
if
err
!=
nil
{
return
data
,
err
}
return
data
,
nil
}
//GetHistoryDataList 获取历史数据
func
(
s
*
DataService
)
GetHistoryDataList
(
arg
request
.
GetHistoryDataList
)
([]
admin
.
QshMonitorData
,
int64
,
error
)
{
var
count
int64
var
data
[]
admin
.
QshMonitorData
limit
:=
arg
.
PageSize
offset
:=
(
arg
.
Page
-
1
)
*
arg
.
PageSize
db
:=
global
.
GVA_DB
.
Model
(
admin
.
QshMonitorData
{})
if
arg
.
ToiletID
!=
0
{
db
.
Where
(
"toilet_id = ?"
,
arg
.
ToiletID
)
}
if
arg
.
TypeName
!=
""
{
db
.
Where
(
"type_name = ?"
,
arg
.
TypeName
)
}
if
arg
.
StartTime
!=
""
{
db
.
Where
(
"created_at >= ?"
,
arg
.
StartTime
)
}
if
arg
.
EndTime
!=
""
{
db
.
Where
(
"created_at <= ?"
,
arg
.
EndTime
)
}
db
.
Count
(
&
count
)
err
:=
db
.
Limit
(
limit
)
.
Offset
(
offset
)
.
Find
(
&
data
)
.
Error
if
err
!=
nil
{
return
data
,
count
,
err
}
return
data
,
count
,
nil
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment