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
623b6af8
Commit
623b6af8
authored
Mar 09, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:等级明细页面
parent
e65b1e3d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
194 additions
and
31 deletions
+194
-31
grade.go
_const/enum/groupPower_e/grade.go
+18
-5
group_rank.go
cv/group_power_cv/group_rank.go
+83
-9
group_grade.go
domain/model/groupPower_m/group_grade.go
+1
-1
group_rank.go
route/group_power_r/group_rank.go
+91
-16
router.go
route/router.go
+1
-0
No files found.
_const/enum/groupPower_e/grade.go
View file @
623b6af8
package
groupPower_e
import
"git.hilo.cn/hilo-common/resource/mysql"
type
GroupPowerGrade
int
const
(
GroupPowerGrade0
GroupPowerGrade
=
0
GroupPowerGrade1
GroupPowerGrade
=
1
GroupPowerGrade2
GroupPowerGrade
=
2
GroupPowerGrade3
GroupPowerGrade
=
3
GroupPowerGrade4
GroupPowerGrade
=
4
GroupPowerGrade1
GroupPowerGrade
=
1
// 青铜
GroupPowerGrade2
GroupPowerGrade
=
2
// 白银
GroupPowerGrade3
GroupPowerGrade
=
3
// 黄金
GroupPowerGrade4
GroupPowerGrade
=
4
// 黑金
GroupPowerGradeMax
=
GroupPowerGrade4
)
var
(
GroupPowerGradeExp
=
map
[
GroupPowerGrade
]
int64
{
GroupPowerGradeExp
=
map
[
GroupPowerGrade
]
mysql
.
Num
{
GroupPowerGrade1
:
2500000
,
GroupPowerGrade2
:
15000000
,
GroupPowerGrade3
:
45000000
,
// todo
GroupPowerGrade4
:
60000000
,
}
)
type
GroupPowerPrivilege
int
const
(
GroupPowerPrivilegeMemberNum
GroupPowerPrivilege
=
1
// 成员数
GroupPowerPrivilegeMgrNum
GroupPowerPrivilege
=
2
// 管理员数
GroupPowerPrivilegeNameplate
GroupPowerPrivilege
=
3
// 家族铭牌
GroupPowerPrivilegeMedal
GroupPowerPrivilege
=
4
// 家族徽章装饰
GroupPowerPrivilegeNameplateEdit
GroupPowerPrivilege
=
5
// 编辑铭牌
GroupPowerPrivilegeNameplateHeadwear
GroupPowerPrivilege
=
6
// 家族头饰
)
cv/group_power_cv/group_rank.go
View file @
623b6af8
...
...
@@ -6,20 +6,33 @@ import (
"hilo-group/cv/user_cv"
)
// 家族基本信息
type
CvGroupPowerInfo
struct
{
GroupPowerId
mysql
.
ID
`json:"groupPowerId"`
// 家族id
Icon
string
`json:"icon"`
// 家族图片
Name
string
`json:"name"`
// 家族名
Nameplate
string
`json:"nameplate"`
// 铭牌
}
// 家族等级
type
CvGroupPowerGrade
struct
{
Grade
groupPower_e
.
GroupPowerGrade
`json:"grade"`
// 等级 0:无 1:青铜 2:白银 3:黄金 4:黑金
Exp
mysql
.
Num
`json:"exp"`
// 经验值
NextExp
mysql
.
Num
`json:"nextExp,omitempty"`
// 升级所需经验值
ExpireAt
string
`json:"expireAt,omitempty"`
// 有效期
ShowExp
bool
`json:"showExp"`
// 是否展示经验值
}
// 家族榜单
type
CvGroupPowerRank
struct
{
MyGroupPower
CvGroupPowerRankData
`json:"myGroupPower"`
Items
[]
CvGroupPowerRankData
`json:"items"`
MyGroupPower
CvGroupPowerRankData
`json:"myGroupPower"`
// 我的家族排名
Items
[]
CvGroupPowerRankData
`json:"items"`
// 列表
}
type
CvGroupPowerRankData
struct
{
GroupPowerId
mysql
.
ID
`json:"groupPowerId"`
// 家族id
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"`
// 排名
CvGroupPowerInfo
`json:",inline"`
CvGroupPowerGrade
`json:",inline"`
Rank
int
`json:"rank"`
// 排名
}
// 家族之星
...
...
@@ -27,3 +40,64 @@ type CvGroupPowerStarData struct {
user_cv
.
CvUserTiny
`json:",inline"`
Score
mysql
.
Num
`json:"score"`
// 对应分值
}
// 资源等级
type
CvResGrade
struct
{
Grade
groupPower_e
.
GroupPowerGrade
`json:"grade"`
// 等级
Icon
string
`json:"icon"`
// 等级icon
BigIcon
string
`json:"bigIcon"`
// 等级大图标
}
// 特权信息
type
CvPrivilege
struct
{
Type
groupPower_e
.
GroupPowerPrivilege
`json:"type"`
// 特权id 1:成员数 2:管理员数 3:家族铭牌 4:家族徽章装饰 5:编辑铭牌 6:家族头饰
Num
int
`json:"num"`
// 数目
}
// 家族等级页
type
CvGroupPowerGradeDetail
struct
{
GroupPowerInfo
CvGroupPowerInfo
`json:"groupPowerInfo"`
// 家族基本信息
GroupPowerGrade
CvGroupPowerGrade
`json:"groupPowerGrade"`
// 家族等级信息
ResGradeList
[]
CvResGrade
`json:"resGradeList"`
// 资源等级列表,青铜、白银、黄金、黑金
PrivilegeList
[]
CvPrivilege
`json:"privilegeList"`
// 等级特权
}
var
CvResGradeList
=
[]
CvResGrade
{
{
groupPower_e
.
GroupPowerGrade1
,
"青铜icon"
,
"青铜bigIcon"
},
// todo
{
groupPower_e
.
GroupPowerGrade2
,
"白银icon"
,
"白银bigIcon"
},
// todo
{
groupPower_e
.
GroupPowerGrade3
,
"黄金icon"
,
"黄金bigIcon"
},
// todo
{
groupPower_e
.
GroupPowerGrade4
,
"黑金icon"
,
"黑金bigIcon"
},
// todo
}
var
GroupPowerGradePrivilegeNum
=
map
[
groupPower_e
.
GroupPowerGrade
][]
CvPrivilege
{
groupPower_e
.
GroupPowerGrade0
:
{},
groupPower_e
.
GroupPowerGrade1
:
{
{
groupPower_e
.
GroupPowerPrivilegeMemberNum
,
300
},
{
groupPower_e
.
GroupPowerPrivilegeMgrNum
,
10
},
{
groupPower_e
.
GroupPowerPrivilegeNameplate
,
1
},
{
groupPower_e
.
GroupPowerPrivilegeMedal
,
1
},
},
groupPower_e
.
GroupPowerGrade2
:
{
{
groupPower_e
.
GroupPowerPrivilegeMemberNum
,
500
},
{
groupPower_e
.
GroupPowerPrivilegeMgrNum
,
15
},
{
groupPower_e
.
GroupPowerPrivilegeNameplate
,
1
},
{
groupPower_e
.
GroupPowerPrivilegeMedal
,
1
},
{
groupPower_e
.
GroupPowerPrivilegeNameplateEdit
,
1
},
},
groupPower_e
.
GroupPowerGrade3
:
{
{
groupPower_e
.
GroupPowerPrivilegeMemberNum
,
800
},
{
groupPower_e
.
GroupPowerPrivilegeMgrNum
,
20
},
{
groupPower_e
.
GroupPowerPrivilegeNameplate
,
1
},
{
groupPower_e
.
GroupPowerPrivilegeMedal
,
1
},
{
groupPower_e
.
GroupPowerPrivilegeNameplateEdit
,
1
},
{
groupPower_e
.
GroupPowerPrivilegeNameplateHeadwear
,
1
},
},
groupPower_e
.
GroupPowerGrade4
:
{
{
groupPower_e
.
GroupPowerPrivilegeMemberNum
,
1200
},
{
groupPower_e
.
GroupPowerPrivilegeMgrNum
,
25
},
{
groupPower_e
.
GroupPowerPrivilegeNameplate
,
1
},
{
groupPower_e
.
GroupPowerPrivilegeMedal
,
1
},
{
groupPower_e
.
GroupPowerPrivilegeNameplateEdit
,
1
},
{
groupPower_e
.
GroupPowerPrivilegeNameplateHeadwear
,
1
},
},
}
domain/model/groupPower_m/group_grade.go
View file @
623b6af8
...
...
@@ -255,7 +255,7 @@ func ClearGroupPowerExp(model *domain.Model) error {
// 清理过期家族等级
func
ClearGroupPowerGrade
(
model
*
domain
.
Model
)
error
{
var
groupPowerGrades
[]
*
GroupPowerGrade
if
err
:=
model
.
DB
()
.
Model
(
GroupPowerGrade
{})
.
Where
(
"expire_at
>
?"
,
time
.
Now
())
.
Find
(
&
groupPowerGrades
)
.
Error
;
err
!=
nil
{
if
err
:=
model
.
DB
()
.
Model
(
GroupPowerGrade
{})
.
Where
(
"expire_at
<
?"
,
time
.
Now
())
.
Find
(
&
groupPowerGrades
)
.
Error
;
err
!=
nil
{
return
err
}
return
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
...
...
route/group_power_r/group_rank.go
View file @
623b6af8
...
...
@@ -15,6 +15,7 @@ import (
"hilo-group/myerr/bizerr"
"hilo-group/req"
"hilo-group/resp"
"strconv"
"time"
)
...
...
@@ -75,24 +76,32 @@ func GroupPowerRank(c *gin.Context) (*mycontext.MyContext, error) {
return
myContext
,
err
}
response
.
MyGroupPower
=
group_power_cv
.
CvGroupPowerRankData
{
GroupPowerId
:
myGroupPower
.
GroupPowerId
,
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
,
CvGroupPowerInfo
:
group_power_cv
.
CvGroupPowerInfo
{
GroupPowerId
:
myGroupPower
.
GroupPowerId
,
Icon
:
groupPowers
[
myGroupPower
.
GroupPowerId
]
.
Icon
,
Name
:
groupPowers
[
myGroupPower
.
GroupPowerId
]
.
Name
,
Nameplate
:
groupPowers
[
myGroupPower
.
GroupPowerId
]
.
Nameplate
,
},
CvGroupPowerGrade
:
group_power_cv
.
CvGroupPowerGrade
{
Grade
:
grades
[
myGroupPower
.
GroupPowerId
]
.
Grade
,
Exp
:
myGroupPowerRank
.
Exp
,
},
Rank
:
myGroupPowerRank
.
Rank
,
}
}
for
r
,
v
:=
range
rank
{
for
_
,
v
:=
range
rank
{
response
.
Items
=
append
(
response
.
Items
,
group_power_cv
.
CvGroupPowerRankData
{
GroupPowerId
:
v
.
GroupPowerId
,
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
,
// 查询已做排序
CvGroupPowerInfo
:
group_power_cv
.
CvGroupPowerInfo
{
GroupPowerId
:
v
.
GroupPowerId
,
Icon
:
groupPowers
[
v
.
GroupPowerId
]
.
Icon
,
Name
:
groupPowers
[
v
.
GroupPowerId
]
.
Name
,
Nameplate
:
groupPowers
[
v
.
GroupPowerId
]
.
Nameplate
,
},
CvGroupPowerGrade
:
group_power_cv
.
CvGroupPowerGrade
{
Grade
:
grades
[
v
.
GroupPowerId
]
.
Grade
,
Exp
:
v
.
Exp
,
},
Rank
:
v
.
Rank
,
})
}
resp
.
ResponseOk
(
c
,
response
)
...
...
@@ -110,7 +119,7 @@ type GroupPowerStarReq struct {
// @Summary 家族之星
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Param groupPowerId query int true "
分页大小 默认:10" default(10)
// @Param groupPowerId query int true "
家族id"
// @Param type query string true "类型 1:送礼 2:活跃 3:收礼物"
// @Param pageSize query int false "分页大小 默认:10" default(10)
// @Param pageIndex query int false "第几个分页,从1开始 默认:1" default(1)
...
...
@@ -153,3 +162,69 @@ func GroupPowerStar(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
response
)
return
myContext
,
nil
}
// @Tags 国家势力
// @Summary 家族等级页
// @Param token header string true "token"
// @Param nonce header string true "随机数字"
// @Param groupPowerId query int true "家族id"
// @Success 200 {object} group_power_cv.CvGroupPowerGradeDetail
// @Router /v1/groupPower/grade/detail [get]
func
GroupPowerGradeDetail
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myContext
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myContext
,
err
}
groupPowerId
,
err
:=
strconv
.
ParseUint
(
c
.
Query
(
"groupPowerId"
),
10
,
16
)
if
err
!=
nil
||
groupPowerId
<=
0
{
return
myContext
,
bizerr
.
InvalidParameter
}
var
model
=
domain
.
CreateModelContext
(
myContext
)
groupPowerInfo
,
err
:=
groupPower_m
.
MGetGroupPowerInfoMap
(
model
,
[]
mysql
.
ID
{
groupPowerId
})
if
err
!=
nil
{
return
myContext
,
err
}
gradeM
,
err
:=
groupPower_m
.
MGetGroupPowerGrade
(
model
,
[]
mysql
.
ID
{
groupPowerId
})
if
err
!=
nil
{
return
myContext
,
err
}
groupPower
,
ok
:=
groupPowerInfo
[
groupPowerId
]
if
!
ok
{
return
myContext
,
bizerr
.
GroupNotFound
}
grade
:=
gradeM
[
groupPowerId
]
nextExp
:=
mysql
.
Num
(
0
)
if
grade
.
Grade
!=
groupPower_e
.
GroupPowerGradeMax
{
nextExp
=
groupPower_e
.
GroupPowerGradeExp
[
grade
.
Grade
+
1
]
-
groupPower_e
.
GroupPowerGradeExp
[
grade
.
Grade
]
}
expireAt
:=
""
if
grade
.
ExpireAt
.
After
(
time
.
Now
())
{
expireAt
=
grade
.
ExpireAt
.
Format
(
"2006-01-02"
)
}
showExp
:=
false
if
exits
,
_
,
err
:=
groupPower_m
.
CheckGroupPowerUser
(
model
,
userId
);
err
!=
nil
{
return
myContext
,
err
}
else
if
exits
{
showExp
=
true
}
response
:=
group_power_cv
.
CvGroupPowerGradeDetail
{
GroupPowerInfo
:
group_power_cv
.
CvGroupPowerInfo
{
GroupPowerId
:
groupPower
.
ID
,
Icon
:
groupPower
.
Icon
,
Name
:
groupPower
.
Name
,
Nameplate
:
groupPower
.
Nameplate
,
},
GroupPowerGrade
:
group_power_cv
.
CvGroupPowerGrade
{
Grade
:
grade
.
Grade
,
Exp
:
grade
.
Exp
,
NextExp
:
nextExp
,
ExpireAt
:
expireAt
,
ShowExp
:
showExp
,
},
ResGradeList
:
group_power_cv
.
CvResGradeList
,
PrivilegeList
:
group_power_cv
.
GroupPowerGradePrivilegeNum
[
grade
.
Grade
],
}
resp
.
ResponseOk
(
c
,
response
)
return
myContext
,
nil
}
route/router.go
View file @
623b6af8
...
...
@@ -127,6 +127,7 @@ func InitRouter() *gin.Engine {
groupPower
.
GET
(
"/billboard/owner/week"
,
wrapper
(
group_power_r
.
GroupPowerBillboardOwnerWeek
))
groupPower
.
GET
(
"/rank/:period"
,
wrapper
(
group_power_r
.
GroupPowerRank
))
groupPower
.
GET
(
"/star"
,
wrapper
(
group_power_r
.
GroupPowerStar
))
groupPower
.
GET
(
"/grade/detail"
,
wrapper
(
group_power_r
.
GroupPowerGradeDetail
))
}
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