Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-manage3.0
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
haoban3.0
haoban-manage3.0
Commits
e13759a1
Commit
e13759a1
authored
Jan 14, 2022
by
墨竹
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:bug修改
parent
6452dad1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
41 deletions
+45
-41
AuthRequestUtil.java
.../java/com/gic/haoban/manage/web/auth/AuthRequestUtil.java
+21
-16
WebBaseController.java
...m/gic/haoban/manage/web/controller/WebBaseController.java
+24
-25
No files found.
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/auth/AuthRequestUtil.java
View file @
e13759a1
package
com
.
gic
.
haoban
.
manage
.
web
.
auth
;
package
com
.
gic
.
haoban
.
manage
.
web
.
auth
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.manage.api.dto.LoginDTO
;
import
com.gic.redis.data.util.RedisUtil
;
import
com.gic.redis.data.util.RedisUtil
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -21,6 +23,7 @@ import java.util.concurrent.TimeUnit;
...
@@ -21,6 +23,7 @@ import java.util.concurrent.TimeUnit;
*
*
* @author hua
* @author hua
*/
*/
@Deprecated
public
class
AuthRequestUtil
{
public
class
AuthRequestUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AuthRequestUtil
.
class
);
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AuthRequestUtil
.
class
);
...
@@ -33,7 +36,7 @@ public class AuthRequestUtil {
...
@@ -33,7 +36,7 @@ public class AuthRequestUtil {
String
userJson
=
JSON
.
toJSONString
(
obj
);
String
userJson
=
JSON
.
toJSONString
(
obj
);
getSession
().
setAttribute
(
LOGIN_SESSION_KEY
,
userJson
);
getSession
().
setAttribute
(
LOGIN_SESSION_KEY
,
userJson
);
}
}
public
static
void
delSessionUser
()
{
public
static
void
delSessionUser
()
{
getSession
().
removeAttribute
(
LOGIN_SESSION_KEY
);
getSession
().
removeAttribute
(
LOGIN_SESSION_KEY
);
}
}
...
@@ -43,8 +46,8 @@ public class AuthRequestUtil {
...
@@ -43,8 +46,8 @@ public class AuthRequestUtil {
if
(
StringUtils
.
isBlank
(
token
))
{
if
(
StringUtils
.
isBlank
(
token
))
{
return
null
;
return
null
;
}
}
Object
cache
=
RedisUtil
.
getCache
(
token
);
//为了做兼容
return
cache
;
return
EntityUtil
.
changeEntityByJSON
(
LoginDTO
.
class
,
RedisUtil
.
getCache
(
token
))
;
}
}
private
static
void
setLoginUserLastToken
(
String
token
,
Object
obj
)
{
private
static
void
setLoginUserLastToken
(
String
token
,
Object
obj
)
{
...
@@ -104,16 +107,18 @@ public class AuthRequestUtil {
...
@@ -104,16 +107,18 @@ public class AuthRequestUtil {
RedisUtil
.
delCache
(
token
);
RedisUtil
.
delCache
(
token
);
}
}
public
static
void
setAppLoginUser
(
Object
obj
,
String
token
)
{
public
static
void
setAppLoginUser
(
Object
obj
,
String
token
)
{
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
getResponse
().
setHeader
(
"token"
,
token
);
//setLoginUserLastToken(token, obj);
//setLoginUserLastToken(token, obj);
}
}
public
static
void
setAppFakeLoginUser
(
Object
obj
)
{
public
static
void
setAppFakeLoginUser
(
Object
obj
)
{
String
token
=
getRequest
().
getHeader
(
"token"
);
String
token
=
getRequest
().
getHeader
(
"token"
);
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
RedisUtil
.
setCache
(
token
,
obj
,
30L
,
TimeUnit
.
DAYS
);
getResponse
().
setHeader
(
"token"
,
token
);
getResponse
().
setHeader
(
"token"
,
token
);
}
}
public
static
HttpSession
getSession
()
{
public
static
HttpSession
getSession
()
{
HttpSession
session
=
null
;
HttpSession
session
=
null
;
try
{
try
{
...
@@ -135,16 +140,16 @@ public class AuthRequestUtil {
...
@@ -135,16 +140,16 @@ public class AuthRequestUtil {
return
attrs
.
getResponse
();
return
attrs
.
getResponse
();
}
}
public
static
Object
getLoginUser
()
{
public
static
Object
getLoginUser
()
{
Cookie
[]
cookies
=
AuthRequestUtil
.
getRequest
().
getCookies
();
Cookie
[]
cookies
=
AuthRequestUtil
.
getRequest
().
getCookies
();
String
token
=
""
;
String
token
=
""
;
if
(
cookies
!=
null
)
{
if
(
cookies
!=
null
)
{
for
(
Cookie
cookie
:
cookies
)
{
for
(
Cookie
cookie
:
cookies
)
{
if
(
cookie
.
getName
().
equals
(
"token"
))
{
if
(
cookie
.
getName
().
equals
(
"token"
))
{
token
=
cookie
.
getValue
();
token
=
cookie
.
getValue
();
}
}
}
}
}
}
return
getAppLoginUser
(
token
);
return
getAppLoginUser
(
token
);
}
}
}
}
haoban-manage3-web/src/main/java/com/gic/haoban/manage/web/controller/WebBaseController.java
View file @
e13759a1
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
package
com
.
gic
.
haoban
.
manage
.
web
.
controller
;
import
com.gic.haoban.auth.api.dto.DisplayRelationShortInfoDTO
;
import
com.gic.haoban.auth.api.dto.DisplayRelationShortInfoDTO
;
import
com.gic.haoban.common.utils.AuthWebRequestUtil
;
import
com.gic.haoban.common.utils.EntityUtil
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.common.utils.HaobanResponse
;
import
com.gic.haoban.manage.api.dto.LoginDTO
;
import
com.gic.haoban.manage.api.dto.LoginDTO
;
import
com.gic.haoban.manage.web.auth.AuthRequestUtil
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
com.gic.haoban.manage.web.errCode.HaoBanErrCode
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
...
@@ -35,14 +36,14 @@ public class WebBaseController {
...
@@ -35,14 +36,14 @@ public class WebBaseController {
public
HaobanResponse
resultResponse
(
HaoBanErrCode
errCode
)
{
public
HaobanResponse
resultResponse
(
HaoBanErrCode
errCode
)
{
return
resultResponse
(
errCode
,
null
,
null
);
return
resultResponse
(
errCode
,
null
,
null
);
}
}
public
HaobanResponse
resultResponse
(
HaoBanErrCode
errCode
,
String
message
,
Object
data
,
String
detailError
)
{
public
HaobanResponse
resultResponse
(
HaoBanErrCode
errCode
,
String
message
,
Object
data
,
String
detailError
)
{
HaobanResponse
response
=
new
HaobanResponse
();
HaobanResponse
response
=
new
HaobanResponse
();
response
.
setMessage
(
message
);
response
.
setMessage
(
message
);
response
.
setDetailError
(
detailError
);
response
.
setDetailError
(
detailError
);
response
.
setErrorCode
(
errCode
.
getCode
());
response
.
setErrorCode
(
errCode
.
getCode
());
return
response
;
return
response
;
}
}
/**
/**
* 获取登陆信息
* 获取登陆信息
...
@@ -50,31 +51,29 @@ public class WebBaseController {
...
@@ -50,31 +51,29 @@ public class WebBaseController {
* @return
* @return
*/
*/
protected
LoginDTO
getLoginUser
()
{
protected
LoginDTO
getLoginUser
()
{
LoginDTO
login
=
(
LoginDTO
)
AuthRequestUtil
.
getLoginUser
();
//为了做兼容
return
login
;
Object
loginUser
=
AuthWebRequestUtil
.
getLoginUser
();
return
EntityUtil
.
changeEntityByJSON
(
LoginDTO
.
class
,
loginUser
);
}
}
public
boolean
haveRight
(
List
<
DisplayRelationShortInfoDTO
>
list
){
public
boolean
haveRight
(
List
<
DisplayRelationShortInfoDTO
>
list
)
{
List
<
String
>
groupList
=
new
ArrayList
<
String
>();
List
<
String
>
groupList
=
new
ArrayList
<
String
>();
List
<
String
>
storeList
=
new
ArrayList
<
String
>();
List
<
String
>
storeList
=
new
ArrayList
<
String
>();
List
<
String
>
clerkList
=
new
ArrayList
<
String
>();
List
<
String
>
clerkList
=
new
ArrayList
<
String
>();
if
(
list
==
null
){
if
(
list
==
null
)
{
return
false
;
return
false
;
}
for
(
DisplayRelationShortInfoDTO
showDto
:
list
){
if
(
showDto
.
getGroupId
()!=
null
){
groupList
.
add
(
showDto
.
getGroupId
());
}
if
(
showDto
.
getStoreId
()!=
null
){
storeList
.
add
(
showDto
.
getStoreId
());
}
if
(
showDto
.
getClerkId
()!=
null
){
clerkList
.
add
(
showDto
.
getClerkId
());
}
}
}
if
(
CollectionUtils
.
isEmpty
(
groupList
)
&&
CollectionUtils
.
isEmpty
(
storeList
)
&&
CollectionUtils
.
isEmpty
(
clerkList
)){
for
(
DisplayRelationShortInfoDTO
showDto
:
list
)
{
return
false
;
if
(
showDto
.
getGroupId
()
!=
null
)
{
groupList
.
add
(
showDto
.
getGroupId
());
}
if
(
showDto
.
getStoreId
()
!=
null
)
{
storeList
.
add
(
showDto
.
getStoreId
());
}
if
(
showDto
.
getClerkId
()
!=
null
)
{
clerkList
.
add
(
showDto
.
getClerkId
());
}
}
}
return
true
;
return
!
CollectionUtils
.
isEmpty
(
groupList
)
||
!
CollectionUtils
.
isEmpty
(
storeList
)
||
!
CollectionUtils
.
isEmpty
(
clerkList
)
;
}
}
}
}
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