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
7bb301e5
Commit
7bb301e5
authored
Mar 10, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
内部接口
parent
8a6ea690
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
108 additions
and
6 deletions
+108
-6
group_rank.go
cv/group_power_cv/group_rank.go
+15
-3
group_info.go
domain/model/groupPower_m/group_info.go
+14
-0
group_rank.go
route/group_power_r/group_rank.go
+3
-3
inner.go
route/group_power_r/inner.go
+69
-0
router.go
route/router.go
+7
-0
No files found.
cv/group_power_cv/group_rank.go
View file @
7bb301e5
...
...
@@ -6,14 +6,26 @@ import (
"hilo-group/cv/user_cv"
)
// 家族
基本
信息
// 家族信息
type
CvGroupPowerInfo
struct
{
CvGroupPowerBase
`json:",inline"`
CvGroupPowerMember
`json:",inline"`
}
// 家族基本信息
type
CvGroupPowerBase
struct
{
GroupPowerId
mysql
.
ID
`json:"groupPowerId"`
// 家族id
Icon
string
`json:"icon"`
// 家族图片
Name
string
`json:"name"`
// 家族名
Nameplate
string
`json:"nameplate"`
// 铭牌
}
// 家族成员
type
CvGroupPowerMember
struct
{
MemberNum
mysql
.
Num
`json:"memberNum"`
// 当前成员数
MemberLimit
mysql
.
Num
`json:"memberLimit"`
// 成员上限
}
// 家族等级
type
CvGroupPowerGrade
struct
{
Grade
groupPower_e
.
GroupPowerGrade
`json:"grade"`
// 等级 0:无 1:青铜 2:白银 3:黄金 4:黑金
...
...
@@ -30,7 +42,7 @@ type CvGroupPowerRank struct {
}
type
CvGroupPowerRankData
struct
{
CvGroupPower
Info
`json:",inline"`
CvGroupPower
Base
`json:",inline"`
CvGroupPowerGrade
`json:",inline"`
Rank
int
`json:"rank"`
// 排名
}
...
...
@@ -56,7 +68,7 @@ type CvPrivilege struct {
// 家族等级页
type
CvGroupPowerGradeDetail
struct
{
GroupPower
Info
CvGroupPowerInfo
`json:"groupPowerInfo
"`
// 家族基本信息
GroupPower
Base
CvGroupPowerBase
`json:"groupPowerBase
"`
// 家族基本信息
GroupPowerGrade
CvGroupPowerGrade
`json:"groupPowerGrade"`
// 家族等级信息
ResGradeList
[]
CvResGrade
`json:"resGradeList"`
// 资源等级列表,青铜、白银、黄金、黑金
PrivilegeList
[]
CvPrivilege
`json:"privilegeList"`
// 等级特权
...
...
domain/model/groupPower_m/group_info.go
View file @
7bb301e5
...
...
@@ -32,3 +32,17 @@ func MGetGroupPowerInfoMap(model *domain.Model, groupPowerIds []mysql.ID) (map[m
}
return
res
,
nil
}
// 批量获取家族成员
func
MGetGroupPowerUsers
(
model
*
domain
.
Model
,
groupPowerIds
[]
mysql
.
ID
)
(
map
[
mysql
.
ID
][]
*
GroupPowerUser
,
error
)
{
var
users
[]
*
GroupPowerUser
res
:=
make
(
map
[
mysql
.
ID
][]
*
GroupPowerUser
)
if
err
:=
model
.
DB
()
.
Model
(
GroupPowerUser
{})
.
Where
(
"group_power_id in ?"
,
groupPowerIds
)
.
Find
(
&
users
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"MGetGroupPowerUsers fail:%v"
,
err
)
return
res
,
err
}
for
i
,
v
:=
range
users
{
res
[
v
.
GroupPowerId
]
=
append
(
res
[
v
.
GroupPowerId
],
users
[
i
])
}
return
res
,
nil
}
route/group_power_r/group_rank.go
View file @
7bb301e5
...
...
@@ -76,7 +76,7 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
err
}
response
.
MyGroupPower
=
group_power_cv
.
CvGroupPowerRankData
{
CvGroupPower
Info
:
group_power_cv
.
CvGroupPowerInfo
{
CvGroupPower
Base
:
group_power_cv
.
CvGroupPowerBase
{
GroupPowerId
:
myGroupPower
.
GroupPowerId
,
Icon
:
groupPowers
[
myGroupPower
.
GroupPowerId
]
.
Icon
,
Name
:
groupPowers
[
myGroupPower
.
GroupPowerId
]
.
Name
,
...
...
@@ -91,7 +91,7 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
}
for
_
,
v
:=
range
rank
{
response
.
Items
=
append
(
response
.
Items
,
group_power_cv
.
CvGroupPowerRankData
{
CvGroupPower
Info
:
group_power_cv
.
CvGroupPowerInfo
{
CvGroupPower
Base
:
group_power_cv
.
CvGroupPowerBase
{
GroupPowerId
:
v
.
GroupPowerId
,
Icon
:
groupPowers
[
v
.
GroupPowerId
]
.
Icon
,
Name
:
groupPowers
[
v
.
GroupPowerId
]
.
Name
,
...
...
@@ -209,7 +209,7 @@ func GroupPowerGradeDetail(c *gin.Context) (*mycontext.MyContext, error) {
showExp
=
true
}
response
:=
group_power_cv
.
CvGroupPowerGradeDetail
{
GroupPower
Info
:
group_power_cv
.
CvGroupPowerInfo
{
GroupPower
Base
:
group_power_cv
.
CvGroupPowerBase
{
GroupPowerId
:
groupPower
.
ID
,
Icon
:
groupPower
.
Icon
,
Name
:
groupPower
.
Name
,
...
...
route/group_power_r/inner.go
0 → 100644
View file @
7bb301e5
package
group_power_r
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/resource/mysql"
"github.com/gin-gonic/gin"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/cv/group_power_cv"
"hilo-group/domain/model/groupPower_m"
"hilo-group/resp"
)
type
MGetGroupPowerReq
struct
{
Ids
[]
mysql
.
ID
`form:"ids" binding:"required"`
}
// @Tags 国家势力-内部
// @Summary 批量获取国家势力信息
// @Param ids query string true "用户id,如:ids=1&ids=2&ids=3"
// @Success 200 {object} map[mysql.ID]group_power_cv.CvGroupPowerInfo
// @Router /inner/groupPower/infos [get]
func
MGetGroupPowers
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
var
model
=
domain
.
CreateModelContext
(
myCtx
)
var
req
MGetGroupPowerReq
if
err
:=
c
.
ShouldBindQuery
(
&
req
);
err
!=
nil
{
return
myCtx
,
err
}
groupPowers
,
err
:=
groupPower_m
.
MGetGroupPowerInfoMap
(
model
,
req
.
Ids
)
if
err
!=
nil
{
return
myCtx
,
err
}
groupPowerUsers
,
err
:=
groupPower_m
.
MGetGroupPowerUsers
(
model
,
req
.
Ids
)
if
err
!=
nil
{
return
myCtx
,
err
}
groupPowerGrade
,
err
:=
groupPower_m
.
MGetGroupPowerGrade
(
model
,
req
.
Ids
)
if
err
!=
nil
{
return
myCtx
,
err
}
response
:=
make
(
map
[
mysql
.
ID
]
group_power_cv
.
CvGroupPowerInfo
)
for
groupPowerId
,
info
:=
range
groupPowers
{
// 成员上限
var
memberLimit
mysql
.
Num
grade
:=
groupPowerGrade
[
groupPowerId
]
.
Grade
if
grade
>=
groupPower_e
.
GroupPowerGrade0
&&
grade
<=
groupPower_e
.
GroupPowerGradeMax
{
memberLimit
=
mysql
.
Num
(
group_power_cv
.
GroupPowerGradePrivilegeNum
[
groupPowerGrade
[
groupPowerId
]
.
Grade
][
0
]
.
Num
)
}
memberNum
:=
mysql
.
Num
(
len
(
groupPowerUsers
[
groupPowerId
]))
if
memberNum
>
memberLimit
{
memberLimit
=
memberNum
}
response
[
groupPowerId
]
=
group_power_cv
.
CvGroupPowerInfo
{
CvGroupPowerBase
:
group_power_cv
.
CvGroupPowerBase
{
GroupPowerId
:
groupPowerId
,
Icon
:
info
.
Icon
,
Name
:
info
.
Name
,
Nameplate
:
info
.
Nameplate
,
},
CvGroupPowerMember
:
group_power_cv
.
CvGroupPowerMember
{
MemberNum
:
memberNum
,
MemberLimit
:
memberLimit
,
},
}
}
resp
.
ResponseOk
(
c
,
response
)
return
myCtx
,
nil
}
route/router.go
View file @
7bb301e5
...
...
@@ -129,6 +129,13 @@ func InitRouter() *gin.Engine {
groupPower
.
GET
(
"/star"
,
wrapper
(
group_power_r
.
GroupPowerStar
))
groupPower
.
GET
(
"/grade/detail"
,
wrapper
(
group_power_r
.
GroupPowerGradeDetail
))
}
// 内部接口
inner
:=
r
.
Group
(
"/inner"
)
innerGroupPower
:=
inner
.
Group
(
"/groupPower"
)
{
innerGroupPower
.
GET
(
"/infos"
,
wrapper
(
group_power_r
.
MGetGroupPowers
))
}
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