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
033d3d04
Commit
033d3d04
authored
Mar 13, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
设置家族管理员
parent
e4ff5c27
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
97 additions
and
14 deletions
+97
-14
family.go
domain/model/groupPower_m/family.go
+9
-0
bizCode.go
myerr/bizerr/bizCode.go
+15
-14
group_power.go
route/group_power_r/group_power.go
+72
-0
router.go
route/router.go
+1
-0
No files found.
domain/model/groupPower_m/family.go
View file @
033d3d04
...
...
@@ -4,6 +4,7 @@ import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/_const/enum/groupPower_e"
"hilo-group/common"
"hilo-group/common/utime"
"time"
...
...
@@ -103,3 +104,11 @@ func GroupPowerQuitList(model *domain.Model, familyId uint64, pageSize, pageInde
nextIdx
,
hasNext
:=
common
.
PageNext
(
count
,
pageIndex
,
pageSize
)
return
rows
,
nextIdx
,
hasNext
,
nil
}
func
UpdateFamilyAdmin
(
model
*
domain
.
Model
,
userId
,
familyId
uint64
,
role
groupPower_e
.
GroupPowerUserRole
)
error
{
err
:=
model
.
Db
.
Exec
(
"update group_power_user set role = ? where group_power_id = ? and user_id = ?"
,
role
,
familyId
,
userId
)
.
Error
if
err
!=
nil
{
return
err
}
return
nil
}
myerr/bizerr/bizCode.go
View file @
033d3d04
...
...
@@ -85,6 +85,7 @@ var (
GroupPowerHaveNoPower
=
myerr
.
NewBusinessCode
(
15012
,
"You have no power"
,
myerr
.
BusinessData
{})
// 没有权限
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
{})
// 已经改变了
TaskHasAward
=
myerr
.
NewBusinessCode
(
19001
,
"task has award"
,
myerr
.
BusinessData
{})
...
...
route/group_power_r/group_power.go
View file @
033d3d04
...
...
@@ -1184,3 +1184,75 @@ func GroupPowerQuitList(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponsePageBaseOk
(
c
,
result
,
nextPageIndex
,
hasNextPage
)
return
myContext
,
nil
}
// @Tags 家族
// @Summary 设置/取消管理员
// @Param userExtId formData string false "用户extId"
// @Param type formData int true "1.设置为管理员,2.取消管理员"
// @Success 200
// @Router /v1/groupPower/admin [post]
func
GroupPowerSetAdmin
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myContext
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myContext
,
err
}
optType
,
err
:=
strconv
.
Atoi
(
c
.
PostForm
(
"type"
))
if
err
!=
nil
{
return
myContext
,
bizerr
.
InvalidParameter
}
if
optType
<
1
||
optType
>
2
{
return
myContext
,
bizerr
.
InvalidParameter
}
userExtId
:=
c
.
PostForm
(
"userExtId"
)
if
userExtId
==
""
{
return
myContext
,
bizerr
.
InvalidParameter
}
model
:=
domain
.
CreateModelContext
(
myContext
)
optUser
,
err
:=
user_c
.
GetUserByExternalId
(
model
,
userExtId
)
if
err
!=
nil
{
return
myContext
,
err
}
// 判断是否加入了家族
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
}
// 被操作者是否加入了家族
gpOptUser
:=
groupPower_m
.
GroupPowerUser
{
UserId
:
optUser
.
ID
}
optGroupPUser
,
err
:=
gpOptUser
.
GetGroupPowerUser
(
model
)
if
err
!=
nil
{
return
myContext
,
err
}
if
optGroupPUser
==
nil
{
return
myContext
,
bizerr
.
GroupPowerHaveNoJoin
}
// 目标身份
var
targetRole
groupPower_e
.
GroupPowerUserRole
if
optType
==
1
{
targetRole
=
groupPower_e
.
GroupPowerUserRoleAdmin
}
else
{
targetRole
=
groupPower_e
.
GroupPowerUserRoleUser
}
// 和原来的身份是否一致
if
optGroupPUser
.
Role
==
targetRole
{
return
myContext
,
bizerr
.
GroupPowerHaveAlreadyChange
}
// 变更
err
=
groupPower_m
.
UpdateFamilyAdmin
(
model
,
userId
,
optGroupPUser
.
GroupPowerId
,
targetRole
)
if
optGroupPUser
==
nil
{
return
myContext
,
myerr
.
WrapErr
(
err
)
}
resp
.
ResponseOk
(
c
,
nil
)
return
myContext
,
nil
}
route/router.go
View file @
033d3d04
...
...
@@ -134,6 +134,7 @@ func InitRouter() *gin.Engine {
groupPower
.
GET
(
"/apply/list"
,
wrapper
(
group_power_r
.
GroupPowerApplyList
))
groupPower
.
POST
(
"/quit"
,
wrapper
(
group_power_r
.
GroupPowerQuit
))
groupPower
.
GET
(
"/quit/list"
,
wrapper
(
group_power_r
.
GroupPowerQuitList
))
groupPower
.
POST
(
"/admin"
,
wrapper
(
group_power_r
.
GroupPowerSetAdmin
))
}
charge
:=
v1
.
Group
(
"/charge"
)
...
...
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