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
982b8d0f
Commit
982b8d0f
authored
Mar 10, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
家族成员
parent
bd5b7076
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
1 deletion
+102
-1
group_power_apply.go
domain/model/groupPower_m/group_power_apply.go
+49
-0
3.5.0.sql
mysql/3.5.0.sql
+15
-1
group_power.go
route/group_power_r/group_power.go
+37
-0
router.go
route/router.go
+1
-0
No files found.
domain/model/groupPower_m/group_power_apply.go
0 → 100644
View file @
982b8d0f
package
groupPower_m
import
(
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/myerr"
"time"
)
type
GroupPowerApplyJoin
struct
{
Id
uint64
`json:"id"`
UserId
uint64
`json:"user_id"`
GroupPowerId
uint64
`json:"group_power_id"`
CreatedTime
time
.
Time
`json:"created_time"`
UpdatedTime
time
.
Time
`json:"updated_time"`
IsAccept
int8
`json:"is_accept"`
}
func
InsertGroupPowerApplyJoin
(
userId
,
familyId
uint64
)
error
{
nowTime
:=
time
.
Now
()
sql
:=
"insert into group_power_apply_join(user_id,group_power_id,is_accept,created_time,updated_time) "
+
"value(?,?,?,?,?) on duplicate key update is_accept=?,created_time=?,updated_time=?"
err
:=
mysql
.
Db
.
Exec
(
sql
,
userId
,
familyId
,
0
,
nowTime
,
nowTime
,
0
,
nowTime
,
nowTime
)
.
Error
if
err
!=
nil
{
return
myerr
.
WrapErr
(
err
)
}
return
nil
}
func
GetGroupPowerApplyJoin
(
userId
,
familyId
uint64
)
(
*
GroupPowerApplyJoin
,
error
)
{
res
:=
new
(
GroupPowerApplyJoin
)
err
:=
mysql
.
Db
.
Where
(
GroupPowerApplyJoin
{
UserId
:
userId
,
GroupPowerId
:
familyId
})
.
Where
(
"is_accept=0"
)
.
First
(
&
res
)
.
Error
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
nil
,
nil
}
else
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
}
return
res
,
nil
}
func
AcceptGroupPowerApplyJoin
(
userId
,
familyId
uint64
)
error
{
err
:=
mysql
.
Db
.
Exec
(
"update group_power_apply_join set is_accept = 1 where user_id=? and group_power_id=?"
,
userId
,
familyId
)
.
Error
if
err
!=
nil
{
return
myerr
.
WrapErr
(
err
)
}
return
nil
}
mysql/3.5.0.sql
View file @
982b8d0f
...
@@ -16,4 +16,18 @@ CREATE TABLE `group_power_invite_join` (
...
@@ -16,4 +16,18 @@ CREATE TABLE `group_power_invite_join` (
UNIQUE
KEY
`user_group`
(
`user_id`
,
`group_power_id`
),
UNIQUE
KEY
`user_group`
(
`user_id`
,
`group_power_id`
),
KEY
`group_power_id`
(
`group_power_id`
),
KEY
`group_power_id`
(
`group_power_id`
),
KEY
`invite_user_id`
(
`invite_user_id`
)
KEY
`invite_user_id`
(
`invite_user_id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
COMMENT
=
'邀请加入家族'
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
COMMENT
=
'邀请加入家族'
;
\ No newline at end of file
CREATE
TABLE
`group_power_apply_join`
(
`id`
bigint
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`user_id`
bigint
unsigned
NOT
NULL
COMMENT
'申请者id'
,
`group_power_id`
bigint
unsigned
NOT
NULL
,
`created_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`updated_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
,
`is_accept`
tinyint
NOT
NULL
DEFAULT
'0'
COMMENT
'是否已经接受'
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`user_group`
(
`user_id`
,
`group_power_id`
),
UNIQUE
KEY
`u_apply`
(
`user_id`
,
`group_power_id`
,
`is_accept`
)
USING
BTREE
,
KEY
`group_power_id`
(
`group_power_id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
COMMENT
=
'申请加入家族'
;
\ No newline at end of file
route/group_power_r/group_power.go
View file @
982b8d0f
...
@@ -847,3 +847,40 @@ func GroupPowerMembers(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -847,3 +847,40 @@ func GroupPowerMembers(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
result
)
resp
.
ResponseOk
(
c
,
result
)
return
myContext
,
nil
return
myContext
,
nil
}
}
// @Tags 家族
// @Summary 申请加入家族
// @Param id formData int true "家族id"
// @Success 200
// @Router /v1/groupPower/applyJoin [get]
func
GroupPowerApplyJoin
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myContext
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myContext
,
err
}
familyId
,
err
:=
strconv
.
ParseUint
(
c
.
PostForm
(
"id"
),
10
,
64
)
if
err
!=
nil
{
return
myContext
,
myerr
.
WrapErr
(
err
)
}
model
:=
domain
.
CreateModelContext
(
myContext
)
// 判断家族是否存在
gp
:=
&
groupPower_m
.
GroupPower
{
Entity
:
mysql
.
Entity
{
ID
:
familyId
}}
gpInfo
,
err
:=
gp
.
Get
(
model
)
if
err
!=
nil
{
return
myContext
,
err
}
if
gpInfo
==
nil
||
gpInfo
.
ID
<=
0
{
return
myContext
,
bizerr
.
InvalidParameter
}
// 插入申请表
err
=
groupPower_m
.
InsertGroupPowerApplyJoin
(
userId
,
gpInfo
.
ID
)
if
err
!=
nil
{
return
myContext
,
err
}
resp
.
ResponseOk
(
c
,
nil
)
return
myContext
,
nil
}
route/router.go
View file @
982b8d0f
...
@@ -129,6 +129,7 @@ func InitRouter() *gin.Engine {
...
@@ -129,6 +129,7 @@ func InitRouter() *gin.Engine {
groupPower
.
GET
(
"/info"
,
wrapper
(
group_power_r
.
GroupPowerInfo
))
groupPower
.
GET
(
"/info"
,
wrapper
(
group_power_r
.
GroupPowerInfo
))
groupPower
.
GET
(
"/rooms"
,
wrapper
(
group_power_r
.
GroupPowerRooms
))
groupPower
.
GET
(
"/rooms"
,
wrapper
(
group_power_r
.
GroupPowerRooms
))
groupPower
.
GET
(
"/members"
,
wrapper
(
group_power_r
.
GroupPowerMembers
))
groupPower
.
GET
(
"/members"
,
wrapper
(
group_power_r
.
GroupPowerMembers
))
groupPower
.
POST
(
"/applyJoin"
,
wrapper
(
group_power_r
.
GroupPowerApplyJoin
))
}
}
charge
:=
v1
.
Group
(
"/charge"
)
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