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
b86a202e
Commit
b86a202e
authored
Mar 13, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改家族信息
parent
033d3d04
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
0 deletions
+122
-0
family.go
domain/model/groupPower_m/family.go
+45
-0
bizCode.go
myerr/bizerr/bizCode.go
+3
-0
group_power.go
route/group_power_r/group_power.go
+74
-0
No files found.
domain/model/groupPower_m/family.go
View file @
b86a202e
...
...
@@ -7,6 +7,8 @@ import (
"hilo-group/_const/enum/groupPower_e"
"hilo-group/common"
"hilo-group/common/utime"
"hilo-group/myerr"
"hilo-group/myerr/bizerr"
"time"
)
...
...
@@ -112,3 +114,46 @@ func UpdateFamilyAdmin(model *domain.Model, userId, familyId uint64, role groupP
}
return
nil
}
func
UpdateFamily
(
model
*
domain
.
Model
,
familyId
uint64
,
name
,
nameplate
,
declaration
,
icon
string
)
error
{
if
familyId
==
0
||
(
name
==
""
&&
nameplate
==
""
&&
declaration
==
""
&&
icon
==
""
)
{
return
nil
}
db
:=
model
.
Db
.
Model
(
GroupPower
{})
updateMap
:=
make
(
map
[
string
]
interface
{})
if
name
!=
""
{
updateMap
[
"name"
]
=
name
}
if
nameplate
!=
""
{
updateMap
[
"nameplate"
]
=
nameplate
db
=
db
.
Where
(
"not exists (select id from group_power where nameplate = ?)"
,
nameplate
)
}
if
declaration
!=
""
{
updateMap
[
"declaration"
]
=
declaration
}
if
icon
!=
""
{
updateMap
[
"icon"
]
=
icon
}
result
:=
db
.
Updates
(
updateMap
)
.
Limit
(
1
)
if
result
.
Error
!=
nil
{
return
myerr
.
WrapErr
(
result
.
Error
)
}
if
result
.
RowsAffected
<=
0
{
return
myerr
.
WrapErr
(
bizerr
.
GroupPowerHaveChangeInfo
)
}
return
nil
}
func
IsExistsNameplate
(
model
*
domain
.
Model
,
nameplate
string
)
bool
{
var
count
int64
err
:=
model
.
Db
.
Model
(
GroupPower
{})
.
Where
(
"nameplate = ?"
,
nameplate
)
.
Count
(
&
count
)
.
Error
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"IsExistsNameplate err:%v, nameplate:%s"
,
err
,
nameplate
)
return
false
}
if
count
>
0
{
return
true
}
return
false
}
myerr/bizerr/bizCode.go
View file @
b86a202e
...
...
@@ -86,6 +86,9 @@ var (
GroupPowerHaveNoApply
=
myerr
.
NewBusinessCode
(
15013
,
"User have no apply"
,
myerr
.
BusinessData
{})
// 没有找到申请
GroupPowerHaveAlreadyApply
=
myerr
.
NewBusinessCode
(
15014
,
"Already applied"
,
myerr
.
BusinessData
{})
// 已经申请过
GroupPowerHaveAlreadyChange
=
myerr
.
NewBusinessCode
(
15015
,
"Already changed"
,
myerr
.
BusinessData
{})
// 已经改变了
GroupPowerHaveChangeInfo
=
myerr
.
NewBusinessCode
(
15016
,
"Setting failed"
,
myerr
.
BusinessData
{})
// 修改失败
GroupPowerHaveTooLong
=
myerr
.
NewBusinessCode
(
15017
,
"too long"
,
myerr
.
BusinessData
{})
// 长度太长
GroupPowerCannotRepeated
=
myerr
.
NewBusinessCode
(
15018
,
"Cannot be repeated"
,
myerr
.
BusinessData
{})
// 不能重复
TaskHasAward
=
myerr
.
NewBusinessCode
(
19001
,
"task has award"
,
myerr
.
BusinessData
{})
...
...
route/group_power_r/group_power.go
View file @
b86a202e
...
...
@@ -1256,3 +1256,77 @@ func GroupPowerSetAdmin(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
nil
)
return
myContext
,
nil
}
// @Tags 家族
// @Summary 设置家族信息
// @Param id formData int true "家族id"
// @Param icon formData string false "家族图片"
// @Param name formData string false "家族名称"
// @Param nameplate formData string false "家族铭牌"
// @Param declaration formData string false "家族宣言"
// @Success 200
// @Router /v1/groupPower/info/set [post]
func
GroupPowerSetInfo
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myContext
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myContext
,
err
}
type
param
struct
{
Id
uint64
`json:"id"`
Name
string
`json:"name"`
Nameplate
string
`json:"nameplate"`
// 铭牌
Declaration
string
`json:"declaration"`
// 宣言
Icon
string
`json:"icon"`
// 头像
}
para
:=
new
(
param
)
if
err
:=
c
.
ShouldBind
(
&
para
);
err
!=
nil
{
return
myContext
,
err
}
if
para
.
Id
<=
0
{
return
myContext
,
bizerr
.
InvalidParameter
}
model
:=
domain
.
CreateModelContext
(
myContext
)
// 判断是否加入了家族
gpU
:=
groupPower_m
.
GroupPowerUser
{
UserId
:
userId
}
myGroupPUser
,
err
:=
gpU
.
GetGroupPowerUser
(
model
)
if
err
!=
nil
{
return
myContext
,
err
}
// 操作者是否加入了家族,是否有操作权限
if
myGroupPUser
==
nil
{
return
myContext
,
bizerr
.
GroupPowerHaveNoJoin
}
if
myGroupPUser
.
Role
!=
groupPower_e
.
GroupPowerUserRoleMgr
{
return
myContext
,
bizerr
.
GroupPowerHaveNoPower
}
// 检查铭牌是否能够修改
if
para
.
Nameplate
!=
""
{
// 等级检查
gp
:=
&
groupPower_m
.
GroupPower
{
Entity
:
mysql
.
Entity
{
ID
:
myGroupPUser
.
GroupPowerId
}}
groupPInfo
,
err
:=
gp
.
Get
(
model
)
if
err
!=
nil
{
return
myContext
,
err
}
if
groupPInfo
.
Grade
<
1
{
return
myContext
,
bizerr
.
GroupPowerHaveNoPower
}
// 检查铭牌长度和唯一性
if
len
(
para
.
Nameplate
)
>
10
{
return
myContext
,
bizerr
.
GroupPowerHaveTooLong
}
if
groupPower_m
.
IsExistsNameplate
(
model
,
para
.
Nameplate
)
{
return
myContext
,
bizerr
.
GroupPowerCannotRepeated
}
}
// 修改家族信息
err
=
groupPower_m
.
UpdateFamily
(
model
,
userId
,
para
.
Name
,
para
.
Nameplate
,
para
.
Declaration
,
para
.
Icon
)
if
err
!=
nil
{
return
myContext
,
myerr
.
WrapErr
(
err
)
}
resp
.
ResponseOk
(
c
,
nil
)
return
myContext
,
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