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
983add29
Commit
983add29
authored
Mar 09, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
批量获取家族信息
parent
f7d159d0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
31 deletions
+42
-31
group_rank.go
cv/group_power_cv/group_rank.go
+1
-2
groupPower.go
domain/model/groupPower_m/groupPower.go
+0
-23
group_info.go
domain/model/groupPower_m/group_info.go
+31
-0
group_rank.go
route/group_power_r/group_rank.go
+10
-6
No files found.
cv/group_power_cv/group_rank.go
View file @
983add29
...
...
@@ -14,13 +14,12 @@ type CvGroupPowerRank struct {
type
CvGroupPowerRankData
struct
{
GroupPowerId
mysql
.
ID
`json:"groupPowerId"`
// 家族id
GroupPic
string
`json:"groupPic"`
// 家族图片
Icon
string
`json:"icon"`
// 家族图片
Name
string
`json:"name"`
// 家族名
Nameplate
string
`json:"nameplate"`
// 铭牌
Grade
groupPower_e
.
GroupPowerGrade
`json:"grade"`
// 等级 0:无 1:青铜 2:白银 3:黄金 4:黑金
Exp
mysql
.
Num
`json:"exp"`
// 经验值
Rank
int
`json:"rank"`
// 排名
// todo 铭牌,图片等字段, 等伟健哥哥的结构体
}
// 家族之星
...
...
domain/model/groupPower_m/groupPower.go
View file @
983add29
...
...
@@ -368,29 +368,6 @@ func GetGroupPowerNames(db *gorm.DB, ids []mysql.ID) (map[mysql.ID]string, error
return
result
,
nil
}
type
GroupPowerInfo
struct
{
PowerId
mysql
.
ID
Owner
mysql
.
ID
Name
string
}
func
BatchGetGroupPower
(
db
*
gorm
.
DB
,
ids
[]
mysql
.
ID
)
(
map
[
mysql
.
ID
]
GroupPowerInfo
,
error
)
{
rows
:=
make
([]
GroupPowerInfo
,
0
)
if
len
(
ids
)
>
0
{
if
err
:=
db
.
Model
(
&
GroupPower
{})
.
Select
(
"p.id AS power_id, u.user_id AS owner, p.name"
)
.
Joins
(
"AS p INNER JOIN group_power_user AS u ON p.id = u.group_power_id"
)
.
Where
(
"p.id IN ? AND p.status = ? AND role = ?"
,
ids
,
groupPower_e
.
GroupPowerUserHas
,
groupPower_e
.
GroupPowerUserRoleMgr
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
return
nil
,
err
}
}
result
:=
make
(
map
[
mysql
.
ID
]
GroupPowerInfo
,
0
)
for
_
,
i
:=
range
rows
{
result
[
i
.
PowerId
]
=
i
}
return
result
,
nil
}
func
GetGroupPower
(
model
*
domain
.
Model
,
id
mysql
.
ID
)
(
*
GroupPower
,
error
)
{
groupPower
:=
GroupPower
{}
if
err
:=
model
.
Db
.
Model
(
&
GroupPower
{})
.
First
(
&
groupPower
,
id
)
.
Error
;
err
!=
nil
{
...
...
domain/model/groupPower_m/group_info.go
0 → 100644
View file @
983add29
package
groupPower_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
)
type
GroupPowerInfo
struct
{
mysql
.
Entity
GroupUid
string
Name
string
Nameplate
string
Declaration
string
Icon
string
Status
int
}
func
(
GroupPowerInfo
)
TableName
()
string
{
return
"group_power"
}
// 批量获取家族信息
func
MGetGroupPowerInfoMap
(
model
*
domain
.
Model
,
groupPowerIds
[]
mysql
.
ID
)
(
map
[
mysql
.
ID
]
GroupPowerInfo
,
error
)
{
var
rows
[]
GroupPowerInfo
res
:=
make
(
map
[
mysql
.
ID
]
GroupPowerInfo
)
if
err
:=
model
.
DB
()
.
Model
(
GroupPowerInfo
{})
.
Where
(
"id in ?"
,
groupPowerIds
)
.
Find
(
&
rows
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"MGetGroupPowerInfo fail:%v"
,
err
)
return
res
,
err
}
return
res
,
nil
}
route/group_power_r/group_rank.go
View file @
983add29
...
...
@@ -65,6 +65,10 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
if
err
!=
nil
{
return
myContext
,
err
}
groupPowers
,
err
:=
groupPower_m
.
MGetGroupPowerInfoMap
(
model
,
ids
)
if
err
!=
nil
{
return
myContext
,
err
}
if
myGroupPower
!=
nil
&&
myGroupPower
.
Role
==
groupPower_e
.
GroupPowerUserRoleMgr
{
myGroupPowerRank
,
err
:=
groupPower_m
.
GetGroupPowerExpMyRank
(
model
,
beginDate
,
endDate
,
myGroupPower
.
GroupPowerId
)
if
err
!=
nil
{
...
...
@@ -72,9 +76,9 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
}
response
.
MyGroupPower
=
group_power_cv
.
CvGroupPowerRankData
{
GroupPowerId
:
myGroupPower
.
GroupPowerId
,
GroupPic
:
"todo"
,
Name
:
"todo"
,
Nameplate
:
"todo"
,
Icon
:
groupPowers
[
myGroupPower
.
ID
]
.
Icon
,
Name
:
groupPowers
[
myGroupPower
.
ID
]
.
Name
,
Nameplate
:
groupPowers
[
myGroupPower
.
ID
]
.
Nameplate
,
Grade
:
grades
[
myGroupPower
.
GroupPowerId
]
.
Grade
,
Exp
:
myGroupPowerRank
.
Exp
,
Rank
:
myGroupPowerRank
.
Rank
,
...
...
@@ -83,9 +87,9 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
for
r
,
v
:=
range
rank
{
response
.
Items
=
append
(
response
.
Items
,
group_power_cv
.
CvGroupPowerRankData
{
GroupPowerId
:
v
.
GroupPowerId
,
GroupPic
:
"todo"
,
// todo
Name
:
"todo"
,
Nameplate
:
"todo"
,
Icon
:
groupPowers
[
v
.
GroupPowerId
]
.
Icon
,
Name
:
groupPowers
[
v
.
GroupPowerId
]
.
Name
,
Nameplate
:
groupPowers
[
v
.
GroupPowerId
]
.
Nameplate
,
Grade
:
grades
[
v
.
GroupPowerId
]
.
Grade
,
Exp
:
v
.
Exp
,
Rank
:
r
+
1
,
// 查询已做排序
...
...
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