Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-user
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
chenweijian
hilo-user
Commits
406c237b
Commit
406c237b
authored
Jun 16, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trust
parent
2fcefb22
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
11 deletions
+36
-11
headwear.go
cv/headwear_cv/headwear.go
+36
-11
No files found.
cv/headwear_cv/headwear.go
View file @
406c237b
package
headwear_cv
package
headwear_cv
import
(
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"gorm.io/gorm"
"hilo-user/_const/enum/headwear_e"
"hilo-user/_const/enum/headwear_e"
"hilo-user/domain/model/cp_m"
"hilo-user/domain/model/res_m"
"hilo-user/domain/model/res_m"
"hilo-user/domain/model/user_m"
"hilo-user/domain/model/user_m"
"hilo-user/myerr"
"hilo-user/myerr"
...
@@ -17,6 +19,7 @@ type CvHeadwear struct {
...
@@ -17,6 +19,7 @@ type CvHeadwear struct {
PicUrl
mysql
.
Str
`json:"picUrl"`
PicUrl
mysql
.
Str
`json:"picUrl"`
EffectUrl
mysql
.
Str
`json:"effectUrl"`
EffectUrl
mysql
.
Str
`json:"effectUrl"`
TimeLeft
int64
`json:"timeLeft"`
// 离到期还有多少秒(过期则是负数)
TimeLeft
int64
`json:"timeLeft"`
// 离到期还有多少秒(过期则是负数)
HeadwearIcon
string
`json:"headwearIcon"`
}
}
type
CvHeadwearDiamond
struct
{
type
CvHeadwearDiamond
struct
{
...
@@ -69,7 +72,7 @@ func GetHeadwearList(db *gorm.DB, userId uint64) ([]CvHeadwear, error) {
...
@@ -69,7 +72,7 @@ func GetHeadwearList(db *gorm.DB, userId uint64) ([]CvHeadwear, error) {
}
}
}
}
// 如果没有一个using,则找第一个没过期的充当
// 如果没有一个using,则找第一个没过期的充当
if
!
hasUsing
{
if
!
hasUsing
{
for
i
,
e
:=
range
result
{
for
i
,
e
:=
range
result
{
if
e
.
TimeLeft
>
0
{
if
e
.
TimeLeft
>
0
{
result
[
i
]
.
Using
=
true
result
[
i
]
.
Using
=
true
...
@@ -128,6 +131,28 @@ func BatchGetCvHeadwears(userIds []uint64) (map[uint64]CvHeadwear, error) {
...
@@ -128,6 +131,28 @@ func BatchGetCvHeadwears(userIds []uint64) (map[uint64]CvHeadwear, error) {
for
i
,
_
:=
range
resHeadwears
{
for
i
,
_
:=
range
resHeadwears
{
resHeadwearMap
[
resHeadwears
[
i
]
.
ID
]
=
resHeadwears
[
i
]
resHeadwearMap
[
resHeadwears
[
i
]
.
ID
]
=
resHeadwears
[
i
]
}
}
// cp 相关
var
model
=
domain
.
CreateModelNil
()
cpRelations
:=
cp_m
.
MGetCpRelation
(
model
,
userIds
)
var
m
=
make
(
map
[
uint64
]
cp_m
.
CpRelation
)
var
cpUserIds
[]
uint64
for
i
,
v
:=
range
cpRelations
{
m
[
v
.
UserId1
]
=
cpRelations
[
i
]
m
[
v
.
UserId2
]
=
cpRelations
[
i
]
cpUserIds
=
append
(
cpUserIds
,
v
.
UserId1
)
cpUserIds
=
append
(
cpUserIds
,
v
.
UserId2
)
}
users
,
_
:=
user_m
.
GetUserMapByIds
(
model
,
cpUserIds
)
var
response
=
make
(
map
[
uint64
]
string
)
for
_
,
uid
:=
range
userIds
{
if
cpRelation
,
ok
:=
m
[
uid
];
ok
{
cpUserId
:=
cpRelation
.
UserId2
if
cpUserId
==
uid
{
cpUserId
=
cpRelation
.
UserId1
}
response
[
uid
]
=
users
[
cpUserId
]
.
Avatar
}
}
result
:=
make
(
map
[
uint64
]
CvHeadwear
,
0
)
result
:=
make
(
map
[
uint64
]
CvHeadwear
,
0
)
for
_
,
r
:=
range
rows
{
for
_
,
r
:=
range
rows
{
...
@@ -138,6 +163,7 @@ func BatchGetCvHeadwears(userIds []uint64) (map[uint64]CvHeadwear, error) {
...
@@ -138,6 +163,7 @@ func BatchGetCvHeadwears(userIds []uint64) (map[uint64]CvHeadwear, error) {
PicUrl
:
headwear
.
PicUrl
,
PicUrl
:
headwear
.
PicUrl
,
EffectUrl
:
headwear
.
EffectUrl
,
EffectUrl
:
headwear
.
EffectUrl
,
Using
:
r
.
Using
==
headwear_e
.
YesUsing
,
Using
:
r
.
Using
==
headwear_e
.
YesUsing
,
HeadwearIcon
:
response
[
r
.
UserId
],
}
}
}
}
...
@@ -145,4 +171,3 @@ func BatchGetCvHeadwears(userIds []uint64) (map[uint64]CvHeadwear, error) {
...
@@ -145,4 +171,3 @@ func BatchGetCvHeadwears(userIds []uint64) (map[uint64]CvHeadwear, error) {
return
result
,
nil
return
result
,
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