Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neo4jRelation
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
qiuchaofei
neo4jRelation
Commits
a2b7ac36
Commit
a2b7ac36
authored
Jul 14, 2023
by
leo330
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限开发
parent
e39e6d16
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
775 additions
and
10 deletions
+775
-10
pom.xml
pom.xml
+1
-1
AbstractOptionMaker.java
...e/metadata/metadataRelation/auth/AbstractOptionMaker.java
+49
-0
Auth.java
...va/com/keymobile/metadata/metadataRelation/auth/Auth.java
+7
-0
Authority.java
...m/keymobile/metadata/metadataRelation/auth/Authority.java
+145
-0
AuthorityChecker.java
...bile/metadata/metadataRelation/auth/AuthorityChecker.java
+51
-0
AuthorityService.java
...bile/metadata/metadataRelation/auth/AuthorityService.java
+80
-0
Feature.java
...com/keymobile/metadata/metadataRelation/auth/Feature.java
+41
-0
MetaRelationMaker.java
...ile/metadata/metadataRelation/auth/MetaRelationMaker.java
+86
-0
OptionImpl.java
.../keymobile/metadata/metadataRelation/auth/OptionImpl.java
+97
-0
OptionMaker.java
...keymobile/metadata/metadataRelation/auth/OptionMaker.java
+12
-0
OptionMakerFactory.java
...le/metadata/metadataRelation/auth/OptionMakerFactory.java
+37
-0
OptionPropertyDataImpl.java
...etadata/metadataRelation/auth/OptionPropertyDataImpl.java
+58
-0
Range.java
...a/com/keymobile/metadata/metadataRelation/auth/Range.java
+31
-0
AuthorityApi.java
...le/metadata/metadataRelation/controller/AuthorityApi.java
+61
-0
application-local.yml
src/main/resources/application-local.yml
+19
-9
No files found.
pom.xml
View file @
a2b7ac36
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
</parent>
</parent>
<properties>
<properties>
<auth.version>
3.0.12-release
</auth.version>
<auth.version>
4.0.9-beta
</auth.version>
</properties>
</properties>
<dependencies>
<dependencies>
...
...
src/main/java/com/keymobile/metadata/metadataRelation/auth/AbstractOptionMaker.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.stream.Collectors
;
public
abstract
class
AbstractOptionMaker
implements
OptionMaker
{
public
List
<
String
>
featureNameList
;
public
List
<
Integer
>
featureBitList
;
public
Integer
featureTotalBit
;
public
AbstractOptionMaker
()
{
featureNameList
=
getFeatureList
().
stream
().
map
(
feature
->
feature
.
getDisplayName
()).
collect
(
Collectors
.
toList
());
featureBitList
=
getFeatureList
().
stream
().
map
(
feature
->
feature
.
getBit
()).
collect
(
Collectors
.
toList
());
featureTotalBit
=
getFeatureList
().
stream
().
mapToInt
(
Feature:
:
getBit
).
sum
();
}
public
List
<
Feature
>
getFeatureList
()
{
return
Arrays
.
asList
(
new
Feature
(
"import"
,
"导入"
,
Auth
.
Btn
.
IMPORT_BIT
)
);
}
public
List
<
String
>
getFeatureNameList
()
{
return
getFeatureList
().
stream
().
map
(
feature
->
feature
.
getName
()).
collect
(
Collectors
.
toList
());
}
public
List
<
Integer
>
getFeatureBitList
()
{
return
getFeatureList
().
stream
().
map
(
feature
->
feature
.
getBit
()).
collect
(
Collectors
.
toList
());
}
public
Integer
getFeatureTotalBit
()
{
return
getFeatureList
().
stream
().
mapToInt
(
Feature:
:
getBit
).
sum
();
}
@Override
public
abstract
List
<
OptionPropertyDataImpl
>
getOptionProperties
();
@Override
public
abstract
List
<
OptionImpl
>
getOptions
(
Long
dataRoleId
,
Long
domainId
);
@Override
public
abstract
List
<
OptionImpl
>
saveOptions
(
Long
dataRoleId
,
List
<
OptionImpl
>
options
,
Long
domainId
);
public
abstract
List
<
Feature
>
getMyFeatureList
();
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/Auth.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
public
final
class
Auth
{
public
interface
Btn
{
int
IMPORT_BIT
=
1
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/Authority.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
import
org.springframework.data.annotation.Id
;
import
org.springframework.data.mongodb.core.index.Indexed
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.util.List
;
@Document
(
collection
=
"mdr_authority"
)
public
class
Authority
{
@Id
private
String
id
;
private
String
name
;
@Indexed
private
Long
domainId
;
@Indexed
private
Long
dataRoleId
;
@Indexed
private
String
range
;
@Indexed
private
String
optionId
;
@Indexed
private
String
optionPropertyType
;
private
String
optionDataType
;
private
Integer
grantedFeature
;
private
String
value
;
private
List
<
String
>
parentFullQualifiedName
;
public
Authority
()
{
}
public
Authority
(
String
id
,
Long
dataRoleId
,
String
range
,
String
optionId
,
Integer
grantedFeature
,
String
value
)
{
this
.
id
=
id
;
this
.
dataRoleId
=
dataRoleId
;
this
.
range
=
range
;
this
.
optionId
=
optionId
;
this
.
grantedFeature
=
grantedFeature
;
this
.
value
=
value
;
}
public
Authority
(
String
id
,
String
name
,
Long
domainId
,
Long
dataRoleId
,
String
range
,
String
optionId
,
String
optionPropertyType
,
Integer
grantedFeature
,
String
value
,
List
<
String
>
parentFullQualifiedName
)
{
this
.
id
=
id
;
this
.
name
=
name
;
this
.
domainId
=
domainId
;
this
.
dataRoleId
=
dataRoleId
;
this
.
range
=
range
;
this
.
optionId
=
optionId
;
this
.
optionPropertyType
=
optionPropertyType
;
this
.
grantedFeature
=
grantedFeature
;
this
.
value
=
value
;
this
.
parentFullQualifiedName
=
parentFullQualifiedName
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
Long
getDomainId
()
{
return
domainId
;
}
public
void
setDomainId
(
Long
domainId
)
{
this
.
domainId
=
domainId
;
}
public
Long
getDataRoleId
()
{
return
dataRoleId
;
}
public
void
setDataRoleId
(
Long
dataRoleId
)
{
this
.
dataRoleId
=
dataRoleId
;
}
public
String
getRange
()
{
return
range
;
}
public
void
setRange
(
String
range
)
{
this
.
range
=
range
;
}
public
String
getOptionId
()
{
return
optionId
;
}
public
void
setOptionId
(
String
optionId
)
{
this
.
optionId
=
optionId
;
}
public
Integer
getGrantedFeature
()
{
return
grantedFeature
;
}
public
void
setGrantedFeature
(
Integer
grantedFeature
)
{
this
.
grantedFeature
=
grantedFeature
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getOptionPropertyType
()
{
return
optionPropertyType
;
}
public
void
setOptionPropertyType
(
String
optionPropertyType
)
{
this
.
optionPropertyType
=
optionPropertyType
;
}
public
List
<
String
>
getParentFullQualifiedName
()
{
return
parentFullQualifiedName
;
}
public
void
setParentFullQualifiedName
(
List
<
String
>
parentFullQualifiedName
)
{
this
.
parentFullQualifiedName
=
parentFullQualifiedName
;
}
public
String
getOptionDataType
()
{
return
optionDataType
;
}
public
void
setOptionDataType
(
String
optionDataType
)
{
this
.
optionDataType
=
optionDataType
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/AuthorityChecker.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
import
com.keymobile.auth.common.security.GrantedAuthHelper
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
public
class
AuthorityChecker
{
@Autowired
private
MongoTemplate
mongoTemplate
;
public
Boolean
hasPermission
(
String
range
,
String
optionId
,
Integer
btnBit
,
Long
domainId
)
{
List
<
Long
>
dataRoleIdList
=
getUserDataRoleIds
();
Criteria
criteria
=
Criteria
.
where
(
"range"
).
is
(
range
)
.
and
(
"dataRoleId"
).
in
(
dataRoleIdList
).
and
(
"optionId"
).
is
(
optionId
);
List
<
Authority
>
authorityList
=
mongoTemplate
.
find
(
Query
.
query
(
criteria
),
Authority
.
class
);
boolean
result
=
false
;
for
(
Authority
authority
:
authorityList
)
{
if
((
authority
.
getGrantedFeature
()
&
btnBit
)
>
0
)
{
result
=
true
;
break
;
}
}
return
result
;
}
public
Boolean
hasPermission
(
Long
dataRoleId
,
String
range
,
String
optionId
,
Integer
btnBit
)
{
List
<
Authority
>
authorityList
=
mongoTemplate
.
find
(
Query
.
query
(
Criteria
.
where
(
"range"
).
is
(
range
)
.
and
(
"dataRoleId"
).
is
(
dataRoleId
).
and
(
"optionId"
).
is
(
optionId
)),
Authority
.
class
);
boolean
result
=
false
;
for
(
Authority
authority
:
authorityList
)
{
if
((
authority
.
getGrantedFeature
()
&
btnBit
)
>
0
)
{
result
=
true
;
break
;
}
}
return
result
;
}
private
List
<
Long
>
getUserDataRoleIds
()
{
return
GrantedAuthHelper
.
getGrantedRoles
();
}
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/AuthorityService.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
import
com.google.common.collect.Lists
;
import
com.keymobile.auth.common.security.GrantedAuthHelper
;
import
org.apache.commons.lang3.StringUtils
;
import
org.bson.BsonRegularExpression
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
public
class
AuthorityService
{
private
static
String
ROLE_ID_FIELD_NAME
=
"roleId"
;
private
static
String
MENU_ID_FIELD_NAME
=
"menuId"
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
OptionMakerFactory
optionMakerFactory
;
@Autowired
private
AuthorityChecker
authorityChecker
;
private
OptionMaker
optionMaker
;
public
List
<
OptionImpl
>
getOptions
(
Long
dataRoleId
,
String
range
,
Long
domainId
)
{
OptionMaker
optionMaker
=
optionMakerFactory
.
getOptionMakerByRange
(
range
);
return
optionMaker
.
getOptions
(
dataRoleId
,
domainId
);
}
public
List
<
OptionImpl
>
saveOptions
(
Long
dataRoleId
,
String
range
,
List
<
OptionImpl
>
optionList
,
Long
domainId
)
{
OptionMaker
optionMaker
=
optionMakerFactory
.
getOptionMakerByRange
(
range
);
return
optionMaker
.
saveOptions
(
dataRoleId
,
optionList
,
domainId
);
}
public
List
<
OptionPropertyDataImpl
>
getOptionProperties
(
String
range
)
{
OptionMaker
optionMaker
=
optionMakerFactory
.
getOptionMakerByRange
(
range
);
return
optionMaker
.
getOptionProperties
();
}
public
List
<
Map
<
String
,
Object
>>
listAllRanges
()
{
List
<
Map
<
String
,
Object
>>
rangeList
=
new
ArrayList
<>();
for
(
Range
range
:
Range
.
values
())
{
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"id"
,
range
.
getId
());
map
.
put
(
"name"
,
range
.
getName
());
rangeList
.
add
(
map
);
}
return
rangeList
;
}
public
List
<
Feature
>
getAllowButtons
(
String
range
,
String
optionId
,
Long
domainId
)
{
OptionMaker
optionMaker
=
optionMakerFactory
.
getOptionMakerByRange
(
range
);
AbstractOptionMaker
abstractOptionMaker
=
(
AbstractOptionMaker
)
optionMaker
;
List
<
Feature
>
featureList
=
abstractOptionMaker
.
getMyFeatureList
();
List
<
Feature
>
allowButtons
=
new
ArrayList
<>();
featureList
.
forEach
(
feature
->
{
if
(
authorityChecker
.
hasPermission
(
range
,
optionId
,
feature
.
getBit
(),
domainId
))
{
allowButtons
.
add
(
feature
);
}
});
return
allowButtons
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/Feature.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
public
class
Feature
{
private
String
name
;
private
String
displayName
;
private
int
bit
;
public
Feature
(
String
name
,
String
displayName
,
int
bit
)
{
this
.
name
=
name
;
this
.
displayName
=
displayName
;
this
.
bit
=
bit
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDisplayName
()
{
return
displayName
;
}
public
void
setDisplayName
(
String
displayName
)
{
this
.
displayName
=
displayName
;
}
public
int
getBit
()
{
return
bit
;
}
public
void
setBit
(
int
bit
)
{
this
.
bit
=
bit
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/MetaRelationMaker.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
import
com.google.common.collect.Lists
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
public
class
MetaRelationMaker
extends
AbstractOptionMaker
{
public
static
final
String
RANGE
=
Range
.
METADATA_RELATION
.
getId
();
private
static
final
String
RANGE_FIELD
=
"range"
;
private
static
final
String
DATA_ROLE_ID_FIELD
=
"dataRoleId"
;
@Autowired
private
MongoTemplate
mongoTemplate
;
public
List
<
OptionPropertyDataImpl
>
getOptionProperties
()
{
return
Lists
.
newArrayList
(
new
OptionPropertyDataImpl
(
featureTotalBit
-
(
Auth
.
Btn
.
IMPORT_BIT
),
featureNameList
.
toArray
(
new
String
[
0
]),
featureBitList
.
toArray
(
new
Integer
[
0
])));
}
public
List
<
OptionImpl
>
getOptions
(
Long
dataRoleId
,
Long
domainId
)
{
//根据角色id获取选中的option
List
<
Authority
>
authorityList
=
mongoTemplate
.
find
(
Query
.
query
(
Criteria
.
where
(
RANGE_FIELD
).
is
(
RANGE
).
and
(
DATA_ROLE_ID_FIELD
).
is
(
dataRoleId
)),
Authority
.
class
);
Map
<
String
,
Integer
>
savedGrantedFeature
;
if
(
null
!=
authorityList
)
{
savedGrantedFeature
=
authorityList
.
stream
().
collect
(
Collectors
.
toMap
(
Authority:
:
getOptionId
,
Authority:
:
getGrantedFeature
));
}
else
{
savedGrantedFeature
=
new
HashMap
<>();
}
List
<
OptionImpl
>
optionList
=
new
ArrayList
<>();
addOption
(
savedGrantedFeature
,
optionList
,
"关系图谱"
,
"关系图谱"
,
featureTotalBit
-
Auth
.
Btn
.
IMPORT_BIT
);
return
optionList
;
}
private
void
addOption
(
Map
<
String
,
Integer
>
savedGrantedFeature
,
List
<
OptionImpl
>
optionList
,
String
name
,
String
id
,
Integer
mask
)
{
Integer
modelGrantedFeature
=
savedGrantedFeature
.
get
(
id
);
optionList
.
add
(
dirToOption
(
id
,
name
,
new
String
[]{},
modelGrantedFeature
,
mask
));
}
@Override
public
List
<
OptionImpl
>
saveOptions
(
Long
dataRoleId
,
List
<
OptionImpl
>
options
,
Long
domainId
)
{
List
<
Authority
>
exist
=
mongoTemplate
.
find
(
Query
.
query
(
Criteria
.
where
(
"dataRoleId"
).
is
(
dataRoleId
).
and
(
"range"
).
is
(
RANGE
)),
Authority
.
class
);
List
<
Authority
>
authorityList
=
options
.
stream
().
map
(
option
->
{
Authority
authority
=
new
Authority
();
authority
.
setOptionId
(
option
.
getId
());
authority
.
setRange
(
RANGE
);
authority
.
setDataRoleId
(
dataRoleId
);
authority
.
setGrantedFeature
(
option
.
getGrantedFeature
());
return
authority
;
}).
collect
(
Collectors
.
toList
());
mongoTemplate
.
insertAll
(
authorityList
);
List
<
String
>
existIds
=
exist
.
stream
().
map
(
option
->
option
.
getId
()).
collect
(
Collectors
.
toList
());
mongoTemplate
.
findAllAndRemove
(
Query
.
query
(
Criteria
.
where
(
"_id"
).
in
(
existIds
)),
Authority
.
class
);
return
options
;
}
@Override
public
List
<
Feature
>
getMyFeatureList
()
{
return
Arrays
.
asList
(
new
Feature
(
"import"
,
"导入"
,
Auth
.
Btn
.
IMPORT_BIT
)
);
}
private
OptionImpl
dirToOption
(
String
id
,
String
name
,
String
[]
parentPath
,
Integer
grantedFeature
,
Integer
mask
)
{
if
(
null
==
grantedFeature
)
{
grantedFeature
=
0
;
}
OptionPropertyDataImpl
optionPropertyData
=
new
OptionPropertyDataImpl
();
optionPropertyData
.
setFeatureBits
(
featureBitList
.
toArray
(
new
Integer
[
0
]));
optionPropertyData
.
setFeatures
(
featureNameList
.
toArray
(
new
String
[
0
]));
optionPropertyData
.
setMask
(
mask
);
OptionImpl
optionData
=
new
OptionImpl
(
id
,
name
,
parentPath
,
optionPropertyData
,
grantedFeature
,
true
);
return
optionData
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/OptionImpl.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
import
com.keymobile.auth.common.conf.Option
;
import
com.keymobile.auth.common.conf.OptionProperty
;
public
class
OptionImpl
implements
Option
{
private
String
id
;
private
String
name
;
private
String
[]
parentFullQualifiedName
;
private
OptionPropertyDataImpl
optionProperty
;
private
String
optionPropertyType
=
"default"
;
private
Integer
grantedFeature
;
private
Boolean
isGrantable
;
public
OptionImpl
()
{
}
public
OptionImpl
(
String
id
,
String
name
,
String
[]
parentFullQualifiedName
,
OptionPropertyDataImpl
optionProperty
,
Integer
grantedFeature
,
boolean
isGrantable
)
{
this
.
id
=
id
;
this
.
name
=
name
;
this
.
parentFullQualifiedName
=
parentFullQualifiedName
;
this
.
optionProperty
=
optionProperty
;
this
.
grantedFeature
=
grantedFeature
;
this
.
isGrantable
=
isGrantable
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setOptionProperty
(
OptionPropertyDataImpl
optionProperty
)
{
this
.
optionProperty
=
optionProperty
;
}
public
void
setGrantedFeature
(
Integer
grantedFeature
)
{
this
.
grantedFeature
=
grantedFeature
;
}
public
void
setOptionPropertyType
(
String
optionPropertyType
)
{
this
.
optionPropertyType
=
optionPropertyType
;
}
public
Boolean
getGrantable
()
{
return
isGrantable
;
}
public
void
setGrantable
(
Boolean
grantable
)
{
isGrantable
=
grantable
;
}
@Override
public
String
getId
()
{
return
id
;
}
@Override
public
String
getName
()
{
return
name
;
}
@Override
public
String
[]
getParentFullQualifiedName
()
{
return
parentFullQualifiedName
;
}
@Override
public
OptionProperty
getOptionProperty
()
{
return
optionProperty
;
}
@Override
public
String
getOptionPropertyType
()
{
return
optionPropertyType
;
}
@Override
public
Integer
getDisabledFeature
()
{
return
0
;
}
@Override
public
Integer
getGrantedFeature
()
{
return
grantedFeature
;
}
@Override
public
boolean
isGrantable
()
{
return
isGrantable
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/OptionMaker.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
import
java.util.List
;
public
interface
OptionMaker
{
List
<
OptionPropertyDataImpl
>
getOptionProperties
();
List
<
OptionImpl
>
getOptions
(
Long
dataRoleId
,
Long
domainId
);
List
<
OptionImpl
>
saveOptions
(
Long
dataRoleId
,
List
<
OptionImpl
>
options
,
Long
domainId
);
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/OptionMakerFactory.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.HashMap
;
import
java.util.List
;
@Service
public
class
OptionMakerFactory
{
HashMap
<
String
,
OptionMaker
>
optionProviderMakers
=
new
HashMap
<>();
@Autowired
public
void
setMetaRelationMaker
(
MetaRelationMaker
metaModelOptionMaker
)
{
optionProviderMakers
.
put
(
Range
.
METADATA_RELATION
.
getId
(),
metaModelOptionMaker
);
}
public
OptionMaker
getOptionMakerByRange
(
String
range
)
{
if
(
null
!=
optionProviderMakers
.
get
(
range
))
{
return
optionProviderMakers
.
get
(
range
);
}
else
{
throw
new
RuntimeException
(
"unSupport range "
+
range
);
}
}
public
List
<
OptionPropertyDataImpl
>
getOptionProperties
(
String
range
)
{
if
(
null
!=
optionProviderMakers
.
get
(
range
))
{
return
optionProviderMakers
.
get
(
range
).
getOptionProperties
();
}
else
{
throw
new
RuntimeException
(
"unSupport range "
+
range
);
}
}
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/OptionPropertyDataImpl.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
import
com.keymobile.auth.common.conf.OptionProperty
;
public
class
OptionPropertyDataImpl
implements
OptionProperty
{
private
Integer
mask
;
private
String
[]
features
;
private
Integer
[]
featureBits
;
private
String
optionPropertyType
=
"default"
;
public
OptionPropertyDataImpl
()
{
}
public
OptionPropertyDataImpl
(
Integer
mask
,
String
[]
features
,
Integer
[]
featureBits
)
{
this
.
mask
=
mask
;
this
.
features
=
features
;
this
.
featureBits
=
featureBits
;
}
public
OptionPropertyDataImpl
(
Integer
mask
,
String
[]
features
,
Integer
[]
featureBits
,
String
optionPropertyType
)
{
this
.
mask
=
mask
;
this
.
features
=
features
;
this
.
featureBits
=
featureBits
;
this
.
optionPropertyType
=
optionPropertyType
;
}
public
void
setMask
(
Integer
mask
)
{
this
.
mask
=
mask
;
}
public
void
setFeatures
(
String
[]
features
)
{
this
.
features
=
features
;
}
public
void
setFeatureBits
(
Integer
[]
featureBits
)
{
this
.
featureBits
=
featureBits
;
}
@Override
public
Integer
getMask
()
{
return
mask
;
}
@Override
public
String
[]
getFeatures
()
{
return
features
;
}
@Override
public
Integer
[]
getFeatureBits
()
{
return
featureBits
;
}
@Override
public
String
getOptionPropertyType
()
{
return
optionPropertyType
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/auth/Range.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
auth
;
public
enum
Range
{
METADATA_RELATION
(
"metadataRelation"
,
"关系图谱"
);
private
String
id
;
private
String
name
;
Range
(
String
id
,
String
name
)
{
this
.
id
=
id
;
this
.
name
=
name
;
}
public
String
getId
()
{
return
id
;
}
public
String
getName
()
{
return
name
;
}
public
static
String
getTypeById
(
String
rangeId
)
{
for
(
Range
range
:
Range
.
values
())
{
if
(
range
.
getId
().
equals
(
rangeId
))
return
range
.
getName
();
}
return
""
;
}
}
src/main/java/com/keymobile/metadata/metadataRelation/controller/AuthorityApi.java
0 → 100644
View file @
a2b7ac36
package
com
.
keymobile
.
metadata
.
metadataRelation
.
controller
;
import
com.keymobile.auth.common.conf.OptionProvider
;
import
com.keymobile.metadata.metadataRelation.auth.AuthorityService
;
import
com.keymobile.metadata.metadataRelation.auth.Feature
;
import
com.keymobile.metadata.metadataRelation.auth.OptionImpl
;
import
com.keymobile.metadata.metadataRelation.auth.OptionPropertyDataImpl
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
import
java.util.Map
;
@Api
(
value
=
"授权信息相关"
,
tags
=
"授权信息相关"
)
@RestController
@RequestMapping
(
value
=
"/rest/auth"
)
public
class
AuthorityApi
implements
OptionProvider
<
OptionImpl
,
OptionPropertyDataImpl
>
{
@Autowired
private
AuthorityService
authorityService
;
@Override
@ApiOperation
(
value
=
"获取权限属性"
,
notes
=
"获取权限属性"
)
@GetMapping
(
value
=
"/getOptionProperties"
)
public
List
<
OptionPropertyDataImpl
>
getOptionProperties
(
@RequestParam
String
range
)
{
return
authorityService
.
getOptionProperties
(
range
);
}
@Override
@ApiOperation
(
value
=
"获取权限数据"
,
notes
=
"获取权限数据"
)
@GetMapping
(
value
=
"/getOptions"
)
public
List
<
OptionImpl
>
getOptions
(
@RequestParam
Long
dataRoleId
,
@RequestParam
String
range
,
@RequestParam
(
required
=
false
)
Long
domainId
)
{
return
authorityService
.
getOptions
(
dataRoleId
,
range
,
domainId
);
}
@Override
@ApiOperation
(
value
=
"保存权限数据"
,
notes
=
"保存权限数据"
)
@PostMapping
(
value
=
"/saveOptions"
)
public
List
<
OptionImpl
>
saveOptions
(
@RequestParam
Long
dataRoleId
,
@RequestParam
String
range
,
@RequestBody
List
<
OptionImpl
>
optionList
,
@RequestParam
(
required
=
false
)
Long
domainId
)
{
return
authorityService
.
saveOptions
(
dataRoleId
,
range
,
optionList
,
domainId
);
}
@ApiOperation
(
value
=
"获取所有的range"
,
notes
=
"获取所有的range"
)
@GetMapping
(
value
=
"/listAllRanges"
)
public
List
<
Map
<
String
,
Object
>>
listAllRanges
()
{
return
authorityService
.
listAllRanges
();
}
@ApiOperation
(
value
=
"返回可操作按钮权限"
,
notes
=
"返回可操作按钮权限"
)
@GetMapping
(
value
=
"/getAllowButtons"
)
public
List
<
Feature
>
getAllowButtons
(
@RequestParam
String
range
,
@RequestParam
String
optionId
,
@RequestParam
(
required
=
false
)
Long
domainId
)
{
return
authorityService
.
getAllowButtons
(
range
,
optionId
,
domainId
);
}
}
src/main/resources/application-local.yml
View file @
a2b7ac36
...
@@ -17,7 +17,7 @@ spring:
...
@@ -17,7 +17,7 @@ spring:
main
:
main
:
allow-bean-definition-overriding
:
true
allow-bean-definition-overriding
:
true
datasource
:
datasource
:
url
:
jdbc:mysql://
192.168.0.192
:3306/p0?autoReconnect=true&useUnicode=true&characterEncoding=utf-8
url
:
jdbc:mysql://
dev-vm-00
:3306/p0?autoReconnect=true&useUnicode=true&characterEncoding=utf-8
username
:
p_test
username
:
p_test
password
:
p_test
password
:
p_test
initialization-mode
:
always
initialization-mode
:
always
...
@@ -25,18 +25,18 @@ spring:
...
@@ -25,18 +25,18 @@ spring:
hikari
:
hikari
:
maximum-pool-size
:
5
maximum-pool-size
:
5
redis
:
redis
:
host
:
192.168.0.1
00
host
:
p-
00
port
:
6379
port
:
6379
eureka
:
eureka
:
client
:
client
:
registerWithEureka
:
fals
e
registerWithEureka
:
tru
e
region
:
default
region
:
default
registryFetchIntervalSeconds
:
5
registryFetchIntervalSeconds
:
5
serviceUrl
:
serviceUrl
:
defaultZone
:
http://
192.168.0.11
1:8081/eureka/
defaultZone
:
http://
p-0
1:8081/eureka/
instance
:
#
instance:
prefer-ip-address
:
true
#
prefer-ip-address: true
security
:
security
:
permit
:
false
permit
:
false
authUser
:
root
authUser
:
root
...
@@ -44,7 +44,18 @@ security:
...
@@ -44,7 +44,18 @@ security:
mongodb
:
mongodb
:
database
:
szsedev
database
:
szsedev
uri
:
192.168.0.192
uri
:
dev-vm-00
username
:
szse
username
:
szse
password
:
szse
password
:
szse
maxConnectionIdleTime
:
10000
maxConnectionIdleTime
:
10000
\ No newline at end of file
management
:
metrics
:
tags
:
application
:
${spring.application.name}
endpoints
:
health
:
show-details
:
always
web
:
exposure
:
include
:
prometheus
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