切换导航条
此项目
正在载入...
登录
allied-creation
/
performance
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxvhui
2 years ago
提交
8f1fd5f0b4b1a59f700b816179c7a4e9b2f196cb
1 个父辈
e4426e1b
更新获取个人信息
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
99 行增加
和
3 行删除
pkg/application/auth/adapter/me_info.go
pkg/application/auth/command/me_info.go
pkg/application/auth/service/auth.go
pkg/port/beego/controllers/auth_controller.go
pkg/application/auth/adapter/me_info.go
0 → 100644
查看文件 @
8f1fd5f
package
adapter
type
MeInfo
struct
{
UserId
int64
`json:"userId"`
//用户名称
CompanyId
int64
`json:"companyId"`
//公司id
CompanyName
string
`json:"companyName"`
//公司名称
Phone
string
`json:"phone"`
// 手机号
Name
string
`json:"name"`
// 员工名称
IsHrbp
bool
`json:"isHrbp"`
//是否 是hrbp
IsParent
bool
`json:"isParent"`
//是否 是上级
}
...
...
pkg/application/auth/command/me_info.go
0 → 100644
查看文件 @
8f1fd5f
package
command
type
GetMeInfo
struct
{
UserId
int64
`json:"-"`
CompanyId
int64
`json:"-"`
}
...
...
pkg/application/auth/service/auth.go
查看文件 @
8f1fd5f
...
...
@@ -2,6 +2,7 @@ package service
import
(
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/adapter"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/auth/command"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
...
...
@@ -156,3 +157,76 @@ func (service *AuthService) MobileLogin(param *command.MobileLoginCommand) (map[
}
return
result
,
nil
}
// 获取我的
func
(
service
*
AuthService
)
MeInfo
(
param
*
command
.
GetMeInfo
)
(
*
adapter
.
MeInfo
,
error
)
{
transactionContext
,
err
:=
factory
.
CreateTransactionContext
(
nil
)
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
if
errStart
:=
transactionContext
.
StartTransaction
();
errStart
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
errStart
.
Error
())
}
defer
func
()
{
_
=
transactionContext
.
RollbackTransaction
()
}()
userRepository
:=
factory
.
CreateUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
companyRepository
:=
factory
.
CreateCompanyRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
roleRepo
:=
factory
.
CreateRoleRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
roleUserRepo
:=
factory
.
CreateRoleUserRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
userData
,
err
:=
userRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
param
.
UserId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取员工数据"
+
err
.
Error
())
}
_
,
parentUser
,
err
:=
userRepository
.
Find
(
map
[
string
]
interface
{}{
"parentId"
:
userData
.
Id
,
"limit"
:
1
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取员工数据"
+
err
.
Error
())
}
companyData
,
err
:=
companyRepository
.
FindOne
(
map
[
string
]
interface
{}{
"id"
:
param
.
CompanyId
,
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取公司数据"
+
err
.
Error
())
}
_
,
roleList
,
err
:=
roleRepo
.
Find
(
map
[
string
]
interface
{}{
"type"
:
domain
.
RoleTypeSystem
,
"companyId"
:
param
.
CompanyId
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取角色信息列表"
+
err
.
Error
())
}
_
,
userRoleList
,
err
:=
roleUserRepo
.
Find
(
map
[
string
]
interface
{}{
"companyId"
:
param
.
CompanyId
,
"userId"
:
param
.
UserId
})
if
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
INTERNAL_SERVER_ERROR
,
"获取用户的角色信息列表"
+
err
.
Error
())
}
// 拥有HRBP权限
isHrbp
:=
false
loop
:
for
_
,
v
:=
range
userRoleList
{
for
_
,
v2
:=
range
roleList
{
if
v
.
RoleId
==
v2
.
Id
{
isHrbp
=
true
break
loop
}
}
}
if
err
:=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
application
.
ThrowError
(
application
.
TRANSACTION_ERROR
,
err
.
Error
())
}
info
:=
adapter
.
MeInfo
{
UserId
:
userData
.
Id
,
CompanyId
:
companyData
.
Id
,
CompanyName
:
companyData
.
Name
,
Phone
:
userData
.
Account
,
Name
:
userData
.
Name
,
IsHrbp
:
isHrbp
,
IsParent
:
false
,
}
if
len
(
parentUser
)
>
0
{
info
.
IsParent
=
true
}
return
&
info
,
nil
}
...
...
pkg/port/beego/controllers/auth_controller.go
查看文件 @
8f1fd5f
...
...
@@ -20,11 +20,16 @@ func (controller *AuthController) Login() {
controller
.
Response
(
resp
,
err
)
}
// 获取个人信息
func
(
controller
*
AuthController
)
User
()
{
userAuth
:=
controller
.
Ctx
.
Input
.
GetData
(
domain
.
UserAuth
{})
.
(
*
domain
.
UserAuth
)
controller
.
Response
(
map
[
string
]
interface
{}{
"user"
:
userAuth
,
},
nil
)
authService
:=
&
service
.
AuthService
{}
param
:=
&
command
.
GetMeInfo
{
UserId
:
userAuth
.
UserId
,
CompanyId
:
userAuth
.
CompanyId
,
}
resp
,
err
:=
authService
.
MeInfo
(
param
)
controller
.
Response
(
resp
,
err
)
}
// Login 手机端登录
...
...
请
注册
或
登录
后发表评论