Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chuanshan_gov_platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
廖旭伟
chuanshan_gov_platform
Commits
8e7955e7
Commit
8e7955e7
authored
Mar 07, 2024
by
廖旭伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改登录bug
parent
a2325080
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
63 deletions
+69
-63
single-matter/src/main/java/com/mortals/xhx/base/login/web/LoginController.java
.../java/com/mortals/xhx/base/login/web/LoginController.java
+69
-63
No files found.
single-matter/src/main/java/com/mortals/xhx/base/login/web/LoginController.java
View file @
8e7955e7
...
@@ -19,6 +19,8 @@ import com.mortals.xhx.base.system.user.model.UserEntity;
...
@@ -19,6 +19,8 @@ import com.mortals.xhx.base.system.user.model.UserEntity;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.base.system.valid.service.ValidCodeService
;
import
com.mortals.xhx.base.system.valid.service.ValidCodeService
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.pdu.user.UserPdu
;
import
com.mortals.xhx.feign.user.IUserFeign
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -48,8 +50,8 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
...
@@ -48,8 +50,8 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
@Autowired
@Autowired
private
ICacheService
cacheService
;
private
ICacheService
cacheService
;
//
@Autowired
@Autowired
//
private IUserFeign userFeign;
private
IUserFeign
userFeign
;
private
static
Log
logger
=
LogFactory
.
getLog
(
LoginController
.
class
);
private
static
Log
logger
=
LogFactory
.
getLog
(
LoginController
.
class
);
...
@@ -57,76 +59,80 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
...
@@ -57,76 +59,80 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
public
String
login
(
@RequestBody
LoginForm
loginForm
)
throws
Exception
{
public
String
login
(
@RequestBody
LoginForm
loginForm
)
throws
Exception
{
String
loginName
=
loginForm
.
getLoginName
();
String
password
=
loginForm
.
getPassword
();
UserPdu
userPdu
=
new
UserPdu
();
userPdu
.
setLoginName
(
loginName
);
userPdu
.
setPassword
(
password
);
String
resp
=
userFeign
.
portalLogin
(
userPdu
);
return
resp
;
// JSONObject ret = new JSONObject();
// String loginName = loginForm.getLoginName();
// String loginName = loginForm.getLoginName();
// String password = loginForm.getPassword();
// String password = loginForm.getPassword();
// //String securityCode = loginForm.getSecurityCode();
// String ip = super.getRequestIP(request);
// if (StringUtils.isEmpty(loginName) || StringUtils.isEmpty(password)) {
// ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
// ret.put(KEY_RESULT_MSG, "未获取到用户信息,请重新登录");
// return ret.toJSONString();
// }
// UserEntity userEntity = null;
// try {
// loginForm.validate();
//
//
// UserPdu userPdu = new UserPdu();
// userEntity = userService.doLogin(loginName, password, ip);
// userPdu.setLoginName(loginName);
// userEntity.setLastLoginAddress(ip);
// userPdu.setPassword(password);
// //saveCurrUser(request, response, userEntity);
// String resp = userFeign.portalLogin(userPdu);
// recordSysLog(request, userEntity, "用户登录系统成功!");
// // 返回拥有的菜单数据
// Set<String> urls = resourceService.findUrlSetByUserId(userEntity.getId());
// List<MenuEntity> outlookBarList = menuService.findTreeMenu(userEntity, urls);
// String currUserName = userEntity.getRealName();
// if (currUserName == null || currUserName.trim().length() == 0) {
// currUserName = "管理员";
// }
// userEntity.setLoginTime(System.currentTimeMillis());
// userEntity.setToken(IdUtil.fastSimpleUUID());
// userEntity.setExpireTime(DateUtils.addCurrDate(7).getTime());
// String token = authTokenService.createToken(userEntity);
// JSONObject data = new JSONObject();
// data.put("token", token);
// data.put("currUserName", currUserName);
// data.put("barList", outlookBarList);
// data.put("id", userEntity.getId());
// data.put("userType", userEntity.getUserType());
//
//
// return resp;
// //this.generateBlackCookie(request, response, loginName, urls);
// ret.put(KEY_RESULT_DATA, data);
// ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
JSONObject
ret
=
new
JSONObject
();
// ret.put(KEY_RESULT_MSG, "用户登录系统成功!");
String
loginName
=
loginForm
.
getLoginName
();
// ret.put("resources", urls);
String
password
=
loginForm
.
getPassword
();
//
//String securityCode = loginForm.getSecurityCode();
// return ret.toJSONString();
String
ip
=
super
.
getRequestIP
(
request
);
// } catch (Exception e) {
if
(
StringUtils
.
isEmpty
(
loginName
)
||
StringUtils
.
isEmpty
(
password
))
{
// log.error("login error ", e);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
// if (userEntity == null) {
ret
.
put
(
KEY_RESULT_MSG
,
"未获取到用户信息,请重新登录"
);
// userEntity = new UserEntity();
return
ret
.
toJSONString
();
// userEntity.setLoginName(loginName);
}
// }
UserEntity
userEntity
=
null
;
// ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
try
{
// ret.put(KEY_RESULT_MSG, super.convertException(e));
loginForm
.
validate
();
// return ret.toJSONString();
// }
userEntity
=
userService
.
doLogin
(
loginName
,
password
,
ip
);
userEntity
.
setLastLoginAddress
(
ip
);
//saveCurrUser(request, response, userEntity);
recordSysLog
(
request
,
userEntity
,
"用户登录系统成功!"
);
// 返回拥有的菜单数据
Set
<
String
>
urls
=
resourceService
.
findUrlSetByUserId
(
userEntity
.
getId
());
List
<
MenuEntity
>
outlookBarList
=
menuService
.
findTreeMenu
(
userEntity
,
urls
);
String
currUserName
=
userEntity
.
getRealName
();
if
(
currUserName
==
null
||
currUserName
.
trim
().
length
()
==
0
)
{
currUserName
=
"管理员"
;
}
userEntity
.
setLoginTime
(
System
.
currentTimeMillis
());
userEntity
.
setToken
(
IdUtil
.
fastSimpleUUID
());
userEntity
.
setExpireTime
(
DateUtils
.
addCurrDate
(
7
).
getTime
());
String
token
=
authTokenService
.
createToken
(
userEntity
);
JSONObject
data
=
new
JSONObject
();
data
.
put
(
"token"
,
token
);
data
.
put
(
"currUserName"
,
currUserName
);
data
.
put
(
"barList"
,
outlookBarList
);
data
.
put
(
"id"
,
userEntity
.
getId
());
data
.
put
(
"userType"
,
userEntity
.
getUserType
());
//this.generateBlackCookie(request, response, loginName, urls);
ret
.
put
(
KEY_RESULT_DATA
,
data
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
ret
.
put
(
KEY_RESULT_MSG
,
"用户登录系统成功!"
);
ret
.
put
(
"resources"
,
urls
);
return
ret
.
toJSONString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"login error "
,
e
);
if
(
userEntity
==
null
)
{
userEntity
=
new
UserEntity
();
userEntity
.
setLoginName
(
loginName
);
}
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
return
ret
.
toJSONString
();
}
}
}
@RequestMapping
(
"logout"
)
@RequestMapping
(
"logout"
)
public
void
logout
()
throws
Exception
{
public
String
logout
()
throws
Exception
{
recordSysLog
(
request
,
"退出登录"
);
recordSysLog
(
request
,
"退出登录"
);
super
.
removeCurrUser
(
request
);
super
.
removeCurrUser
(
request
);
JSONObject
ret
=
new
JSONObject
();
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
ret
.
put
(
KEY_RESULT_MSG
,
"用户退出系统成功!"
);
return
ret
.
toJSONString
();
}
}
@RequestMapping
(
"index"
)
@RequestMapping
(
"index"
)
...
...
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