Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
hujiebin
hilo-group
Commits
32fb64dc
Commit
32fb64dc
authored
Apr 11, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量获取用户范围上麦时长
parent
4be5481e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
0 deletions
+47
-0
mic.go
domain/model/mic_m/mic.go
+15
-0
inner.go
route/mic_r/inner.go
+31
-0
router.go
route/router.go
+1
-0
No files found.
domain/model/mic_m/mic.go
View file @
32fb64dc
...
...
@@ -89,3 +89,18 @@ func MGetUserOnMicSeconds(model *domain.Model, day string, tz timezone_e.Timezon
}
return
res
,
nil
}
// 批量获取用户上麦时长
// @return userId->seconds
func
MGetUserOnMicSecondsRange
(
model
*
domain
.
Model
,
beginDate
,
endDate
string
,
tz
timezone_e
.
Timezone
,
userIds
[]
uint64
)
(
map
[
mysql
.
ID
]
mysql
.
Num
,
error
)
{
var
rows
[]
UserOnMic
res
:=
make
(
map
[
mysql
.
ID
]
mysql
.
Num
)
if
err
:=
model
.
DB
()
.
Model
(
UserOnMic
{})
.
Where
(
"`date` >= ? AND `date` <= ? AND tz = ? AND user_id in ?"
,
beginDate
,
endDate
,
tz
,
userIds
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"MGetUserOnMic fail:%v"
,
err
)
return
res
,
err
}
for
_
,
r
:=
range
rows
{
res
[
r
.
UserId
]
=
r
.
Seconds
}
return
res
,
nil
}
route/mic_r/inner.go
View file @
32fb64dc
...
...
@@ -38,3 +38,34 @@ func MGetUserOnMicSeconds(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
response
)
return
myCtx
,
nil
}
type
MGetUserOnMicSecondsRangeReq
struct
{
BeginDate
string
`form:"beginDate" binding:"required"`
EndDate
string
`form:"endDate" binding:"required"`
Ids
[]
mysql
.
ID
`form:"ids" binding:"required"`
Tz
timezone_e
.
Timezone
`form:"tz"`
}
// @Tags 麦位-内部
// @Summary 批量获取用户范围上麦时长
// @Param beginDate query string true "天 格式2006-001-02"
// @Param endDate query string true "天 格式2006-001-02"
// @Param ids query string true "用户id,如:ids=1&ids=2&ids=3"
// @Param tz query string false "时区 0:北京时间(默认) 1:沙特时间"
// @Success 200 {object} map[uint64]uint32
// @Router /inner/mic/onMicSeconds [get]
func
MGetUserOnMicSecondsRange
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
var
model
=
domain
.
CreateModelContext
(
myCtx
)
var
req
MGetUserOnMicSecondsRangeReq
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
return
myCtx
,
err
}
onMic
,
err
:=
mic_m
.
MGetUserOnMicSecondsRange
(
model
,
req
.
BeginDate
,
req
.
EndDate
,
req
.
Tz
,
req
.
Ids
)
if
err
!=
nil
{
return
myCtx
,
err
}
response
:=
onMic
resp
.
ResponseOk
(
c
,
response
)
return
myCtx
,
nil
}
route/router.go
View file @
32fb64dc
...
...
@@ -161,6 +161,7 @@ func InitRouter() *gin.Engine {
innerMic
:=
inner
.
Group
(
"/mic"
)
{
innerMic
.
GET
(
"/onMicSeconds"
,
wrapper
(
mic_r
.
MGetUserOnMicSeconds
))
innerMic
.
GET
(
"/onMicSeconds/range"
,
wrapper
(
mic_r
.
MGetUserOnMicSecondsRange
))
}
r
.
GET
(
"/test"
,
wrapper
(
group_power_r
.
Test
))
return
r
...
...
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