Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
base_platform_enterprise
gic-platform-auth
Commits
f30f00d2
Commit
f30f00d2
authored
Nov 13, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
通过token查询登录信息
parent
255485d5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
73 deletions
+7
-73
LoginController.java
...ain/java/com/gic/auth/web/controller/LoginController.java
+7
-73
No files found.
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/LoginController.java
View file @
f30f00d2
...
...
@@ -6,6 +6,7 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
com.gic.enterprise.ano.IgnoreLogin
;
...
...
@@ -147,88 +148,21 @@ public class LoginController {
* @Title: login
* @Description:
* @author guojuxing
* @param enterpriseId
* @param phone
* @param realName
* @param redirectUrl
* @param request
* @param response
* @return com.gic.commons.webapi.reponse.RestResponse
*/
@IgnoreLogin
@RequestMapping
(
"login-for-operation"
)
public
RestResponse
login
(
Integer
enterpriseId
,
String
phone
,
String
realName
,
String
redirectUrl
,
HttpServletResponse
response
)
throws
IOException
{
if
(
StringUtils
.
isBlank
(
redirectUrl
))
{
redirectUrl
=
"https://four.gicdev.com/cost-center/"
;
}
public
RestResponse
login
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
String
redirectUrl
=
request
.
getParameter
(
"redirectUrl"
);
String
token
=
request
.
getParameter
(
"token"
);
response
.
setStatus
(
302
);
if
(
UserContext
.
getContext
().
get
(
).
getUserInfo
()
!=
null
)
{
if
(
UserContext
.
getContext
().
get
ByToken
(
token
).
getUserInfo
()
!=
null
)
{
//已有登录信息
//跳转到页面
//暂时写死跳转到计费中心首页
response
.
setHeader
(
"location"
,
redirectUrl
);
return
RestResponse
.
success
();
}
ServiceResponse
<
OperationUserDTO
>
userResult
=
operationUserApiService
.
getByPhone
(
phone
,
enterpriseId
);
if
(
userResult
.
isSuccess
())
{
//获取运营实施信息
OperationUserDTO
user
=
userResult
.
getResult
();
if
(
user
==
null
)
{
//新建运营实施账号
OperationUserDTO
temp
=
new
OperationUserDTO
();
temp
.
setEnterpriseId
(
enterpriseId
);
temp
.
setPhoneNumber
(
phone
);
temp
.
setOperationUserName
(
realName
);
ServiceResponse
<
Integer
>
saveResult
=
operationUserApiService
.
save
(
temp
);
user
=
temp
;
user
.
setOperationUserId
(
saveResult
.
getResult
());
}
//gic用户信息塞入
UserDetail
userDetail
=
new
UserDetail
();
//设置登录用户信息
userDetail
.
setUserId
(
user
.
getOperationUserId
());
UserInfo
userInfo
=
new
UserInfo
();
userInfo
.
setPhoneNumber
(
phone
);
userInfo
.
setEnterpriseId
(
enterpriseId
);
userInfo
.
setSuperAdmin
(
1
);
userInfo
.
setUserName
(
user
.
getOperationUserName
());
userInfo
.
setUserId
(
user
.
getOperationUserId
());
userDetail
.
setUserInfo
(
userInfo
);
//设置企业资料
ServiceResponse
<
EnterpriseDTO
>
enterprise
=
this
.
enterpriseApiService
.
getEnterpriseById
(
enterpriseId
);
if
(
enterprise
.
isSuccess
())
{
EnterpriseDTO
enterpriseDTO
=
enterprise
.
getResult
();
if
(
enterpriseDTO
!=
null
)
{
userDetail
.
setEnterpriseInfo
(
EntityUtil
.
changeEntityNew
(
EnterpriseInfo
.
class
,
enterpriseDTO
));
}
}
//设置权限
//获取超管的用户ID,用来获取超管权限
ServiceResponse
<
UserDTO
>
adminResult
=
userApiService
.
getUserByEnterpriseId
(
enterpriseId
);
Integer
adminUserId
=
adminResult
.
getResult
().
getUserId
();
ServiceResponse
<
List
<
MenuDTO
>>
menuResult
=
menuApiService
.
listUserMenu
(
adminUserId
);
if
(
menuResult
.
isSuccess
())
{
List
<
MenuDTO
>
menuList
=
menuResult
.
getResult
();
List
<
MenuInfo
>
menuInfoList
=
EntityUtil
.
changeEntityListNew
(
MenuInfo
.
class
,
menuList
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
16
);
Map
<
String
,
MenuInfo
>
moduleMap
=
new
HashMap
<>(
16
);
for
(
MenuInfo
menuDTO
:
menuInfoList
)
{
if
(
StringUtils
.
isBlank
(
menuDTO
.
getMenuUrl
()))
{
continue
;
}
moduleMap
.
put
(
menuDTO
.
getProjectUrlForWeb
()
+
menuDTO
.
getMenuUrl
(),
menuDTO
);
map
.
put
(
menuDTO
.
getMenuUrl
(),
menuDTO
);
}
userDetail
.
setMenuInfoList
(
menuInfoList
);
userDetail
.
setMenuUrlMap
(
map
);
userDetail
.
setModuleUrlMap
(
moduleMap
);
}
//塞缓存
UserDetailUtils
.
setUserDetail
(
userDetail
);
//跳转到页面
//暂时写死跳转到计费中心首页
response
.
setHeader
(
"location"
,
redirectUrl
);
}
return
RestResponse
.
success
();
return
RestResponse
.
failure
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"token错误"
);
}
}
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