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
328264a4
Commit
328264a4
authored
Mar 06, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
家族迁移
parent
631597ae
Changes
16
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1899 additions
and
34 deletions
+1899
-34
msg.go
_const/enum/msg_e/msg.go
+133
-0
groupPower.go
cv/group_power_cv/groupPower.go
+641
-0
group_power.go
cv/group_power_cv/group_power.go
+0
-31
user.go
cv/user_cv/user.go
+136
-2
groupPowerJoin.go
domain/event/group_power_ev/groupPowerJoin.go
+29
-0
groupPowerLeave.go
domain/event/group_power_ev/groupPowerLeave.go
+29
-0
msg.go
domain/model/msg_m/msg.go
+54
-0
repo.go
domain/model/msg_m/repo.go
+13
-0
event_init.go
domain/service/event_s/event_init.go
+73
-0
group_power.go
domain/service/group_power_s/group_power.go
+68
-0
go.mod
go.mod
+2
-0
go.sum
go.sum
+12
-0
main.go
main.go
+2
-1
bizCode.go
myerr/bizerr/bizCode.go
+1
-0
group_power.go
route/group_power_r/group_power.go
+694
-0
router.go
route/router.go
+12
-0
No files found.
_const/enum/msg_e/msg.go
View file @
328264a4
package
msg_e
package
msg_e
import
"git.hilo.cn/hilo-common/resource/mysql"
type
MsgIdType
=
uint
type
MsgIdType
=
uint
const
(
const
(
...
@@ -17,3 +19,134 @@ const (
...
@@ -17,3 +19,134 @@ const (
MSG_ID_USER_TRANSFER
MsgIdType
=
114
MSG_ID_USER_TRANSFER
MsgIdType
=
114
MSG_ID_NO_POWER_TO_SVIP6
MsgIdType
=
115
// 不能对svip6做某些动作
MSG_ID_NO_POWER_TO_SVIP6
MsgIdType
=
115
// 不能对svip6做某些动作
)
)
//消息发送类型,消息接收者是谁 1:通知 2:官网 3:被喜欢通知 (注意:MsgReceiveType 同 MsgUserRecordType 不是树形关系s)
//MsgReceive 结构体服务
type
MsgReceiveType
=
mysql
.
Type
const
(
//小助手的通知
UserMsgReceiveType
MsgReceiveType
=
1
//系统的通知
SysMsgReceiveType
MsgReceiveType
=
2
//喜欢消息
LikeMeReceiveType
MsgReceiveType
=
3
//工会用户通知
TradeUnionReceiveType
MsgReceiveType
=
4
//用户召回
UserRecall
MsgReceiveType
=
5
//video请求
VideoSend
MsgReceiveType
=
6
//访问
VisitReceiveType
MsgReceiveType
=
7
//拉黑
BlockReceiveType
MsgReceiveType
=
8
//短信验证码
SmsCode
MsgReceiveType
=
9
)
//跳转类型 0:无调整 1:网页跳转 2:app跳转 3:跳转到钻石 4:跳转到背包
type
ActionType
=
uint16
const
(
NonActionType
ActionType
=
0
WebActionType
ActionType
=
1
AppActionType
ActionType
=
2
)
//消息记录类型(设计的不好,应该是根据消息样式类型设计,而不是业务类型,渣渣)
type
MsgUserRecordType
=
mysql
.
Type
const
(
//新用户
//NewUserType MsgUserRecordType = 1
//举报
ReportType
MsgUserRecordType
=
2
//喜欢我
//LikeMeType MsgUserRecordType = 3
//重置图片
ResetAvatarType
MsgUserRecordType
=
4
//
//喜欢我
LikeMeType
MsgUserRecordType
=
5
//访问
VisitType
MsgUserRecordType
=
6
//新匹配记录
MatchHistoryType
MsgUserRecordType
=
7
//互相喜欢
LikeEachType
MsgUserRecordType
=
8
//你获得s%钻石的礼物收益!
DiamondIncome
MsgUserRecordType
=
9
//榜单结果
ActivityBillboardResult
MsgUserRecordType
=
10
//榜单钻石收益
ActivityBillboardDiamond
MsgUserRecordType
=
11
//榜单坐骑收益
ActivityBillboardProperty
MsgUserRecordType
=
12
//通过收礼物获得豆子
ActivityBeanProperty
MsgUserRecordType
=
13
//管理人送钻石
MgrSendDiamondProperty
MsgUserRecordType
=
14
//群组榜单钻石收益
ActivityGroupBillboardDiamond
MsgUserRecordType
=
15
//群组榜单坐骑收益
ActivityGroupBillboardProperty
MsgUserRecordType
=
16
//群组支持收益
GroupSupport
MsgUserRecordType
=
17
//群组支持提醒结果
GroupSupportResult
MsgUserRecordType
=
18
//管理人送座驾
MgrSendProperty
MsgUserRecordType
=
19
//送道具(座驾,头饰都属于道具)
AddProps
MsgUserRecordType
=
20
//MISS活动获胜
ActivityBillboardBeLikeResult
=
21
//CP活动获胜
ActivityBillboardCpResult
=
22
//加入势力主
GroupPowerUserJoin
=
23
//离开势力主
GroupPowerUserLeave
=
24
//贵族
AddNoble
=
25
//日充值活动通知
ActivityTriggerDayPay
=
26
//也门活动通知
ActivityTriggerYemen
=
27
//月充值活动通知
ActivityTriggerMonthPay
=
28
FruitTycoonAward
=
29
// 水果大亨获奖
LuckyboxRecycle
=
30
//幸运盒子回收
HlTemp1
=
31
//产品黄蕾,2022/06/29 临时要求发给某人的小助手消息
HLTemp2
=
32
//问卷调查
NewUserInviteAuditPassed
=
33
// 新用户奖励活动审核通过
NewUserInviteAuditFailed
=
34
// 新用户奖励活动审核不通过
NewUserInviterAward
=
35
// 新用户奖励活动邀请成功数达标
PowerSupportSalary
=
36
// 势力扶持工资领取 提醒
CountryStarOrdinaryAward
=
37
// 国家之星瓜分奖提醒
GroupActivityRewardMsg
=
38
// 群组活动钻石奖励提醒
TemplateActAwardMsg
=
39
// 通用模板活动奖励提醒
TemplateSmsCode
=
40
// 通用模板活动奖励提醒
NewUserRegisterPush1
=
44
// 首次充值免费获得永久充值勋章!累积充值$50可申请特殊ID:ABBABB!
NewUserRegisterPush2
=
45
// 邀请朋友来Hilo,最高获得100,000钻石奖励!
NewUserRegisterPush3
=
46
// 举办首个活动,领取10,000钻石和35%奖杯奖励!
ActFruitPutRankAward
=
47
// 水果机投入排行榜提醒领奖
)
type
MsgSysUserType
=
mysql
.
Type
const
(
//系统消息
SysType
MsgSysUserType
=
1
//小助手消息
AssistantType
MsgSysUserType
=
2
)
//resMsgTransalte 中 msg_type 同 type, msg_type是属于一级类型 type属于二级类型。 msg_type 对应MsgReceiveType type:部分对应MsgUserRecordType MsgUserRecordType(应该是小助手的类型)
type
MsgSysRecordType
=
mysql
.
Type
const
(
//这个值木有意义,
SysMsgSysRecordType1
MsgSysRecordType
=
1
SysMsgSysRecordType2
MsgSysRecordType
=
2
)
cv/group_power_cv/groupPower.go
0 → 100644
View file @
328264a4
This diff is collapsed.
Click to expand it.
cv/group_power_cv/group_power.go
deleted
100644 → 0
View file @
631597ae
package
group_power_cv
import
(
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/domain/model/groupPower_m"
)
func
BatchGetGroupPower
(
db
*
gorm
.
DB
,
userIds
[]
uint64
)
(
map
[
uint64
]
uint64
,
map
[
uint64
]
string
,
error
)
{
if
len
(
userIds
)
<=
0
{
return
nil
,
nil
,
nil
}
groupPowers
,
err
:=
groupPower_m
.
GetGroupPowerMap
(
db
,
userIds
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
gpIds
:=
make
([]
uint64
,
0
)
for
_
,
i
:=
range
groupPowers
{
gpIds
=
append
(
gpIds
,
i
)
}
powerNames
,
err
:=
groupPower_m
.
GetGroupPowerNames
(
db
,
gpIds
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
groupPowerNames
:=
make
(
map
[
mysql
.
ID
]
string
,
0
)
for
i
,
g
:=
range
groupPowers
{
groupPowerNames
[
i
]
=
powerNames
[
g
]
}
return
groupPowers
,
groupPowerNames
,
nil
}
cv/user_cv/user.go
View file @
328264a4
...
@@ -2,6 +2,7 @@ package user_cv
...
@@ -2,6 +2,7 @@ package user_cv
import
(
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/rpc"
"git.hilo.cn/hilo-common/rpc"
.
"git.hilo.cn/hilo-common/utils"
.
"git.hilo.cn/hilo-common/utils"
...
@@ -183,7 +184,7 @@ func GetUserTinyBy(user user_m.User) CvUserTiny {
...
@@ -183,7 +184,7 @@ func GetUserTinyBy(user user_m.User) CvUserTiny {
}
}
func
GetUserDetailMap
(
userIds
[]
mysql
.
ID
,
myUserId
mysql
.
ID
)
(
map
[
mysql
.
ID
]
*
CvUserDetail
,
error
)
{
func
GetUserDetailMap
(
userIds
[]
mysql
.
ID
,
myUserId
mysql
.
ID
)
(
map
[
mysql
.
ID
]
*
CvUserDetail
,
error
)
{
cvUserDetails
,
err
:=
g
etUserDetailByIds
(
userIds
,
myUserId
)
cvUserDetails
,
err
:=
G
etUserDetailByIds
(
userIds
,
myUserId
)
if
err
!=
nil
{
if
err
!=
nil
{
return
map
[
mysql
.
ID
]
*
CvUserDetail
{},
err
return
map
[
mysql
.
ID
]
*
CvUserDetail
{},
err
}
}
...
@@ -195,7 +196,7 @@ func GetUserDetailMap(userIds []mysql.ID, myUserId mysql.ID) (map[mysql.ID]*CvUs
...
@@ -195,7 +196,7 @@ func GetUserDetailMap(userIds []mysql.ID, myUserId mysql.ID) (map[mysql.ID]*CvUs
return
mapIdUser
,
nil
return
mapIdUser
,
nil
}
}
func
g
etUserDetailByIds
(
userIds
[]
mysql
.
ID
,
myUserId
mysql
.
ID
)
([]
*
CvUserDetail
,
error
)
{
func
G
etUserDetailByIds
(
userIds
[]
mysql
.
ID
,
myUserId
mysql
.
ID
)
([]
*
CvUserDetail
,
error
)
{
if
len
(
userIds
)
==
0
{
if
len
(
userIds
)
==
0
{
return
nil
,
nil
return
nil
,
nil
}
}
...
@@ -899,3 +900,136 @@ func userToDetailOne(model *domain.Model, user *user_m.User, myUserId mysql.ID,
...
@@ -899,3 +900,136 @@ func userToDetailOne(model *domain.Model, user *user_m.User, myUserId mysql.ID,
return
cvUserDetail
,
nil
return
cvUserDetail
,
nil
}
}
func
GetUserBaseMap
(
userIds
[]
mysql
.
ID
,
myUserId
mysql
.
ID
)
(
map
[
mysql
.
ID
]
*
CvUserBase
,
error
)
{
userBases
,
err
:=
GetUserBases
(
userIds
,
myUserId
)
if
err
!=
nil
{
return
nil
,
err
}
//转换成map
mapIdUser
:=
map
[
mysql
.
ID
]
*
CvUserBase
{}
for
i
:=
0
;
i
<
len
(
userBases
);
i
++
{
mapIdUser
[
*
userBases
[
i
]
.
Id
]
=
userBases
[
i
]
}
return
mapIdUser
,
nil
}
//批量获取用户基本信息
func
GetUserBases
(
userIds
[]
mysql
.
ID
,
myUserId
mysql
.
ID
)
([]
*
CvUserBase
,
error
)
{
if
len
(
userIds
)
==
0
{
return
[]
*
CvUserBase
{},
nil
}
var
users
[]
user_m
.
User
if
err
:=
mysql
.
Db
.
Model
(
&
user_m
.
User
{})
.
Where
(
"id in (?)"
,
userIds
)
.
Find
(
&
users
)
.
Error
;
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
vips
,
err
:=
user_m
.
BatchGetVips
(
userIds
)
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
svips
,
err
:=
rpc
.
MGetUserSvip
(
domain
.
CreateModelNil
(),
userIds
)
if
err
!=
nil
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
headwearMap
,
err
:=
headwear_cv
.
BatchGetCvHeadwears
(
userIds
)
if
err
!=
nil
{
return
nil
,
err
}
logger
:=
mylogrus
.
MyLog
.
WithField
(
"func"
,
"GetUserBases"
)
medals
,
err
:=
user_m
.
BatchGetUserMedalMerge
(
logger
,
mysql
.
Db
,
userIds
)
if
err
!=
nil
{
return
nil
,
err
}
medals
,
medalInfo
,
err
:=
medal_cv
.
GetMedalInfoMap
(
mysql
.
Db
,
medals
)
if
err
!=
nil
{
return
nil
,
err
}
up
:=
user_m
.
UserProperty
{}
rides
,
err
:=
up
.
BatchGet
(
mysql
.
Db
,
userIds
)
if
err
!=
nil
{
return
nil
,
err
}
//rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db)
properties
,
err
:=
property_cv
.
GetPropertyAll
(
mysql
.
Db
)
if
err
!=
nil
{
return
nil
,
err
}
nobles
,
err
:=
noble_m
.
BatchGetActiveNoble
(
mysql
.
Db
,
userIds
)
if
err
!=
nil
{
return
nil
,
err
}
superManagerMap
,
err
:=
user_m
.
GetSuperManagerMap
(
userIds
)
if
err
!=
nil
{
return
nil
,
err
}
cvUserBases
:=
[]
*
CvUserBase
{}
for
i
:=
0
;
i
<
len
(
users
);
i
++
{
user
:=
users
[
i
]
invisible
:=
IfLogout
(
user
.
LogoutTime
)
invisibleAvatar
:=
""
invisibleNick
:=
user
.
Code
//for _, p := range svips[user.ID].Privileges {
// if p.Type == 17 && p.UserSwitch { // 神秘人特权
// invisible = true
// invisibleAvatar, invisibleNick = rpc.ReplaceSvipAvatarNick(invisibleAvatar, invisibleNick, svips[user.ID].Privileges)
// }
//}
cvUserBase
:=
&
CvUserBase
{
Id
:
&
user
.
ID
,
Avatar
:
StrNil
(
IfLogoutStr
(
invisible
,
invisibleAvatar
,
user
.
Avatar
)),
DefaultAvatar
:
&
user
.
DefaultAvatar
,
ExternalId
:
StrToString
(
&
user
.
ExternalId
),
Nick
:
StrNil
(
IfLogoutNick
(
invisible
,
invisibleNick
,
user
.
Nick
)),
Description
:
StrNil
(
IfLogoutStr
(
invisible
,
""
,
user
.
Description
)),
Sex
:
TypeToUint8
(
&
user
.
Sex
),
Country
:
StrNil
(
user
.
Country
),
CountryIcon
:
StrNil
(
user
.
CountryIcon
),
Code
:
StrToString
(
&
user
.
Code
),
IsPrettyCode
:
user
.
IsPrettyCode
(),
IsVip
:
vips
[
user
.
ID
]
!=
nil
,
IsOfficialStaff
:
superManagerMap
[
user
.
ID
],
Medals
:
IfLogoutMedals
(
invisible
,
[]
uint32
{},
medals
[
user
.
ID
]),
MedalInfo
:
IfLogoutMedalInfo
(
invisible
,
[]
medal_cv
.
CvMedal
{},
medalInfo
[
user
.
ID
]),
Ride
:
IfLogoutRide
(
IfLogout
(
user
.
LogoutTime
),
property_cv
.
CvProperty
{},
property_cv
.
CvProperty
{
Id
:
rides
[
user
.
ID
],
PicUrl
:
properties
[
rides
[
user
.
ID
]]
.
PicUrl
,
EffectUrl
:
properties
[
rides
[
user
.
ID
]]
.
EffectUrl
,
Using
:
true
,
SenderAvatar
:
properties
[
rides
[
user
.
ID
]]
.
SenderAvatar
,
ReceiverAvatar
:
properties
[
rides
[
user
.
ID
]]
.
ReceiverAvatar
,
}),
Noble
:
noble_cv
.
CvNoble
{
Level
:
nobles
[
user
.
ID
]
.
Level
,
EndTime
:
nobles
[
user
.
ID
]
.
EndTime
.
Unix
(),
},
}
if
cvUserBase
.
Noble
.
Level
<=
0
{
cvUserBase
.
Noble
.
EndTime
=
0
}
//
if
headwear
,
flag
:=
headwearMap
[
user
.
ID
];
flag
{
cvUserBase
.
Headwear
=
IfLogoutHeadwear
(
IfLogout
(
user
.
LogoutTime
),
nil
,
&
headwear
)
}
if
user
.
ID
==
myUserId
{
cvUserBase
.
VipExpireTime
=
vips
[
user
.
ID
]
cvUserBase
.
IsShowAge
=
TypeToUint8
(
&
user
.
IsShowAge
)
cvUserBase
.
Birthday
=
BirthdayToUint64
(
&
user
.
Birthday
)
}
else
if
user
.
IsShowAge
==
mysql
.
OPEN
{
cvUserBase
.
Birthday
=
BirthdayToUint64
(
&
user
.
Birthday
)
}
cvUserBase
.
Svip
=
svips
[
user
.
ID
]
cvUserBases
=
append
(
cvUserBases
,
cvUserBase
)
}
return
cvUserBases
,
nil
}
domain/event/group_power_ev/groupPowerJoin.go
0 → 100644
View file @
328264a4
package
group_power_ev
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
)
//注册监听
var
groupPowerJoinListen
=
new
(
domain
.
EventBase
)
type
GroupPowerJoinEvent
struct
{
UserId
mysql
.
ID
GroupPowerId
mysql
.
ID
}
//添加领域事件,在每个领域模型中init中添加,因为这是静态业务,非动态的。
func
AddGroupPowerJoinSync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventSync
(
groupPowerJoinListen
,
callback
)
}
//加入到异步操作中
func
AddGroupPowerJoinAsync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventAsync
(
groupPowerJoinListen
,
callback
)
}
//领域事件发布
func
PublishGroupPowerJoin
(
model
*
domain
.
Model
,
event
interface
{})
error
{
return
domain
.
PublishEvent
(
groupPowerJoinListen
,
model
,
event
)
}
domain/event/group_power_ev/groupPowerLeave.go
0 → 100644
View file @
328264a4
package
group_power_ev
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
)
type
GroupPowerLeaveEvent
struct
{
UserId
mysql
.
ID
GroupPowerId
mysql
.
ID
}
//注册监听
var
groupPowerLeaveListen
=
new
(
domain
.
EventBase
)
//添加领域事件,在每个领域模型中init中添加,因为这是静态业务,非动态的。
func
AddGroupPowerLeaveSync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventSync
(
groupPowerLeaveListen
,
callback
)
}
//加入到异步操作中
func
AddGroupPowerLeaveAsync
(
callback
func
(
model
*
domain
.
Model
,
event
interface
{})
error
)
{
domain
.
AddEventAsync
(
groupPowerLeaveListen
,
callback
)
}
//领域事件发布
func
PublishGroupPowerLeave
(
model
*
domain
.
Model
,
event
interface
{})
error
{
return
domain
.
PublishEvent
(
groupPowerLeaveListen
,
model
,
event
)
}
domain/model/msg_m/msg.go
0 → 100644
View file @
328264a4
package
msg_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/sdk/emas"
"git.hilo.cn/hilo-common/utils"
"hilo-group/_const/enum/msg_e"
)
type
MsgUserRecord
struct
{
mysql
.
Entity
*
domain
.
Model
`gorm:"-"`
UserId
mysql
.
ID
Type
msg_e
.
MsgUserRecordType
Nick
mysql
.
Str
NickUserId
mysql
.
ID
//用户的别名
DiamondIncome
mysql
.
Str
DayNum
mysql
.
Str
//多少天
PropertyUrl
mysql
.
Str
//道具地址
BeanNum
mysql
.
Str
//多少豆子
GroupCode
mysql
.
Str
//群组code
}
type
MsgReceive
struct
{
Type
msg_e
.
MsgReceiveType
`json:"type"`
}
func
NewUserRecord
(
model
*
domain
.
Model
,
userId
mysql
.
ID
,
t
msg_e
.
MsgUserRecordType
,
nick
mysql
.
Str
,
nickUserId
mysql
.
ID
,
diamondIncome
mysql
.
Str
,
dayNum
mysql
.
Str
,
propertyUrl
mysql
.
Str
,
beanNum
mysql
.
Str
,
groupCode
mysql
.
Str
)
*
MsgUserRecord
{
return
&
MsgUserRecord
{
Model
:
model
,
UserId
:
userId
,
Type
:
t
,
Nick
:
nick
,
NickUserId
:
nickUserId
,
DiamondIncome
:
diamondIncome
,
DayNum
:
dayNum
,
PropertyUrl
:
propertyUrl
,
BeanNum
:
beanNum
,
GroupCode
:
groupCode
,
}
}
//发给小助手的消息, 不需要抛出错误
func
SendEmasMsgAssistant
(
model
*
domain
.
Model
,
externalId
string
,
deviceType
string
)
error
{
str
,
_
:=
utils
.
ToString
(
MsgReceive
{
Type
:
msg_e
.
UserMsgReceiveType
,
})
err
:=
emas
.
SendMsg
(
externalId
,
deviceType
,
str
)
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"emas.SendMsg err:%v"
,
err
)
}
return
nil
}
domain/model/msg_m/repo.go
0 → 100644
View file @
328264a4
package
msg_m
import
(
"hilo-group/domain/model"
"hilo-group/myerr"
)
func
(
msgUserRecord
*
MsgUserRecord
)
Persistent
()
error
{
if
err
:=
model
.
Persistent
(
msgUserRecord
.
Db
,
msgUserRecord
);
err
!=
nil
{
return
myerr
.
WrapErr
(
err
)
}
return
nil
}
domain/service/event_s/event_init.go
0 → 100644
View file @
328264a4
package
event_s
import
(
"git.hilo.cn/hilo-common/domain"
"hilo-group/_const/enum/msg_e"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/msg_m"
"hilo-group/domain/model/user_m"
)
func
EventInit
()
{
GroupPowerEvents
()
}
func
GroupPowerEvents
()
{
//加入势力
group_power_ev
.
AddGroupPowerJoinAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
event
,
ok
:=
e
.
(
*
group_power_ev
.
GroupPowerJoinEvent
)
if
!
ok
{
model
.
Log
.
Errorf
(
"AddGroupPowerJoinAsync event type err"
)
return
nil
}
model
.
Log
.
Infof
(
"msg AddGroupPowerJoinAsync UserId:%v, GroupPowerId:%v"
,
event
.
UserId
,
event
.
GroupPowerId
)
//获取势力主
mgrUserId
,
err
:=
groupPower_m
.
GetGroupPowerMgr
(
model
,
event
.
GroupPowerId
)
if
err
!=
nil
{
return
err
}
mgrUser
,
err
:=
user_m
.
GetUser
(
model
,
mgrUserId
)
if
err
!=
nil
{
return
err
}
joinUser
,
err
:=
user_m
.
GetUser
(
model
,
event
.
UserId
)
if
err
!=
nil
{
return
err
}
if
err
:=
msg_m
.
NewUserRecord
(
model
,
mgrUser
.
ID
,
msg_e
.
GroupPowerUserJoin
,
joinUser
.
Nick
,
joinUser
.
ID
,
""
,
""
,
""
,
""
,
""
)
.
Persistent
();
err
!=
nil
{
model
.
Log
.
Errorf
(
"msg AddGroupPowerJoinAsync NewUserRecord err:%v"
,
err
)
return
nil
}
msg_m
.
SendEmasMsgAssistant
(
model
,
mgrUser
.
ExternalId
,
mgrUser
.
DeviceType
)
return
nil
})
//离开势力
group_power_ev
.
AddGroupPowerLeaveAsync
(
func
(
model
*
domain
.
Model
,
e
interface
{})
error
{
event
,
ok
:=
e
.
(
*
group_power_ev
.
GroupPowerLeaveEvent
)
if
!
ok
{
model
.
Log
.
Errorf
(
"AddGroupPowerLeaveAsync event type err"
)
return
nil
}
model
.
Log
.
Infof
(
"msg AddGroupPowerLeaveAsync UserId:%v, GroupPowerId:%v"
,
event
.
UserId
,
event
.
GroupPowerId
)
//获取势力主
mgrUserId
,
err
:=
groupPower_m
.
GetGroupPowerMgr
(
model
,
event
.
GroupPowerId
)
if
err
!=
nil
{
return
err
}
mgrUser
,
err
:=
user_m
.
GetUser
(
model
,
mgrUserId
)
if
err
!=
nil
{
return
err
}
joinUser
,
err
:=
user_m
.
GetUser
(
model
,
event
.
UserId
)
if
err
!=
nil
{
return
err
}
if
err
:=
msg_m
.
NewUserRecord
(
model
,
mgrUser
.
ID
,
msg_e
.
GroupPowerUserLeave
,
joinUser
.
Nick
,
joinUser
.
ID
,
""
,
""
,
""
,
""
,
""
)
.
Persistent
();
err
!=
nil
{
model
.
Log
.
Errorf
(
"msg AddGroupPowerLeaveAsync NewUserRecord err:%v"
,
err
)
return
nil
}
msg_m
.
SendEmasMsgAssistant
(
model
,
mgrUser
.
ExternalId
,
mgrUser
.
DeviceType
)
return
nil
})
}
domain/service/group_power_s/group_power.go
0 → 100644
View file @
328264a4
package
group_power_s
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/resource/mysql"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/model/groupPower_m"
)
type
GroupPowerService
struct
{
svc
*
domain
.
Service
}
func
NewGroupPowerService
(
myContext
*
mycontext
.
MyContext
)
*
GroupPowerService
{
svc
:=
domain
.
CreateService
(
myContext
)
return
&
GroupPowerService
{
svc
}
}
//用户加入国家势力
func
(
s
*
GroupPowerService
)
GroupPowerUserJoin
(
groupPowerId
mysql
.
ID
,
userId
mysql
.
ID
)
error
{
return
s
.
svc
.
Transactional
(
func
()
error
{
model
:=
domain
.
CreateModelContext
(
s
.
svc
.
MyContext
)
groupPower
,
err
:=
groupPower_m
.
GetGroupPower
(
model
,
groupPowerId
)
if
err
!=
nil
{
return
err
}
groupPowerUser
,
err
:=
groupPower
.
UserJoin
(
userId
)
if
err
!=
nil
{
return
err
}
if
err
:=
groupPowerUser
.
Persistent
();
err
!=
nil
{
return
err
}
return
group_power_ev
.
PublishGroupPowerJoin
(
model
,
&
group_power_ev
.
GroupPowerJoinEvent
{
UserId
:
userId
,
GroupPowerId
:
groupPowerId
,
})
})
}
//用户退出国家势力
func
(
s
*
GroupPowerService
)
GroupPowerUserLeave
(
groupPowerId
mysql
.
ID
,
userId
mysql
.
ID
)
(
int
,
error
)
{
remainSeconds
:=
0
err
:=
s
.
svc
.
Transactional
(
func
()
error
{
model
:=
domain
.
CreateModelContext
(
s
.
svc
.
MyContext
)
groupPower
,
err
:=
groupPower_m
.
GetGroupPower
(
model
,
groupPowerId
)
if
err
!=
nil
{
return
err
}
groupPowerUser
,
timeDiff
,
err
:=
groupPower
.
UserLeave
(
userId
)
if
err
!=
nil
{
if
timeDiff
>
0
{
remainSeconds
=
int
(
timeDiff
.
Seconds
())
return
err
}
return
err
}
if
err
:=
groupPowerUser
.
Persistent
();
err
!=
nil
{
return
err
}
return
group_power_ev
.
PublishGroupPowerLeave
(
model
,
&
group_power_ev
.
GroupPowerLeaveEvent
{
UserId
:
userId
,
GroupPowerId
:
groupPowerId
,
})
})
return
remainSeconds
,
err
}
go.mod
View file @
328264a4
...
@@ -11,6 +11,7 @@ require (
...
@@ -11,6 +11,7 @@ require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1274 // indirect
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/bluele/gcache v0.0.2 // indirect
github.com/bluele/gcache v0.0.2 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
...
@@ -40,6 +41,7 @@ require (
...
@@ -40,6 +41,7 @@ require (
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect
github.com/joho/godotenv v1.3.0 // indirect
github.com/joho/godotenv v1.3.0 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
github.com/leodido/go-urn v1.2.0 // indirect
...
...
go.sum
View file @
328264a4
...
@@ -13,6 +13,8 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV
...
@@ -13,6 +13,8 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1274 h1:u48e7I7h/BY5uDP8xiIFNaUkdTVk7hjj/Sucg8FrxNU=
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1274/go.mod h1:9CMdKNL3ynIGPpfTcdwTvIm8SGuAZYYC4jFVSSvE1YQ=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I=
...
@@ -90,6 +92,7 @@ github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC
...
@@ -90,6 +92,7 @@ github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
...
@@ -115,6 +118,7 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
...
@@ -115,6 +118,7 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/consul/api v1.7.0 h1:tGs8Oep67r8CcA2Ycmb/8BLBcJ70St44mF2X10a/qPg=
github.com/hashicorp/consul/api v1.7.0 h1:tGs8Oep67r8CcA2Ycmb/8BLBcJ70St44mF2X10a/qPg=
github.com/hashicorp/consul/api v1.7.0/go.mod h1:1NSuaUUkFaJzMasbfq/11wKYWSR67Xn6r2DXKhuDNFg=
github.com/hashicorp/consul/api v1.7.0/go.mod h1:1NSuaUUkFaJzMasbfq/11wKYWSR67Xn6r2DXKhuDNFg=
...
@@ -151,12 +155,15 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
...
@@ -151,12 +155,15 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
...
@@ -222,6 +229,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
...
@@ -222,6 +229,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
...
@@ -316,6 +325,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
...
@@ -316,6 +325,7 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190606050223-4d9ae51c2468/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b h1:/mJ+GKieZA6hFDQGdWZrjj4AXPl5ylY+5HusG80roy0=
golang.org/x/tools v0.0.0-20190611222205-d73e1c7e250b h1:/mJ+GKieZA6hFDQGdWZrjj4AXPl5ylY+5HusG80roy0=
...
@@ -358,6 +368,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
...
@@ -358,6 +368,7 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
gopkg.in/go-playground/validator.v8 v8.18.2/go.mod h1:RX2a/7Ha8BgOhfk7j780h4/u/RRjR0eouCJSH80/M2Y=
gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c=
gopkg.in/ini.v1 v1.63.2 h1:tGK/CyBg7SMzb60vP1M03vNZ3VDu3wGQJwn7Sxi9r3c=
gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.63.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
...
@@ -368,6 +379,7 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
...
@@ -368,6 +379,7 @@ gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gorm.io/driver/mysql v1.4.3 h1:/JhWJhO2v17d8hjApTltKNADm7K7YI2ogkR7avJUL3k=
gorm.io/driver/mysql v1.4.3 h1:/JhWJhO2v17d8hjApTltKNADm7K7YI2ogkR7avJUL3k=
gorm.io/driver/mysql v1.4.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
gorm.io/driver/mysql v1.4.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE=
gorm.io/gorm v1.23.8 h1:h8sGJ+biDgBA1AD1Ha9gFCx7h8npU7AsLdlkX0n2TpE=
...
...
main.go
View file @
328264a4
...
@@ -3,6 +3,7 @@ package main
...
@@ -3,6 +3,7 @@ package main
import
(
import
(
"fmt"
"fmt"
"git.hilo.cn/hilo-common/resource/consul"
"git.hilo.cn/hilo-common/resource/consul"
"hilo-group/domain/service/event_s"
"hilo-group/route"
"hilo-group/route"
)
)
...
@@ -14,7 +15,7 @@ const (
...
@@ -14,7 +15,7 @@ const (
func
main
()
{
func
main
()
{
//cron.Init() // 开启定时任务
//cron.Init() // 开启定时任务
//event_s.EventInit()
// 注册事件(内部事件+mysql拟kafka)
event_s
.
EventInit
()
// 注册事件(内部事件+mysql拟kafka)
r
:=
route
.
InitRouter
()
// 注册路由
r
:=
route
.
InitRouter
()
// 注册路由
consul
.
RegisterToConsul
(
PORT
,
RegisterName
,
RegisterTag
)
// 服务注册
consul
.
RegisterToConsul
(
PORT
,
RegisterName
,
RegisterTag
)
// 服务注册
r
.
Run
(
fmt
.
Sprintf
(
":%d"
,
PORT
))
// 启动服务
r
.
Run
(
fmt
.
Sprintf
(
":%d"
,
PORT
))
// 启动服务
...
...
myerr/bizerr/bizCode.go
View file @
328264a4
...
@@ -49,6 +49,7 @@ var (
...
@@ -49,6 +49,7 @@ var (
GroupPowerHasJoinOther
=
myerr
.
NewBusinessCode
(
15001
,
"You already have joined power, please exit first"
,
myerr
.
BusinessData
{})
// 已经加入了其它国家势力
GroupPowerHasJoinOther
=
myerr
.
NewBusinessCode
(
15001
,
"You already have joined power, please exit first"
,
myerr
.
BusinessData
{})
// 已经加入了其它国家势力
GroupPowerHasJoinMy
=
myerr
.
NewBusinessCode
(
15002
,
"You already have joined power, please exit first"
,
myerr
.
BusinessData
{})
// 已经加入了该国家势力
GroupPowerHasJoinMy
=
myerr
.
NewBusinessCode
(
15002
,
"You already have joined power, please exit first"
,
myerr
.
BusinessData
{})
// 已经加入了该国家势力
GroupPowerOwnerLeave
=
myerr
.
NewBusinessCode
(
15003
,
"power owner cannot exit"
,
myerr
.
BusinessData
{})
// 势力主不能退出
GroupPowerOwnerLeave
=
myerr
.
NewBusinessCode
(
15003
,
"power owner cannot exit"
,
myerr
.
BusinessData
{})
// 势力主不能退出
GroupPowerNotExist
=
myerr
.
NewBusinessCode
(
15004
,
"国家势力不存在"
,
myerr
.
BusinessData
{})
// 国家势力不存在
GroupPowerNoOwner
=
myerr
.
NewBusinessCode
(
15005
,
"power owner not exits or unique"
,
myerr
.
BusinessData
{})
// 国家势力主不存在或不唯一
GroupPowerNoOwner
=
myerr
.
NewBusinessCode
(
15005
,
"power owner not exits or unique"
,
myerr
.
BusinessData
{})
// 国家势力主不存在或不唯一
GroupPowerStayTooShort
=
myerr
.
NewBusinessCode
(
15006
,
"You joined this power not more than 10 days ago"
,
myerr
.
BusinessData
{})
// 加入国家势力不超过10天
GroupPowerStayTooShort
=
myerr
.
NewBusinessCode
(
15006
,
"You joined this power not more than 10 days ago"
,
myerr
.
BusinessData
{})
// 加入国家势力不超过10天
...
...
route/group_power_r/group_power.go
0 → 100644
View file @
328264a4
This diff is collapsed.
Click to expand it.
route/router.go
View file @
328264a4
...
@@ -5,6 +5,7 @@ import (
...
@@ -5,6 +5,7 @@ import (
ginSwagger
"github.com/swaggo/gin-swagger"
ginSwagger
"github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
"github.com/swaggo/gin-swagger/swaggerFiles"
_
"hilo-group/docs"
_
"hilo-group/docs"
"hilo-group/route/group_power_r"
"hilo-group/route/group_r"
"hilo-group/route/group_r"
)
)
...
@@ -110,5 +111,16 @@ func InitRouter() *gin.Engine {
...
@@ -110,5 +111,16 @@ func InitRouter() *gin.Engine {
//imGroup.GET("/medal/all", wrapper(GroupMedalAll))
//imGroup.GET("/medal/all", wrapper(GroupMedalAll))
//imGroup.GET("/medal/room", wrapper(GetRoomMedal))
//imGroup.GET("/medal/room", wrapper(GetRoomMedal))
}
}
groupPower
:=
v1
.
Group
(
"/groupPower"
)
{
groupPower
.
POST
(
"/user"
,
wrapper
(
group_power_r
.
GroupPowerJoin
))
groupPower
.
DELETE
(
"/user/:groupPowerId"
,
wrapper
(
group_power_r
.
GroupPowerLeave
))
groupPower
.
GET
(
"/title/:groupPowerId"
,
wrapper
(
group_power_r
.
GetGroupPowerTitle
))
groupPower
.
GET
(
"/group/:groupPowerId"
,
wrapper
(
group_power_r
.
GetGroupPowerGroups
))
groupPower
.
GET
(
"/team"
,
wrapper
(
group_power_r
.
GroupPowerTeam
))
groupPower
.
GET
(
"/billboard/week"
,
wrapper
(
group_power_r
.
GroupPowerBillboardWeek
))
groupPower
.
GET
(
"/billboard/owner/week"
,
wrapper
(
group_power_r
.
GroupPowerBillboardOwnerWeek
))
}
return
r
return
r
}
}
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