Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzuaa
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzuaa
提交
932968e6
提交
932968e6
编写于
12月 14, 2020
作者:
ibizdev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
zoo457790531 发布系统代码 [ibiz-uaa,UAA鉴权]
上级
c92a1f3c
变更
8
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
400 行增加
和
3 行删除
+400
-3
sys-roles.ts
app_web/src/mock/entity/sys-roles/sys-roles.ts
+38
-0
sys-role-service-base.ts
app_web/src/service/sys-role/sys-role-service-base.ts
+14
-0
SysRoleExService.java
.../cn/ibizlab/core/extensions/service/SysRoleExService.java
+35
-0
ISysRoleService.java
...ain/java/cn/ibizlab/core/uaa/service/ISysRoleService.java
+2
-0
SysRoleServiceImpl.java
.../cn/ibizlab/core/uaa/service/impl/SysRoleServiceImpl.java
+291
-0
h2_table.xml
ibzuaa-core/src/main/resources/liquibase/h2_table.xml
+2
-2
systemResource.json
...aa-core/src/main/resources/permission/systemResource.json
+1
-1
SysRoleResource.java
...pi/src/main/java/cn/ibizlab/api/rest/SysRoleResource.java
+17
-0
未找到文件。
app_web/src/mock/entity/sys-roles/sys-roles.ts
浏览文件 @
932968e6
...
...
@@ -233,6 +233,44 @@ mock.onPost(new RegExp(/^\/sysroles\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).repl
return
[
status
,
data
];
});
// NoRepeat
mock
.
onPost
(
new
RegExp
(
/^
\/
sysroles
\/?([
a-zA-Z0-9
\-\;]{0,35})\/
norepeat$/
)).
reply
((
config
:
any
)
=>
{
console
.
groupCollapsed
(
"实体:sysrole 方法: NoRepeat"
);
console
.
table
({
url
:
config
.
url
,
method
:
config
.
method
,
data
:
config
.
data
});
let
status
=
MockAdapter
.
mockStatus
(
config
);
if
(
status
!==
200
)
{
return
[
status
,
null
];
}
const
paramArray
:
Array
<
any
>
=
[
'roleid'
];
const
matchArray
:
any
=
new
RegExp
(
/^
\/
sysroles
\/([
a-zA-Z0-9
\-\;]{1,35})\/
norepeat$/
).
exec
(
config
.
url
);
let
tempValue
:
any
=
{};
if
(
matchArray
&&
matchArray
.
length
>
1
&&
paramArray
&&
paramArray
.
length
>
0
){
paramArray
.
forEach
((
item
:
any
,
index
:
number
)
=>
{
Object
.
defineProperty
(
tempValue
,
item
,
{
enumerable
:
true
,
value
:
matchArray
[
index
+
1
]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.roleid, tempValue.roleid));
let
data
=
JSON
.
parse
(
config
.
data
);
mockDatas
.
forEach
((
item
)
=>
{
if
(
item
[
'roleid'
]
==
tempValue
[
'roleid'
]
){
for
(
let
value
in
data
){
if
(
item
.
hasOwnProperty
(
value
)){
item
[
value
]
=
data
[
value
];
}
}
}
})
console
.
groupCollapsed
(
"response数据 status: "
+
status
+
" data: "
);
console
.
table
(
data
);
console
.
groupEnd
();
console
.
groupEnd
();
return
[
status
,
data
];
});
// Save
mock
.
onPost
(
new
RegExp
(
/^
\/
sysroles
\/?([
a-zA-Z0-9
\-\;]{0,35})\/
save$/
)).
reply
((
config
:
any
)
=>
{
console
.
groupCollapsed
(
"实体:sysrole 方法: Save"
);
...
...
app_web/src/service/sys-role/sys-role-service-base.ts
浏览文件 @
932968e6
...
...
@@ -155,6 +155,20 @@ export default class SysRoleServiceBase extends EntityService {
return
res
;
}
/**
* NoRepeat接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof SysRoleServiceBase
*/
public
async
NoRepeat
(
context
:
any
=
{},
data
:
any
=
{},
isloading
?:
boolean
):
Promise
<
any
>
{
let
res
:
any
=
Http
.
getInstance
().
post
(
`/sysroles/
${
context
.
sysrole
}
/norepeat`
,
data
,
isloading
);
return
res
;
}
/**
* Save接口方法
*
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/extensions/service/SysRoleExService.java
0 → 100644
浏览文件 @
932968e6
package
cn
.
ibizlab
.
core
.
extensions
.
service
;
import
cn.ibizlab.core.uaa.service.impl.SysRoleServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
cn.ibizlab.core.uaa.domain.SysRole
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.context.annotation.Primary
;
import
java.util.*
;
/**
* 实体[系统角色] 自定义服务对象
*/
@Slf4j
@Primary
@Service
(
"SysRoleExService"
)
public
class
SysRoleExService
extends
SysRoleServiceImpl
{
@Override
protected
Class
currentModelClass
()
{
return
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
ReflectionKit
.
getSuperClassGenericType
(
this
.
getClass
().
getSuperclass
(),
1
);
}
/**
* [NoRepeat:角色去重查询] 行为扩展:去除父子关系
* @param et
* @return
*/
@Override
@Transactional
public
SysRole
noRepeat
(
SysRole
et
)
{
return
super
.
noRepeat
(
et
);
}
}
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/service/ISysRoleService.java
浏览文件 @
932968e6
...
...
@@ -37,6 +37,8 @@ public interface ISysRoleService extends IService<SysRole> {
SysRole
get
(
String
key
);
SysRole
getDraft
(
SysRole
et
);
boolean
checkKey
(
SysRole
et
);
SysRole
noRepeat
(
SysRole
et
);
boolean
noRepeatBatch
(
List
<
SysRole
>
etList
);
boolean
save
(
SysRole
et
);
@CacheEvict
(
value
=
"sysrole"
,
allEntries
=
true
)
void
saveBatch
(
List
<
SysRole
>
list
);
...
...
ibzuaa-core/src/main/java/cn/ibizlab/core/uaa/service/impl/SysRoleServiceImpl.java
0 → 100644
浏览文件 @
932968e6
package
cn
.
ibizlab
.
core
.
uaa
.
service
.
impl
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Map
;
import
java.util.HashSet
;
import
java.util.HashMap
;
import
java.util.Collection
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.math.BigInteger
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cglib.beans.BeanCopier
;
import
org.springframework.stereotype.Service
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.context.annotation.Lazy
;
import
cn.ibizlab.core.uaa.domain.SysRole
;
import
cn.ibizlab.core.uaa.filter.SysRoleSearchContext
;
import
cn.ibizlab.core.uaa.service.ISysRoleService
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
cn.ibizlab.core.uaa.mapper.SysRoleMapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.util.StringUtils
;
/**
* 实体[系统角色] 服务对象接口实现
*/
@Slf4j
@Service
(
"SysRoleServiceImpl"
)
public
class
SysRoleServiceImpl
extends
ServiceImpl
<
SysRoleMapper
,
SysRole
>
implements
ISysRoleService
{
@Autowired
@Lazy
protected
cn
.
ibizlab
.
core
.
uaa
.
service
.
ISysRolePermissionService
sysrolepermissionService
;
protected
cn
.
ibizlab
.
core
.
uaa
.
service
.
ISysRoleService
sysroleService
=
this
;
@Autowired
@Lazy
protected
cn
.
ibizlab
.
core
.
uaa
.
service
.
ISysUserRoleService
sysuserroleService
;
protected
int
batchSize
=
500
;
@Override
@Transactional
public
boolean
create
(
SysRole
et
)
{
fillParentData
(
et
);
if
(!
this
.
retBool
(
this
.
baseMapper
.
insert
(
et
)))
{
return
false
;
}
CachedBeanCopier
.
copy
(
get
(
et
.
getRoleid
()),
et
);
return
true
;
}
@Override
@Transactional
public
void
createBatch
(
List
<
SysRole
>
list
)
{
list
.
forEach
(
item
->
fillParentData
(
item
));
this
.
saveBatch
(
list
,
batchSize
);
}
@Override
@Transactional
public
boolean
update
(
SysRole
et
)
{
fillParentData
(
et
);
if
(!
update
(
et
,
(
Wrapper
)
et
.
getUpdateWrapper
(
true
).
eq
(
"sys_roleid"
,
et
.
getRoleid
())))
{
return
false
;
}
CachedBeanCopier
.
copy
(
get
(
et
.
getRoleid
()),
et
);
return
true
;
}
@Override
@Transactional
public
void
updateBatch
(
List
<
SysRole
>
list
)
{
list
.
forEach
(
item
->
fillParentData
(
item
));
updateBatchById
(
list
,
batchSize
);
}
@Override
@Transactional
public
boolean
remove
(
String
key
)
{
sysrolepermissionService
.
removeByRoleid
(
key
);
sysuserroleService
.
removeByRoleid
(
key
);
boolean
result
=
removeById
(
key
);
return
result
;
}
@Override
@Transactional
public
void
removeBatch
(
Collection
<
String
>
idList
)
{
sysrolepermissionService
.
removeByRoleid
(
idList
);
sysuserroleService
.
removeByRoleid
(
idList
);
removeByIds
(
idList
);
}
@Override
@Transactional
public
SysRole
get
(
String
key
)
{
SysRole
et
=
getById
(
key
);
if
(
et
==
null
){
et
=
new
SysRole
();
et
.
setRoleid
(
key
);
}
else
{
}
return
et
;
}
@Override
public
SysRole
getDraft
(
SysRole
et
)
{
fillParentData
(
et
);
return
et
;
}
@Override
public
boolean
checkKey
(
SysRole
et
)
{
return
(!
ObjectUtils
.
isEmpty
(
et
.
getRoleid
()))
&&
(!
Objects
.
isNull
(
this
.
getById
(
et
.
getRoleid
())));
}
@Override
@Transactional
public
SysRole
noRepeat
(
SysRole
et
)
{
//自定义代码
return
et
;
}
@Override
@Transactional
public
boolean
noRepeatBatch
(
List
<
SysRole
>
etList
)
{
for
(
SysRole
et
:
etList
)
{
noRepeat
(
et
);
}
return
true
;
}
@Override
@Transactional
public
boolean
save
(
SysRole
et
)
{
if
(!
saveOrUpdate
(
et
))
{
return
false
;
}
return
true
;
}
@Override
@Transactional
public
boolean
saveOrUpdate
(
SysRole
et
)
{
if
(
null
==
et
)
{
return
false
;
}
else
{
return
checkKey
(
et
)
?
this
.
update
(
et
)
:
this
.
create
(
et
);
}
}
@Override
@Transactional
public
boolean
saveBatch
(
Collection
<
SysRole
>
list
)
{
list
.
forEach
(
item
->
fillParentData
(
item
));
saveOrUpdateBatch
(
list
,
batchSize
);
return
true
;
}
@Override
@Transactional
public
void
saveBatch
(
List
<
SysRole
>
list
)
{
list
.
forEach
(
item
->
fillParentData
(
item
));
saveOrUpdateBatch
(
list
,
batchSize
);
}
@Override
public
List
<
SysRole
>
selectByProleid
(
String
roleid
)
{
return
baseMapper
.
selectByProleid
(
roleid
);
}
@Override
public
void
removeByProleid
(
String
roleid
)
{
this
.
remove
(
new
QueryWrapper
<
SysRole
>().
eq
(
"proleid"
,
roleid
));
}
/**
* 查询集合 DEFAULT
*/
@Override
public
Page
<
SysRole
>
searchDefault
(
SysRoleSearchContext
context
)
{
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
<
SysRole
>
pages
=
baseMapper
.
searchDefault
(
context
.
getPages
(),
context
,
context
.
getSelectCond
());
return
new
PageImpl
<
SysRole
>(
pages
.
getRecords
(),
context
.
getPageable
(),
pages
.
getTotal
());
}
/**
* 查询集合 数据查询
*/
@Override
public
Page
<
SysRole
>
searchNoRepeat
(
SysRoleSearchContext
context
)
{
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
<
SysRole
>
pages
=
baseMapper
.
searchNoRepeat
(
context
.
getPages
(),
context
,
context
.
getSelectCond
());
return
new
PageImpl
<
SysRole
>(
pages
.
getRecords
(),
context
.
getPageable
(),
pages
.
getTotal
());
}
/**
* 为当前实体填充父数据(外键值文本、外键值附加数据)
* @param et
*/
private
void
fillParentData
(
SysRole
et
){
//实体关系[DER1N_SYS_ROLE_SYS_ROLE_PROLEID]
if
(!
ObjectUtils
.
isEmpty
(
et
.
getProleid
())){
cn
.
ibizlab
.
core
.
uaa
.
domain
.
SysRole
parent
=
et
.
getParent
();
if
(
ObjectUtils
.
isEmpty
(
parent
)){
cn
.
ibizlab
.
core
.
uaa
.
domain
.
SysRole
majorEntity
=
sysroleService
.
get
(
et
.
getProleid
());
et
.
setParent
(
majorEntity
);
parent
=
majorEntity
;
}
et
.
setProlename
(
parent
.
getRolename
());
}
}
@Override
public
List
<
JSONObject
>
select
(
String
sql
,
Map
param
){
return
this
.
baseMapper
.
selectBySQL
(
sql
,
param
);
}
@Override
@Transactional
public
boolean
execute
(
String
sql
,
Map
param
){
if
(
sql
==
null
||
sql
.
isEmpty
())
{
return
false
;
}
if
(
sql
.
toLowerCase
().
trim
().
startsWith
(
"insert"
))
{
return
this
.
baseMapper
.
insertBySQL
(
sql
,
param
);
}
if
(
sql
.
toLowerCase
().
trim
().
startsWith
(
"update"
))
{
return
this
.
baseMapper
.
updateBySQL
(
sql
,
param
);
}
if
(
sql
.
toLowerCase
().
trim
().
startsWith
(
"delete"
))
{
return
this
.
baseMapper
.
deleteBySQL
(
sql
,
param
);
}
log
.
warn
(
"暂未支持的SQL语法"
);
return
true
;
}
@Override
public
List
<
SysRole
>
getSysroleByIds
(
List
<
String
>
ids
)
{
return
this
.
listByIds
(
ids
);
}
@Override
public
List
<
SysRole
>
getSysroleByEntities
(
List
<
SysRole
>
entities
)
{
List
ids
=
new
ArrayList
();
for
(
SysRole
entity
:
entities
){
Serializable
id
=
entity
.
getRoleid
();
if
(!
ObjectUtils
.
isEmpty
(
id
)){
ids
.
add
(
id
);
}
}
if
(
ids
.
size
()>
0
)
{
return
this
.
listByIds
(
ids
);
}
else
{
return
entities
;
}
}
}
ibzuaa-core/src/main/resources/liquibase/h2_table.xml
浏览文件 @
932968e6
...
...
@@ -106,7 +106,7 @@
<!--输出实体[SYS_ROLE]数据结构 -->
<changeSet
author=
"root"
id=
"tab-sys_role-2
4
-5"
>
<changeSet
author=
"root"
id=
"tab-sys_role-2
6
-5"
>
<createTable
tableName=
"IBZROLE"
>
<column
name=
"SYS_ROLEID"
remarks=
""
type=
"VARCHAR(100)"
>
<constraints
primaryKey=
"true"
primaryKeyName=
"PK_SYS_ROLE_SYS_ROLEID"
/>
...
...
@@ -189,7 +189,7 @@
<!--输出实体[SYS_PSSYSTEM]外键关系 -->
<!--输出实体[SYS_PERMISSION]外键关系 -->
<!--输出实体[SYS_ROLE]外键关系 -->
<changeSet
author=
"root"
id=
"fk-sys_role-2
4
-9"
>
<changeSet
author=
"root"
id=
"fk-sys_role-2
6
-9"
>
<addForeignKeyConstraint
baseColumnNames=
"PROLEID"
baseTableName=
"IBZROLE"
constraintName=
"DER1N_SYS_ROLE_SYS_ROLE_PROLEI"
deferrable=
"false"
initiallyDeferred=
"false"
onDelete=
"RESTRICT"
onUpdate=
"RESTRICT"
referencedColumnNames=
"SYS_ROLEID"
referencedTableName=
"IBZROLE"
validate=
"true"
/>
</changeSet>
<!--输出实体[SYS_ROLE_PERMISSION]外键关系 -->
...
...
ibzuaa-core/src/main/resources/permission/systemResource.json
浏览文件 @
932968e6
...
...
@@ -48,7 +48,7 @@
"delogicname"
:
"系统角色"
,
"sysmoudle"
:{
"id"
:
"UAA"
,
"name"
:
"uaa"
},
"dedataset"
:[{
"id"
:
"Default"
,
"name"
:
"DEFAULT"
},{
"id"
:
"NoRepeat"
,
"name"
:
"数据查询"
}],
"deaction"
:[{
"id"
:
"Create"
,
"name"
:
"Create"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Update"
,
"name"
:
"Update"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Remove"
,
"name"
:
"Remove"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Get"
,
"name"
:
"Get"
,
"type"
:
"BUILTIN"
},{
"id"
:
"GetDraft"
,
"name"
:
"GetDraft"
,
"type"
:
"BUILTIN"
},{
"id"
:
"CheckKey"
,
"name"
:
"CheckKey"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Save"
,
"name"
:
"Save"
,
"type"
:
"BUILTIN"
}],
"deaction"
:[{
"id"
:
"Create"
,
"name"
:
"Create"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Update"
,
"name"
:
"Update"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Remove"
,
"name"
:
"Remove"
,
"type"
:
"BUILTIN"
},{
"id"
:
"Get"
,
"name"
:
"Get"
,
"type"
:
"BUILTIN"
},{
"id"
:
"GetDraft"
,
"name"
:
"GetDraft"
,
"type"
:
"BUILTIN"
},{
"id"
:
"CheckKey"
,
"name"
:
"CheckKey"
,
"type"
:
"BUILTIN"
},{
"id"
:
"
NoRepeat"
,
"name"
:
"角色去重查询"
,
"type"
:
"USERCUSTOM"
},{
"id"
:
"
Save"
,
"name"
:
"Save"
,
"type"
:
"BUILTIN"
}],
"datascope"
:[{
"id"
:
"all"
,
"name"
:
"全部数据"
},
{
"id"
:
"createman"
,
"name"
:
"创建人"
}]
}
,
{
...
...
ibzuaa-provider/ibzuaa-provider-api/src/main/java/cn/ibizlab/api/rest/SysRoleResource.java
浏览文件 @
932968e6
...
...
@@ -121,6 +121,23 @@ public class SysRoleResource {
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
sysroleService
.
checkKey
(
sysroleMapping
.
toDomain
(
sysroledto
)));
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzuaa-SysRole-NoRepeat-all')"
)
@ApiOperation
(
value
=
"角色去重查询"
,
tags
=
{
"系统角色"
},
notes
=
"角色去重查询"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/sysroles/{sysrole_id}/norepeat"
)
public
ResponseEntity
<
SysRoleDTO
>
noRepeat
(
@PathVariable
(
"sysrole_id"
)
String
sysrole_id
,
@RequestBody
SysRoleDTO
sysroledto
)
{
SysRole
domain
=
sysroleMapping
.
toDomain
(
sysroledto
);
domain
.
setRoleid
(
sysrole_id
);
domain
=
sysroleService
.
noRepeat
(
domain
);
sysroledto
=
sysroleMapping
.
toDto
(
domain
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
sysroledto
);
}
@PreAuthorize
(
"hasAnyAuthority('ROLE_SUPERADMIN','ibzuaa-SysRole-NoRepeat-all')"
)
@ApiOperation
(
value
=
"批量处理[角色去重查询]"
,
tags
=
{
"系统角色"
},
notes
=
"批量处理[角色去重查询]"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/sysroles/{sysrole_id}/norepeatbatch"
)
public
ResponseEntity
<
Boolean
>
noRepeatBatch
(
@RequestBody
List
<
SysRoleDTO
>
sysroledtos
)
{
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
sysroleService
.
noRepeatBatch
(
sysroleMapping
.
toDomain
(
sysroledtos
)));
}
@PreAuthorize
(
"hasPermission(this.sysroleMapping.toDomain(#sysroledto),'ibzuaa-SysRole-Save')"
)
@ApiOperation
(
value
=
"保存系统角色"
,
tags
=
{
"系统角色"
},
notes
=
"保存系统角色"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/sysroles/save"
)
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录