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
3bcb57cd
Commit
3bcb57cd
authored
Mar 13, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
退出家族
parent
6de10476
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
8 deletions
+49
-8
family.go
domain/model/groupPower_m/family.go
+16
-0
3.5.0.sql
mysql/3.5.0.sql
+13
-1
group_power.go
route/group_power_r/group_power.go
+19
-7
router.go
route/router.go
+1
-0
No files found.
domain/model/groupPower_m/family.go
View file @
3bcb57cd
...
...
@@ -16,6 +16,12 @@ type GroupPowerGrade struct {
ExpireAt
time
.
Time
`json:"expire_at"`
}
type
GroupPowerQuitLog
struct
{
Id
uint64
`json:"id"`
UserId
uint64
`json:"user_id"`
MgrId
uint64
`json:"mgr_id"`
}
func
(
this
*
GroupPower
)
Get
(
model
*
domain
.
Model
)
(
*
GroupPower
,
error
)
{
group
:=
new
(
GroupPower
)
err
:=
model
.
Db
.
Where
(
this
)
.
First
(
&
group
)
.
Error
...
...
@@ -69,3 +75,13 @@ func (gpu *GroupPowerUser) GetGroupPowerUser(model *domain.Model) (*GroupPowerUs
func
(
gpu
*
GroupPowerUser
)
Create
(
db
*
gorm
.
DB
)
error
{
return
db
.
Create
(
gpu
)
.
Error
}
func
QuitFamily
(
model
*
domain
.
Model
,
userId
,
mgrId
,
familyId
uint64
)
error
{
err
:=
model
.
Db
.
Exec
(
"delete from group_power_user where group_power_id = ? and user_id = ?"
,
familyId
,
userId
)
.
Error
if
err
!=
nil
{
return
err
}
// log
log
:=
&
GroupPowerQuitLog
{
UserId
:
userId
,
MgrId
:
mgrId
}
return
model
.
Db
.
Create
(
log
)
.
Error
}
mysql/3.5.0.sql
View file @
3bcb57cd
...
...
@@ -30,3 +30,15 @@ CREATE TABLE `group_power_apply_join` (
KEY
`group_power_id`
(
`group_power_id`
),
KEY
`user_id`
(
`user_id`
)
USING
BTREE
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
2
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
COMMENT
=
'申请加入家族'
;
CREATE
TABLE
`group_power_quit_log`
(
`id`
bigint
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`user_id`
bigint
NOT
NULL
COMMENT
'用户id'
,
`mgr_id`
bigint
NOT
NULL
COMMENT
'操作人id'
,
`created_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`updated_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
,
PRIMARY
KEY
(
`id`
),
KEY
`user_id`
(
`user_id`
)
USING
BTREE
,
KEY
`created_time`
(
`created_time`
)
USING
BTREE
,
KEY
`mgr_id`
(
`mgr_id`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
;
\ No newline at end of file
route/group_power_r/group_power.go
View file @
3bcb57cd
...
...
@@ -1066,8 +1066,13 @@ func GroupPowerQuit(c *gin.Context) (*mycontext.MyContext, error) {
if
groupPUser
==
nil
{
return
myContext
,
bizerr
.
GroupPowerHaveNoJoin
}
// 退出家族
// log
// 退出家族、log
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
return
groupPower_m
.
QuitFamily
(
model
,
userId
,
userId
,
groupPUser
.
GroupPowerId
)
})
if
err
!=
nil
{
return
myContext
,
err
}
resp
.
ResponseOk
(
c
,
nil
)
return
myContext
,
nil
...
...
@@ -1094,16 +1099,23 @@ func GroupPowerQuit(c *gin.Context) (*mycontext.MyContext, error) {
if
err
!=
nil
{
return
myContext
,
err
}
groupPUser
,
err
:=
gpU
.
GetGroupPowerUser
(
model
)
// 被踢者
gpUKick
:=
groupPower_m
.
GroupPowerUser
{
UserId
:
userId
}
kickGroupPUser
,
err
:=
gpUKick
.
GetGroupPowerUser
(
model
)
if
err
!=
nil
{
return
myContext
,
err
}
if
g
roupPUser
==
nil
{
if
kickG
roupPUser
==
nil
{
return
myContext
,
bizerr
.
GroupPowerHaveNoJoin
}
// 退出家族
// log
// 退出家族、log
err
=
model
.
Transaction
(
func
(
model
*
domain
.
Model
)
error
{
return
groupPower_m
.
QuitFamily
(
model
,
u
.
ID
,
userId
,
kickGroupPUser
.
GroupPowerId
)
})
if
err
!=
nil
{
return
myContext
,
err
}
resp
.
ResponseOk
(
c
,
u
)
resp
.
ResponseOk
(
c
,
nil
)
return
myContext
,
nil
}
route/router.go
View file @
3bcb57cd
...
...
@@ -132,6 +132,7 @@ func InitRouter() *gin.Engine {
groupPower
.
POST
(
"/apply"
,
wrapper
(
group_power_r
.
GroupPowerApplyJoin
))
groupPower
.
POST
(
"/apply/pass"
,
wrapper
(
group_power_r
.
GroupPowerApplyPass
))
groupPower
.
GET
(
"/apply/list"
,
wrapper
(
group_power_r
.
GroupPowerApplyList
))
groupPower
.
POST
(
"/quit"
,
wrapper
(
group_power_r
.
GroupPowerQuit
))
}
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