Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
smart_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
赵啸非
smart_gov_platform
Commits
8bca6289
Commit
8bca6289
authored
Nov 21, 2023
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加资源自动刷新获取
parent
fc59ef0b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
18 deletions
+42
-18
portal-manager/src/main/java/com/mortals/xhx/base/login/web/LoginController.java
.../java/com/mortals/xhx/base/login/web/LoginController.java
+33
-16
portal-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
...ase/system/resource/service/impl/ResourceServiceImpl.java
+9
-2
No files found.
portal-manager/src/main/java/com/mortals/xhx/base/login/web/LoginController.java
View file @
8bca6289
...
@@ -6,14 +6,18 @@ import com.alibaba.fastjson.JSONArray;
...
@@ -6,14 +6,18 @@ import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.service.IUser
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.DateUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.framework.web.BaseCRUDJsonBodyMappingController
;
import
com.mortals.xhx.base.system.resource.service.ResourceService
;
import
com.mortals.xhx.base.system.valid.service.ValidCodeService
;
import
com.mortals.xhx.base.system.valid.service.ValidCodeService
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.pdu.SitePdu
;
import
com.mortals.xhx.common.pdu.SitePdu
;
import
com.mortals.xhx.common.utils.LoginAESUtil
;
import
com.mortals.xhx.common.utils.LoginAESUtil
;
import
com.mortals.xhx.common.utils.MenuEncodeUtil
;
import
com.mortals.xhx.feign.model.IApiModelFeign
;
import
com.mortals.xhx.feign.model.IApiModelFeign
;
import
com.mortals.xhx.feign.rsp.ApiResp
;
import
com.mortals.xhx.feign.rsp.ApiResp
;
import
com.mortals.xhx.module.menu.model.MenuEntity
;
import
com.mortals.xhx.module.menu.model.MenuEntity
;
...
@@ -22,6 +26,7 @@ import com.mortals.xhx.module.user.model.UserEntity;
...
@@ -22,6 +26,7 @@ import com.mortals.xhx.module.user.model.UserEntity;
import
com.mortals.xhx.module.user.service.UserService
;
import
com.mortals.xhx.module.user.service.UserService
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -43,9 +48,13 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
...
@@ -43,9 +48,13 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
private
IApiModelFeign
apiModelFeign
;
private
IApiModelFeign
apiModelFeign
;
@Autowired
@Autowired
private
ValidCodeService
validCodeService
;
private
ValidCodeService
validCodeService
;
@Autowired
private
ICacheService
cacheService
;
@Autowired
private
ResourceService
resourceService
;
private
static
final
String
AES_KEY
=
"0000000671595991"
;
private
static
final
String
AES_KEY
=
"0000000671595991"
;
private
static
final
String
AES_IV
=
"tdrdadq59tbss5n7"
;
private
static
final
String
AES_IV
=
"tdrdadq59tbss5n7"
;
@RequestMapping
(
"login"
)
@RequestMapping
(
"login"
)
public
String
login
(
@RequestBody
LoginForm
loginForm
)
throws
Exception
{
public
String
login
(
@RequestBody
LoginForm
loginForm
)
throws
Exception
{
...
@@ -59,15 +68,15 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
...
@@ -59,15 +68,15 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
ret
.
put
(
KEY_RESULT_MSG
,
"未获取到用户信息,请重新登录"
);
ret
.
put
(
KEY_RESULT_MSG
,
"未获取到用户信息,请重新登录"
);
return
ret
.
toJSONString
();
return
ret
.
toJSONString
();
}
}
if
(
loginForm
.
getType
()!=
null
&&
loginForm
.
getType
()==
2
)
{
if
(
loginForm
.
getType
()
!=
null
&&
loginForm
.
getType
()
==
2
)
{
loginName
=
LoginAESUtil
.
decrypt
(
loginName
,
AES_KEY
,
AES_IV
,
LoginAESUtil
.
AES_CBC
);
loginName
=
LoginAESUtil
.
decrypt
(
loginName
,
AES_KEY
,
AES_IV
,
LoginAESUtil
.
AES_CBC
);
password
=
LoginAESUtil
.
decrypt
(
password
,
AES_KEY
,
AES_IV
,
LoginAESUtil
.
AES_CBC
);
password
=
LoginAESUtil
.
decrypt
(
password
,
AES_KEY
,
AES_IV
,
LoginAESUtil
.
AES_CBC
);
}
}
UserEntity
userEntity
=
null
;
UserEntity
userEntity
=
null
;
try
{
try
{
loginForm
.
validate
();
loginForm
.
validate
();
boolean
validCode
=
validCodeService
.
doCheckImageValidCode
(
loginForm
.
getMark
(),
super
.
getRequestIP
(
request
),
loginForm
.
getSecurityCode
());
boolean
validCode
=
validCodeService
.
doCheckImageValidCode
(
loginForm
.
getMark
(),
super
.
getRequestIP
(
request
),
loginForm
.
getSecurityCode
());
if
(!
validCode
)
{
if
(!
validCode
)
{
throw
new
AppException
(
"验证码错误"
);
throw
new
AppException
(
"验证码错误"
);
}
}
userEntity
=
userService
.
userdoLogin
(
loginName
,
password
,
ip
);
userEntity
=
userService
.
userdoLogin
(
loginName
,
password
,
ip
);
...
@@ -82,15 +91,23 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
...
@@ -82,15 +91,23 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
List
<
MenuEntity
>
menuList
=
menuService
.
findTreeMenuByUser
(
userEntity
);
List
<
MenuEntity
>
menuList
=
menuService
.
findTreeMenuByUser
(
userEntity
);
userEntity
.
setMenuList
(
menuList
);
userEntity
.
setMenuList
(
menuList
);
data
.
put
(
"user"
,
userEntity
);
data
.
put
(
"user"
,
userEntity
);
if
(
userEntity
.
getId
()==
1
&&
StringUtils
.
isEmpty
(
userEntity
.
getAreaCodes
())){
Set
<
String
>
urls
=
new
HashSet
<>();
String
menuUrl
=
cacheService
.
hget
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userEntity
.
getId
().
toString
(),
String
.
class
);
if
(
ObjectUtils
.
isEmpty
(
menuUrl
))
{
urls
=
resourceService
.
findUrlSetByUserId
(
userEntity
.
getId
());
menuUrl
=
MenuEncodeUtil
.
generateMenuUrlCode
(
urls
);
cacheService
.
hset
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userEntity
.
getId
().
toString
(),
menuUrl
);
}
data
.
put
(
"urls"
,
urls
);
if
(
userEntity
.
getId
()
==
1
&&
StringUtils
.
isEmpty
(
userEntity
.
getAreaCodes
()))
{
JSONArray
siteList
=
new
JSONArray
();
JSONArray
siteList
=
new
JSONArray
();
JSONObject
siteObject
=
new
JSONObject
();
JSONObject
siteObject
=
new
JSONObject
();
siteObject
.
put
(
"id"
,
0
);
siteObject
.
put
(
"id"
,
0
);
siteObject
.
put
(
"siteName"
,
"无站点"
);
siteObject
.
put
(
"siteName"
,
"无站点"
);
siteList
.
add
(
siteObject
);
siteList
.
add
(
siteObject
);
data
.
put
(
"siteList"
,
siteList
);
data
.
put
(
"siteList"
,
siteList
);
}
else
{
}
else
{
if
(
StringUtils
.
isNotEmpty
(
userEntity
.
getAreaCodes
()))
{
if
(
StringUtils
.
isNotEmpty
(
userEntity
.
getAreaCodes
()))
{
SitePdu
sitePdu
=
new
SitePdu
();
SitePdu
sitePdu
=
new
SitePdu
();
List
<
String
>
areaCodeList
=
Arrays
.
asList
(
userEntity
.
getAreaCodes
().
split
(
","
));
List
<
String
>
areaCodeList
=
Arrays
.
asList
(
userEntity
.
getAreaCodes
().
split
(
","
));
sitePdu
.
setAreaCodeList
(
areaCodeList
);
sitePdu
.
setAreaCodeList
(
areaCodeList
);
...
@@ -99,12 +116,12 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
...
@@ -99,12 +116,12 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
if
(
apiResp
.
getCode
()
!=
YesNoEnum
.
YES
.
getValue
())
{
if
(
apiResp
.
getCode
()
!=
YesNoEnum
.
YES
.
getValue
())
{
throw
new
AppException
(
"获取用户站点列表树数据失败:"
+
apiResp
.
getMsg
());
throw
new
AppException
(
"获取用户站点列表树数据失败:"
+
apiResp
.
getMsg
());
}
}
if
(
apiResp
.
getData
().
get
(
"data"
)!=
null
)
{
if
(
apiResp
.
getData
().
get
(
"data"
)
!=
null
)
{
data
.
put
(
"siteList"
,
apiResp
.
getData
().
get
(
"data"
));
data
.
put
(
"siteList"
,
apiResp
.
getData
().
get
(
"data"
));
}
else
{
}
else
{
data
.
put
(
"siteList"
,
Collections
.
emptyList
());
data
.
put
(
"siteList"
,
Collections
.
emptyList
());
}
}
}
else
{
}
else
{
data
.
put
(
"siteList"
,
Collections
.
emptyList
());
data
.
put
(
"siteList"
,
Collections
.
emptyList
());
}
}
}
}
...
@@ -120,9 +137,9 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
...
@@ -120,9 +137,9 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
return
ret
.
toJSONString
();
return
ret
.
toJSONString
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"login error "
,
e
);
log
.
error
(
"login error "
,
e
);
if
(
e
instanceof
AppException
)
{
if
(
e
instanceof
AppException
)
{
ret
.
put
(
KEY_RESULT_CODE
,
((
AppException
)
e
).
getCode
());
ret
.
put
(
KEY_RESULT_CODE
,
((
AppException
)
e
).
getCode
());
}
else
{
}
else
{
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
}
}
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
...
...
portal-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
View file @
8bca6289
...
@@ -71,7 +71,14 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
...
@@ -71,7 +71,14 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
@Override
@Override
public
Set
<
String
>
findUrlSetByUserId
(
Long
userId
)
throws
AppException
{
public
Set
<
String
>
findUrlSetByUserId
(
Long
userId
)
throws
AppException
{
Set
<
String
>
urls
=
new
HashSet
<>();
Set
<
String
>
urls
=
new
HashSet
<>();
List
<
ResourceEntity
>
resList
=
this
.
findListByUserId
(
userId
);
List
<
ResourceEntity
>
resList
=
new
ArrayList
<>();
if
(
1L
==
userId
)
{
//管理员
resList
=
this
.
find
(
new
ResourceQuery
());
}
else
{
resList
=
this
.
findListByUserId
(
userId
);
}
for
(
ResourceEntity
res
:
resList
)
{
for
(
ResourceEntity
res
:
resList
)
{
String
url
=
res
.
getUrl
();
String
url
=
res
.
getUrl
();
if
(
StringUtils
.
isEmpty
(
url
))
{
if
(
StringUtils
.
isEmpty
(
url
))
{
...
@@ -92,7 +99,7 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
...
@@ -92,7 +99,7 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao, Re
public
Rest
<
String
>
refreshResourceUrl
(
String
packageName
,
Context
context
)
{
public
Rest
<
String
>
refreshResourceUrl
(
String
packageName
,
Context
context
)
{
List
<
Class
<?>>
classList
=
ControllerScanUtil
.
getAllClassByPackageName
(
packageName
);
List
<
Class
<?>>
classList
=
ControllerScanUtil
.
getAllClassByPackageName
(
packageName
);
//System.out.println(classList); //获取到了所有的类
//System.out.println(classList); //获取到了所有的类
List
<
ResourceEntity
>
newResourcelist
=
ControllerScanUtil
.
getAnnotationInfo
(
classList
).
stream
().
filter
(
f
->
!
ObjectUtils
.
isEmpty
(
f
.
getUrl
())).
collect
(
Collectors
.
toList
());
List
<
ResourceEntity
>
newResourcelist
=
ControllerScanUtil
.
getAnnotationInfo
(
classList
).
stream
().
filter
(
f
->
!
ObjectUtils
.
isEmpty
(
f
.
getUrl
())).
collect
(
Collectors
.
toList
());
Map
<
String
,
List
<
ResourceEntity
>>
localResourceMap
=
this
.
find
(
new
ResourceQuery
()).
stream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getName
()));
Map
<
String
,
List
<
ResourceEntity
>>
localResourceMap
=
this
.
find
(
new
ResourceQuery
()).
stream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getName
()));
Map
<
String
,
List
<
ResourceEntity
>>
newResourceMap
=
newResourcelist
.
stream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getName
()));
Map
<
String
,
List
<
ResourceEntity
>>
newResourceMap
=
newResourcelist
.
stream
().
collect
(
Collectors
.
groupingBy
(
x
->
x
.
getName
()));
...
...
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