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
e7e17b9b
Commit
e7e17b9b
authored
1 year ago
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改门户资源鉴权
parent
d500463e
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
1923 additions
and
402 deletions
+1923
-402
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteServiceImpl.java
...mortals/xhx/module/site/service/impl/SiteServiceImpl.java
+18
-7
base-manager/src/main/java/com/mortals/xhx/module/skin/service/impl/SkinBaseServiceImpl.java
...als/xhx/module/skin/service/impl/SkinBaseServiceImpl.java
+9
-0
common-lib/src/main/java/com/mortals/xhx/feign/area/IApiAreaFeign.java
...c/main/java/com/mortals/xhx/feign/area/IApiAreaFeign.java
+20
-0
common-lib/src/main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
.../main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
+18
-0
common-lib/src/main/java/com/mortals/xhx/feign/skin/ISkinFillFeign.java
.../main/java/com/mortals/xhx/feign/skin/ISkinFillFeign.java
+76
-0
common-lib/src/main/java/com/mortals/xhx/feign/skin/ISkinSampleFeign.java
...ain/java/com/mortals/xhx/feign/skin/ISkinSampleFeign.java
+76
-0
portal-manager/db/add.sql
portal-manager/db/add.sql
+9
-1
portal-manager/doc/政务一体化门户.docx
portal-manager/doc/政务一体化门户.docx
+0
-0
portal-manager/src/main/java/com/mortals/xhx/base/framework/security/AuthTokenServiceImpl.java
...als/xhx/base/framework/security/AuthTokenServiceImpl.java
+31
-4
portal-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
...ase/system/resource/service/impl/ResourceServiceImpl.java
+34
-10
portal-manager/src/main/java/com/mortals/xhx/module/role/model/RoleAuthEntity.java
...ava/com/mortals/xhx/module/role/model/RoleAuthEntity.java
+26
-58
portal-manager/src/main/java/com/mortals/xhx/module/role/model/RoleAuthQuery.java
...java/com/mortals/xhx/module/role/model/RoleAuthQuery.java
+656
-174
portal-manager/src/main/java/com/mortals/xhx/module/role/service/RoleAuthService.java
.../com/mortals/xhx/module/role/service/RoleAuthService.java
+4
-0
portal-manager/src/main/java/com/mortals/xhx/module/role/service/impl/RoleAuthServiceImpl.java
...als/xhx/module/role/service/impl/RoleAuthServiceImpl.java
+30
-8
portal-manager/src/main/java/com/mortals/xhx/module/role/web/RoleAuthController.java
...a/com/mortals/xhx/module/role/web/RoleAuthController.java
+21
-0
portal-manager/src/main/java/com/mortals/xhx/module/user/model/vo/UserVo.java
...ain/java/com/mortals/xhx/module/user/model/vo/UserVo.java
+5
-0
portal-manager/src/main/java/com/mortals/xhx/module/user/service/UserService.java
...java/com/mortals/xhx/module/user/service/UserService.java
+2
-1
portal-manager/src/main/java/com/mortals/xhx/module/user/service/impl/UserServiceImpl.java
...mortals/xhx/module/user/service/impl/UserServiceImpl.java
+43
-33
portal-manager/src/main/resources/sqlmap/base/system/resource.xml
...anager/src/main/resources/sqlmap/base/system/resource.xml
+428
-0
portal-manager/src/main/resources/sqlmap/base/system/resourceExt.xml
...ger/src/main/resources/sqlmap/base/system/resourceExt.xml
+24
-0
portal-manager/src/main/resources/sqlmap/module/role/RoleAuthMapper.xml
.../src/main/resources/sqlmap/module/role/RoleAuthMapper.xml
+393
-106
No files found.
base-manager/src/main/java/com/mortals/xhx/module/site/service/impl/SiteServiceImpl.java
View file @
e7e17b9b
...
@@ -5,6 +5,7 @@ import cn.hutool.core.util.URLUtil;
...
@@ -5,6 +5,7 @@ import cn.hutool.core.util.URLUtil;
import
cn.hutool.core.util.ZipUtil
;
import
cn.hutool.core.util.ZipUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.ap.GlobalSysInfo
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.framework.exception.AppException
;
import
com.mortals.framework.exception.AppException
;
...
@@ -13,6 +14,7 @@ import com.mortals.framework.model.PageInfo;
...
@@ -13,6 +14,7 @@ import com.mortals.framework.model.PageInfo;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.util.DataUtil
;
import
com.mortals.framework.util.DataUtil
;
import
com.mortals.framework.util.HttpUtil
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.framework.util.StringUtils
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.base.system.user.service.UserService
;
import
com.mortals.xhx.common.code.AreaLevelDxTypeEnum
;
import
com.mortals.xhx.common.code.AreaLevelDxTypeEnum
;
...
@@ -60,6 +62,7 @@ import org.springframework.util.ObjectUtils;
...
@@ -60,6 +62,7 @@ import org.springframework.util.ObjectUtils;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
static
com
.
mortals
.
framework
.
util
.
HttpUtil
.
HEADER_CONTENT_TYPE
;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.*;
import
static
com
.
mortals
.
xhx
.
common
.
key
.
Constant
.*;
/**
/**
...
@@ -189,7 +192,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
...
@@ -189,7 +192,6 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
//刷新站点树
//刷新站点树
//ThreadPool.getInstance().execute(new SyncTreeSiteThread(this,context));
//ThreadPool.getInstance().execute(new SyncTreeSiteThread(this,context));
Rest
<
String
>
rest
=
userFeign
.
synchSiteAuth
();
Rest
<
String
>
rest
=
userFeign
.
synchSiteAuth
();
log
.
info
(
"站点更新2"
);
if
(
rest
.
getCode
().
equals
(
YesNoEnum
.
YES
.
getValue
()))
{
if
(
rest
.
getCode
().
equals
(
YesNoEnum
.
YES
.
getValue
()))
{
UserPdu
userPdu
=
new
UserPdu
();
UserPdu
userPdu
=
new
UserPdu
();
userPdu
.
setPage
(
1
);
userPdu
.
setPage
(
1
);
...
@@ -197,10 +199,23 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
...
@@ -197,10 +199,23 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
Rest
<
RespData
<
List
<
UserPdu
>>>
list
=
userFeign
.
list
(
userPdu
);
Rest
<
RespData
<
List
<
UserPdu
>>>
list
=
userFeign
.
list
(
userPdu
);
userService
.
updateUserList
(
list
.
getData
().
getData
());
userService
.
updateUserList
(
list
.
getData
().
getData
());
}
}
log
.
info
(
"站点更新3"
);
//更新同步部门相关
//更新同步部门相关
deptService
.
syncDeptBySiteId
(
entity
,
context
);
deptService
.
syncDeptBySiteId
(
entity
,
context
);
log
.
info
(
"站点更新4"
);
//通知php系统更新
String
phpUrl
=
GlobalSysInfo
.
getParamValue
(
PARAM_SERVER_PHP_HTTP_URL
,
"http://172.15.28.116:8090"
);
HashMap
<
String
,
String
>
paramsMap
=
new
HashMap
<>();
paramsMap
.
put
(
"siteid"
,
entity
.
getId
().
toString
());
phpUrl
+=
"/api/site/childSiteSet"
;
String
resp
=
null
;
try
{
resp
=
HttpUtil
.
doGet
(
phpUrl
,
paramsMap
);
log
.
info
(
"thirdPartyUrl =>resp:{}"
,
resp
);
}
catch
(
Exception
e
)
{
log
.
error
(
"异常:"
,
e
);
}
}
}
...
@@ -327,17 +342,13 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
...
@@ -327,17 +342,13 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
protected
void
updateAfter
(
SiteEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
updateAfter
(
SiteEntity
entity
,
Context
context
)
throws
AppException
{
super
.
updateAfter
(
entity
,
context
);
super
.
updateAfter
(
entity
,
context
);
//刷新站点树
//刷新站点树
log
.
info
(
"update1"
);
Rest
<
String
>
rest
=
userFeign
.
synchSiteAuth
();
Rest
<
String
>
rest
=
userFeign
.
synchSiteAuth
();
if
(
rest
.
getCode
().
equals
(
YesNoEnum
.
YES
.
getValue
()))
{
if
(
rest
.
getCode
().
equals
(
YesNoEnum
.
YES
.
getValue
()))
{
log
.
info
(
"update2"
);
UserPdu
userPdu
=
new
UserPdu
();
UserPdu
userPdu
=
new
UserPdu
();
userPdu
.
setPage
(
1
);
userPdu
.
setPage
(
1
);
userPdu
.
setSize
(-
1
);
userPdu
.
setSize
(-
1
);
Rest
<
RespData
<
List
<
UserPdu
>>>
list
=
userFeign
.
list
(
userPdu
);
Rest
<
RespData
<
List
<
UserPdu
>>>
list
=
userFeign
.
list
(
userPdu
);
log
.
info
(
"update21"
);
userService
.
updateUserList
(
list
.
getData
().
getData
());
userService
.
updateUserList
(
list
.
getData
().
getData
());
log
.
info
(
"update22"
);
}
}
if
(
refresh
)
{
if
(
refresh
)
{
//通知设备更新站点信息
//通知设备更新站点信息
...
...
This diff is collapsed.
Click to expand it.
base-manager/src/main/java/com/mortals/xhx/module/skin/service/impl/SkinBaseServiceImpl.java
View file @
e7e17b9b
...
@@ -17,6 +17,8 @@ import com.mortals.xhx.common.code.FiletypeEnum;
...
@@ -17,6 +17,8 @@ import com.mortals.xhx.common.code.FiletypeEnum;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.key.Constant
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.BeanUtil
;
import
com.mortals.xhx.common.utils.FreeMarkerUtils
;
import
com.mortals.xhx.common.utils.FreeMarkerUtils
;
import
com.mortals.xhx.feign.skin.ISkinFillFeign
;
import
com.mortals.xhx.feign.skin.ISkinSampleFeign
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.model.ProductEntity
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.module.product.service.ProductService
;
import
com.mortals.xhx.module.skin.dao.SkinBaseDao
;
import
com.mortals.xhx.module.skin.dao.SkinBaseDao
;
...
@@ -64,6 +66,10 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
...
@@ -64,6 +66,10 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
private
ProductService
productService
;
private
ProductService
productService
;
@Autowired
@Autowired
private
ParamService
paramService
;
private
ParamService
paramService
;
@Autowired
private
ISkinSampleFeign
skinSampleFeign
;
@Autowired
private
ISkinFillFeign
skinFillFeign
;
@Override
@Override
protected
void
validData
(
SkinBaseEntity
entity
,
Context
context
)
throws
AppException
{
protected
void
validData
(
SkinBaseEntity
entity
,
Context
context
)
throws
AppException
{
...
@@ -161,6 +167,9 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
...
@@ -161,6 +167,9 @@ public class SkinBaseServiceImpl extends AbstractCRUDServiceImpl<SkinBaseDao, Sk
});
});
skinFieldService
.
save
(
entity
.
getSkinFieldList
(),
context
);
skinFieldService
.
save
(
entity
.
getSkinFieldList
(),
context
);
}
}
//通知子系统同步皮肤数据
skinSampleFeign
.
refreshSkin
();
skinFillFeign
.
refreshSkin
();
}
}
@Override
@Override
...
...
This diff is collapsed.
Click to expand it.
common-lib/src/main/java/com/mortals/xhx/feign/area/IApiAreaFeign.java
View file @
e7e17b9b
package
com.mortals.xhx.feign.area
;
package
com.mortals.xhx.feign.area
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
com.mortals.xhx.common.code.ApiRespCodeEnum
;
import
com.mortals.xhx.common.pdu.SitePdu
;
import
com.mortals.xhx.common.pdu.SitePdu
;
import
com.mortals.xhx.feign.IFeign
;
import
com.mortals.xhx.feign.IFeign
;
...
@@ -70,6 +71,15 @@ public interface IApiAreaFeign extends IFeign {
...
@@ -70,6 +71,15 @@ public interface IApiAreaFeign extends IFeign {
@PostMapping
(
value
=
"/site/getFlatSitesByAreaIds"
)
@PostMapping
(
value
=
"/site/getFlatSitesByAreaIds"
)
String
getFlatSitesByAreaIds
(
@RequestBody
SitePdu
query
);
String
getFlatSitesByAreaIds
(
@RequestBody
SitePdu
query
);
/**
* 用户刷新通知
*
* @param
* @return
*/
@PostMapping
(
value
=
"/usr/refreshUser"
)
Rest
<
Void
>
refreshUser
();
// /**
// /**
// * 根据条件查询站点列表
// * 根据条件查询站点列表
// * @param query
// * @param query
...
@@ -134,6 +144,16 @@ class AreaFeignFallbackFactory implements FallbackFactory<IApiAreaFeign> {
...
@@ -134,6 +144,16 @@ class AreaFeignFallbackFactory implements FallbackFactory<IApiAreaFeign> {
return
JSON
.
toJSONString
(
failResp
);
return
JSON
.
toJSONString
(
failResp
);
}
}
/**
* @return
*/
@Override
public
Rest
<
Void
>
refreshUser
()
{
return
Rest
.
fail
(
"暂时无法通知设备,请稍后再试!"
);
}
// @Override
// @Override
// public String getSitesByQuery(SitePdu query) {
// public String getSitesByQuery(SitePdu query) {
// ApiResp<String> failResp = new ApiResp<>();
// ApiResp<String> failResp = new ApiResp<>();
...
...
This diff is collapsed.
Click to expand it.
common-lib/src/main/java/com/mortals/xhx/feign/device/IDeviceFeign.java
View file @
e7e17b9b
...
@@ -69,6 +69,16 @@ public interface IDeviceFeign extends IFeign {
...
@@ -69,6 +69,16 @@ public interface IDeviceFeign extends IFeign {
Rest
<
Void
>
refreshMessage
(
@RequestBody
DevicePdu
devicePdu
);
Rest
<
Void
>
refreshMessage
(
@RequestBody
DevicePdu
devicePdu
);
/**
* 用户刷新通知
*
* @param
* @return
*/
@PostMapping
(
value
=
"/usr/refreshUser"
)
Rest
<
Void
>
refreshUser
();
}
}
...
@@ -106,6 +116,14 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
...
@@ -106,6 +116,14 @@ class DeviceFeignFallbackFactory implements FallbackFactory<IDeviceFeign> {
public
Rest
<
Void
>
refreshMessage
(
DevicePdu
devicePdu
)
{
public
Rest
<
Void
>
refreshMessage
(
DevicePdu
devicePdu
)
{
return
Rest
.
fail
(
"暂时无法通知设备,请稍后再试!"
);
return
Rest
.
fail
(
"暂时无法通知设备,请稍后再试!"
);
}
}
/**
* @return
*/
@Override
public
Rest
<
Void
>
refreshUser
()
{
return
Rest
.
fail
(
"暂时无法通知设备,请稍后再试!"
);
}
};
};
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
common-lib/src/main/java/com/mortals/xhx/feign/skin/ISkinFillFeign.java
0 → 100644
View file @
e7e17b9b
package
com.mortals.xhx.feign.skin
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.xhx.feign.IFeign
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.PostMapping
;
/**
* 填单皮肤 Feign接口
* @author zxfei
* @date 2022-10-26
*/
@FeignClient
(
name
=
"fill-manager"
,
path
=
"/fm"
,
fallbackFactory
=
SkinFillFeignFallbackFactory
.
class
)
public
interface
ISkinFillFeign
extends
IFeign
{
/**
* 皮肤变更通知
*
* @param
* @return
*/
@PostMapping
(
value
=
"/skin/refreshSkin"
)
Rest
<
Void
>
refreshSkin
();
/**
* 用户刷新通知
*
* @param
* @return
*/
@PostMapping
(
value
=
"/usr/refreshUser"
)
Rest
<
Void
>
refreshUser
();
}
@Slf4j
@Component
class
SkinFillFeignFallbackFactory
implements
FallbackFactory
<
ISkinFillFeign
>
{
@Override
public
ISkinFillFeign
create
(
Throwable
t
)
{
return
new
ISkinFillFeign
()
{
/**
* @param
* @return
*/
@Override
public
Rest
<
Void
>
refreshSkin
()
{
return
Rest
.
fail
(
"暂时无法通知设备,请稍后再试!"
);
}
/**
* @return
*/
@Override
public
Rest
<
Void
>
refreshUser
()
{
return
Rest
.
fail
(
"暂时无法通知设备,请稍后再试!"
);
}
};
}
}
This diff is collapsed.
Click to expand it.
common-lib/src/main/java/com/mortals/xhx/feign/skin/ISkinSampleFeign.java
0 → 100644
View file @
e7e17b9b
package
com.mortals.xhx.feign.skin
;
import
com.mortals.framework.common.Rest
;
import
com.mortals.xhx.feign.IFeign
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.*
;
/**
* 样表皮肤 Feign接口
* @author zxfei
* @date 2022-10-26
*/
@FeignClient
(
name
=
"sample-form-manager"
,
path
=
"/sampleform"
,
fallbackFactory
=
SkinFillFeignFallbackFactory
.
class
)
public
interface
ISkinSampleFeign
extends
IFeign
{
/**
* 皮肤变更通知
*
* @param
* @return
*/
@PostMapping
(
value
=
"/skin/refreshSkin"
)
Rest
<
Void
>
refreshSkin
();
/**
* 用户刷新通知
*
* @param
* @return
*/
@PostMapping
(
value
=
"/usr/refreshUser"
)
Rest
<
Void
>
refreshUser
();
}
@Slf4j
@Component
class
SkinSampleFeignFallbackFactory
implements
FallbackFactory
<
ISkinFillFeign
>
{
@Override
public
ISkinFillFeign
create
(
Throwable
t
)
{
return
new
ISkinFillFeign
()
{
/**
* @param
* @return
*/
@Override
public
Rest
<
Void
>
refreshSkin
()
{
return
Rest
.
fail
(
"暂时无法通知设备,请稍后再试!"
);
}
/**
* @return
*/
@Override
public
Rest
<
Void
>
refreshUser
()
{
return
Rest
.
fail
(
"暂时无法通知设备,请稍后再试!"
);
}
};
}
}
This diff is collapsed.
Click to expand it.
portal-manager/db/add.sql
View file @
e7e17b9b
...
@@ -61,4 +61,12 @@ CREATE TABLE `mortals_xhx_user_model_collect` (
...
@@ -61,4 +61,12 @@ CREATE TABLE `mortals_xhx_user_model_collect` (
ALTER
TABLE
`mortals_xhx_user_model_collect`
ALTER
TABLE
`mortals_xhx_user_model_collect`
ADD
COLUMN
`siteId`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'站点ID'
;
ADD
COLUMN
`siteId`
bigint
(
20
)
DEFAULT
NULL
COMMENT
'站点ID'
;
UPDATE
mortals_xhx_user_model_collect
SET
siteId
=
1
;
UPDATE
mortals_xhx_user_model_collect
SET
siteId
=
1
;
\ No newline at end of file
-- ----------------------------
2023
-
11
-
13
-- ----------------------------
ALTER
TABLE
mortals_xhx_role_auth
ADD
COLUMN
`resourceId`
bigint
(
20
)
COMMENT
'资源ID'
;
ALTER
TABLE
mortals_xhx_role_auth
ADD
COLUMN
`createTime`
datetime
COMMENT
'创建时间'
;
ALTER
TABLE
mortals_xhx_role_auth
ADD
COLUMN
`createUserId`
bigint
(
20
)
COMMENT
'创建用户'
;
ALTER
TABLE
mortals_xhx_role_auth
ADD
COLUMN
`createUserName`
varchar
(
50
)
COMMENT
'创建用户名称'
;
This diff is collapsed.
Click to expand it.
portal-manager/doc/政务一体化门户.docx
View file @
e7e17b9b
No preview for this file type
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/base/framework/security/AuthTokenServiceImpl.java
View file @
e7e17b9b
...
@@ -8,6 +8,11 @@ import com.mortals.framework.service.ICacheService;
...
@@ -8,6 +8,11 @@ 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.xhx.base.system.resource.service.ResourceService
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.utils.MenuEncodeUtil
;
import
com.mortals.xhx.module.user.model.UserEntity
;
import
com.mortals.xhx.module.user.service.UserService
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Claims
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.Jwts
;
import
io.jsonwebtoken.SignatureAlgorithm
;
import
io.jsonwebtoken.SignatureAlgorithm
;
...
@@ -50,6 +55,9 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -50,6 +55,9 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
@Value
(
"${token.prefix:}"
)
@Value
(
"${token.prefix:}"
)
private
String
tokenPrefix
;
private
String
tokenPrefix
;
@Autowired
private
UserService
userService
;
protected
static
final
Long
MILLIS_SECOND
=
1
l
;
protected
static
final
Long
MILLIS_SECOND
=
1
l
;
protected
static
final
Long
MILLIS_MINUTE
=
60
*
MILLIS_SECOND
;
protected
static
final
Long
MILLIS_MINUTE
=
60
*
MILLIS_SECOND
;
...
@@ -65,6 +73,9 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -65,6 +73,9 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
@Autowired
@Autowired
private
ICacheService
cacheService
;
private
ICacheService
cacheService
;
@Autowired
private
ResourceService
resourceService
;
/**
/**
* 获取信息
* 获取信息
*
*
...
@@ -85,7 +96,25 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -85,7 +96,25 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
String
uuid
=
(
String
)
claims
.
get
(
SysConstains
.
LOGIN_USER_KEY
);
String
uuid
=
(
String
)
claims
.
get
(
SysConstains
.
LOGIN_USER_KEY
);
String
userKey
=
getTokenKey
(
uuid
);
String
userKey
=
getTokenKey
(
uuid
);
String
userStr
=
cacheService
.
get
(
userKey
);
String
userStr
=
cacheService
.
get
(
userKey
);
if
(
StringUtils
.
isNotEmpty
(
userStr
))
{
UserEntity
userEntity
=
JSONObject
.
parseObject
(
userStr
,
UserEntity
.
class
);
userEntity
.
setToken
(
token
);
//更新portal 中的id 为 device中的id
// UserEntity temp = userService.selectOne(new UserQuery().loginName(userEntity.getLoginName()));
UserEntity
temp
=
userService
.
getExtCache
(
userEntity
.
getLoginName
());
if
(!
ObjectUtils
.
isEmpty
(
temp
))
{
userEntity
.
setId
(
temp
.
getId
());
}
//更新resource 路径
String
menuUrlCode
=
cacheService
.
hget
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userEntity
.
getId
().
toString
(),
String
.
class
);
if
(
ObjectUtils
.
isEmpty
(
menuUrlCode
))
{
Set
<
String
>
urls
=
resourceService
.
findUrlSetByUserId
(
userEntity
.
getId
());
menuUrlCode
=
MenuEncodeUtil
.
generateMenuUrlCode
(
urls
);
cacheService
.
hset
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userEntity
.
getId
().
toString
(),
menuUrlCode
);
}
userEntity
.
setMenuUrl
(
menuUrlCode
);
return
userEntity
;
/* if (StringUtils.isNotEmpty(userStr)) {
JSONObject userObj = JSON.parseObject(userStr);
JSONObject userObj = JSON.parseObject(userStr);
Long userId = userObj.getLongValue("id");
Long userId = userObj.getLongValue("id");
Integer userType = userObj.getIntValue("userType");
Integer userType = userObj.getIntValue("userType");
...
@@ -198,8 +227,6 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -198,8 +227,6 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
public void setExpireTime(Long expireTime) {
public void setExpireTime(Long expireTime) {
}
}
@Override
@Override
public String getMenuUrl() {
public String getMenuUrl() {
return menuUrl;
return menuUrl;
...
@@ -207,7 +234,7 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
...
@@ -207,7 +234,7 @@ public class AuthTokenServiceImpl implements IAuthTokenService {
};
};
}
}
*/
// return cacheService.get(userKey, IUser.class);
// return cacheService.get(userKey, IUser.class);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"解析jwt token异常!"
,
e
);
log
.
error
(
"解析jwt token异常!"
,
e
);
...
...
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/base/system/resource/service/impl/ResourceServiceImpl.java
View file @
e7e17b9b
/**
/**
* 文件:ResourceServiceImpl.java
* 文件:ResourceServiceImpl.java
* 版本:1.0.0
* 版本:1.0.0
* 日期:
* 日期:
* Copyright ®
* Copyright ®
* All right reserved.
* All right reserved.
*/
*/
package
com.mortals.xhx.base.system.resource.service.impl
;
package
com.mortals.xhx.base.system.resource.service.impl
;
...
@@ -19,9 +19,14 @@ import com.mortals.xhx.base.system.resource.model.ResourceEntity;
...
@@ -19,9 +19,14 @@ import com.mortals.xhx.base.system.resource.model.ResourceEntity;
import
com.mortals.xhx.base.system.resource.model.ResourceQuery
;
import
com.mortals.xhx.base.system.resource.model.ResourceQuery
;
import
com.mortals.xhx.base.system.resource.service.ResourceService
;
import
com.mortals.xhx.base.system.resource.service.ResourceService
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.common.key.RedisKey
;
import
com.mortals.xhx.module.role.model.RoleAuthEntity
;
import
com.mortals.xhx.module.role.model.RoleAuthQuery
;
import
com.mortals.xhx.module.role.service.RoleAuthService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.ObjectUtils
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -33,15 +38,20 @@ import static com.mortals.xhx.common.utils.MenuEncodeUtil.generateMenuUrlCode;
...
@@ -33,15 +38,20 @@ import static com.mortals.xhx.common.utils.MenuEncodeUtil.generateMenuUrlCode;
* <p>Description: ResourceServiceImpl service接口 </p>
* <p>Description: ResourceServiceImpl service接口 </p>
* <p>Copyright: Copyright ® </p>
* <p>Copyright: Copyright ® </p>
* <p>Company: </p>
* <p>Company: </p>
* @author
*
* @author
* @version 1.0.0
* @version 1.0.0
*/
*/
@Service
(
"resourceService"
)
@Service
(
"resourceService"
)
public
class
ResourceServiceImpl
extends
AbstractCRUDServiceImpl
<
ResourceDao
,
ResourceEntity
,
Long
>
implements
ResourceService
{
public
class
ResourceServiceImpl
extends
AbstractCRUDServiceImpl
<
ResourceDao
,
ResourceEntity
,
Long
>
implements
ResourceService
{
@Autowired
@Autowired
private
ICacheService
cacheService
;
private
ICacheService
cacheService
;
@Autowired
private
RoleAuthService
roleAuthService
;
@Override
@Override
public
List
<
ResourceEntity
>
findAllEnable
()
throws
AppException
{
public
List
<
ResourceEntity
>
findAllEnable
()
throws
AppException
{
ResourceQuery
params
=
new
ResourceQuery
();
ResourceQuery
params
=
new
ResourceQuery
();
...
@@ -90,13 +100,27 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao,Res
...
@@ -90,13 +100,27 @@ public class ResourceServiceImpl extends AbstractCRUDServiceImpl<ResourceDao,Res
updateUserMenuUrlCache
();
updateUserMenuUrlCache
();
}
}
@Override
protected
void
removeAfter
(
Long
[]
ids
,
Context
context
,
int
result
)
throws
AppException
{
//删除关联表中数据
if
(!
ObjectUtils
.
isEmpty
(
ids
))
{
RoleAuthQuery
query
=
new
RoleAuthQuery
();
query
.
setResourceIdList
(
Arrays
.
asList
(
ids
));
List
<
RoleAuthEntity
>
roleAuthEntities
=
roleAuthService
.
find
(
query
);
if
(!
ObjectUtils
.
isEmpty
(
roleAuthEntities
))
{
roleAuthService
.
remove
(
roleAuthEntities
.
stream
().
map
(
m
->
m
.
getId
()).
toArray
(
Long
[]::
new
),
context
);
updateUserMenuUrlCache
();
}
}
}
private
void
updateUserMenuUrlCache
()
{
private
void
updateUserMenuUrlCache
()
{
//更新用户菜单
//更新用户菜单
Set
<
String
>
hkeys
=
cacheService
.
hkeys
(
RedisKey
.
KEY_USER_MENU_CACHE
);
Set
<
String
>
hkeys
=
cacheService
.
hkeys
(
RedisKey
.
KEY_USER_MENU_CACHE
);
for
(
String
userId
:
hkeys
)
{
for
(
String
userId
:
hkeys
)
{
Set
<
String
>
urls
=
this
.
findUrlSetByUserId
(
DataUtil
.
converStr2Long
(
userId
,
0L
));
Set
<
String
>
urls
=
this
.
findUrlSetByUserId
(
DataUtil
.
converStr2Long
(
userId
,
0L
));
String
menuUrlCode
=
generateMenuUrlCode
(
urls
);
String
menuUrlCode
=
generateMenuUrlCode
(
urls
);
cacheService
.
hset
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userId
,
menuUrlCode
);
cacheService
.
hset
(
RedisKey
.
KEY_USER_MENU_CACHE
,
userId
,
menuUrlCode
);
}
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/role/model/RoleAuthEntity.java
View file @
e7e17b9b
package
com.mortals.xhx.module.role.model
;
package
com.mortals.xhx.module.role.model
;
import
java.util.List
;
import
java.util.List
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.math.BigDecimal
;
import
cn.hutool.core.date.DateUtil
;
import
java.util.Date
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.mortals.framework.annotation.Excel
;
import
com.mortals.framework.annotation.Excel
;
import
com.mortals.framework.model.BaseEntityLong
;
import
com.mortals.framework.model.BaseEntityLong
;
import
com.mortals.xhx.module.role.model.vo.RoleAuthVo
;
import
com.mortals.xhx.module.role.model.vo.RoleAuthVo
;
import
lombok.Data
;
/**
/**
* 角色菜单权限关联实体对象
* 角色菜单权限关联实体对象
*
*
* @author zxfei
* @author zxfei
* @date 2022-06-02
* @date 2023-11-13
*/
*/
@Data
public
class
RoleAuthEntity
extends
RoleAuthVo
{
public
class
RoleAuthEntity
extends
RoleAuthVo
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/**
/**
* 角色ID
* 角色ID
*/
*/
private
Long
roleId
;
private
Long
roleId
;
/**
/**
* 菜单ID
* 菜单ID
*/
*/
private
Long
menuId
;
private
Long
menuId
;
public
RoleAuthEntity
(){}
/**
/**
* 获取 角色ID
* 资源ID
* @return Long
*/
*/
private
Long
resourceId
;
public
Long
getRoleId
(){
return
roleId
;
}
/**
* 设置 角色ID
* @param roleId
*/
public
void
setRoleId
(
Long
roleId
){
this
.
roleId
=
roleId
;
}
/**
* 获取 菜单ID
* @return Long
*/
public
Long
getMenuId
(){
return
menuId
;
}
/**
/**
* 设置 菜单ID
* 创建用户名称
* @param menuId
*/
*/
private
String
createUserName
;
public
void
setMenuId
(
Long
menuId
){
this
.
menuId
=
menuId
;
}
@Override
@Override
public
int
hashCode
()
{
public
int
hashCode
()
{
return
this
.
getId
().
hashCode
();
return
this
.
getId
().
hashCode
();
}
}
@Override
@Override
public
boolean
equals
(
Object
obj
)
{
public
boolean
equals
(
Object
obj
)
{
...
@@ -70,23 +45,16 @@ public class RoleAuthEntity extends RoleAuthVo {
...
@@ -70,23 +45,16 @@ public class RoleAuthEntity extends RoleAuthVo {
if
(
obj
instanceof
RoleAuthEntity
)
{
if
(
obj
instanceof
RoleAuthEntity
)
{
RoleAuthEntity
tmp
=
(
RoleAuthEntity
)
obj
;
RoleAuthEntity
tmp
=
(
RoleAuthEntity
)
obj
;
if
(
this
.
getId
()
==
tmp
.
getId
())
{
if
(
this
.
getId
()
==
tmp
.
getId
())
{
return
true
;
return
true
;
}
}
}
}
return
false
;
return
false
;
}
}
public
String
toString
(){
StringBuilder
sb
=
new
StringBuilder
(
""
);
sb
.
append
(
",roleId:"
).
append
(
getRoleId
());
sb
.
append
(
",menuId:"
).
append
(
getMenuId
());
return
sb
.
toString
();
}
public
void
initAttrValue
(){
public
void
initAttrValue
(){
this
.
roleId
=
null
;
this
.
role
Id
=
null
;
this
.
menu
Id
=
null
;
this
.
resourceId
=
null
;
this
.
menuId
=
null
;
this
.
createUserName
=
""
;
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/role/model/RoleAuthQuery.java
View file @
e7e17b9b
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/role/service/RoleAuthService.java
View file @
e7e17b9b
...
@@ -28,4 +28,8 @@ public interface RoleAuthService extends ICRUDService<RoleAuthEntity, Long> {
...
@@ -28,4 +28,8 @@ public interface RoleAuthService extends ICRUDService<RoleAuthEntity, Long> {
* @return
* @return
*/
*/
Map
<
Long
,
List
<
Long
>>
getMenuIdByRole
(
Long
userId
);
Map
<
Long
,
List
<
Long
>>
getMenuIdByRole
(
Long
userId
);
/** 角色分配资源 */
void
doDistributionSource
(
RoleAuthQuery
query
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/role/service/impl/RoleAuthServiceImpl.java
View file @
e7e17b9b
...
@@ -29,6 +29,27 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
...
@@ -29,6 +29,27 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
@Autowired
@Autowired
private
RoleUserService
roleUserService
;
private
RoleUserService
roleUserService
;
@Override
public
void
doDistributionSource
(
RoleAuthQuery
query
)
{
// 删除角色资源老数据
Long
roleId
=
query
.
getRoleId
();
Map
<
String
,
Object
>
condition
=
new
HashMap
<>();
condition
.
put
(
"roleId"
,
roleId
);
condition
.
put
(
"menuId"
,
null
);
this
.
dao
.
delete
(
condition
);
List
<
RoleAuthEntity
>
list
=
new
ArrayList
<>();
for
(
Long
sourceId
:
query
.
getResourceIdList
())
{
RoleAuthEntity
entity
=
new
RoleAuthEntity
();
entity
.
setRoleId
(
roleId
);
entity
.
setResourceId
(
sourceId
);
list
.
add
(
entity
);
}
this
.
dao
.
insertBatch
(
list
);
}
@Override
@Override
public
void
assignMenu
(
RoleAuthQuery
query
)
{
public
void
assignMenu
(
RoleAuthQuery
query
)
{
Map
<
Long
,
MenuEntity
>
menuEntityMap
=
menuService
.
find
(
new
MenuQuery
()).
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getId
(),
y
->
y
));
Map
<
Long
,
MenuEntity
>
menuEntityMap
=
menuService
.
find
(
new
MenuQuery
()).
stream
().
collect
(
Collectors
.
toMap
(
x
->
x
.
getId
(),
y
->
y
));
...
@@ -36,6 +57,7 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
...
@@ -36,6 +57,7 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
Long
roleId
=
query
.
getRoleId
();
Long
roleId
=
query
.
getRoleId
();
Map
<
String
,
Object
>
condition
=
new
HashMap
<>();
Map
<
String
,
Object
>
condition
=
new
HashMap
<>();
condition
.
put
(
"roleId"
,
roleId
);
condition
.
put
(
"roleId"
,
roleId
);
condition
.
put
(
"resoruceId"
,
null
);
this
.
dao
.
delete
(
condition
);
this
.
dao
.
delete
(
condition
);
Set
<
Long
>
curSet
=
query
.
getMenuIdList
().
stream
().
collect
(
Collectors
.
toSet
());
Set
<
Long
>
curSet
=
query
.
getMenuIdList
().
stream
().
collect
(
Collectors
.
toSet
());
...
@@ -70,27 +92,27 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
...
@@ -70,27 +92,27 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
}
}
@Override
@Override
public
Map
<
Long
,
List
<
Long
>>
getMenuIdByRole
(
Long
roleId
)
{
public
Map
<
Long
,
List
<
Long
>>
getMenuIdByRole
(
Long
roleId
)
{
RoleAuthQuery
condition
=
new
RoleAuthQuery
();
RoleAuthQuery
condition
=
new
RoleAuthQuery
();
condition
.
setRoleId
(
roleId
);
condition
.
setRoleId
(
roleId
);
List
<
RoleAuthEntity
>
roleModelEntities
=
this
.
find
(
condition
);
List
<
RoleAuthEntity
>
roleModelEntities
=
this
.
find
(
condition
);
if
(
CollectionUtils
.
isNotEmpty
(
roleModelEntities
))
{
if
(
CollectionUtils
.
isNotEmpty
(
roleModelEntities
))
{
List
<
Long
>
menuIds
=
roleModelEntities
.
stream
().
map
(
RoleAuthEntity:
:
getMenuId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
menuIds
=
roleModelEntities
.
stream
().
map
(
RoleAuthEntity:
:
getMenuId
).
collect
(
Collectors
.
toList
());
MenuQuery
query1
=
new
MenuQuery
();
MenuQuery
query1
=
new
MenuQuery
();
query1
.
setIdList
(
menuIds
);
query1
.
setIdList
(
menuIds
);
List
<
MenuEntity
>
menuEntities
=
menuService
.
find
(
query1
);
List
<
MenuEntity
>
menuEntities
=
menuService
.
find
(
query1
);
Map
<
Long
,
List
<
Long
>>
map
=
new
HashMap
<>();
Map
<
Long
,
List
<
Long
>>
map
=
new
HashMap
<>();
menuEntities
.
forEach
(
m
->
{
menuEntities
.
forEach
(
m
->
{
if
(
map
.
containsKey
(
m
.
getParentId
()))
{
if
(
map
.
containsKey
(
m
.
getParentId
()))
{
map
.
get
(
m
.
getParentId
()).
add
(
m
.
getId
());
map
.
get
(
m
.
getParentId
()).
add
(
m
.
getId
());
}
else
{
}
else
{
List
<
Long
>
menuIdList
=
new
ArrayList
<>();
List
<
Long
>
menuIdList
=
new
ArrayList
<>();
menuIdList
.
add
(
m
.
getId
());
menuIdList
.
add
(
m
.
getId
());
map
.
put
(
m
.
getParentId
(),
menuIdList
);
map
.
put
(
m
.
getParentId
(),
menuIdList
);
}
}
});
});
return
map
;
return
map
;
}
else
{
}
else
{
return
Collections
.
emptyMap
();
return
Collections
.
emptyMap
();
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/role/web/RoleAuthController.java
View file @
e7e17b9b
...
@@ -37,6 +37,27 @@ public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAu
...
@@ -37,6 +37,27 @@ public class RoleAuthController extends BaseCRUDJsonBodyMappingController<RoleAu
super
.
init
(
model
,
context
);
super
.
init
(
model
,
context
);
}
}
/**
* 分配资源
*/
@PostMapping
(
value
=
"distributionSource"
)
public
String
distributionUser
(
@RequestBody
RoleAuthQuery
query
)
{
try
{
service
.
doDistributionSource
(
query
);
JSONObject
ret
=
new
JSONObject
();
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_SUCCESS
);
return
ret
.
toJSONString
();
}
catch
(
Exception
e
)
{
log
.
error
(
"分配角色资源错误"
,
e
);
JSONObject
ret
=
new
JSONObject
();
ret
.
put
(
KEY_RESULT_CODE
,
VALUE_RESULT_FAILURE
);
ret
.
put
(
KEY_RESULT_MSG
,
super
.
convertException
(
e
));
return
ret
.
toJSONString
();
}
}
/**
/**
* 分配菜单到角色
* 分配菜单到角色
*/
*/
...
...
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/user/model/vo/UserVo.java
View file @
e7e17b9b
...
@@ -57,6 +57,11 @@ public class UserVo extends BaseEntityLong {
...
@@ -57,6 +57,11 @@ public class UserVo extends BaseEntityLong {
private
String
oldPwd
;
private
String
oldPwd
;
private
String
newPwd
;
private
String
newPwd
;
/**
* 菜单栏
*/
private
String
menuUrl
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
UserQuery
userEntity
=
new
UserQuery
();
UserQuery
userEntity
=
new
UserQuery
();
...
...
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/user/service/UserService.java
View file @
e7e17b9b
...
@@ -4,6 +4,7 @@ import com.mortals.framework.exception.AppException;
...
@@ -4,6 +4,7 @@ import com.mortals.framework.exception.AppException;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.Context
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.PageInfo
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.ICRUDCacheService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.framework.service.ICRUDService
;
import
com.mortals.xhx.module.user.model.UserEntity
;
import
com.mortals.xhx.module.user.model.UserEntity
;
import
com.mortals.xhx.module.user.model.UserEntityExt
;
import
com.mortals.xhx.module.user.model.UserEntityExt
;
...
@@ -16,7 +17,7 @@ import com.mortals.xhx.module.user.model.UserEntityExt;
...
@@ -16,7 +17,7 @@ import com.mortals.xhx.module.user.model.UserEntityExt;
* @author zxfei
* @author zxfei
* @date 2022-05-25
* @date 2022-05-25
*/
*/
public
interface
UserService
extends
ICRUD
Service
<
UserEntity
,
Long
>
{
public
interface
UserService
extends
ICRUD
CacheService
<
UserEntity
,
Long
>
{
/**
/**
* 用户登录
* 用户登录
*
*
...
...
This diff is collapsed.
Click to expand it.
portal-manager/src/main/java/com/mortals/xhx/module/user/service/impl/UserServiceImpl.java
View file @
e7e17b9b
...
@@ -12,6 +12,7 @@ import com.mortals.framework.model.PageInfo;
...
@@ -12,6 +12,7 @@ import com.mortals.framework.model.PageInfo;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.model.Result
;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.framework.service.IAuthTokenService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.ICacheService
;
import
com.mortals.framework.service.impl.AbstractCRUDCacheServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.service.impl.AbstractCRUDServiceImpl
;
import
com.mortals.framework.util.*
;
import
com.mortals.framework.util.*
;
import
com.mortals.xhx.common.code.YesNoEnum
;
import
com.mortals.xhx.common.code.YesNoEnum
;
...
@@ -44,7 +45,7 @@ import java.util.stream.Collectors;
...
@@ -44,7 +45,7 @@ import java.util.stream.Collectors;
* @date 2022-05-25
* @date 2022-05-25
*/
*/
@Service
(
"userService"
)
@Service
(
"userService"
)
public
class
UserServiceImpl
extends
AbstractCRUDServiceImpl
<
UserDao
,
UserEntity
,
Long
>
implements
UserService
{
public
class
UserServiceImpl
extends
AbstractCRUD
Cache
ServiceImpl
<
UserDao
,
UserEntity
,
Long
>
implements
UserService
{
@Autowired
@Autowired
private
MenuService
menuService
;
private
MenuService
menuService
;
@Autowired
@Autowired
...
@@ -60,8 +61,17 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
...
@@ -60,8 +61,17 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
@Autowired
@Autowired
private
UserPwdRecordDao
userPwdRecordDao
;
private
UserPwdRecordDao
userPwdRecordDao
;
/**
* @param data
* @return
*/
@Override
protected
String
getExtKey
(
UserEntity
data
)
{
return
data
.
getLoginName
();
}
/* @Override
/* @Override
protected void findAfter(UserEntity entity, PageInfo pageInfo, Context context, List<UserEntity> list) throws AppException {
protected void findAfter(UserEntity entity, PageInfo pageInfo, Context context, List<UserEntity> list) throws AppException {
Map<Long, String> roleMap = roleService.find(new RoleQuery()).stream().collect(Collectors.toMap(x -> x.getId(), y -> y.getName()));
Map<Long, String> roleMap = roleService.find(new RoleQuery()).stream().collect(Collectors.toMap(x -> x.getId(), y -> y.getName()));
List<Long> userIdList = list.stream().map(item -> item.getId()).collect(Collectors.toList());
List<Long> userIdList = list.stream().map(item -> item.getId()).collect(Collectors.toList());
...
@@ -79,22 +89,22 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
...
@@ -79,22 +89,22 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
private
void
doHandlerUser
(
UserEntity
entity
)
throws
AppException
{
private
void
doHandlerUser
(
UserEntity
entity
)
throws
AppException
{
if
(
StringUtils
.
isNotEmpty
(
entity
.
getLoginPwd
()))
{
if
(
StringUtils
.
isNotEmpty
(
entity
.
getLoginPwd
()))
{
if
(!
Solution
.
strongPasswordCheckerII
(
entity
.
getLoginPwd
()))
{
if
(!
Solution
.
strongPasswordCheckerII
(
entity
.
getLoginPwd
()))
{
throw
new
AppException
(
"新密码至少八位以上,包含大小写加特殊字符加数字"
);
throw
new
AppException
(
"新密码至少八位以上,包含大小写加特殊字符加数字"
);
}
}
try
{
try
{
if
(
StringUtils
.
isEmpty
(
entity
.
getSaltKey
()))
{
if
(
StringUtils
.
isEmpty
(
entity
.
getSaltKey
()))
{
String
saltKey
=
SecurityCode
.
getSecurityCode
(
6
,
SecurityCode
.
SecurityCodeLevel
.
Medium
,
false
);
String
saltKey
=
SecurityCode
.
getSecurityCode
(
6
,
SecurityCode
.
SecurityCodeLevel
.
Medium
,
false
);
entity
.
setSaltKey
(
saltKey
);
entity
.
setSaltKey
(
saltKey
);
}
}
entity
.
setLoginPwd
(
SecurityUtil
.
md5DoubleEncoding
(
entity
.
getLoginPwd
()
+
entity
.
getSaltKey
()));
entity
.
setLoginPwd
(
SecurityUtil
.
md5DoubleEncoding
(
entity
.
getLoginPwd
()
+
entity
.
getSaltKey
()));
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
AppException
(
"密码转换异常"
);
throw
new
AppException
(
"密码转换异常"
);
}
}
if
(
entity
.
getId
()!=
null
)
{
if
(
entity
.
getId
()
!=
null
)
{
UserEntity
old
=
this
.
get
(
entity
.
getId
());
UserEntity
old
=
this
.
get
(
entity
.
getId
());
if
(
old
!=
null
)
{
if
(
old
!=
null
)
{
if
(!
old
.
getLoginPwd
().
equals
(
entity
.
getLoginPwd
()))
{
if
(!
old
.
getLoginPwd
().
equals
(
entity
.
getLoginPwd
()))
{
//判断新密码与最近五次修改密码是否相同
//判断新密码与最近五次修改密码是否相同
UserPwdRecordQuery
recordQuery
=
new
UserPwdRecordQuery
();
UserPwdRecordQuery
recordQuery
=
new
UserPwdRecordQuery
();
recordQuery
.
setUserId
(
entity
.
getId
());
recordQuery
.
setUserId
(
entity
.
getId
());
...
@@ -103,10 +113,10 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
...
@@ -103,10 +113,10 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
add
(
new
OrderCol
(
"a.createTime"
,
"desc"
));
add
(
new
OrderCol
(
"a.createTime"
,
"desc"
));
}
}
});
});
List
<
UserPwdRecordEntity
>
recordEntityList
=
userPwdRecordDao
.
getList
(
recordQuery
,
0
,
5
);
List
<
UserPwdRecordEntity
>
recordEntityList
=
userPwdRecordDao
.
getList
(
recordQuery
,
0
,
5
);
if
(
CollectionUtils
.
isNotEmpty
(
recordEntityList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
recordEntityList
))
{
for
(
UserPwdRecordEntity
item:
recordEntityList
)
{
for
(
UserPwdRecordEntity
item
:
recordEntityList
)
{
if
(
item
.
getLoginPwd
().
equals
(
entity
.
getLoginPwd
()))
{
if
(
item
.
getLoginPwd
().
equals
(
entity
.
getLoginPwd
()))
{
throw
new
AppException
(
"新密码不能与最近五次密码相同!"
);
throw
new
AppException
(
"新密码不能与最近五次密码相同!"
);
}
}
}
}
...
@@ -178,39 +188,39 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
...
@@ -178,39 +188,39 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
if
(
sysUser
==
null
||
!
sysUser
.
getLoginName
().
equals
(
loginName
))
{
if
(
sysUser
==
null
||
!
sysUser
.
getLoginName
().
equals
(
loginName
))
{
throw
new
AppException
(
"用户名不存在!"
);
throw
new
AppException
(
"用户名不存在!"
);
}
}
if
(
sysUser
.
getErrorCount
()==
null
)
{
if
(
sysUser
.
getErrorCount
()
==
null
)
{
sysUser
.
setErrorCount
(
0
);
sysUser
.
setErrorCount
(
0
);
}
}
if
(
sysUser
.
getLoginLock
()==
null
)
{
if
(
sysUser
.
getLoginLock
()
==
null
)
{
sysUser
.
setLoginLock
(
0
);
sysUser
.
setLoginLock
(
0
);
}
}
if
(
sysUser
.
getLoginLock
()
==
1
&&
sysUser
.
getLockTime
()!=
null
)
{
if
(
sysUser
.
getLoginLock
()
==
1
&&
sysUser
.
getLockTime
()
!=
null
)
{
String
nowStr
=
DateUtils
.
getCurrStrDate
();
String
nowStr
=
DateUtils
.
getCurrStrDate
();
String
loginDateStr
=
DateUtils
.
getDateTime
(
sysUser
.
getLockTime
(),
"yyyy-MM-dd"
);
String
loginDateStr
=
DateUtils
.
getDateTime
(
sysUser
.
getLockTime
(),
"yyyy-MM-dd"
);
if
(
nowStr
.
equals
(
loginDateStr
))
{
if
(
nowStr
.
equals
(
loginDateStr
))
{
throw
new
AppException
(
"此账号当天密码错误次数已达上限,已被锁定"
);
throw
new
AppException
(
"此账号当天密码错误次数已达上限,已被锁定"
);
}
}
}
}
try
{
try
{
if
(
StringUtils
.
isNotEmpty
(
sysUser
.
getSaltKey
()))
{
if
(
StringUtils
.
isNotEmpty
(
sysUser
.
getSaltKey
()))
{
password
+=
sysUser
.
getSaltKey
();
password
+=
sysUser
.
getSaltKey
();
}
}
if
(!
sysUser
.
getLoginPwd
().
equals
(
SecurityUtil
.
md5DoubleEncoding
(
password
)))
{
if
(!
sysUser
.
getLoginPwd
().
equals
(
SecurityUtil
.
md5DoubleEncoding
(
password
)))
{
UserEntity
update
=
new
UserEntity
();
UserEntity
update
=
new
UserEntity
();
update
.
setId
(
sysUser
.
getId
());
update
.
setId
(
sysUser
.
getId
());
update
.
setErrorCount
(
sysUser
.
getErrorCount
()
+
1
);
update
.
setErrorCount
(
sysUser
.
getErrorCount
()
+
1
);
if
(
update
.
getErrorCount
()==
5
)
{
if
(
update
.
getErrorCount
()
==
5
)
{
update
.
setLoginLock
(
1
);
update
.
setLoginLock
(
1
);
update
.
setLockTime
(
new
Date
());
update
.
setLockTime
(
new
Date
());
}
}
this
.
dao
.
update
(
update
);
this
.
dao
.
update
(
update
);
throw
new
AppException
(
"登录密码错误!"
);
throw
new
AppException
(
"登录密码错误!"
);
}
else
{
}
else
{
if
(
sysUser
.
getLastUpdatePwdTime
()!=
null
)
{
if
(
sysUser
.
getLastUpdatePwdTime
()
!=
null
)
{
long
day
=
DateUtils
.
getBetween
(
sysUser
.
getLastUpdatePwdTime
(),
new
Date
(),
2
);
long
day
=
DateUtils
.
getBetween
(
sysUser
.
getLastUpdatePwdTime
(),
new
Date
(),
2
);
if
(
day
>=
90
)
{
if
(
day
>=
90
)
{
throw
new
AppException
(
99998
,
"密码已超过三个月没有更改,请修改以后再登录"
);
throw
new
AppException
(
99998
,
"密码已超过三个月没有更改,请修改以后再登录"
);
}
}
}
}
}
}
...
@@ -261,13 +271,13 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
...
@@ -261,13 +271,13 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
throw
new
AppException
(
"帐号错误!"
);
throw
new
AppException
(
"帐号错误!"
);
}
}
try
{
try
{
if
(
StringUtils
.
isNotEmpty
(
sysUser
.
getSaltKey
()))
{
if
(
StringUtils
.
isNotEmpty
(
sysUser
.
getSaltKey
()))
{
oldPwd
+=
sysUser
.
getSaltKey
();
oldPwd
+=
sysUser
.
getSaltKey
();
}
}
if
(!
sysUser
.
getLoginPwd
().
equals
(
SecurityUtil
.
md5DoubleEncoding
(
oldPwd
)))
{
if
(!
sysUser
.
getLoginPwd
().
equals
(
SecurityUtil
.
md5DoubleEncoding
(
oldPwd
)))
{
throw
new
AppException
(
"原始密码错误!"
);
throw
new
AppException
(
"原始密码错误!"
);
}
}
if
(!
Solution
.
strongPasswordCheckerII
(
newPwd
))
{
if
(!
Solution
.
strongPasswordCheckerII
(
newPwd
))
{
throw
new
AppException
(
"新密码至少八位以上,包含大小写加特殊字符加数字"
);
throw
new
AppException
(
"新密码至少八位以上,包含大小写加特殊字符加数字"
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -275,8 +285,8 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
...
@@ -275,8 +285,8 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
}
}
try
{
try
{
if
(
StringUtils
.
isEmpty
(
sysUser
.
getSaltKey
()))
{
if
(
StringUtils
.
isEmpty
(
sysUser
.
getSaltKey
()))
{
String
saltKey
=
SecurityCode
.
getSecurityCode
(
6
,
SecurityCode
.
SecurityCodeLevel
.
Medium
,
false
);
String
saltKey
=
SecurityCode
.
getSecurityCode
(
6
,
SecurityCode
.
SecurityCodeLevel
.
Medium
,
false
);
sysUser
.
setSaltKey
(
saltKey
);
sysUser
.
setSaltKey
(
saltKey
);
}
}
newPwd
+=
sysUser
.
getSaltKey
();
newPwd
+=
sysUser
.
getSaltKey
();
...
@@ -289,10 +299,10 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
...
@@ -289,10 +299,10 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
add
(
new
OrderCol
(
"a.createTime"
,
"desc"
));
add
(
new
OrderCol
(
"a.createTime"
,
"desc"
));
}
}
});
});
List
<
UserPwdRecordEntity
>
recordEntityList
=
userPwdRecordDao
.
getList
(
recordQuery
,
0
,
5
);
List
<
UserPwdRecordEntity
>
recordEntityList
=
userPwdRecordDao
.
getList
(
recordQuery
,
0
,
5
);
if
(
CollectionUtils
.
isNotEmpty
(
recordEntityList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
recordEntityList
))
{
for
(
UserPwdRecordEntity
item:
recordEntityList
)
{
for
(
UserPwdRecordEntity
item
:
recordEntityList
)
{
if
(
item
.
getLoginPwd
().
equals
(
sysUser
.
getLoginPwd
()))
{
if
(
item
.
getLoginPwd
().
equals
(
sysUser
.
getLoginPwd
()))
{
throw
new
AppException
(
"新密码不能与最近五次密码相同!"
);
throw
new
AppException
(
"新密码不能与最近五次密码相同!"
);
}
}
}
}
...
@@ -445,8 +455,8 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
...
@@ -445,8 +455,8 @@ public class UserServiceImpl extends AbstractCRUDServiceImpl<UserDao, UserEntity
throw
new
AppException
(
"帐号错误!"
);
throw
new
AppException
(
"帐号错误!"
);
}
}
try
{
try
{
if
(
StringUtils
.
isEmpty
(
sysUser
.
getSaltKey
()))
{
if
(
StringUtils
.
isEmpty
(
sysUser
.
getSaltKey
()))
{
String
saltKey
=
SecurityCode
.
getSecurityCode
(
6
,
SecurityCode
.
SecurityCodeLevel
.
Medium
,
false
);
String
saltKey
=
SecurityCode
.
getSecurityCode
(
6
,
SecurityCode
.
SecurityCodeLevel
.
Medium
,
false
);
sysUser
.
setSaltKey
(
saltKey
);
sysUser
.
setSaltKey
(
saltKey
);
}
}
sysUser
.
setLoginPwd
(
SecurityUtil
.
md5DoubleEncoding
(
newPwd
+
sysUser
.
getSaltKey
()));
sysUser
.
setLoginPwd
(
SecurityUtil
.
md5DoubleEncoding
(
newPwd
+
sysUser
.
getSaltKey
()));
...
...
This diff is collapsed.
Click to expand it.
portal-manager/src/main/resources/sqlmap/base/system/resource.xml
0 → 100644
View file @
e7e17b9b
This diff is collapsed.
Click to expand it.
portal-manager/src/main/resources/sqlmap/base/system/resourceExt.xml
0 → 100644
View file @
e7e17b9b
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"mybatis-3-mapper.dtd">
<mapper
namespace=
"com.mortals.xhx.base.system.resource.dao.ibatis.ResourceDaoImpl"
>
<!-- 获取列表 -->
<select
id=
"getListByUserId"
parameterType=
"paramDto"
resultMap=
"ResourceEntity-Map"
>
select
<include
refid=
"_columns"
/>
from mortals_xhx_resource as a
where a.authType in(0,1,2) or a.id IN
(select resourceId
from mortals_xhx_role_auth as b
left join mortals_xhx_role_user as c
on b.roleId=c.roleId
where c.userId=#{condition.userId})
</select>
<select
id=
"getAllByUserType"
parameterType=
"java.util.HashMap"
resultMap=
"ResourceEntity-Map"
>
select
<include
refid=
"_columns"
/>
from mortals_xhx_resource as a
where a.userType=#{userType}
</select>
</mapper>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
portal-manager/src/main/resources/sqlmap/module/role/RoleAuthMapper.xml
View file @
e7e17b9b
This diff is collapsed.
Click to expand it.
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