diff --git a/build.gradle b/build.gradle index a09cb75..153c20c 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,8 @@ allprojects { subprojects { ext { - version '0.6.0' - gaea_version = '0.7.0' + version '0.6.1' + gaea_version = '0.9.0' spring_version = "2.3.0.RELEASE" } diff --git a/src/zeus.app/build.gradle b/src/zeus.app/build.gradle index 1662c1a..a1b2418 100644 --- a/src/zeus.app/build.gradle +++ b/src/zeus.app/build.gradle @@ -1,10 +1,12 @@ buildscript { dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:$spring_version") + classpath("org.jetbrains.kotlin:kotlin-allopen:$kotlin_version") } } apply plugin: 'org.springframework.boot' +apply plugin: 'kotlin-spring' jar.enabled = true //jar SKIPPED问题,不设置可能会无法打jar @@ -14,7 +16,6 @@ dependencies { compile "com.synebula:gaea.app:$gaea_version" compile "com.synebula:gaea.mongo:$gaea_version" - compile group: 'com.google.code.gson', name: 'gson', version: '2.8.6' } publishing { diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/component/ZeusAspect.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/component/ZeusAspect.kt index 04d9ab1..03372e6 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/component/ZeusAspect.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/component/ZeusAspect.kt @@ -9,7 +9,7 @@ import org.springframework.stereotype.Component @Component class ZeusAspect : AppAspect() { - @Pointcut("execution(* com.synebula.zeus.app.controller..*(..))") + @Pointcut("target(com.synebula.gaea.app.IApplication)") override fun func() { } } \ No newline at end of file diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusBeans.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusBeans.kt index 4efc28a..6850c89 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusBeans.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusBeans.kt @@ -22,22 +22,22 @@ import org.springframework.data.mongodb.core.MongoTemplate "com.synebula.gaea.app.component" ] ) -open class ZeusBeans { +class ZeusBeans { @Bean @Primary - open fun > repository(template: MongoTemplate) + fun > repository(template: MongoTemplate) : IRepository = MongoRepository(template) @Bean @Primary - open fun query(template: MongoTemplate, logger: ILogger? = null) + fun query(template: MongoTemplate, logger: ILogger? = null) : IQuery = MongoQuery(template, logger) @Bean - open fun gson(): Gson = Gson() + fun gson(): Gson = Gson() @Bean - open fun serializer(gson: Gson): IJsonSerializer { + fun serializer(gson: Gson): IJsonSerializer { return object : IJsonSerializer { override fun serialize(src: S): String { return gson.toJson(src) diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/SignInOutApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/SignInOutApp.kt index 0153621..7a338af 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/SignInOutApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/SignInOutApp.kt @@ -1,26 +1,54 @@ package com.synebula.zeus.app.controller import com.synebula.gaea.app.IApplication -import com.synebula.gaea.app.component.HttpMessage +import com.synebula.gaea.app.component.security.TokenManager +import com.synebula.gaea.app.struct.HttpMessage +import com.synebula.gaea.data.message.Status +import com.synebula.gaea.data.serialization.json.IJsonSerializer import com.synebula.gaea.log.ILogger +import com.synebula.gaea.query.IQuery +import com.synebula.zeus.domain.service.cmd.rbac.UserCmd +import com.synebula.zeus.domain.service.contr.rbac.IUserService import com.synebula.zeus.query.contr.IUserQuery -import com.synebula.zeus.query.impl.UserQuery -import org.springframework.data.mongodb.core.MongoTemplate +import com.synebula.zeus.query.view.UserView +import org.springframework.beans.factory.annotation.Autowired import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/sign") -open class SignInOutApp(template: MongoTemplate, override var logger: ILogger?) : IApplication { - var query: IUserQuery = UserQuery(template) +class SignInOutApp(override var logger: ILogger?) : IApplication { + @Autowired + lateinit var query: IQuery + + @Autowired + lateinit var userQuery: IUserQuery + + @Autowired + lateinit var userService: IUserService + + @Autowired + lateinit var tokenHelper: TokenManager + + @Autowired + lateinit var serializer: IJsonSerializer override var name: String = "用户登录管理" @PostMapping("/in") - fun signIn(name: String, password: String): HttpMessage { + fun signIn(name: String, password: String, remember: Boolean?): HttpMessage { return this.safeExecute("用户登录出现异常") { - it.load(this.query.signIn(name, password)) + val message = this.userQuery.signIn(name, password) + if (message.data != null) { + val user = message.data + user!!.remember = remember ?: false + val token = tokenHelper.sign(message.data!!) + it.data = token + } else { + it.load(message) + } } } @@ -28,4 +56,18 @@ open class SignInOutApp(template: MongoTemplate, override var logger: ILogger?) fun signOut(user: String): HttpMessage { return HttpMessage(user) } + + @PostMapping("/up") + fun signUp(@RequestBody command: UserCmd): HttpMessage { + return this.safeExecute("用户注册出错, 用户信息: ${serializer.serialize(command)}") { + val list = this.query.list(mapOf(Pair("name", command.name)), UserView::class.java) + if (list.count() == 0) { + val message = userService.add(command) + it.data = message.data + } else { + it.status = Status.Failure + it.message = "系统中已存在该用户" + } + } + } } \ No newline at end of file diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/GroupApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/GroupApp.kt index f15c2e8..4e84b27 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/GroupApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/GroupApp.kt @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/groups") -open class GroupApp( +class GroupApp( service: IGroupService, query: IQuery, logger: ILogger diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/RoleApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/RoleApp.kt index 9c4842e..6354c7d 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/RoleApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/RoleApp.kt @@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/roles") -open class RoleApp( +class RoleApp( service: IRoleService, query: IQuery, logger: ILogger diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/UserApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/UserApp.kt index aaf5812..80eca15 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/UserApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/UserApp.kt @@ -1,7 +1,7 @@ package com.synebula.zeus.app.controller.rbac import com.synebula.gaea.app.Application -import com.synebula.gaea.app.component.HttpMessage +import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.data.message.Status import com.synebula.gaea.data.serialization.json.IJsonSerializer import com.synebula.gaea.log.ILogger @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.* @RestController @RequestMapping("/users") -open class UserApp( +class UserApp( service: IUserService, query: IQuery, logger: ILogger diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/InterfaceApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/InterfaceApp.kt index 3f39ea5..9e84bc7 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/InterfaceApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/InterfaceApp.kt @@ -1,7 +1,7 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application -import com.synebula.gaea.app.component.HttpMessage +import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.log.ILogger import com.synebula.zeus.domain.service.cmd.rbac.resource.InterfaceCmd import com.synebula.zeus.domain.service.contr.rbac.resource.IInterfaceService @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/interfaces") -open class InterfaceApp( +class InterfaceApp( service: IInterfaceService, logger: ILogger, var interfaceQuery: IInterfaceQuery @@ -23,24 +23,24 @@ open class InterfaceApp( service, interfaceQuery, logger ) { - @GetMapping("/in-system/{system}/permission/{role}") - fun withSystemPermission(@PathVariable system: String, @PathVariable role: String): HttpMessage { + @GetMapping("/in-system/{system}/authorized/{role}") + fun authorized(@PathVariable system: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> - msg.data = this.interfaceQuery.withPermission(role, system) + msg.data = this.interfaceQuery.authorized(role, system) } } - @GetMapping("/permission/{role}") - fun withPermission(@PathVariable role: String): HttpMessage { + @GetMapping("/authorized/{role}") + fun authorized(@PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> - msg.data = this.interfaceQuery.withPermission(role) + msg.data = this.interfaceQuery.authorized(role) } } - @GetMapping("/{api}/authentication/{role}") - fun authentication(@PathVariable api: String, @PathVariable role: String): HttpMessage { + @GetMapping("/{api}/authorize/{role}") + fun authorize(@PathVariable api: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> - msg.data = this.interfaceQuery.authentication(api, role) + msg.data = this.interfaceQuery.authorize(api, role) } } } \ No newline at end of file diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PageApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PageApp.kt index c1d19c0..ddf73d0 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PageApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PageApp.kt @@ -1,8 +1,8 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application -import com.synebula.gaea.app.component.HttpMessage import com.synebula.gaea.app.component.aop.annotation.ModuleName +import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.log.ILogger import com.synebula.zeus.domain.service.cmd.rbac.resource.PageCmd import com.synebula.zeus.domain.service.contr.rbac.resource.IPageService @@ -16,7 +16,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/pages") @ModuleName("页面") -open class PageApp( +class PageApp( service: IPageService, logger: ILogger, var pageQuery: IPageQuery @@ -25,35 +25,31 @@ open class PageApp( service, pageQuery, logger ) { - override fun list(params: LinkedHashMap): HttpMessage { - return super.list(params) - } - - @GetMapping("/in-system/{system}/permission/{role}") - fun withSystemPermission(@PathVariable system: String, @PathVariable role: String): HttpMessage { + @GetMapping("/in-system/{system}/authorized/{role}") + fun authorized(@PathVariable system: String, @PathVariable role: String): HttpMessage { val msg = HttpMessage() - msg.data = this.pageQuery.withPermission(role, system) + msg.data = this.pageQuery.authorized(role, system) return msg } - @GetMapping("/permission/{role}") - fun withPermission(@PathVariable role: String): HttpMessage { + @GetMapping("/authorized/{role}") + fun authorized(@PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> - msg.data = this.pageQuery.withPermission(role) + msg.data = this.pageQuery.authorized(role) } } - @GetMapping("/{page}/authentication/{role}") - fun authentication(@PathVariable page: String, @PathVariable role: String): HttpMessage { + @GetMapping("/{page}/authorize/{role}") + fun authorize(@PathVariable page: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> - msg.data = this.pageQuery.authentication(page, role) + msg.data = this.pageQuery.authorize(page, role) } } - @GetMapping("/authentication/{role}") - fun uriAuthentication(@PathVariable role: String, uri: String): HttpMessage { + @GetMapping("/authorize/{role}") + fun uriAuthorize(@PathVariable role: String, uri: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> - msg.data = this.pageQuery.uriAuthentication(uri, role) + msg.data = this.pageQuery.uriAuthorize(uri, role) } } diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PermissionApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PermissionApp.kt index d6b995d..22e8484 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PermissionApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PermissionApp.kt @@ -11,11 +11,11 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/permissions") -open class PermissionApp( - service: IPermissionService, - query: IPermissionQuery, - logger: ILogger +class PermissionApp( + service: IPermissionService, + query: IPermissionQuery, + logger: ILogger ) : Application( - "权限信息", PermissionView::class.java, - service, query, logger + "权限信息", PermissionView::class.java, + service, query, logger ) \ No newline at end of file diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/SystemApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/SystemApp.kt index 2789d72..cbdfd2b 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/SystemApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/SystemApp.kt @@ -1,7 +1,7 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application -import com.synebula.gaea.app.component.HttpMessage +import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.log.ILogger import com.synebula.zeus.domain.service.cmd.rbac.resource.SystemCmd import com.synebula.zeus.domain.service.contr.rbac.resource.ISystemService @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/systems") -open class SystemApp( +class SystemApp( service: ISystemService, logger: ILogger, var systemQuery: ISystemQuery @@ -22,17 +22,17 @@ open class SystemApp( "系统信息", SystemView::class.java, service, systemQuery, logger ) { - @GetMapping("/permission/{role}") - fun withPermission(@PathVariable role: String): HttpMessage { + @GetMapping("/authorized/{role}") + fun authorized(@PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> - msg.data = this.systemQuery.withPermission(role) + msg.data = this.systemQuery.authorized(role) } } - @GetMapping("/{system}/authentication/{role}") - fun authentication(@PathVariable system: String, @PathVariable role: String): HttpMessage { + @GetMapping("/{system}/authorize/{role}") + fun authorize(@PathVariable system: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> - msg.data = this.systemQuery.authentication(system, role) + msg.data = this.systemQuery.authorize(system, role) } } } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IInterfaceQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IInterfaceQuery.kt index 8380b4f..4857359 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IInterfaceQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IInterfaceQuery.kt @@ -6,9 +6,9 @@ import com.synebula.zeus.query.view.resource.InterfaceView interface IInterfaceQuery : IQuery { - fun withPermission(role: String): List + fun authorized(role: String): List - fun withPermission(role: String, system: String?): List + fun authorized(role: String, system: String?): List - fun authentication(resource: String, role: String): PermissionType? + fun authorize(resource: String, role: String): PermissionType? } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IPageQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IPageQuery.kt index 9681ebf..b0c425e 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IPageQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IPageQuery.kt @@ -6,11 +6,11 @@ import com.synebula.zeus.query.view.resource.PageView interface IPageQuery : IQuery { - fun withPermission(role: String): List + fun authorized(role: String): List - fun withPermission(role: String, system: String? ): List + fun authorized(role: String, system: String? ): List - fun authentication(resource: String, role: String): PermissionType? + fun authorize(resource: String, role: String): PermissionType? - fun uriAuthentication(path: String, role: String): PermissionType? + fun uriAuthorize(path: String, role: String): PermissionType? } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/ISystemQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/ISystemQuery.kt index 6b3c130..ad82c64 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/ISystemQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/ISystemQuery.kt @@ -6,7 +6,7 @@ import com.synebula.zeus.query.view.resource.SystemView interface ISystemQuery : IQuery { - fun withPermission(role: String): List + fun authorized(role: String): List - fun authentication(resource: String, role: String): PermissionType? + fun authorize(resource: String, role: String): PermissionType? } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/UserQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/UserQuery.kt index 3f297f3..bbc6077 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/UserQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/UserQuery.kt @@ -29,7 +29,7 @@ class UserQuery(var template: MongoTemplate) : IUserQuery { val group = this.template.findOne(whereId(user.group), GroupView::class.java, "group") DataMessage( SignUserView( - user.id, user.name, user.realName ?: "", + user.id, user.realName ?: "", user.role ?: "", role?.name ?: "", user.group ?: "", group?.name ?: "" ) diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/InterfaceQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/InterfaceQuery.kt index b8d2252..15027b2 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/InterfaceQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/InterfaceQuery.kt @@ -15,14 +15,14 @@ class InterfaceQuery(template: MongoTemplate, var permissionQuery: IPermissionQu private val clazz = InterfaceView::class.java - override fun withPermission(role: String): List { - return this.withPermission(role, null) + override fun authorized(role: String): List { + return this.authorized(role, null) } - override fun withPermission(role: String, system: String?): List { + override fun authorized(role: String, system: String?): List { if (system != null) { - val permission = this.systemQuery.authentication(system, role) + val permission = this.systemQuery.authorize(system, role) if (permission == PermissionType.Deny) return listOf() } @@ -36,7 +36,7 @@ class InterfaceQuery(template: MongoTemplate, var permissionQuery: IPermissionQu } } - override fun authentication(resource: String, role: String): PermissionType? { + override fun authorize(resource: String, role: String): PermissionType { return this.permissionQuery.authentication(ResourceType.Interface, resource, role) } } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/PageQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/PageQuery.kt index d40c1c2..1af97c1 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/PageQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/PageQuery.kt @@ -12,16 +12,16 @@ import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query class PageQuery(template: MongoTemplate, var permissionQuery: IPermissionQuery, var systemQuery: ISystemQuery) : - MongoQuery(template), IPageQuery { + MongoQuery(template), IPageQuery { private val clazz = PageView::class.java - override fun withPermission(role: String): List { - return this.withPermission(role, null) + override fun authorized(role: String): List { + return this.authorized(role, null) } - override fun withPermission(role: String, system: String?): List { + override fun authorized(role: String, system: String?): List { if (system != null) { - val permission = this.systemQuery.authentication(system, role) + val permission = this.systemQuery.authorize(system, role) if (permission == PermissionType.Deny) return listOf() } @@ -35,13 +35,15 @@ class PageQuery(template: MongoTemplate, var permissionQuery: IPermissionQuery, } } - override fun authentication(resource: String, role: String): PermissionType? { + override fun authorize(resource: String, role: String): PermissionType { return this.permissionQuery.authentication(ResourceType.Page, resource, role) } - override fun uriAuthentication(path: String, role: String): PermissionType? { - val page = this.template.findOne(Query.query(Criteria.where("uri").`is`(path)), - this.clazz, this.collection(this.clazz)) ?: return null - return this.authentication(page.id!!, role) + override fun uriAuthorize(path: String, role: String): PermissionType? { + val page = this.template.findOne( + Query.query(Criteria.where("uri").`is`(path)), + this.clazz, this.collection(this.clazz) + ) ?: return null + return this.authorize(page.id!!, role) } } diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/SystemQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/SystemQuery.kt index 3610547..5cb6b50 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/SystemQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/SystemQuery.kt @@ -10,13 +10,13 @@ import org.springframework.data.mongodb.core.MongoTemplate class SystemQuery(template: MongoTemplate, var permissionQuery: PermissionQuery) : MongoQuery(template), ISystemQuery { private val clazz = SystemView::class.java - override fun withPermission(role: String): List { + override fun authorized(role: String): List { val systems = this.list(mapOf(), this.clazz) val permissions = this.permissionQuery.resourcePermissions(ResourceType.System, role) return systems.filter { i -> permissions.find { p -> i.id == p.resource }?.authority == PermissionType.Allow } } - override fun authentication(resource: String, role: String): PermissionType? { + override fun authorize(resource: String, role: String): PermissionType { return this.permissionQuery.authentication(ResourceType.System, resource, role) } } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/SignUserView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/SignUserView.kt index 14d68d6..4fe7275 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/SignUserView.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/SignUserView.kt @@ -1,11 +1,34 @@ package com.synebula.zeus.query.view class SignUserView( - var id: String = "", - var name: String = "", - var realName: String = "", - var role: String = "", - var roleName: String = "", - var group: String = "", - var groupName: String = "" + /** + * 用户id + */ + var uid: String = "", + + /** + * 用户名称 + */ + var uname: String = "", + + /** + * 角色id + */ + var rid: String = "", + + /** + * 角色名称 + */ + var rname: String = "", + + /** + * 组id + */ + var gid: String = "", + + /** + * 组名称 + */ + var gname: String = "", + var remember: Boolean = false ) \ No newline at end of file