Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-user
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
chenweijian
hilo-user
Commits
8874a8e0
Commit
8874a8e0
authored
Jun 27, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
派对邀请
parent
4771b478
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
12 deletions
+119
-12
invite_apply.go
domain/model/invite_m/invite_apply.go
+22
-0
bizCode.go
myerr/bizerr/bizCode.go
+4
-2
新人派对申请.sql
mysql/新人派对申请.sql
+9
-5
party_invite.go
route/invite_r/party_invite.go
+79
-5
router.go
route/router.go
+5
-0
No files found.
domain/model/invite_m/invite_apply.go
0 → 100644
View file @
8874a8e0
package
invite_m
import
"git.hilo.cn/hilo-common/domain"
type
InviteApply
struct
{
Id
uint64
`json:"id"`
UserId
uint64
`json:"user_id"`
NewUserId
uint64
`json:"new_user_id"`
Platform
string
`json:"platform"`
RechargeInfo
string
`json:"recharge_info"`
Status
uint8
`json:"status"`
// 状态0.未审核1.已通过2.已拒绝
VideoUrl
string
`json:"video_url"`
}
func
CreateInviteApply
(
model
*
domain
.
Model
,
userId
,
newUserId
uint64
,
platform
,
recharge
,
videoUrl
string
)
error
{
err
:=
model
.
DB
()
.
Create
(
InviteApply
{
UserId
:
userId
,
NewUserId
:
newUserId
,
Platform
:
platform
,
RechargeInfo
:
recharge
,
VideoUrl
:
videoUrl
})
.
Error
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"CreateInviteApply err:%v"
,
err
)
return
err
}
return
nil
}
myerr/bizerr/bizCode.go
View file @
8874a8e0
...
...
@@ -26,6 +26,8 @@ var (
// 群组
GroupNotFound
=
myerr
.
NewBusinessCode
(
14001
,
"Group not found"
,
myerr
.
BusinessData
{})
// 找不到该群
CpAlreadyInvite
=
myerr
.
NewBusinessCode
(
50120
,
"Already invited"
,
myerr
.
BusinessData
{})
// 已经发送过邀请了
CpHaveCancelNoDeal
=
myerr
.
NewBusinessCode
(
50121
,
"You have a cancel apply"
,
myerr
.
BusinessData
{})
// 有接触申请需要处理
CpAlreadyInvite
=
myerr
.
NewBusinessCode
(
50120
,
"Already invited"
,
myerr
.
BusinessData
{})
// 已经发送过邀请了
CpHaveCancelNoDeal
=
myerr
.
NewBusinessCode
(
50121
,
"You have a cancel apply"
,
myerr
.
BusinessData
{})
// 有接触申请需要处理
InviteApplyNoPermission
=
myerr
.
NewBusinessCode
(
50122
,
"This user does not have invitation permission"
,
myerr
.
BusinessData
{})
// 该用户没有邀请权限
InviteApplyAlreadyInvited
=
myerr
.
NewBusinessCode
(
50123
,
"Already invited by someone else"
,
myerr
.
BusinessData
{})
// 已经被别人邀请了
)
mysql/新人派对申请.sql
View file @
8874a8e0
...
...
@@ -2,13 +2,16 @@ CREATE TABLE `invite_apply` (
`id`
bigint
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`user_id`
bigint
NOT
NULL
COMMENT
'发起申请者'
,
`new_user_id`
bigint
NOT
NULL
COMMENT
'被邀请的人'
,
`platform`
tinyint
unsigned
NOT
NULL
COMMENT
'从那个平台过来'
,
`status`
tinyint
unsigned
NOT
NULL
COMMENT
'状态1.未接受2.已接受3.拒接导致退费4.过期导致退费'
,
`platform`
varchar
(
20
)
NOT
NULL
COMMENT
'从那个平台过来'
,
`recharge_info`
varchar
(
50
)
NOT
NULL
COMMENT
'新用户在其它平台充值的标志'
,
`status`
tinyint
unsigned
NOT
NULL
COMMENT
'状态0.未审核1.已通过2.已拒绝'
,
`video_url`
varchar
(
400
)
NOT
NULL
COMMENT
'上传的视频url'
,
`created_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`updated_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
,
PRIMARY
KEY
(
`id`
),
KEY
`uid_idx`
(
`user_id`
)
USING
BTREE
,
KEY
`uid2_idx`
(
`invite_user_id`
)
USING
BTREE
,
KEY
`status_idx`
(
`status`
)
USING
BTREE
,
KEY
`user_id`
(
`user_id`
)
USING
BTREE
,
KEY
`new_user_id`
(
`new_user_id`
)
USING
BTREE
,
KEY
`platform`
(
`platform`
)
USING
BTREE
,
KEY
`status`
(
`status`
)
USING
BTREE
,
KEY
`created_time`
(
`created_time`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_0900_ai_ci
COMMENT
=
'新人邀请申请'
;
\ No newline at end of file
route/invite_r/party_invite.go
View file @
8874a8e0
package
invite_r
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"github.com/gin-gonic/gin"
"hilo-user/domain/model/invite_m"
"hilo-user/domain/model/promotion_m"
"hilo-user/domain/model/user_m"
"hilo-user/myerr/bizerr"
"hilo-user/resp"
)
// @Tags 新人
排队申
请
// @Tags 新人
邀
请
// @Summary 提交申请
// @Param externalId formData string true "对方的externalId"
// @Param type formData int true "类型1.撤销2.接受"
// @Param newUserCode formData string true "被邀请人id"
// @Param platform formData string true "平台"
// @Param recharge formData string true "充值金额"
// @Param userCode formData string true "邀请人id"
// @Param videoUrl formData string true "充值金额"
// @Success 200
// @Router /v2/cp/relation/cancel/reply [post]
func
InvitePartyReply
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
// @Router /v2/user/invite/apply [post]
func
InviteApply
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myCtx
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
type
paramStr
struct
{
NewUserCode
string
`form:"newUserCode" binding:"required"`
Platform
string
`form:"platform" binding:"required"`
Recharge
string
`form:"recharge" binding:"required"`
UserCode
string
`form:"userCode" binding:"required"`
VideoUrl
string
`form:"videoUrl" binding:"required"`
}
var
param
paramStr
if
err
:=
c
.
ShouldBind
(
&
param
);
err
!=
nil
{
return
myCtx
,
err
}
model
:=
domain
.
CreateModelContext
(
myCtx
)
// 平台是否填写正确
platforms
:=
promotion_m
.
GetPromotionPlatforms
(
model
)
var
existsPlatform
bool
for
_
,
v
:=
range
platforms
{
if
v
==
param
.
Platform
{
existsPlatform
=
true
}
}
if
!
existsPlatform
{
model
.
Log
.
Errorf
(
"InviteApply param:%v"
,
param
)
return
myCtx
,
bizerr
.
InvalidParameter
}
// code 是否存在
newUser
,
err
:=
user_m
.
GetUserByCode
(
model
,
param
.
NewUserCode
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"InviteApply param:%v"
,
param
)
return
myCtx
,
err
}
user
,
err
:=
user_m
.
GetUserByCode
(
model
,
param
.
UserCode
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"InviteApply param:%v"
,
param
)
return
myCtx
,
err
}
if
newUser
.
ID
==
0
||
user
.
ID
==
0
{
model
.
Log
.
Errorf
(
"InviteApply param:%v"
,
param
)
return
myCtx
,
bizerr
.
InvalidParameter
}
// 邀请人是否有资格邀请
if
!
promotion_m
.
IsPromotionAgent
(
model
,
user
.
ID
)
{
model
.
Log
.
Errorf
(
"InviteApply 没有邀请资格 param:%v"
,
param
)
return
myCtx
,
bizerr
.
InviteApplyNoPermission
}
// 被邀请人是否符合条件
isInvite
,
err
:=
promotion_m
.
IsPromotionInvitee
(
model
,
user
.
ID
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"InviteApply param:%v"
,
param
)
return
myCtx
,
err
}
if
isInvite
{
model
.
Log
.
Errorf
(
"InviteApply 已经被别人邀请了 param:%v"
,
param
)
return
myCtx
,
bizerr
.
InviteApplyAlreadyInvited
}
// 插入邀请表
err
=
invite_m
.
CreateInviteApply
(
model
,
user
.
ID
,
newUser
.
ID
,
param
.
Platform
,
param
.
Recharge
,
param
.
VideoUrl
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"InviteApply param:%v"
,
param
)
return
myCtx
,
err
}
resp
.
ResponseOk
(
c
,
nil
)
return
myCtx
,
nil
}
route/router.go
View file @
8874a8e0
...
...
@@ -12,6 +12,7 @@ import (
"hilo-user/domain/model/msg_m"
"hilo-user/resp"
"hilo-user/route/cp_r"
"hilo-user/route/invite_r"
"hilo-user/route/user_r"
)
...
...
@@ -52,6 +53,10 @@ func InitRouter() *gin.Engine {
//cp.GET("/relation/detail", wrapper(cp_r.CpDetailPage))
cp
.
GET
(
"/im/check"
,
wrapper
(
cp_r
.
CheckCpImExpire
))
}
userV2
:=
v2
.
Group
(
"/user"
)
{
userV2
.
GET
(
"/invite/apply"
,
wrapper
(
invite_r
.
InviteApply
))
}
inner
:=
r
.
Group
(
"/inner"
)
inner
.
Use
(
ExceptionHandle
,
LoggerHandle
)
innerUser
:=
inner
.
Group
(
"/user"
)
...
...
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