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
631597ae
Commit
631597ae
authored
Mar 06, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:先处理国家势力的
parent
d6a0473c
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
315 additions
and
27 deletions
+315
-27
enum.go
_const/enum/group_e/enum.go
+2
-0
user.go
cv/user_cv/user.go
+158
-19
country_mgr.go
domain/model/country_m/country_mgr.go
+40
-0
oauth.go
domain/model/user_m/oauth.go
+35
-0
phone.go
domain/model/user_m/phone.go
+38
-0
welcome_text.go
domain/service/group_s/welcome_text.go
+34
-0
group_op.go
route/group_r/group_op.go
+7
-7
router.go
route/router.go
+1
-1
No files found.
_const/enum/group_e/enum.go
View file @
631597ae
...
@@ -132,3 +132,5 @@ const (
...
@@ -132,3 +132,5 @@ const (
SWITCH_ON
=
1
SWITCH_ON
=
1
SWITH_OFF
=
0
SWITH_OFF
=
0
)
)
var
GROUP_ROLE_VIEW_LIMIT
=
10
cv/user_cv/user.go
View file @
631597ae
This diff is collapsed.
Click to expand it.
domain/model/country_m/country_mgr.go
0 → 100644
View file @
631597ae
package
country_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/_const/enum/country_e"
"hilo-group/myerr"
)
type
CountryMgrUser
struct
{
mysql
.
Entity
Country
string
UserId
mysql
.
ID
Role
country_e
.
CountryMgrRole
}
// 获取国家管理人员
func
GetCountryMgr
(
model
*
domain
.
Model
,
userId
mysql
.
ID
)
(
*
CountryMgrUser
,
error
)
{
cmu
:=
new
(
CountryMgrUser
)
if
err
:=
model
.
Db
.
WithContext
(
model
.
MyContext
.
Context
)
.
Where
(
"user_id = ?"
,
userId
)
.
First
(
&
cmu
)
.
Error
;
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
nil
,
nil
}
else
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
}
return
cmu
,
nil
}
// 更新国家管理人员
func
(
cmu
*
CountryMgrUser
)
UpdateCountryMgr
(
userId
mysql
.
ID
,
role
country_e
.
CountryMgrRole
,
country
string
)
*
CountryMgrUser
{
cmu
.
UserId
,
cmu
.
Role
,
cmu
.
Country
=
userId
,
role
,
country
return
cmu
}
// 删除国家管理人员
func
(
cmu
*
CountryMgrUser
)
DeleteCountryMgr
()
{
cmu
.
SetDel
()
}
domain/model/user_m/oauth.go
0 → 100644
View file @
631597ae
package
user_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/myerr"
)
type
UserOauth
struct
{
UserId
uint64
`json:"user_id"`
ThirdPartyId
string
`json:"third_party_id"`
ThirdPartyType
int8
`json:"third_party_type"`
}
func
(
p
*
UserOauth
)
TableName
()
string
{
return
"user_oauth"
}
func
GetUserOauthByUserId
(
model
*
domain
.
Model
,
userId
uint64
,
thirdType
uint8
)
([]
*
UserOauth
,
error
)
{
res
:=
make
([]
*
UserOauth
,
0
)
db
:=
mysql
.
Db
.
Where
(
&
UserOauth
{
UserId
:
userId
})
if
thirdType
>
0
{
db
=
db
.
Where
(
&
UserOauth
{
ThirdPartyType
:
int8
(
thirdType
)})
}
err
:=
db
.
Find
(
&
res
)
.
Error
if
err
!=
nil
{
if
err
==
gorm
.
ErrRecordNotFound
{
return
nil
,
nil
}
else
{
return
nil
,
myerr
.
WrapErr
(
err
)
}
}
return
res
,
nil
}
domain/model/user_m/phone.go
0 → 100644
View file @
631597ae
package
user_m
import
(
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"time"
)
type
UserBindInfo
struct
{
UserId
uint64
`json:"user_id"`
Phone
string
`json:"phone"`
PhoneCountry
string
`json:"phone_country"`
Pwd
string
`json:"pwd"`
AreaCode
string
`json:"area_code"`
Icon
string
`json:"icon"`
CreateAt
time
.
Time
`json:"create_at"`
UpdateAt
time
.
Time
`json:"update_at"`
}
func
(
p
*
UserBindInfo
)
TableName
()
string
{
return
"user_bind_info"
}
type
UserPhoneInfo
struct
{
Phone
string
`json:"phone"`
PhoneCountry
string
`json:"phoneCountry"`
AreaCode
string
`json:"areaCode"`
Icon
string
`json:"icon"`
}
func
GetUserBindInfoByUserId
(
model
*
domain
.
Model
,
userId
uint64
)
(
*
UserBindInfo
,
error
)
{
res
:=
new
(
UserBindInfo
)
err
:=
mysql
.
Db
.
Where
(
&
UserBindInfo
{
UserId
:
userId
})
.
First
(
&
res
)
.
Error
if
err
!=
nil
{
return
nil
,
err
}
return
res
,
nil
}
domain/service/group_s/welcome_text.go
0 → 100644
View file @
631597ae
package
group_s
import
(
"git.hilo.cn/hilo-common/domain"
"hilo-group/_const/enum/msg_e"
"hilo-group/domain/model/group_m"
"hilo-group/domain/model/res_m"
)
func
(
s
*
GroupService
)
GetWelcomeText
(
groupInfo
*
group_m
.
GroupInfo
)
(
string
,
uint64
,
bool
,
error
)
{
model
:=
domain
.
CreateModelContext
(
s
.
svc
.
MyContext
)
g
:=
group_m
.
GroupWelcomeText
{
GroupId
:
groupInfo
.
ImGroupId
}
gwt
,
err
:=
g
.
Get
(
model
.
Db
)
if
err
!=
nil
{
return
""
,
0
,
false
,
err
}
if
gwt
==
nil
{
// 通过国家推断语言
lang
,
err
:=
res_m
.
GetLangeByCountry
(
model
.
Db
,
groupInfo
.
Country
)
if
err
!=
nil
{
return
""
,
0
,
false
,
err
}
resMul
,
err
:=
res_m
.
GetResMultiTextBy
(
model
.
Db
,
msg_e
.
MSG_ID_GROUP_WELCOME
,
lang
)
if
err
!=
nil
{
return
""
,
0
,
false
,
err
}
return
resMul
.
Content
,
groupInfo
.
Owner
,
true
,
nil
}
else
{
return
gwt
.
Text
,
gwt
.
UserId
,
false
,
nil
}
}
route/group_r/group_op.go
View file @
631597ae
...
@@ -391,7 +391,7 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -391,7 +391,7 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
}
}
model
.
Log
.
Infof
(
"GetGroupDetail, after GetGroupTop3Consume: +%v"
,
result
)
model
.
Log
.
Infof
(
"GetGroupDetail, after GetGroupTop3Consume: +%v"
,
result
)
result
.
WelcomeText
,
_
,
_
,
err
=
myService
.
GetWelcomeText
(
groupInfo
)
result
.
WelcomeText
,
_
,
_
,
err
=
group_s
.
NewGroupService
(
myContext
)
.
GetWelcomeText
(
groupInfo
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
}
}
...
@@ -488,7 +488,7 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -488,7 +488,7 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, err
return myContext, err
}
}
*/
*/
superManagerMap
,
err
:=
cv
.
GetSuperManagerMap
(
userIds
)
superManagerMap
,
err
:=
user_m
.
GetSuperManagerMap
(
userIds
)
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
}
}
...
@@ -497,8 +497,8 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -497,8 +497,8 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
for
u
,
_
:=
range
users
{
for
u
,
_
:=
range
users
{
m
:=
users
[
u
]
m
:=
users
[
u
]
result
.
RoleMembers
=
append
(
result
.
RoleMembers
,
cv
.
RoleMemberInfo
{
result
.
RoleMembers
=
append
(
result
.
RoleMembers
,
group_
cv
.
RoleMemberInfo
{
CvUserBase
:
cv
.
CvUserBase
{
CvUserBase
:
user_
cv
.
CvUserBase
{
Avatar
:
&
m
.
Avatar
,
Avatar
:
&
m
.
Avatar
,
ExternalId
:
&
m
.
ExternalId
,
ExternalId
:
&
m
.
ExternalId
,
Nick
:
&
m
.
Nick
,
Nick
:
&
m
.
Nick
,
...
@@ -530,20 +530,20 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -530,20 +530,20 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
})
})
// 截取前N个
// 截取前N个
endPos
:=
common
.
GROUP_ROLE_VIEW_LIMIT
endPos
:=
group_e
.
GROUP_ROLE_VIEW_LIMIT
if
endPos
>
len
(
result
.
RoleMembers
)
{
if
endPos
>
len
(
result
.
RoleMembers
)
{
endPos
=
len
(
result
.
RoleMembers
)
endPos
=
len
(
result
.
RoleMembers
)
}
}
result
.
RoleMembers
=
result
.
RoleMembers
[
0
:
endPos
]
result
.
RoleMembers
=
result
.
RoleMembers
[
0
:
endPos
]
// todo: 直接用全量接口,只为方便
// todo: 直接用全量接口,只为方便
supportLevels
,
err
:=
myService
.
GetWeekMaxSupportLevelMap
()
supportLevels
,
err
:=
group_s
.
NewGroupService
(
myContext
)
.
GetWeekMaxSupportLevelMap
()
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
}
}
result
.
SupportLevel
=
supportLevels
[
groupId
]
result
.
SupportLevel
=
supportLevels
[
groupId
]
ResponseOk
(
c
,
result
)
resp
.
ResponseOk
(
c
,
result
)
return
myContext
,
nil
return
myContext
,
nil
}
}
route/router.go
View file @
631597ae
...
@@ -25,7 +25,7 @@ func InitRouter() *gin.Engine {
...
@@ -25,7 +25,7 @@ func InitRouter() *gin.Engine {
imGroup
.
POST
(
"/group"
,
wrapper
(
group_r
.
CreateGroup
))
imGroup
.
POST
(
"/group"
,
wrapper
(
group_r
.
CreateGroup
))
imGroup
.
DELETE
(
"/group/:groupId"
,
wrapper
(
group_r
.
DestroyGroup
))
imGroup
.
DELETE
(
"/group/:groupId"
,
wrapper
(
group_r
.
DestroyGroup
))
imGroup
.
GET
(
"/group/:code"
,
wrapper
(
group_r
.
GetGroupInfo
))
imGroup
.
GET
(
"/group/:code"
,
wrapper
(
group_r
.
GetGroupInfo
))
imGroup
.
GET
(
"/detail/:groupId"
,
wrapper
(
GetGroupDetail
))
imGroup
.
GET
(
"/detail/:groupId"
,
wrapper
(
group_r
.
GetGroupDetail
))
//imGroup.PUT("/group/:groupId", wrapper(ModifyGroupInfo))
//imGroup.PUT("/group/:groupId", wrapper(ModifyGroupInfo))
//imGroup.GET("/search/:code", wrapper(SearchGroup))
//imGroup.GET("/search/:code", wrapper(SearchGroup))
//imGroup.DELETE("/member/:groupId", wrapper(LeaveGroup))
//imGroup.DELETE("/member/:groupId", wrapper(LeaveGroup))
...
...
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