modify permission type, default means not config it, null means not exist

This commit is contained in:
2020-11-20 16:56:14 +08:00
parent b2370ce256
commit fd5b74d917
4 changed files with 8 additions and 7 deletions

View File

@@ -21,7 +21,7 @@ allprojects {
subprojects {
ext {
version '0.5.1'
version '0.5.2'
gaea_version = '0.6.0'
spring_version = "2.3.0.RELEASE"
}

View File

@@ -1,6 +1,7 @@
package com.synebula.zeus.env
enum class PermissionType {
Default,
Deny,
Allow
}
}

View File

@@ -9,5 +9,5 @@ interface IPermissionQuery : IQuery {
fun resourcePermissions(resourceType: ResourceType, role: String): List<PermissionView>
fun authentication(resourceType: ResourceType, resource: String, role: String): PermissionType?
}
fun authentication(resourceType: ResourceType, resource: String, role: String): PermissionType
}

View File

@@ -21,13 +21,13 @@ class PermissionQuery(template: MongoTemplate) : MongoQuery(template), IPermissi
), this.clazz, this.collection)
}
override fun authentication(resourceType: ResourceType, resource: String, role: String): PermissionType? {
override fun authentication(resourceType: ResourceType, resource: String, role: String): PermissionType {
val permission = this.template.findOne(
Query.query(
Criteria.where("type").`is`(resourceType)
.and("resource").`is`(resource)
.and("role").`is`(role)
), this.clazz, this.collection)
return permission?.authority
return permission?.authority ?: PermissionType.Default
}
}
}