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
ea79ac0e
Commit
ea79ac0e
authored
Mar 22, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
家族成员增加判断上限
parent
47229384
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
7 deletions
+52
-7
family.go
domain/model/groupPower_m/family.go
+12
-0
groupPower.go
domain/model/groupPower_m/groupPower.go
+6
-5
bizCode.go
myerr/bizerr/bizCode.go
+1
-0
group_power.go
route/group_power_r/group_power.go
+33
-2
No files found.
domain/model/groupPower_m/family.go
View file @
ea79ac0e
...
@@ -40,6 +40,9 @@ func (this *GroupPower) Get(model *domain.Model) (*GroupPower, error) {
...
@@ -40,6 +40,9 @@ func (this *GroupPower) Get(model *domain.Model) (*GroupPower, error) {
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
if
err
!=
nil
&&
err
!=
gorm
.
ErrRecordNotFound
{
return
nil
,
err
return
nil
,
err
}
}
if
grade
.
GroupPowerId
>
0
{
group
.
Grade
=
grade
.
Grade
}
return
group
,
nil
return
group
,
nil
}
}
...
@@ -159,3 +162,12 @@ func IsExistsNameplate(model *domain.Model, nameplate string) bool {
...
@@ -159,3 +162,12 @@ func IsExistsNameplate(model *domain.Model, nameplate string) bool {
}
}
return
false
return
false
}
}
func
GetMemberNum
(
model
*
domain
.
Model
,
familyId
uint64
)
(
int64
,
error
)
{
var
count
int64
err
:=
model
.
Db
.
Model
(
GroupPowerUser
{})
.
Where
(
"group_power_id=?"
,
familyId
)
.
Count
(
&
count
)
.
Error
if
err
!=
nil
{
return
0
,
err
}
return
count
,
nil
}
domain/model/groupPower_m/groupPower.go
View file @
ea79ac0e
...
@@ -31,6 +31,7 @@ type GroupPower struct {
...
@@ -31,6 +31,7 @@ type GroupPower struct {
Icon
mysql
.
Str
// 头像
Icon
mysql
.
Str
// 头像
GradeName
mysql
.
Str
// 等级称号
GradeName
mysql
.
Str
// 等级称号
GradeMedal
mysql
.
Str
// 等级勋章图片
GradeMedal
mysql
.
Str
// 等级勋章图片
Grade
groupPower_e
.
GroupPowerGrade
`gorm:"-"`
}
}
type
GroupPowerUser
struct
{
type
GroupPowerUser
struct
{
...
...
myerr/bizerr/bizCode.go
View file @
ea79ac0e
...
@@ -92,6 +92,7 @@ var (
...
@@ -92,6 +92,7 @@ var (
GroupPowerCannotQuit
=
myerr
.
NewBusinessCode
(
15019
,
"Cannot quit"
,
myerr
.
BusinessData
{})
// 不能退出
GroupPowerCannotQuit
=
myerr
.
NewBusinessCode
(
15019
,
"Cannot quit"
,
myerr
.
BusinessData
{})
// 不能退出
GroupPowerUserHaveNoJoin
=
myerr
.
NewBusinessCode
(
15020
,
"User have no joined power"
,
myerr
.
BusinessData
{})
// 还未加入国家势力
GroupPowerUserHaveNoJoin
=
myerr
.
NewBusinessCode
(
15020
,
"User have no joined power"
,
myerr
.
BusinessData
{})
// 还未加入国家势力
GroupPowerChangeNameplate
=
myerr
.
NewBusinessCode
(
15021
,
"Can only be modified at the silver level"
,
myerr
.
BusinessData
{})
// 修改铭牌不够等级
GroupPowerChangeNameplate
=
myerr
.
NewBusinessCode
(
15021
,
"Can only be modified at the silver level"
,
myerr
.
BusinessData
{})
// 修改铭牌不够等级
GroupPowerMemberMax
=
myerr
.
NewBusinessCode
(
15022
,
"The family size has reached the upper limit"
,
myerr
.
BusinessData
{})
// 家族人数达到上限
TaskHasAward
=
myerr
.
NewBusinessCode
(
19001
,
"task has award"
,
myerr
.
BusinessData
{})
TaskHasAward
=
myerr
.
NewBusinessCode
(
19001
,
"task has award"
,
myerr
.
BusinessData
{})
...
...
route/group_power_r/group_power.go
View file @
ea79ac0e
...
@@ -743,7 +743,6 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -743,7 +743,6 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
for
_
,
v
:=
range
members
{
for
_
,
v
:=
range
members
{
resMembers
=
append
(
resMembers
,
&
group_power_cv
.
GroupPowerUser
{
User
:
userMap
[
v
.
UserId
],
Role
:
v
.
Role
})
resMembers
=
append
(
resMembers
,
&
group_power_cv
.
GroupPowerUser
{
User
:
userMap
[
v
.
UserId
],
Role
:
v
.
Role
})
}
}
groupPowerGrade
,
err
:=
groupPower_m
.
MGetGroupPowerGrade
(
model
,
[]
mysql
.
ID
{
gp
.
ID
})
gradeM
,
err
:=
groupPower_m
.
MGetGroupPowerGrade
(
model
,
[]
mysql
.
ID
{
gp
.
ID
})
gradeM
,
err
:=
groupPower_m
.
MGetGroupPowerGrade
(
model
,
[]
mysql
.
ID
{
gp
.
ID
})
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
...
@@ -756,7 +755,7 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -756,7 +755,7 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
info
:=
&
group_power_cv
.
GroupPower
{
info
:=
&
group_power_cv
.
GroupPower
{
Id
:
gpInfo
.
ID
,
Name
:
gpInfo
.
Name
,
Nameplate
:
gpInfo
.
Nameplate
,
Declaration
:
gpInfo
.
Declaration
,
Icon
:
gpInfo
.
Icon
,
Id
:
gpInfo
.
ID
,
Name
:
gpInfo
.
Name
,
Nameplate
:
gpInfo
.
Nameplate
,
Declaration
:
gpInfo
.
Declaration
,
Icon
:
gpInfo
.
Icon
,
Grade
:
grade
.
Grade
,
Exp
:
grade
.
Exp
,
NextExp
:
nextExp
,
GradeName
:
gpInfo
.
GradeName
,
GradeMedal
:
gpInfo
.
GradeMedal
,
Grade
:
grade
.
Grade
,
Exp
:
grade
.
Exp
,
NextExp
:
nextExp
,
GradeName
:
gpInfo
.
GradeName
,
GradeMedal
:
gpInfo
.
GradeMedal
,
MemberNum
:
mysql
.
Num
(
total
),
MemberMax
:
mysql
.
Num
(
group_power_cv
.
GroupPowerGradePrivilegeNum
[
gr
oupPowerGrade
[
gp
.
ID
]
.
Grade
][
0
]
.
Num
),
MemberNum
:
mysql
.
Num
(
total
),
MemberMax
:
mysql
.
Num
(
group_power_cv
.
GroupPowerGradePrivilegeNum
[
gr
ade
.
Grade
][
0
]
.
Num
),
}
}
if
info
.
Icon
!=
""
{
if
info
.
Icon
!=
""
{
info
.
Icon
=
common
.
MakeFullUrl
(
info
.
Icon
)
info
.
Icon
=
common
.
MakeFullUrl
(
info
.
Icon
)
...
@@ -975,6 +974,15 @@ func GroupPowerApplyJoin(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -975,6 +974,15 @@ func GroupPowerApplyJoin(c *gin.Context) (*mycontext.MyContext, error) {
if
len
(
uList
)
>
0
{
if
len
(
uList
)
>
0
{
return
myContext
,
bizerr
.
GroupPowerHasJoinOther
return
myContext
,
bizerr
.
GroupPowerHasJoinOther
}
}
// 判断家族是否满人了
nowNum
,
err
:=
groupPower_m
.
GetMemberNum
(
model
,
familyId
)
if
err
!=
nil
{
return
myContext
,
myerr
.
WrapErr
(
err
)
}
maxNum
:=
group_power_cv
.
GroupPowerGradePrivilegeNum
[
gpInfo
.
Grade
][
0
]
.
Num
if
nowNum
+
1
>
int64
(
maxNum
)
{
return
myContext
,
bizerr
.
GroupPowerMemberMax
}
// 插入申请表
// 插入申请表
err
=
groupPower_m
.
InsertGroupPowerApplyJoin
(
model
,
userId
,
gpInfo
.
ID
)
err
=
groupPower_m
.
InsertGroupPowerApplyJoin
(
model
,
userId
,
gpInfo
.
ID
)
...
@@ -1046,6 +1054,20 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1046,6 +1054,20 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
nil
)
resp
.
ResponseOk
(
c
,
nil
)
return
myContext
,
nil
return
myContext
,
nil
}
}
// 判断家族是否满人了
nowNum
,
err
:=
groupPower_m
.
GetMemberNum
(
model
,
apply
.
GroupPowerId
)
if
err
!=
nil
{
return
myContext
,
myerr
.
WrapErr
(
err
)
}
gradeM
,
err
:=
groupPower_m
.
MGetGroupPowerGrade
(
model
,
[]
mysql
.
ID
{
apply
.
GroupPowerId
})
if
err
!=
nil
{
return
myContext
,
err
}
grade
:=
gradeM
[
apply
.
GroupPowerId
]
maxNum
:=
group_power_cv
.
GroupPowerGradePrivilegeNum
[
grade
.
Grade
][
0
]
.
Num
if
int
(
nowNum
+
1
)
>
maxNum
{
return
myContext
,
bizerr
.
GroupPowerMemberMax
}
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
txModel
:=
domain
.
CreateModel
(
model
.
CtxAndDb
)
txModel
:=
domain
.
CreateModel
(
model
.
CtxAndDb
)
...
@@ -1056,6 +1078,15 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -1056,6 +1078,15 @@ func GroupPowerApplyPass(c *gin.Context) (*mycontext.MyContext, error) {
txModel
.
Log
.
Errorf
(
"GroupPowerApplyPass err:%v, info:%v"
,
err
,
gpU
)
txModel
.
Log
.
Errorf
(
"GroupPowerApplyPass err:%v, info:%v"
,
err
,
gpU
)
return
err
return
err
}
}
newNum
,
err
:=
groupPower_m
.
GetMemberNum
(
txModel
,
apply
.
GroupPowerId
)
if
err
!=
nil
{
txModel
.
Log
.
Errorf
(
"GroupPowerApplyPass err:%v, info:%v"
,
err
,
gpU
)
return
err
}
if
int
(
newNum
)
>
maxNum
{
txModel
.
Log
.
Errorf
(
"GroupPowerApplyPass err:%v, info:%v"
,
bizerr
.
GroupPowerMemberMax
,
gpU
)
return
bizerr
.
GroupPowerMemberMax
}
// 更改申请表状态
// 更改申请表状态
err
=
groupPower_m
.
OptGroupPowerApplyJoinById
(
model
,
apply
.
Id
,
userId
,
optType
)
err
=
groupPower_m
.
OptGroupPowerApplyJoinById
(
model
,
apply
.
Id
,
userId
,
optType
)
if
err
!=
nil
{
if
err
!=
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