From de43b82f24e5c73b138e2bdbabefcbe175695c82 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 23 Mar 2021 17:01:56 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=B3=A8=E8=A7=A3?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++-- .../com/synebula/zeus/app/component/ZeusAspect.kt | 15 +++++++++++++++ .../com/synebula/zeus/app/config/ZeusBeans.kt | 6 ++++++ .../app/config/{ZeusSpring.kt => ZeusServices.kt} | 3 +-- .../synebula/zeus/app/controller/SignInOutApp.kt | 2 +- .../synebula/zeus/app/controller/rbac/GroupApp.kt | 2 +- .../synebula/zeus/app/controller/rbac/RoleApp.kt | 2 +- .../synebula/zeus/app/controller/rbac/UserApp.kt | 2 +- .../app/controller/rbac/resource/InterfaceApp.kt | 2 +- .../zeus/app/controller/rbac/resource/PageApp.kt | 14 ++++++++++---- .../app/controller/rbac/resource/PermissionApp.kt | 2 +- .../app/controller/rbac/resource/SystemApp.kt | 2 +- .../zeus/domain/service/impl/rbac/UserService.kt | 6 +++--- 13 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 src/zeus.app/src/main/kotlin/com/synebula/zeus/app/component/ZeusAspect.kt rename src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/{ZeusSpring.kt => ZeusServices.kt} (90%) diff --git a/build.gradle b/build.gradle index 726eea1..a09cb75 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,8 @@ allprojects { subprojects { ext { - version '0.5.2' - gaea_version = '0.6.1' + version '0.6.0' + gaea_version = '0.7.0' spring_version = "2.3.0.RELEASE" } 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 new file mode 100644 index 0000000..04d9ab1 --- /dev/null +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/component/ZeusAspect.kt @@ -0,0 +1,15 @@ +package com.synebula.zeus.app.component + +import com.synebula.gaea.app.component.aop.AppAspect +import org.aspectj.lang.annotation.Aspect +import org.aspectj.lang.annotation.Pointcut +import org.springframework.stereotype.Component + +@Aspect +@Component +class ZeusAspect : AppAspect() { + + @Pointcut("execution(* com.synebula.zeus.app.controller..*(..))") + 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 c49368c..4efc28a 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 @@ -10,12 +10,18 @@ import com.synebula.gaea.mongo.repository.MongoRepository import com.synebula.gaea.query.IQuery import com.synebula.zeus.domain.service.contr.component.IUserNotifier import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Primary import org.springframework.data.mongodb.core.MongoTemplate @Configuration +@ComponentScan( + basePackages = [ + "com.synebula.gaea.app.component" + ] +) open class ZeusBeans { @Bean @Primary diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusSpring.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt similarity index 90% rename from src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusSpring.kt rename to src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt index 59bed60..d4f8285 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusSpring.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt @@ -9,10 +9,9 @@ import org.springframework.stereotype.Component @Component @ComponentScan( basePackages = [ - "com.synebula.gaea.app.component", "com.synebula.zeus.domain.service.impl", "com.synebula.zeus.query.impl" ], includeFilters = [Filter(type = FilterType.CUSTOM, classes = [AllTypeFilter::class])] ) -class ZeusSpring \ No newline at end of file +class ZeusServices \ No newline at end of file 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 cb5c0b6..0153621 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 @@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/sign") -class SignInOutApp(template: MongoTemplate, override var logger: ILogger?) : IApplication { +open class SignInOutApp(template: MongoTemplate, override var logger: ILogger?) : IApplication { var query: IUserQuery = UserQuery(template) override var name: String = "用户登录管理" 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 4e84b27..f15c2e8 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") -class GroupApp( +open 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 6354c7d..9c4842e 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") -class RoleApp( +open 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 f32e4b5..aaf5812 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 @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.* @RestController @RequestMapping("/users") -class UserApp( +open 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 a20835a..3f39ea5 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 @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/interfaces") -class InterfaceApp( +open class InterfaceApp( service: IInterfaceService, logger: ILogger, var interfaceQuery: IInterfaceQuery 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 6120b98..c1d19c0 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 @@ -2,6 +2,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.component.aop.annotation.ModuleName 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 @@ -14,7 +15,8 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/pages") -class PageApp( +@ModuleName("页面") +open class PageApp( service: IPageService, logger: ILogger, var pageQuery: IPageQuery @@ -23,11 +25,15 @@ 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 { - return this.safeExecute("获取有权资源列表失败") { msg -> - msg.data = this.pageQuery.withPermission(role, system) - } + val msg = HttpMessage() + msg.data = this.pageQuery.withPermission(role, system) + return msg } @GetMapping("/permission/{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 fc0837d..d6b995d 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,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/permissions") -class PermissionApp( +open class PermissionApp( service: IPermissionService, query: IPermissionQuery, logger: ILogger 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 f49ea66..2789d72 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 @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/systems") -class SystemApp( +open class SystemApp( service: ISystemService, logger: ILogger, var systemQuery: ISystemQuery diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt index c6b6f8e..0af5f01 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt @@ -22,7 +22,7 @@ class UserService( logger: ILogger, groupService: IGroupService, roleService: IRoleService, - var userNotifier: IUserNotifier + var userNotifier: IUserNotifier? ) : Service(User::class.java, repository, converter, logger), IUserService { init { @@ -50,7 +50,7 @@ class UserService( user.token = UUID.randomUUID().toString() user.alive = false this.repository.add(user, this.clazz) - userNotifier.added(user.id!!, user.name, user.token!!) + userNotifier?.added(user.id!!, user.name, user.token!!) return DataMessage(user.id!!) } @@ -108,7 +108,7 @@ class UserService( return if (user.alive) { user.token = UUID.randomUUID().toString() this.repository.update(user, this.clazz) - userNotifier.forgot(user.id!!, user.name, user.token!!) + userNotifier?.forgot(user.id!!, user.name, user.token!!) DataMessage() } else DataMessage(Status.Failure, "用户还未激活, 请先激活用户") From 7f97a1d9a396e1cba2076f3a1680fa05a32fd627 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 6 Apr 2021 20:58:05 +0800 Subject: [PATCH 02/14] =?UTF-8?q?=E7=A7=BB=E9=99=A4open=E7=AD=89=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E4=BB=A3=E7=A0=81=EF=BC=9B=E9=87=8D=E5=91=BD=E5=90=8D?= =?UTF-8?q?=E6=8E=88=E6=9D=83api=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 +- src/zeus.app/build.gradle | 3 +- .../synebula/zeus/app/component/ZeusAspect.kt | 2 +- .../com/synebula/zeus/app/config/ZeusBeans.kt | 10 ++-- .../zeus/app/controller/SignInOutApp.kt | 56 ++++++++++++++++--- .../zeus/app/controller/rbac/GroupApp.kt | 2 +- .../zeus/app/controller/rbac/RoleApp.kt | 2 +- .../zeus/app/controller/rbac/UserApp.kt | 4 +- .../controller/rbac/resource/InterfaceApp.kt | 22 ++++---- .../app/controller/rbac/resource/PageApp.kt | 32 +++++------ .../controller/rbac/resource/PermissionApp.kt | 12 ++-- .../app/controller/rbac/resource/SystemApp.kt | 16 +++--- .../query/contr/resouce/IInterfaceQuery.kt | 6 +- .../zeus/query/contr/resouce/IPageQuery.kt | 8 +-- .../zeus/query/contr/resouce/ISystemQuery.kt | 4 +- .../com/synebula/zeus/query/impl/UserQuery.kt | 2 +- .../zeus/query/impl/resouce/InterfaceQuery.kt | 10 ++-- .../zeus/query/impl/resouce/PageQuery.kt | 22 ++++---- .../zeus/query/impl/resouce/SystemQuery.kt | 4 +- .../synebula/zeus/query/view/SignUserView.kt | 37 +++++++++--- 20 files changed, 161 insertions(+), 97 deletions(-) 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 From 2eac2765151469caedcd68daf0bc4368c0245495 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 7 Apr 2021 11:02:50 +0800 Subject: [PATCH 03/14] =?UTF-8?q?0.6.2=E5=A2=9E=E5=8A=A0api=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++-- .../kotlin/com/synebula/zeus/app/controller/SignInOutApp.kt | 4 ++++ .../zeus/app/controller/rbac/resource/InterfaceApp.kt | 4 ++++ .../synebula/zeus/app/controller/rbac/resource/PageApp.kt | 5 +++++ .../synebula/zeus/app/controller/rbac/resource/SystemApp.kt | 3 +++ 5 files changed, 18 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 153c20c..241d8e2 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,8 @@ allprojects { subprojects { ext { - version '0.6.1' - gaea_version = '0.9.0' + version '0.6.2' + gaea_version = '0.9.1' spring_version = "2.3.0.RELEASE" } 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 7a338af..aa1a8e5 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,6 +1,7 @@ package com.synebula.zeus.app.controller import com.synebula.gaea.app.IApplication +import com.synebula.gaea.app.component.aop.annotation.MethodName import com.synebula.gaea.app.component.security.TokenManager import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.data.message.Status @@ -37,6 +38,7 @@ class SignInOutApp(override var logger: ILogger?) : IApplication { override var name: String = "用户登录管理" + @MethodName("用户登录") @PostMapping("/in") fun signIn(name: String, password: String, remember: Boolean?): HttpMessage { return this.safeExecute("用户登录出现异常") { @@ -52,11 +54,13 @@ class SignInOutApp(override var logger: ILogger?) : IApplication { } } + @MethodName("用户登出") @PostMapping("/out") fun signOut(user: String): HttpMessage { return HttpMessage(user) } + @MethodName("用户注册") @PostMapping("/up") fun signUp(@RequestBody command: UserCmd): HttpMessage { return this.safeExecute("用户注册出错, 用户信息: ${serializer.serialize(command)}") { 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 9e84bc7..6ae965c 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,6 +1,7 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application +import com.synebula.gaea.app.component.aop.annotation.MethodName import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.log.ILogger import com.synebula.zeus.domain.service.cmd.rbac.resource.InterfaceCmd @@ -23,6 +24,7 @@ class InterfaceApp( service, interfaceQuery, logger ) { + @MethodName("获取角色系统下有权接口") @GetMapping("/in-system/{system}/authorized/{role}") fun authorized(@PathVariable system: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> @@ -30,6 +32,7 @@ class InterfaceApp( } } + @MethodName("获取角色全部有权接口") @GetMapping("/authorized/{role}") fun authorized(@PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> @@ -37,6 +40,7 @@ class InterfaceApp( } } + @MethodName("验证角色接口权限") @GetMapping("/{api}/authorize/{role}") fun authorize(@PathVariable api: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> 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 ddf73d0..cd6501e 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,6 +1,7 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application +import com.synebula.gaea.app.component.aop.annotation.MethodName import com.synebula.gaea.app.component.aop.annotation.ModuleName import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.log.ILogger @@ -25,6 +26,7 @@ class PageApp( service, pageQuery, logger ) { + @MethodName("获取角色系统下有权页面") @GetMapping("/in-system/{system}/authorized/{role}") fun authorized(@PathVariable system: String, @PathVariable role: String): HttpMessage { val msg = HttpMessage() @@ -32,6 +34,7 @@ class PageApp( return msg } + @MethodName("获取角色全部有权页面") @GetMapping("/authorized/{role}") fun authorized(@PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> @@ -39,6 +42,7 @@ class PageApp( } } + @MethodName("验证角色页面权限") @GetMapping("/{page}/authorize/{role}") fun authorize(@PathVariable page: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> @@ -46,6 +50,7 @@ class PageApp( } } + @MethodName("验证角色URL权限") @GetMapping("/authorize/{role}") fun uriAuthorize(@PathVariable role: String, uri: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> 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 cbdfd2b..b249078 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,6 +1,7 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application +import com.synebula.gaea.app.component.aop.annotation.MethodName import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.log.ILogger import com.synebula.zeus.domain.service.cmd.rbac.resource.SystemCmd @@ -22,6 +23,7 @@ class SystemApp( "系统信息", SystemView::class.java, service, systemQuery, logger ) { + @MethodName("获取角色有权系统") @GetMapping("/authorized/{role}") fun authorized(@PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> @@ -29,6 +31,7 @@ class SystemApp( } } + @MethodName("验证角色系统权限") @GetMapping("/{system}/authorize/{role}") fun authorize(@PathVariable system: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> From de843b0139dc8c654dc085d31f96c035c9a91fcb Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 8 Apr 2021 00:01:39 +0800 Subject: [PATCH 04/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9gaea=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 241d8e2..e60ec5f 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ allprojects { subprojects { ext { version '0.6.2' - gaea_version = '0.9.1' + gaea_version = '0.10.0' spring_version = "2.3.0.RELEASE" } From d3d994972f4a9ca95ca649ee1d8a35c5859ce016 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 8 Apr 2021 21:26:38 +0800 Subject: [PATCH 05/14] =?UTF-8?q?=E4=BF=AE=E8=AE=A2gaea=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e60ec5f..1aaf54c 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ allprojects { subprojects { ext { version '0.6.2' - gaea_version = '0.10.0' + gaea_version = '0.10.1' spring_version = "2.3.0.RELEASE" } From 2ccb640fa7c8524a617c89a0f93763a1b8109e5d Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 11 Apr 2021 16:15:14 +0800 Subject: [PATCH 06/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0gaea=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E8=87=B30.10.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 1aaf54c..15a7ea8 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ allprojects { subprojects { ext { version '0.6.2' - gaea_version = '0.10.1' + gaea_version = '0.10.2' spring_version = "2.3.0.RELEASE" } From 61cc17686803a50f3a660c616975936f7a3a4d57 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 12 Apr 2021 20:33:38 +0800 Subject: [PATCH 07/14] =?UTF-8?q?=E4=BF=AE=E8=AE=A2gaea=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 15a7ea8..0a74c1e 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ allprojects { subprojects { ext { version '0.6.2' - gaea_version = '0.10.2' + gaea_version = '0.10.3' spring_version = "2.3.0.RELEASE" } From 45d080b27cd90c35076fee6a0cd4897db6c6d567 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 16 Apr 2021 14:32:10 +0800 Subject: [PATCH 08/14] =?UTF-8?q?0.6.3=20=E5=A2=9E=E5=8A=A0Role=20?= =?UTF-8?q?=E5=92=8CGroup=20=E7=9A=84desc=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- .../main/kotlin/com/synebula/zeus/domain/model/rbac/Group.kt | 1 + .../main/kotlin/com/synebula/zeus/domain/model/rbac/Role.kt | 3 ++- .../com/synebula/zeus/domain/service/cmd/rbac/GroupCmd.kt | 1 + .../com/synebula/zeus/domain/service/cmd/rbac/RoleCmd.kt | 1 + .../src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt | 2 ++ .../src/main/kotlin/com/synebula/zeus/query/view/RoleView.kt | 1 + 7 files changed, 9 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 0a74c1e..f65feab 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ allprojects { subprojects { ext { - version '0.6.2' + version '0.6.3' gaea_version = '0.10.3' spring_version = "2.3.0.RELEASE" } diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Group.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Group.kt index f0476f2..ce4af1d 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Group.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Group.kt @@ -4,4 +4,5 @@ import com.synebula.gaea.domain.model.AggregateRoot class Group(override var id: String? = null) : AggregateRoot() { var name = "" + var desc = "" } \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Role.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Role.kt index d8eebe6..841096e 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Role.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Role.kt @@ -2,6 +2,7 @@ package com.synebula.zeus.domain.model.rbac import com.synebula.gaea.domain.model.AggregateRoot -class Role(override var id: String?) : AggregateRoot() { +class Role(override var id: String? = null) : AggregateRoot() { var name = "" + var desc = "" } \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/GroupCmd.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/GroupCmd.kt index c556215..2ceb6f4 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/GroupCmd.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/GroupCmd.kt @@ -5,4 +5,5 @@ import com.synebula.gaea.domain.service.Command class GroupCmd : Command() { var id: String? = null var name = "" + var desc = "" } \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/RoleCmd.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/RoleCmd.kt index 589a389..b041a82 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/RoleCmd.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/RoleCmd.kt @@ -5,4 +5,5 @@ import com.synebula.gaea.domain.service.Command class RoleCmd : Command() { var id: String? = null var name = "" + var desc = "" } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt index a8f3e9c..de2529d 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt @@ -10,4 +10,6 @@ class GroupView { @Where(Operator.like) var name = "" + + var desc = "" } diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/RoleView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/RoleView.kt index 0846d7f..65b7409 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/RoleView.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/RoleView.kt @@ -6,4 +6,5 @@ import com.synebula.gaea.query.annotation.Table class RoleView { var id: String? = null var name = "" + var desc = "" } \ No newline at end of file From d0807c56fa249cb90bea7a90499699099646a5ac Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 18 Apr 2021 00:07:34 +0800 Subject: [PATCH 09/14] =?UTF-8?q?0.7.0=20=E9=87=8D=E6=9E=84permission?= =?UTF-8?q?=E4=B8=BAauthority=E5=B9=B6=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- settings.gradle | 2 + src/zeus.app/build.gradle | 1 + .../synebula/zeus/app/config/ZeusServices.kt | 3 +- .../zeus/app/controller/rbac/AuthorityApp.kt | 42 +++++++++++++++++++ .../controller/rbac/resource/PermissionApp.kt | 21 ---------- .../zeus/domain/model/rbac/Authority.kt | 19 +++++++++ .../domain/model/rbac/resource/Permission.kt | 12 ------ .../domain/repository/IAuthorityRepository.kt | 8 ++++ .../service/cmd/rbac/AuthorityBatchAddCmd.kt | 12 ++++++ .../PermissionCmd.kt => AuthorityCmd.kt} | 8 ++-- .../service/contr/rbac/IAuthorityService.kt | 14 +++++++ .../contr/rbac/resource/IPermissionService.kt | 7 ---- .../service/impl/rbac/AuthorityService.kt | 26 ++++++++++++ .../impl/rbac/resource/PermissionService.kt | 13 ------ .../{PermissionType.kt => AuthorityType.kt} | 2 +- src/zeus.query/build.gradle | 2 +- .../zeus/query/contr/IAuthorityQuery.kt | 26 ++++++++++++ .../query/contr/resouce/IInterfaceQuery.kt | 4 +- .../zeus/query/contr/resouce/IPageQuery.kt | 6 +-- .../query/contr/resouce/IPermissionQuery.kt | 13 ------ .../zeus/query/contr/resouce/ISystemQuery.kt | 4 +- .../PermissionQuery.kt => AuthorityQuery.kt} | 21 +++++----- .../zeus/query/impl/resouce/InterfaceQuery.kt | 20 ++++----- .../zeus/query/impl/resouce/PageQuery.kt | 22 +++++----- .../zeus/query/impl/resouce/SystemQuery.kt | 13 +++--- .../synebula/zeus/query/view/AuthorityView.kt | 12 ++++++ .../query/view/resource/PermissionView.kt | 12 ------ src/zeus.repository/build.gradle | 17 ++++++++ .../zeus/repository/AuthorityRepository.kt | 22 ++++++++++ 30 files changed, 256 insertions(+), 130 deletions(-) create mode 100644 src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt delete mode 100644 src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PermissionApp.kt create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Authority.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/resource/Permission.kt create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/IAuthorityRepository.kt create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/AuthorityBatchAddCmd.kt rename src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/{resource/PermissionCmd.kt => AuthorityCmd.kt} (52%) create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAuthorityService.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPermissionService.kt create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AuthorityService.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/PermissionService.kt rename src/zeus.env/src/main/kotlin/com/synebula/zeus/env/{PermissionType.kt => AuthorityType.kt} (70%) create mode 100644 src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IAuthorityQuery.kt delete mode 100644 src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IPermissionQuery.kt rename src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/{resouce/PermissionQuery.kt => AuthorityQuery.kt} (55%) create mode 100644 src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/AuthorityView.kt delete mode 100644 src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/resource/PermissionView.kt create mode 100644 src/zeus.repository/build.gradle create mode 100644 src/zeus.repository/src/main/kotlin/com/synebula/zeus/repository/AuthorityRepository.kt diff --git a/build.gradle b/build.gradle index f65feab..827745d 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ allprojects { subprojects { ext { - version '0.6.3' + version '0.7.0' gaea_version = '0.10.3' spring_version = "2.3.0.RELEASE" } diff --git a/settings.gradle b/settings.gradle index 4999cac..4afe6bd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,3 +4,5 @@ include 'src:zeus.app' include 'src:zeus.domain' include 'src:zeus.query' include 'src:zeus.env' +include 'src:zeus.repository' + diff --git a/src/zeus.app/build.gradle b/src/zeus.app/build.gradle index a1b2418..e2f1d02 100644 --- a/src/zeus.app/build.gradle +++ b/src/zeus.app/build.gradle @@ -13,6 +13,7 @@ jar.enabled = true //jar SKIPPED问题,不设置可能会无法打jar dependencies { compile project(":src:zeus.domain") compile project(":src:zeus.query") + compile project(":src:zeus.repository") compile "com.synebula:gaea.app:$gaea_version" compile "com.synebula:gaea.mongo:$gaea_version" diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt index d4f8285..098cee4 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt @@ -10,7 +10,8 @@ import org.springframework.stereotype.Component @ComponentScan( basePackages = [ "com.synebula.zeus.domain.service.impl", - "com.synebula.zeus.query.impl" + "com.synebula.zeus.query.impl", + "com.synebula.zeus.repository" ], includeFilters = [Filter(type = FilterType.CUSTOM, classes = [AllTypeFilter::class])] ) diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt new file mode 100644 index 0000000..8a7cd7b --- /dev/null +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt @@ -0,0 +1,42 @@ +package com.synebula.zeus.app.controller.rbac + +import com.synebula.gaea.app.Application +import com.synebula.gaea.app.component.aop.annotation.MethodName +import com.synebula.gaea.app.struct.HttpMessage +import com.synebula.gaea.log.ILogger +import com.synebula.zeus.domain.service.cmd.rbac.AuthorityBatchAddCmd +import com.synebula.zeus.domain.service.cmd.rbac.AuthorityCmd +import com.synebula.zeus.domain.service.contr.rbac.IAuthorityService +import com.synebula.zeus.env.ResourceType +import com.synebula.zeus.query.contr.IAuthorityQuery +import com.synebula.zeus.query.view.AuthorityView +import org.springframework.web.bind.annotation.* + +@RestController +@RequestMapping("/authorities") +class AuthorityApp( + query: IAuthorityQuery, + logger: ILogger, + private var authorityService: IAuthorityService +) : Application( + "权限信息", AuthorityView::class.java, + authorityService, query, logger +) { + @MethodName("批量添加权限信息") + @PostMapping("/batch") + fun add(@RequestBody cmd: AuthorityBatchAddCmd): HttpMessage { + this.authorityService.add(cmd) + return HttpMessage() + } + + @MethodName("根据资源和角色删除权限") + @DeleteMapping("/{type}/role/{role}") + fun removeByResourceRole( + @PathVariable type: ResourceType, + @PathVariable role: String, + @RequestBody resource: List + ): HttpMessage { + this.authorityService.removeByResourceRole(type, resource, role) + return HttpMessage() + } +} \ No newline at end of file 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 deleted file mode 100644 index 22e8484..0000000 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/resource/PermissionApp.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.synebula.zeus.app.controller.rbac.resource - -import com.synebula.gaea.app.Application -import com.synebula.gaea.log.ILogger -import com.synebula.zeus.domain.service.cmd.rbac.resource.PermissionCmd -import com.synebula.zeus.domain.service.contr.rbac.resource.IPermissionService -import com.synebula.zeus.query.contr.resouce.IPermissionQuery -import com.synebula.zeus.query.view.resource.PermissionView -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -@RestController -@RequestMapping("/permissions") -class PermissionApp( - service: IPermissionService, - query: IPermissionQuery, - logger: ILogger -) : Application( - "权限信息", PermissionView::class.java, - service, query, logger -) \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Authority.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Authority.kt new file mode 100644 index 0000000..24947d6 --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Authority.kt @@ -0,0 +1,19 @@ +package com.synebula.zeus.domain.model.rbac + +import com.synebula.gaea.domain.model.AggregateRoot +import com.synebula.zeus.env.AuthorityType +import com.synebula.zeus.env.ResourceType + +class Authority(override var id: String? = null) : AggregateRoot() { + var role = "" + var resource = "" + var type: ResourceType? = null + var authority = AuthorityType.Allow + + constructor(role: String, resource: String, type: ResourceType?, authority: AuthorityType) : this() { + this.role = role + this.resource = resource + this.type = type + this.authority = authority + } +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/resource/Permission.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/resource/Permission.kt deleted file mode 100644 index e07d0a7..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/resource/Permission.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.synebula.zeus.domain.model.rbac.resource - -import com.synebula.gaea.domain.model.AggregateRoot -import com.synebula.zeus.env.PermissionType -import com.synebula.zeus.env.ResourceType - -class Permission(override var id: String? = null) : AggregateRoot() { - var role = "" - var resource = "" - var type: ResourceType? = null - var authority = PermissionType.Allow -} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/IAuthorityRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/IAuthorityRepository.kt new file mode 100644 index 0000000..9233b3f --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/IAuthorityRepository.kt @@ -0,0 +1,8 @@ +package com.synebula.zeus.domain.repository + +import com.synebula.gaea.domain.repository.IRepository +import com.synebula.zeus.env.ResourceType + +interface IAuthorityRepository : IRepository { + fun removeByResourceRole(type: ResourceType, resource: List, role: String) +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/AuthorityBatchAddCmd.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/AuthorityBatchAddCmd.kt new file mode 100644 index 0000000..e3ed7f6 --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/AuthorityBatchAddCmd.kt @@ -0,0 +1,12 @@ +package com.synebula.zeus.domain.service.cmd.rbac + +import com.synebula.gaea.domain.service.Command +import com.synebula.zeus.env.AuthorityType +import com.synebula.zeus.env.ResourceType + +class AuthorityBatchAddCmd : Command() { + var role = "" + var resource = listOf() + var type: ResourceType? = null + var authority = AuthorityType.Allow +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/resource/PermissionCmd.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/AuthorityCmd.kt similarity index 52% rename from src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/resource/PermissionCmd.kt rename to src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/AuthorityCmd.kt index b23a80b..36cd3dc 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/resource/PermissionCmd.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/rbac/AuthorityCmd.kt @@ -1,13 +1,13 @@ -package com.synebula.zeus.domain.service.cmd.rbac.resource +package com.synebula.zeus.domain.service.cmd.rbac import com.synebula.gaea.domain.service.Command -import com.synebula.zeus.env.PermissionType +import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType -class PermissionCmd : Command() { +class AuthorityCmd : Command() { var id: String? = null var role = "" var resource = "" var type: ResourceType? = null - var authority = PermissionType.Allow + var authority = AuthorityType.Allow } \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAuthorityService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAuthorityService.kt new file mode 100644 index 0000000..8c7e0bd --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAuthorityService.kt @@ -0,0 +1,14 @@ +package com.synebula.zeus.domain.service.contr.rbac + +import com.synebula.gaea.domain.service.IService +import com.synebula.zeus.domain.model.rbac.Authority +import com.synebula.zeus.domain.service.cmd.rbac.AuthorityBatchAddCmd +import com.synebula.zeus.env.ResourceType + +interface IAuthorityService : IService { + + fun add(cmd: AuthorityBatchAddCmd) + + fun removeByResourceRole(type: ResourceType, resource: List, role: String) + +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPermissionService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPermissionService.kt deleted file mode 100644 index 7ec3dbd..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPermissionService.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.synebula.zeus.domain.service.contr.rbac.resource - -import com.synebula.gaea.domain.service.IService - -interface IPermissionService : IService { - -} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AuthorityService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AuthorityService.kt new file mode 100644 index 0000000..76bcb8c --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AuthorityService.kt @@ -0,0 +1,26 @@ +package com.synebula.zeus.domain.service.impl.rbac + +import com.synebula.gaea.data.IObjectConverter +import com.synebula.gaea.domain.service.Service +import com.synebula.gaea.log.ILogger +import com.synebula.zeus.domain.model.rbac.Authority +import com.synebula.zeus.domain.repository.IAuthorityRepository +import com.synebula.zeus.domain.service.cmd.rbac.AuthorityBatchAddCmd +import com.synebula.zeus.domain.service.contr.rbac.IAuthorityService +import com.synebula.zeus.env.ResourceType + +class AuthorityService( + private var authorityRepository: IAuthorityRepository, + converter: IObjectConverter, logger: ILogger +) : Service(Authority::class.java, authorityRepository, converter, logger), + IAuthorityService { + + override fun add(cmd: AuthorityBatchAddCmd) { + val authorities = cmd.resource.map { Authority(cmd.role, it, cmd.type, cmd.authority) } + this.repository.add(authorities, this.clazz) + } + + override fun removeByResourceRole(type: ResourceType, resource: List, role: String) { + this.authorityRepository.removeByResourceRole(type, resource, role) + } +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/PermissionService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/PermissionService.kt deleted file mode 100644 index 6f57fcd..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/PermissionService.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.synebula.zeus.domain.service.impl.rbac.resource - -import com.synebula.gaea.data.IObjectConverter -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.gaea.domain.service.Service -import com.synebula.gaea.log.ILogger -import com.synebula.zeus.domain.model.rbac.resource.Permission -import com.synebula.zeus.domain.service.contr.rbac.resource.IPermissionService - -class PermissionService( - repository: IRepository, - converter: IObjectConverter, logger: ILogger -) : Service(Permission::class.java, repository, converter, logger), IPermissionService \ No newline at end of file diff --git a/src/zeus.env/src/main/kotlin/com/synebula/zeus/env/PermissionType.kt b/src/zeus.env/src/main/kotlin/com/synebula/zeus/env/AuthorityType.kt similarity index 70% rename from src/zeus.env/src/main/kotlin/com/synebula/zeus/env/PermissionType.kt rename to src/zeus.env/src/main/kotlin/com/synebula/zeus/env/AuthorityType.kt index 845023d..c080c85 100644 --- a/src/zeus.env/src/main/kotlin/com/synebula/zeus/env/PermissionType.kt +++ b/src/zeus.env/src/main/kotlin/com/synebula/zeus/env/AuthorityType.kt @@ -1,6 +1,6 @@ package com.synebula.zeus.env -enum class PermissionType { +enum class AuthorityType { Default, Deny, Allow diff --git a/src/zeus.query/build.gradle b/src/zeus.query/build.gradle index 2d2cafd..d1e1cfd 100644 --- a/src/zeus.query/build.gradle +++ b/src/zeus.query/build.gradle @@ -7,7 +7,7 @@ publishing { publications { publish(MavenPublication) { group 'com.synebula' - artifactId 'zeus.view' + artifactId 'zeus.query' version "$version" from components.java } diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IAuthorityQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IAuthorityQuery.kt new file mode 100644 index 0000000..a678e4b --- /dev/null +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IAuthorityQuery.kt @@ -0,0 +1,26 @@ +package com.synebula.zeus.query.contr + +import com.synebula.gaea.query.IQuery +import com.synebula.zeus.env.AuthorityType +import com.synebula.zeus.env.ResourceType +import com.synebula.zeus.query.view.AuthorityView + +interface IAuthorityQuery : IQuery { + + /** + * 获取角色已授权的资源 + * + * @param resourceType 资源类型 + * @param role 角色id + */ + fun authorized(resourceType: ResourceType, role: String): List + + /** + * 获取角色资源的授权信息 + * + * @param resourceType 资源里欸选哪个 + * @param resource 资源id + * @param role 角色id + */ + fun authorize(resourceType: ResourceType, resource: String, role: String): AuthorityType +} 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 4857359..5bce563 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 @@ -1,7 +1,7 @@ package com.synebula.zeus.query.contr.resouce import com.synebula.gaea.query.IQuery -import com.synebula.zeus.env.PermissionType +import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.query.view.resource.InterfaceView interface IInterfaceQuery : IQuery { @@ -10,5 +10,5 @@ interface IInterfaceQuery : IQuery { fun authorized(role: String, system: String?): List - fun authorize(resource: String, role: String): PermissionType? + fun authorize(resource: String, role: String): AuthorityType? } \ 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 b0c425e..c57a9c2 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 @@ -1,7 +1,7 @@ package com.synebula.zeus.query.contr.resouce import com.synebula.gaea.query.IQuery -import com.synebula.zeus.env.PermissionType +import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.query.view.resource.PageView interface IPageQuery : IQuery { @@ -10,7 +10,7 @@ interface IPageQuery : IQuery { fun authorized(role: String, system: String? ): List - fun authorize(resource: String, role: String): PermissionType? + fun authorize(resource: String, role: String): AuthorityType? - fun uriAuthorize(path: String, role: String): PermissionType? + fun uriAuthorize(path: String, role: String): AuthorityType? } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IPermissionQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IPermissionQuery.kt deleted file mode 100644 index 3e66d9a..0000000 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/resouce/IPermissionQuery.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.synebula.zeus.query.contr.resouce - -import com.synebula.gaea.query.IQuery -import com.synebula.zeus.env.PermissionType -import com.synebula.zeus.env.ResourceType -import com.synebula.zeus.query.view.resource.PermissionView - -interface IPermissionQuery : IQuery { - - fun resourcePermissions(resourceType: ResourceType, role: String): List - - fun authentication(resourceType: ResourceType, resource: String, role: String): PermissionType -} 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 ad82c64..c169971 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 @@ -1,12 +1,12 @@ package com.synebula.zeus.query.contr.resouce import com.synebula.gaea.query.IQuery -import com.synebula.zeus.env.PermissionType +import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.query.view.resource.SystemView interface ISystemQuery : IQuery { fun authorized(role: String): List - fun authorize(resource: String, role: String): PermissionType? + fun authorize(resource: String, role: String): AuthorityType? } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/PermissionQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/AuthorityQuery.kt similarity index 55% rename from src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/PermissionQuery.kt rename to src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/AuthorityQuery.kt index 24f176b..3cd011a 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/resouce/PermissionQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/AuthorityQuery.kt @@ -1,19 +1,20 @@ -package com.synebula.zeus.query.impl.resouce +package com.synebula.zeus.query.impl import com.synebula.gaea.mongo.query.MongoQuery -import com.synebula.zeus.env.PermissionType +import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType -import com.synebula.zeus.query.contr.resouce.IPermissionQuery -import com.synebula.zeus.query.view.resource.PermissionView +import com.synebula.zeus.query.contr.IAuthorityQuery +import com.synebula.zeus.query.view.AuthorityView import org.springframework.data.mongodb.core.MongoTemplate import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query -class PermissionQuery(template: MongoTemplate) : MongoQuery(template), IPermissionQuery { - var clazz = PermissionView::class.java +class AuthorityQuery(template: MongoTemplate) : MongoQuery(template), + IAuthorityQuery { + var clazz = AuthorityView::class.java var collection = this.collection(this.clazz) - override fun resourcePermissions(resourceType: ResourceType, role: String): List { + override fun authorized(resourceType: ResourceType, role: String): List { return this.template.find( Query.query( Criteria.where("type").`is`(resourceType) @@ -21,13 +22,13 @@ class PermissionQuery(template: MongoTemplate) : MongoQuery(template), IPermissi ), this.clazz, this.collection) } - override fun authentication(resourceType: ResourceType, resource: String, role: String): PermissionType { - val permission = this.template.findOne( + override fun authorize(resourceType: ResourceType, resource: String, role: String): AuthorityType { + val authority = 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 ?: PermissionType.Default + return authority?.authority ?: AuthorityType.Default } } 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 15027b2..95de796 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 @@ -1,15 +1,15 @@ package com.synebula.zeus.query.impl.resouce import com.synebula.gaea.mongo.query.MongoQuery -import com.synebula.zeus.env.PermissionType +import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType import com.synebula.zeus.query.contr.resouce.IInterfaceQuery -import com.synebula.zeus.query.contr.resouce.IPermissionQuery +import com.synebula.zeus.query.contr.IAuthorityQuery import com.synebula.zeus.query.contr.resouce.ISystemQuery import com.synebula.zeus.query.view.resource.InterfaceView import org.springframework.data.mongodb.core.MongoTemplate -class InterfaceQuery(template: MongoTemplate, var permissionQuery: IPermissionQuery, var systemQuery: ISystemQuery) : +class InterfaceQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, var systemQuery: ISystemQuery) : MongoQuery(template), IInterfaceQuery { @@ -22,21 +22,21 @@ class InterfaceQuery(template: MongoTemplate, var permissionQuery: IPermissionQu override fun authorized(role: String, system: String?): List { if (system != null) { - val permission = this.systemQuery.authorize(system, role) - if (permission == PermissionType.Deny) + val authority = this.systemQuery.authorize(system, role) + if (authority == AuthorityType.Deny) return listOf() } val params = mutableMapOf() if (system != null) params["system"] = system val interfaces = this.list(params, this.clazz) - val permissions = this.permissionQuery.resourcePermissions(ResourceType.Interface, role) + val authorities = this.authorityQuery.authorized(ResourceType.Interface, role) return interfaces.filter { i -> - val permission = permissions.find { p -> i.id == p.resource } - permission == null || permission.authority == PermissionType.Allow + val authority = authorities.find { p -> i.id == p.resource } + authority == null || authority.authority == AuthorityType.Allow } } - override fun authorize(resource: String, role: String): PermissionType { - return this.permissionQuery.authentication(ResourceType.Interface, resource, role) + override fun authorize(resource: String, role: String): AuthorityType { + return this.authorityQuery.authorize(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 1af97c1..8e3792a 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 @@ -1,17 +1,17 @@ package com.synebula.zeus.query.impl.resouce import com.synebula.gaea.mongo.query.MongoQuery -import com.synebula.zeus.env.PermissionType +import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType import com.synebula.zeus.query.contr.resouce.IPageQuery -import com.synebula.zeus.query.contr.resouce.IPermissionQuery +import com.synebula.zeus.query.contr.IAuthorityQuery import com.synebula.zeus.query.contr.resouce.ISystemQuery import com.synebula.zeus.query.view.resource.PageView import org.springframework.data.mongodb.core.MongoTemplate 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) : +class PageQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, var systemQuery: ISystemQuery) : MongoQuery(template), IPageQuery { private val clazz = PageView::class.java @@ -21,25 +21,25 @@ class PageQuery(template: MongoTemplate, var permissionQuery: IPermissionQuery, override fun authorized(role: String, system: String?): List { if (system != null) { - val permission = this.systemQuery.authorize(system, role) - if (permission == PermissionType.Deny) + val authority = this.systemQuery.authorize(system, role) + if (authority == AuthorityType.Deny) return listOf() } val params = mutableMapOf() if (system != null) params["system"] = system val pages = this.list(params, this.clazz) - val permissions = this.permissionQuery.resourcePermissions(ResourceType.Page, role) + val authorities = this.authorityQuery.authorized(ResourceType.Page, role) return pages.filter { i -> - val permission = permissions.find { p -> i.id == p.resource } - permission != null && permission.authority == PermissionType.Allow + val authority = authorities.find { p -> i.id == p.resource } + authority != null && authority.authority == AuthorityType.Allow } } - override fun authorize(resource: String, role: String): PermissionType { - return this.permissionQuery.authentication(ResourceType.Page, resource, role) + override fun authorize(resource: String, role: String): AuthorityType { + return this.authorityQuery.authorize(ResourceType.Page, resource, role) } - override fun uriAuthorize(path: String, role: String): PermissionType? { + override fun uriAuthorize(path: String, role: String): AuthorityType? { val page = this.template.findOne( Query.query(Criteria.where("uri").`is`(path)), this.clazz, this.collection(this.clazz) 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 5cb6b50..b84ac53 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 @@ -1,22 +1,23 @@ package com.synebula.zeus.query.impl.resouce import com.synebula.gaea.mongo.query.MongoQuery -import com.synebula.zeus.env.PermissionType +import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType import com.synebula.zeus.query.contr.resouce.ISystemQuery +import com.synebula.zeus.query.impl.AuthorityQuery import com.synebula.zeus.query.view.resource.SystemView import org.springframework.data.mongodb.core.MongoTemplate -class SystemQuery(template: MongoTemplate, var permissionQuery: PermissionQuery) : MongoQuery(template), ISystemQuery { +class SystemQuery(template: MongoTemplate, var authorityQuery: AuthorityQuery) : MongoQuery(template), ISystemQuery { private val clazz = SystemView::class.java 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 } + val authorities = this.authorityQuery.authorized(ResourceType.System, role) + return systems.filter { i -> authorities.find { p -> i.id == p.resource }?.authority == AuthorityType.Allow } } - override fun authorize(resource: String, role: String): PermissionType { - return this.permissionQuery.authentication(ResourceType.System, resource, role) + override fun authorize(resource: String, role: String): AuthorityType { + return this.authorityQuery.authorize(ResourceType.System, resource, role) } } \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/AuthorityView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/AuthorityView.kt new file mode 100644 index 0000000..1613030 --- /dev/null +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/AuthorityView.kt @@ -0,0 +1,12 @@ +package com.synebula.zeus.query.view + +import com.synebula.zeus.env.AuthorityType +import com.synebula.zeus.env.ResourceType + +class AuthorityView() { + var id: String? = null + var role = "" + var resource = "" + var type: ResourceType? = null + var authority = AuthorityType.Allow +} \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/resource/PermissionView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/resource/PermissionView.kt deleted file mode 100644 index 2031afd..0000000 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/resource/PermissionView.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.synebula.zeus.query.view.resource - -import com.synebula.zeus.env.PermissionType -import com.synebula.zeus.env.ResourceType - -class PermissionView() { - var id: String? = null - var role = "" - var resource = "" - var type: ResourceType? = null - var authority = PermissionType.Allow -} \ No newline at end of file diff --git a/src/zeus.repository/build.gradle b/src/zeus.repository/build.gradle new file mode 100644 index 0000000..1754059 --- /dev/null +++ b/src/zeus.repository/build.gradle @@ -0,0 +1,17 @@ +dependencies { + compile project(":src:zeus.env") + compile project(":src:zeus.domain") + compile "com.synebula:gaea.mongo:$gaea_version" +} + +publishing { + publications { + publish(MavenPublication) { + group 'com.synebula' + artifactId 'zeus.repository' + version "$version" + from components.java + } + } +} + diff --git a/src/zeus.repository/src/main/kotlin/com/synebula/zeus/repository/AuthorityRepository.kt b/src/zeus.repository/src/main/kotlin/com/synebula/zeus/repository/AuthorityRepository.kt new file mode 100644 index 0000000..9f9b3a6 --- /dev/null +++ b/src/zeus.repository/src/main/kotlin/com/synebula/zeus/repository/AuthorityRepository.kt @@ -0,0 +1,22 @@ +package com.synebula.zeus.repository + +import com.synebula.gaea.mongo.repository.MongoRepository +import com.synebula.zeus.domain.model.rbac.Authority +import com.synebula.zeus.domain.repository.IAuthorityRepository +import com.synebula.zeus.env.ResourceType +import org.springframework.data.mongodb.core.MongoTemplate +import org.springframework.data.mongodb.core.query.Criteria +import org.springframework.data.mongodb.core.query.Query + +class AuthorityRepository(var template: MongoTemplate) : MongoRepository(template), IAuthorityRepository { + override fun removeByResourceRole(type: ResourceType, resource: List, role: String) { + this.template.remove( + Query.query( + Criteria.where("type").`is`(type) + .and("resource").`in`(resource) + .and("role").`is`(role) + ), + Authority::class.java + ) + } +} \ No newline at end of file From 65ced3febefa555f99452efdf6690af905e132f0 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 13 May 2021 19:07:33 +0800 Subject: [PATCH 10/14] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=95=E7=94=A80.11.?= =?UTF-8?q?0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- .../synebula/zeus/domain/service/impl/rbac/UserService.kt | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 827745d..843f9ad 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ allprojects { subprojects { ext { version '0.7.0' - gaea_version = '0.10.3' + gaea_version = '0.11.0' spring_version = "2.3.0.RELEASE" } diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt index 0af5f01..fbea66e 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt @@ -60,7 +60,7 @@ class UserService( * @param key 用户ID */ override fun active(key: String, token: String): DataMessage { - val user = this.repository.get(key, this.clazz) + val user = this.repository.get(key, this.clazz)!! return if (user.alive) { DataMessage("用户${user.name}无需重复激活") } else { @@ -77,7 +77,7 @@ class UserService( } override fun changePassword(key: String, password: String, newPassword: String): DataMessage { - val user = this.repository.get(key, this.clazz) + val user = this.repository.get(key, this.clazz)!! return if (user.password == password.toMd5()) { user.password = newPassword.toMd5() user.token = null @@ -91,7 +91,7 @@ class UserService( override fun resetPassword(key: String, password: String, token: String?): DataMessage { - val user = this.repository.get(key, this.clazz) + val user = this.repository.get(key, this.clazz)!! return if (token == user.token) { user.password = password.toMd5() user.token = null @@ -104,7 +104,7 @@ class UserService( } override fun forgotPassword(key: String): DataMessage { - val user = this.repository.get(key, this.clazz) + val user = this.repository.get(key, this.clazz)!! return if (user.alive) { user.token = UUID.randomUUID().toString() this.repository.update(user, this.clazz) From 48d761e79c7739be53131bae3ce4df8929ec5575 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 25 May 2021 15:13:08 +0800 Subject: [PATCH 11/14] =?UTF-8?q?0.7.1=20=E4=BF=AE=E6=94=B9=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=ACgaea=E5=BC=95=E5=85=A5=E5=B8=A6=E6=9D=A5?= =?UTF-8?q?=E7=9A=84=E8=AF=AD=E6=B3=95=E8=A7=84=E8=8C=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++-- .../kotlin/com/synebula/zeus/app/controller/rbac/UserApp.kt | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 843f9ad..4d5dcd0 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,8 @@ allprojects { subprojects { ext { - version '0.7.0' - gaea_version = '0.11.0' + version '0.7.1' + gaea_version = '0.13.0' spring_version = "2.3.0.RELEASE" } 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 80eca15..cc44721 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 @@ -28,7 +28,7 @@ class UserApp( override fun add(command: UserCmd): HttpMessage { return this.safeExecute("查询重复用户信息出错, 用户信息: ${serializer.serialize(command)}") { - val list = this.query!!.list(mapOf(Pair("name", command.name)), UserView::class.java) + val list = this.query.list(mapOf(Pair("name", command.name)), UserView::class.java) if (list.count() == 0) it.from(super.add(command)) else { @@ -54,8 +54,8 @@ class UserApp( @GetMapping("/{name}/forgot") fun forgot(@PathVariable name: String): HttpMessage { return this.safeExecute("遗忘用户密码出现异常") { - val users = this.query?.list(mapOf(Pair("name", name)), UserView::class.java) - if (users != null && users.isNotEmpty()) { + val users = this.query.list(mapOf(Pair("name", name)), UserView::class.java) + if (users.isNotEmpty()) { it.load((this.service as IUserService).forgotPassword(users[0].id)) } else { From 37713b6d320867a45c5b301566d14b052a7a87b7 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 19 Aug 2022 16:05:22 +0800 Subject: [PATCH 12/14] =?UTF-8?q?0.8.0=20=E5=BC=95=E5=85=A5GAEA=201.0?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 19 +++-- src/zeus.app/build.gradle | 11 +-- .../synebula/zeus/app/component/ZeusAspect.kt | 2 +- .../com/synebula/zeus/app/config/ZeusBeans.kt | 25 +----- .../synebula/zeus/app/config/ZeusServices.kt | 16 +--- .../zeus/app/controller/SignInOutApp.kt | 18 ++--- .../zeus/app/controller/rbac/AuthorityApp.kt | 9 +-- .../zeus/app/controller/rbac/GroupApp.kt | 7 +- .../zeus/app/controller/rbac/RoleApp.kt | 7 +- .../zeus/app/controller/rbac/UserApp.kt | 13 ++-- .../controller/rbac/resource/InterfaceApp.kt | 11 ++- .../app/controller/rbac/resource/PageApp.kt | 17 ++-- .../app/controller/rbac/resource/SystemApp.kt | 9 +-- src/zeus.domain/build.gradle | 4 +- .../{ => rbac}/IAuthorityRepository.kt | 5 +- .../repository/rbac/IGroupRepository.kt | 7 ++ .../domain/repository/rbac/IRoleRepository.kt | 7 ++ .../domain/repository/rbac/IUserRepository.kt | 7 ++ .../rbac/resource/IInterfaceRepository.kt | 7 ++ .../rbac/resource/IPageRepository.kt | 7 ++ .../rbac/resource/ISystemRepository.kt | 7 ++ .../{contr => }/component/IUserNotifier.kt | 2 +- .../service/contr/rbac/IGroupService.kt | 8 +- .../domain/service/contr/rbac/IRoleService.kt | 8 +- .../contr/rbac/resource/IInterfaceService.kt | 8 +- .../contr/rbac/resource/IPageService.kt | 8 +- .../contr/rbac/resource/ISystemService.kt | 8 +- .../service/impl/rbac/AuthorityService.kt | 11 ++- .../domain/service/impl/rbac/GroupService.kt | 13 ---- .../domain/service/impl/rbac/RoleService.kt | 13 ---- .../domain/service/impl/rbac/UserService.kt | 77 +++++++++---------- .../impl/rbac/resource/InterfaceService.kt | 13 ---- .../service/impl/rbac/resource/PageService.kt | 13 ---- .../impl/rbac/resource/SystemService.kt | 13 ---- src/zeus.env/build.gradle | 2 +- src/zeus.query/build.gradle | 4 +- .../zeus/query/contr/IAuthorityQuery.kt | 2 +- .../synebula/zeus/query/contr/IGroupQuery.kt | 6 ++ .../synebula/zeus/query/contr/IRoleQuery.kt | 6 ++ .../synebula/zeus/query/contr/IUserQuery.kt | 3 +- .../query/contr/resouce/IInterfaceQuery.kt | 2 +- .../zeus/query/contr/resouce/IPageQuery.kt | 2 +- .../zeus/query/contr/resouce/ISystemQuery.kt | 2 +- .../zeus/query/impl/AuthorityQuery.kt | 27 +++---- .../com/synebula/zeus/query/impl/UserQuery.kt | 7 +- .../zeus/query/impl/resouce/InterfaceQuery.kt | 16 ++-- .../zeus/query/impl/resouce/PageQuery.kt | 9 +-- .../zeus/query/impl/resouce/SystemQuery.kt | 10 +-- .../com/synebula/zeus/query/view/GroupView.kt | 7 +- .../com/synebula/zeus/query/view/RoleView.kt | 2 +- .../com/synebula/zeus/query/view/UserView.kt | 6 +- src/zeus.repository/build.gradle | 6 +- .../zeus/repository/AuthorityRepository.kt | 7 +- 53 files changed, 246 insertions(+), 290 deletions(-) rename src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/{ => rbac}/IAuthorityRepository.kt (52%) create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IGroupRepository.kt create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IRoleRepository.kt create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IUserRepository.kt create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IInterfaceRepository.kt create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IPageRepository.kt create mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/ISystemRepository.kt rename src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/{contr => }/component/IUserNotifier.kt (71%) delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/GroupService.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/RoleService.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/InterfaceService.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/PageService.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/SystemService.kt create mode 100644 src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IGroupQuery.kt create mode 100644 src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IRoleQuery.kt diff --git a/build.gradle b/build.gradle index 4d5dcd0..f181fbe 100644 --- a/build.gradle +++ b/build.gradle @@ -1,11 +1,11 @@ buildscript { ext { - kotlin_version = '1.3.72' + kotlin_version = '1.6.10' } repositories { mavenLocal() - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } mavenCentral() } @@ -22,34 +22,33 @@ allprojects { subprojects { ext { version '0.7.1' - gaea_version = '0.13.0' - spring_version = "2.3.0.RELEASE" + gaea_version = '1.1.0' + spring_version = "2.7.0" } buildscript { repositories { mavenLocal() - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } mavenCentral() } } repositories { mavenLocal() - maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' } mavenCentral() } apply plugin: 'idea' apply plugin: 'java' apply plugin: 'kotlin' - apply plugin: 'maven' apply plugin: 'maven-publish' dependencies { - compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" - testCompile group: 'junit', name: 'junit', version: '4.12' + api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + api "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + testApi group: 'junit', name: 'junit', version: '4.12' } sourceCompatibility = 1.8 diff --git a/src/zeus.app/build.gradle b/src/zeus.app/build.gradle index e2f1d02..8e40c6a 100644 --- a/src/zeus.app/build.gradle +++ b/src/zeus.app/build.gradle @@ -11,11 +11,12 @@ apply plugin: 'kotlin-spring' jar.enabled = true //jar SKIPPED问题,不设置可能会无法打jar dependencies { - compile project(":src:zeus.domain") - compile project(":src:zeus.query") - compile project(":src:zeus.repository") - compile "com.synebula:gaea.app:$gaea_version" - compile "com.synebula:gaea.mongo:$gaea_version" + api project(":src:zeus.domain") + api project(":src:zeus.query") + api project(":src:zeus.repository") + api "com.synebula:gaea.app:$gaea_version" + api "com.synebula:gaea.spring:$gaea_version" + api "com.synebula:gaea.mongodb:$gaea_version" } 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 03372e6..bd24aff 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 @@ -1,6 +1,6 @@ package com.synebula.zeus.app.component -import com.synebula.gaea.app.component.aop.AppAspect +import com.synebula.gaea.spring.aop.AppAspect import org.aspectj.lang.annotation.Aspect import org.aspectj.lang.annotation.Pointcut import org.springframework.stereotype.Component 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 6850c89..9742d30 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 @@ -2,37 +2,14 @@ package com.synebula.zeus.app.config import com.google.gson.Gson import com.synebula.gaea.data.serialization.json.IJsonSerializer -import com.synebula.gaea.domain.model.IAggregateRoot -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.gaea.log.ILogger -import com.synebula.gaea.mongo.query.MongoQuery -import com.synebula.gaea.mongo.repository.MongoRepository -import com.synebula.gaea.query.IQuery -import com.synebula.zeus.domain.service.contr.component.IUserNotifier import org.springframework.context.annotation.Bean import org.springframework.context.annotation.ComponentScan import org.springframework.context.annotation.Configuration -import org.springframework.context.annotation.Primary -import org.springframework.data.mongodb.core.MongoTemplate @Configuration -@ComponentScan( - basePackages = [ - "com.synebula.gaea.app.component" - ] -) +@ComponentScan(basePackages = ["com.synebula.gaea.app.component"]) class ZeusBeans { - @Bean - @Primary - fun > repository(template: MongoTemplate) - : IRepository = MongoRepository(template) - - @Bean - @Primary - fun query(template: MongoTemplate, logger: ILogger? = null) - : IQuery = MongoQuery(template, logger) - @Bean fun gson(): Gson = Gson() diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt index 098cee4..34f986c 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt @@ -1,18 +1,10 @@ package com.synebula.zeus.app.config -import com.synebula.gaea.app.component.AllTypeFilter -import org.springframework.context.annotation.ComponentScan -import org.springframework.context.annotation.ComponentScan.Filter -import org.springframework.context.annotation.FilterType +import com.synebula.gaea.app.autoconfig.service.ServiceScan +import com.synebula.gaea.mongodb.autoconfig.MongodbRepoScan import org.springframework.stereotype.Component @Component -@ComponentScan( - basePackages = [ - "com.synebula.zeus.domain.service.impl", - "com.synebula.zeus.query.impl", - "com.synebula.zeus.repository" - ], - includeFilters = [Filter(type = FilterType.CUSTOM, classes = [AllTypeFilter::class])] -) +@ServiceScan(basePackages = ["com.synebula.zeus.domain.service"]) +@MongodbRepoScan(basePackages = ["com.synebula.zeus.domain.repository", "com.synebula.zeus.repository", "com.synebula.zeus.query"]) class ZeusServices \ No newline at end of file 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 aa1a8e5..b5ce5cc 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,17 +1,15 @@ package com.synebula.zeus.app.controller import com.synebula.gaea.app.IApplication -import com.synebula.gaea.app.component.aop.annotation.MethodName 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.gaea.spring.aop.annotation.Method 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.view.UserView import org.springframework.beans.factory.annotation.Autowired import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody @@ -20,9 +18,7 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/sign") -class SignInOutApp(override var logger: ILogger?) : IApplication { - @Autowired - lateinit var query: IQuery +class SignInOutApp(override var logger: ILogger) : IApplication { @Autowired lateinit var userQuery: IUserQuery @@ -38,7 +34,7 @@ class SignInOutApp(override var logger: ILogger?) : IApplication { override var name: String = "用户登录管理" - @MethodName("用户登录") + @Method("用户登录") @PostMapping("/in") fun signIn(name: String, password: String, remember: Boolean?): HttpMessage { return this.safeExecute("用户登录出现异常") { @@ -54,18 +50,18 @@ class SignInOutApp(override var logger: ILogger?) : IApplication { } } - @MethodName("用户登出") + @Method("用户登出") @PostMapping("/out") fun signOut(user: String): HttpMessage { return HttpMessage(user) } - @MethodName("用户注册") + @Method("用户注册") @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 list = this.userQuery.list(mapOf(Pair("name", command.name))) + if (list.isEmpty()) { val message = userService.add(command) it.data = message.data } else { diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt index 8a7cd7b..bbaed5c 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt @@ -1,9 +1,9 @@ package com.synebula.zeus.app.controller.rbac import com.synebula.gaea.app.Application -import com.synebula.gaea.app.component.aop.annotation.MethodName import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.log.ILogger +import com.synebula.gaea.spring.aop.annotation.Method import com.synebula.zeus.domain.service.cmd.rbac.AuthorityBatchAddCmd import com.synebula.zeus.domain.service.cmd.rbac.AuthorityCmd import com.synebula.zeus.domain.service.contr.rbac.IAuthorityService @@ -19,17 +19,16 @@ class AuthorityApp( logger: ILogger, private var authorityService: IAuthorityService ) : Application( - "权限信息", AuthorityView::class.java, - authorityService, query, logger + "权限信息", authorityService, query, logger ) { - @MethodName("批量添加权限信息") + @Method("批量添加权限信息") @PostMapping("/batch") fun add(@RequestBody cmd: AuthorityBatchAddCmd): HttpMessage { this.authorityService.add(cmd) return HttpMessage() } - @MethodName("根据资源和角色删除权限") + @Method("根据资源和角色删除权限") @DeleteMapping("/{type}/role/{role}") fun removeByResourceRole( @PathVariable type: ResourceType, 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 4e84b27..188f84f 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 @@ -2,9 +2,9 @@ package com.synebula.zeus.app.controller.rbac import com.synebula.gaea.app.Application import com.synebula.gaea.log.ILogger -import com.synebula.gaea.query.IQuery import com.synebula.zeus.domain.service.cmd.rbac.GroupCmd import com.synebula.zeus.domain.service.contr.rbac.IGroupService +import com.synebula.zeus.query.contr.IGroupQuery import com.synebula.zeus.query.view.GroupView import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @@ -13,9 +13,8 @@ import org.springframework.web.bind.annotation.RestController @RequestMapping("/groups") class GroupApp( service: IGroupService, - query: IQuery, + query: IGroupQuery, logger: ILogger ) : Application( - "分组信息", GroupView::class.java, - service, query, logger + "分组信息", service, query, logger ) \ No newline at end of file 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 6354c7d..b6dfa65 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 @@ -2,9 +2,9 @@ package com.synebula.zeus.app.controller.rbac import com.synebula.gaea.app.Application import com.synebula.gaea.log.ILogger -import com.synebula.gaea.query.IQuery import com.synebula.zeus.domain.service.cmd.rbac.RoleCmd import com.synebula.zeus.domain.service.contr.rbac.IRoleService +import com.synebula.zeus.query.contr.IRoleQuery import com.synebula.zeus.query.view.RoleView import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @@ -13,9 +13,8 @@ import org.springframework.web.bind.annotation.RestController @RequestMapping("/roles") class RoleApp( service: IRoleService, - query: IQuery, + query: IRoleQuery, logger: ILogger ) : Application( - "用户信息", RoleView::class.java, - service, query, logger + "用户信息", service, query, logger ) \ No newline at end of file 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 cc44721..f2aeb3c 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 @@ -5,9 +5,9 @@ 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.view.UserView import org.springframework.beans.factory.annotation.Autowired import org.springframework.web.bind.annotation.* @@ -16,11 +16,10 @@ import org.springframework.web.bind.annotation.* @RequestMapping("/users") class UserApp( service: IUserService, - query: IQuery, + query: IUserQuery, logger: ILogger ) : Application( - "用户信息", UserView::class.java, - service, query, logger + "用户信息", service, query, logger ) { @Autowired @@ -28,8 +27,8 @@ class UserApp( override fun add(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 list = this.query.list(mapOf(Pair("name", command.name))) + if (list.isEmpty()) it.from(super.add(command)) else { it.status = Status.Failure @@ -54,7 +53,7 @@ class UserApp( @GetMapping("/{name}/forgot") fun forgot(@PathVariable name: String): HttpMessage { return this.safeExecute("遗忘用户密码出现异常") { - val users = this.query.list(mapOf(Pair("name", name)), UserView::class.java) + val users = this.query.list(mapOf(Pair("name", name))) if (users.isNotEmpty()) { it.load((this.service as IUserService).forgotPassword(users[0].id)) 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 6ae965c..0a62685 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,9 +1,9 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application -import com.synebula.gaea.app.component.aop.annotation.MethodName import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.log.ILogger +import com.synebula.gaea.spring.aop.annotation.Method import com.synebula.zeus.domain.service.cmd.rbac.resource.InterfaceCmd import com.synebula.zeus.domain.service.contr.rbac.resource.IInterfaceService import com.synebula.zeus.query.contr.resouce.IInterfaceQuery @@ -20,11 +20,10 @@ class InterfaceApp( logger: ILogger, var interfaceQuery: IInterfaceQuery ) : Application( - "接口信息", InterfaceView::class.java, - service, interfaceQuery, logger + "接口信息", service, interfaceQuery, logger ) { - @MethodName("获取角色系统下有权接口") + @Method("获取角色系统下有权接口") @GetMapping("/in-system/{system}/authorized/{role}") fun authorized(@PathVariable system: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> @@ -32,7 +31,7 @@ class InterfaceApp( } } - @MethodName("获取角色全部有权接口") + @Method("获取角色全部有权接口") @GetMapping("/authorized/{role}") fun authorized(@PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> @@ -40,7 +39,7 @@ class InterfaceApp( } } - @MethodName("验证角色接口权限") + @Method("验证角色接口权限") @GetMapping("/{api}/authorize/{role}") fun authorize(@PathVariable api: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> 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 cd6501e..76da845 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,10 +1,10 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application -import com.synebula.gaea.app.component.aop.annotation.MethodName -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.gaea.spring.aop.annotation.Method +import com.synebula.gaea.spring.aop.annotation.Module import com.synebula.zeus.domain.service.cmd.rbac.resource.PageCmd import com.synebula.zeus.domain.service.contr.rbac.resource.IPageService import com.synebula.zeus.query.contr.resouce.IPageQuery @@ -16,17 +16,16 @@ import org.springframework.web.bind.annotation.RestController @RestController @RequestMapping("/pages") -@ModuleName("页面") +@Module("页面") class PageApp( service: IPageService, logger: ILogger, var pageQuery: IPageQuery ) : Application( - "页面信息", PageView::class.java, - service, pageQuery, logger + "页面信息", service, pageQuery, logger ) { - @MethodName("获取角色系统下有权页面") + @Method("获取角色系统下有权页面") @GetMapping("/in-system/{system}/authorized/{role}") fun authorized(@PathVariable system: String, @PathVariable role: String): HttpMessage { val msg = HttpMessage() @@ -34,7 +33,7 @@ class PageApp( return msg } - @MethodName("获取角色全部有权页面") + @Method("获取角色全部有权页面") @GetMapping("/authorized/{role}") fun authorized(@PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> @@ -42,7 +41,7 @@ class PageApp( } } - @MethodName("验证角色页面权限") + @Method("验证角色页面权限") @GetMapping("/{page}/authorize/{role}") fun authorize(@PathVariable page: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> @@ -50,7 +49,7 @@ class PageApp( } } - @MethodName("验证角色URL权限") + @Method("验证角色URL权限") @GetMapping("/authorize/{role}") fun uriAuthorize(@PathVariable role: String, uri: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> 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 b249078..9829cde 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,9 +1,9 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application -import com.synebula.gaea.app.component.aop.annotation.MethodName import com.synebula.gaea.app.struct.HttpMessage import com.synebula.gaea.log.ILogger +import com.synebula.gaea.spring.aop.annotation.Method import com.synebula.zeus.domain.service.cmd.rbac.resource.SystemCmd import com.synebula.zeus.domain.service.contr.rbac.resource.ISystemService import com.synebula.zeus.query.contr.resouce.ISystemQuery @@ -20,10 +20,9 @@ class SystemApp( logger: ILogger, var systemQuery: ISystemQuery ) : Application( - "系统信息", SystemView::class.java, - service, systemQuery, logger + "系统信息", service, systemQuery, logger ) { - @MethodName("获取角色有权系统") + @Method("获取角色有权系统") @GetMapping("/authorized/{role}") fun authorized(@PathVariable role: String): HttpMessage { return this.safeExecute("获取有权资源列表失败") { msg -> @@ -31,7 +30,7 @@ class SystemApp( } } - @MethodName("验证角色系统权限") + @Method("验证角色系统权限") @GetMapping("/{system}/authorize/{role}") fun authorize(@PathVariable system: String, @PathVariable role: String): HttpMessage { return this.safeExecute("获取权限信息失败") { msg -> diff --git a/src/zeus.domain/build.gradle b/src/zeus.domain/build.gradle index 039e485..7878df1 100644 --- a/src/zeus.domain/build.gradle +++ b/src/zeus.domain/build.gradle @@ -1,6 +1,6 @@ dependencies { - compile project(":src:zeus.env") - compile "com.synebula:gaea:$gaea_version" + api project(":src:zeus.env") + api "com.synebula:gaea:$gaea_version" } publishing { diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/IAuthorityRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IAuthorityRepository.kt similarity index 52% rename from src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/IAuthorityRepository.kt rename to src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IAuthorityRepository.kt index 9233b3f..4a5e268 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/IAuthorityRepository.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IAuthorityRepository.kt @@ -1,8 +1,9 @@ -package com.synebula.zeus.domain.repository +package com.synebula.zeus.domain.repository.rbac import com.synebula.gaea.domain.repository.IRepository +import com.synebula.zeus.domain.model.rbac.Authority import com.synebula.zeus.env.ResourceType -interface IAuthorityRepository : IRepository { +interface IAuthorityRepository : IRepository { fun removeByResourceRole(type: ResourceType, resource: List, role: String) } \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IGroupRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IGroupRepository.kt new file mode 100644 index 0000000..209eda5 --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IGroupRepository.kt @@ -0,0 +1,7 @@ +package com.synebula.zeus.domain.repository.rbac + +import com.synebula.gaea.domain.repository.IRepository +import com.synebula.zeus.domain.model.rbac.Group + +interface IGroupRepository : IRepository { +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IRoleRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IRoleRepository.kt new file mode 100644 index 0000000..b05f633 --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IRoleRepository.kt @@ -0,0 +1,7 @@ +package com.synebula.zeus.domain.repository.rbac + +import com.synebula.gaea.domain.repository.IRepository +import com.synebula.zeus.domain.model.rbac.Role + +interface IRoleRepository : IRepository { +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IUserRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IUserRepository.kt new file mode 100644 index 0000000..2c59d0e --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IUserRepository.kt @@ -0,0 +1,7 @@ +package com.synebula.zeus.domain.repository.rbac + +import com.synebula.gaea.domain.repository.IRepository +import com.synebula.zeus.domain.model.rbac.User + +interface IUserRepository : IRepository { +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IInterfaceRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IInterfaceRepository.kt new file mode 100644 index 0000000..bbda35f --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IInterfaceRepository.kt @@ -0,0 +1,7 @@ +package com.synebula.zeus.domain.repository.rbac.resource + +import com.synebula.gaea.domain.repository.IRepository +import com.synebula.zeus.domain.model.rbac.resource.Interface + +interface IInterfaceRepository : IRepository { +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IPageRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IPageRepository.kt new file mode 100644 index 0000000..a89bd0d --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IPageRepository.kt @@ -0,0 +1,7 @@ +package com.synebula.zeus.domain.repository.rbac.resource + +import com.synebula.gaea.domain.repository.IRepository +import com.synebula.zeus.domain.model.rbac.resource.Page + +interface IPageRepository : IRepository { +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/ISystemRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/ISystemRepository.kt new file mode 100644 index 0000000..42bf4ab --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/ISystemRepository.kt @@ -0,0 +1,7 @@ +package com.synebula.zeus.domain.repository.rbac.resource + +import com.synebula.gaea.domain.repository.IRepository +import com.synebula.zeus.domain.model.rbac.resource.System + +interface ISystemRepository : IRepository { +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/component/IUserNotifier.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/component/IUserNotifier.kt similarity index 71% rename from src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/component/IUserNotifier.kt rename to src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/component/IUserNotifier.kt index 3138d19..0ab8a8c 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/component/IUserNotifier.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/component/IUserNotifier.kt @@ -1,4 +1,4 @@ -package com.synebula.zeus.domain.service.contr.component +package com.synebula.zeus.domain.service.component interface IUserNotifier { fun added(id: String, name: String, token: String) diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IGroupService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IGroupService.kt index 1d112cb..5a92a45 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IGroupService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IGroupService.kt @@ -1,7 +1,9 @@ package com.synebula.zeus.domain.service.contr.rbac import com.synebula.gaea.domain.service.IService +import com.synebula.gaea.domain.service.ServiceDependency +import com.synebula.zeus.domain.model.rbac.Group +import com.synebula.zeus.domain.repository.rbac.IGroupRepository -interface IGroupService : IService { - -} \ No newline at end of file +@ServiceDependency(clazz = Group::class, repo = IGroupRepository::class) +interface IGroupService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IRoleService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IRoleService.kt index f4ad941..b5726ed 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IRoleService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IRoleService.kt @@ -1,7 +1,9 @@ package com.synebula.zeus.domain.service.contr.rbac import com.synebula.gaea.domain.service.IService +import com.synebula.gaea.domain.service.ServiceDependency +import com.synebula.zeus.domain.model.rbac.Role +import com.synebula.zeus.domain.repository.rbac.IRoleRepository -interface IRoleService : IService { - -} \ No newline at end of file +@ServiceDependency(clazz = Role::class, repo = IRoleRepository::class) +interface IRoleService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IInterfaceService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IInterfaceService.kt index d54c875..f272d3d 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IInterfaceService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IInterfaceService.kt @@ -1,7 +1,9 @@ package com.synebula.zeus.domain.service.contr.rbac.resource import com.synebula.gaea.domain.service.IService +import com.synebula.gaea.domain.service.ServiceDependency +import com.synebula.zeus.domain.model.rbac.resource.Interface +import com.synebula.zeus.domain.repository.rbac.resource.IInterfaceRepository -interface IInterfaceService : IService { - -} \ No newline at end of file +@ServiceDependency(clazz = Interface::class, repo = IInterfaceRepository::class) +interface IInterfaceService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPageService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPageService.kt index d072b77..efb5bbc 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPageService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPageService.kt @@ -1,7 +1,9 @@ package com.synebula.zeus.domain.service.contr.rbac.resource import com.synebula.gaea.domain.service.IService +import com.synebula.gaea.domain.service.ServiceDependency +import com.synebula.zeus.domain.model.rbac.resource.Page +import com.synebula.zeus.domain.repository.rbac.resource.IPageRepository -interface IPageService : IService { - -} \ No newline at end of file +@ServiceDependency(clazz = Page::class, repo = IPageRepository::class) +interface IPageService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/ISystemService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/ISystemService.kt index 3ed21d8..d3ca2ad 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/ISystemService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/ISystemService.kt @@ -1,7 +1,9 @@ package com.synebula.zeus.domain.service.contr.rbac.resource import com.synebula.gaea.domain.service.IService +import com.synebula.gaea.domain.service.ServiceDependency +import com.synebula.zeus.domain.model.rbac.resource.System +import com.synebula.zeus.domain.repository.rbac.resource.ISystemRepository -interface ISystemService : IService { - -} \ No newline at end of file +@ServiceDependency(clazz = System::class, repo = ISystemRepository::class) +interface ISystemService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AuthorityService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AuthorityService.kt index 76bcb8c..9d712ac 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AuthorityService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AuthorityService.kt @@ -1,23 +1,22 @@ package com.synebula.zeus.domain.service.impl.rbac -import com.synebula.gaea.data.IObjectConverter +import com.synebula.gaea.data.serialization.IObjectMapper import com.synebula.gaea.domain.service.Service -import com.synebula.gaea.log.ILogger import com.synebula.zeus.domain.model.rbac.Authority -import com.synebula.zeus.domain.repository.IAuthorityRepository +import com.synebula.zeus.domain.repository.rbac.IAuthorityRepository import com.synebula.zeus.domain.service.cmd.rbac.AuthorityBatchAddCmd import com.synebula.zeus.domain.service.contr.rbac.IAuthorityService import com.synebula.zeus.env.ResourceType class AuthorityService( private var authorityRepository: IAuthorityRepository, - converter: IObjectConverter, logger: ILogger -) : Service(Authority::class.java, authorityRepository, converter, logger), + mapper: IObjectMapper +) : Service(Authority::class.java, authorityRepository, mapper), IAuthorityService { override fun add(cmd: AuthorityBatchAddCmd) { val authorities = cmd.resource.map { Authority(cmd.role, it, cmd.type, cmd.authority) } - this.repository.add(authorities, this.clazz) + this.repository.add(authorities) } override fun removeByResourceRole(type: ResourceType, resource: List, role: String) { diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/GroupService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/GroupService.kt deleted file mode 100644 index d462d17..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/GroupService.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.synebula.zeus.domain.service.impl.rbac - -import com.synebula.gaea.data.IObjectConverter -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.gaea.domain.service.Service -import com.synebula.gaea.log.ILogger -import com.synebula.zeus.domain.model.rbac.Group -import com.synebula.zeus.domain.service.contr.rbac.IGroupService - -class GroupService( - repository: IRepository, - converter: IObjectConverter, logger: ILogger -) : Service(Group::class.java, repository, converter, logger), IGroupService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/RoleService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/RoleService.kt deleted file mode 100644 index fcfb274..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/RoleService.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.synebula.zeus.domain.service.impl.rbac - -import com.synebula.gaea.data.IObjectConverter -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.gaea.domain.service.Service -import com.synebula.gaea.log.ILogger -import com.synebula.zeus.domain.model.rbac.Role -import com.synebula.zeus.domain.service.contr.rbac.IRoleService - -class RoleService( - repository: IRepository, - converter: IObjectConverter, logger: ILogger -) : Service(Role::class.java, repository, converter, logger), IRoleService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt index fbea66e..b6b1f1a 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt @@ -1,55 +1,50 @@ package com.synebula.zeus.domain.service.impl.rbac -import com.synebula.gaea.data.IObjectConverter import com.synebula.gaea.data.message.DataMessage -import com.synebula.gaea.data.message.Message import com.synebula.gaea.data.message.Status -import com.synebula.gaea.domain.repository.IRepository +import com.synebula.gaea.data.serialization.IObjectMapper import com.synebula.gaea.domain.service.ICommand import com.synebula.gaea.domain.service.Service import com.synebula.gaea.ext.toMd5 import com.synebula.gaea.log.ILogger import com.synebula.zeus.domain.model.rbac.User -import com.synebula.zeus.domain.service.contr.component.IUserNotifier -import com.synebula.zeus.domain.service.contr.rbac.IGroupService -import com.synebula.zeus.domain.service.contr.rbac.IRoleService +import com.synebula.zeus.domain.repository.rbac.IUserRepository +import com.synebula.zeus.domain.service.component.IUserNotifier import com.synebula.zeus.domain.service.contr.rbac.IUserService import java.util.* class UserService( - repository: IRepository, - converter: IObjectConverter, - logger: ILogger, - groupService: IGroupService, - roleService: IRoleService, - var userNotifier: IUserNotifier? -) : Service(User::class.java, repository, converter, logger), IUserService { + repository: IUserRepository, + mapper: IObjectMapper, + var userNotifier: IUserNotifier?, + var logger: ILogger +) : Service(User::class.java, repository, mapper), IUserService { - init { - groupService.addBeforeRemoveListener(this.clazz.name) { id -> - val msg = Message() - if (this.repository.count(mapOf(Pair("group", id)), this.clazz) > 0) { - msg.status = Status.Failure - msg.message = "组下还有用户" - } - msg - } - roleService.addBeforeRemoveListener(this.clazz.name) { id -> - val msg = Message() - if (this.repository.count(mapOf(Pair("role", id)), this.clazz) > 0) { - msg.status = Status.Failure - msg.message = "角色下还有用户" - } - msg - } - } +// init { +// groupService.addBeforeRemoveListener(this.clazz.name) { id -> +// val msg = Message() +// if (this.repository.count(mapOf(Pair("group", id)), this.clazz) > 0) { +// msg.status = Status.Failure +// msg.message = "组下还有用户" +// } +// msg +// } +// roleService.addBeforeRemoveListener(this.clazz.name) { id -> +// val msg = Message() +// if (this.repository.count(mapOf(Pair("role", id)), this.clazz) > 0) { +// msg.status = Status.Failure +// msg.message = "角色下还有用户" +// } +// msg +// } +// } override fun add(command: ICommand): DataMessage { - val user = this.convert(command) + val user = this.map(command) user.password = user.password.toMd5() user.token = UUID.randomUUID().toString() user.alive = false - this.repository.add(user, this.clazz) + this.repository.add(user) userNotifier?.added(user.id!!, user.name, user.token!!) return DataMessage(user.id!!) } @@ -60,14 +55,14 @@ class UserService( * @param key 用户ID */ override fun active(key: String, token: String): DataMessage { - val user = this.repository.get(key, this.clazz)!! + val user = this.repository.get(key)!! return if (user.alive) { DataMessage("用户${user.name}无需重复激活") } else { if (token == user.token) { user.alive = true user.token = null - this.repository.update(user, this.clazz) + this.repository.update(user) DataMessage(Status.Success, "用户${user.name}激活成功") } else { logger.warn(this, "用户${user.name}激活失败, {key: ${key}, token: ${token}") @@ -77,11 +72,11 @@ class UserService( } override fun changePassword(key: String, password: String, newPassword: String): DataMessage { - val user = this.repository.get(key, this.clazz)!! + val user = this.repository.get(key)!! return if (user.password == password.toMd5()) { user.password = newPassword.toMd5() user.token = null - this.repository.update(user, this.clazz) + this.repository.update(user) DataMessage() } else { logger.warn(this, "用户修改${user.name}密码失败, 旧密码验证不通过") @@ -91,11 +86,11 @@ class UserService( override fun resetPassword(key: String, password: String, token: String?): DataMessage { - val user = this.repository.get(key, this.clazz)!! + val user = this.repository.get(key)!! return if (token == user.token) { user.password = password.toMd5() user.token = null - this.repository.update(user, this.clazz) + this.repository.update(user) DataMessage() } else { logger.warn(this, "用户重置${user.name}密码失败, 系统密码修改令牌:${user.token}, {key: ${key} , token: ${token}") @@ -104,10 +99,10 @@ class UserService( } override fun forgotPassword(key: String): DataMessage { - val user = this.repository.get(key, this.clazz)!! + val user = this.repository.get(key)!! return if (user.alive) { user.token = UUID.randomUUID().toString() - this.repository.update(user, this.clazz) + this.repository.update(user) userNotifier?.forgot(user.id!!, user.name, user.token!!) DataMessage() } else diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/InterfaceService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/InterfaceService.kt deleted file mode 100644 index 3036f71..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/InterfaceService.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.synebula.zeus.domain.service.impl.rbac.resource - -import com.synebula.gaea.data.IObjectConverter -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.gaea.domain.service.Service -import com.synebula.gaea.log.ILogger -import com.synebula.zeus.domain.model.rbac.resource.Interface -import com.synebula.zeus.domain.service.contr.rbac.resource.IInterfaceService - -class InterfaceService( - repository: IRepository, - converter: IObjectConverter, logger: ILogger -) : Service(Interface::class.java, repository, converter, logger), IInterfaceService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/PageService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/PageService.kt deleted file mode 100644 index e2746f5..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/PageService.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.synebula.zeus.domain.service.impl.rbac.resource - -import com.synebula.gaea.data.IObjectConverter -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.gaea.domain.service.Service -import com.synebula.gaea.log.ILogger -import com.synebula.zeus.domain.model.rbac.resource.Page -import com.synebula.zeus.domain.service.contr.rbac.resource.IPageService - -class PageService( - repository: IRepository, - converter: IObjectConverter, logger: ILogger -) : Service(Page::class.java, repository, converter, logger), IPageService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/SystemService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/SystemService.kt deleted file mode 100644 index 7dac050..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/resource/SystemService.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.synebula.zeus.domain.service.impl.rbac.resource - -import com.synebula.gaea.data.IObjectConverter -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.gaea.domain.service.Service -import com.synebula.gaea.log.ILogger -import com.synebula.zeus.domain.model.rbac.resource.System -import com.synebula.zeus.domain.service.contr.rbac.resource.ISystemService - -class SystemService( - repository: IRepository, - converter: IObjectConverter, logger: ILogger -) : Service(System::class.java, repository, converter, logger), ISystemService \ No newline at end of file diff --git a/src/zeus.env/build.gradle b/src/zeus.env/build.gradle index d6be859..95d531a 100644 --- a/src/zeus.env/build.gradle +++ b/src/zeus.env/build.gradle @@ -1,5 +1,5 @@ dependencies { - compile "com.synebula:gaea:$gaea_version" + api "com.synebula:gaea:$gaea_version" } publishing { diff --git a/src/zeus.query/build.gradle b/src/zeus.query/build.gradle index d1e1cfd..3bd4a66 100644 --- a/src/zeus.query/build.gradle +++ b/src/zeus.query/build.gradle @@ -1,6 +1,6 @@ dependencies { - compile project(":src:zeus.env") - compile "com.synebula:gaea.mongo:$gaea_version" + api project(":src:zeus.env") + api "com.synebula:gaea.mongodb:$gaea_version" } publishing { diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IAuthorityQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IAuthorityQuery.kt index a678e4b..cebfbf8 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IAuthorityQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IAuthorityQuery.kt @@ -5,7 +5,7 @@ import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType import com.synebula.zeus.query.view.AuthorityView -interface IAuthorityQuery : IQuery { +interface IAuthorityQuery : IQuery { /** * 获取角色已授权的资源 diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IGroupQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IGroupQuery.kt new file mode 100644 index 0000000..7afc630 --- /dev/null +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IGroupQuery.kt @@ -0,0 +1,6 @@ +package com.synebula.zeus.query.contr + +import com.synebula.gaea.query.IQuery +import com.synebula.zeus.query.view.GroupView + +interface IGroupQuery : IQuery \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IRoleQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IRoleQuery.kt new file mode 100644 index 0000000..bf85b45 --- /dev/null +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IRoleQuery.kt @@ -0,0 +1,6 @@ +package com.synebula.zeus.query.contr + +import com.synebula.gaea.query.IQuery +import com.synebula.zeus.query.view.RoleView + +interface IRoleQuery : IQuery \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IUserQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IUserQuery.kt index 9e6e0e3..2f48903 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IUserQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IUserQuery.kt @@ -1,10 +1,11 @@ package com.synebula.zeus.query.contr import com.synebula.gaea.data.message.DataMessage +import com.synebula.gaea.query.IQuery import com.synebula.zeus.query.view.SignUserView import com.synebula.zeus.query.view.UserView -interface IUserQuery { +interface IUserQuery : IQuery { /** * 登录接口 * 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 5bce563..43c69d8 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 @@ -4,7 +4,7 @@ import com.synebula.gaea.query.IQuery import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.query.view.resource.InterfaceView -interface IInterfaceQuery : IQuery { +interface IInterfaceQuery : IQuery { fun authorized(role: String): List 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 c57a9c2..af1d25b 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 @@ -4,7 +4,7 @@ import com.synebula.gaea.query.IQuery import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.query.view.resource.PageView -interface IPageQuery : IQuery { +interface IPageQuery : IQuery { fun authorized(role: String): List 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 c169971..e467978 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 @@ -4,7 +4,7 @@ import com.synebula.gaea.query.IQuery import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.query.view.resource.SystemView -interface ISystemQuery : IQuery { +interface ISystemQuery : IQuery { fun authorized(role: String): List diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/AuthorityQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/AuthorityQuery.kt index 3cd011a..93f79ef 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/AuthorityQuery.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/impl/AuthorityQuery.kt @@ -1,6 +1,6 @@ package com.synebula.zeus.query.impl -import com.synebula.gaea.mongo.query.MongoQuery +import com.synebula.gaea.mongodb.query.MongodbQuery import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType import com.synebula.zeus.query.contr.IAuthorityQuery @@ -9,26 +9,27 @@ import org.springframework.data.mongodb.core.MongoTemplate import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query -class AuthorityQuery(template: MongoTemplate) : MongoQuery(template), - IAuthorityQuery { - var clazz = AuthorityView::class.java +class AuthorityQuery(template: MongoTemplate) : + MongodbQuery(AuthorityView::class.java, template), IAuthorityQuery { var collection = this.collection(this.clazz) override fun authorized(resourceType: ResourceType, role: String): List { return this.template.find( - Query.query( - Criteria.where("type").`is`(resourceType) - .and("role").`is`(role) - ), this.clazz, this.collection) + Query.query( + Criteria.where("type").`is`(resourceType) + .and("role").`is`(role) + ), this.clazz, this.collection + ) } override fun authorize(resourceType: ResourceType, resource: String, role: String): AuthorityType { val authority = this.template.findOne( - Query.query( - Criteria.where("type").`is`(resourceType) - .and("resource").`is`(resource) - .and("role").`is`(role) - ), this.clazz, this.collection) + Query.query( + Criteria.where("type").`is`(resourceType) + .and("resource").`is`(resource) + .and("role").`is`(role) + ), this.clazz, this.collection + ) return authority?.authority ?: AuthorityType.Default } } 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 bbc6077..6a18d0b 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 @@ -3,7 +3,8 @@ package com.synebula.zeus.query.impl import com.synebula.gaea.data.message.DataMessage import com.synebula.gaea.data.message.Status import com.synebula.gaea.ext.toMd5 -import com.synebula.gaea.mongo.whereId +import com.synebula.gaea.mongodb.query.MongodbQuery +import com.synebula.gaea.mongodb.whereId import com.synebula.zeus.query.contr.IUserQuery import com.synebula.zeus.query.view.GroupView import com.synebula.zeus.query.view.RoleView @@ -14,8 +15,8 @@ import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query import org.springframework.data.mongodb.core.query.isEqualTo -class UserQuery(var template: MongoTemplate) : IUserQuery { - private val clazz = UserView::class.java +class UserQuery(template: MongoTemplate) : + MongodbQuery(UserView::class.java, template), IUserQuery { override fun signIn(name: String, password: String): DataMessage { val query = Query.query( 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 95de796..7bb15bb 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 @@ -1,19 +1,19 @@ package com.synebula.zeus.query.impl.resouce -import com.synebula.gaea.mongo.query.MongoQuery +import com.synebula.gaea.mongodb.query.MongodbQuery import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType -import com.synebula.zeus.query.contr.resouce.IInterfaceQuery import com.synebula.zeus.query.contr.IAuthorityQuery +import com.synebula.zeus.query.contr.resouce.IInterfaceQuery import com.synebula.zeus.query.contr.resouce.ISystemQuery import com.synebula.zeus.query.view.resource.InterfaceView import org.springframework.data.mongodb.core.MongoTemplate -class InterfaceQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, var systemQuery: ISystemQuery) : - MongoQuery(template), - IInterfaceQuery { - - private val clazz = InterfaceView::class.java +class InterfaceQuery( + template: MongoTemplate, + var authorityQuery: IAuthorityQuery, + var systemQuery: ISystemQuery +) : MongodbQuery(InterfaceView::class.java, template), IInterfaceQuery { override fun authorized(role: String): List { return this.authorized(role, null) @@ -28,7 +28,7 @@ class InterfaceQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuer } val params = mutableMapOf() if (system != null) params["system"] = system - val interfaces = this.list(params, this.clazz) + val interfaces = this.list(params) val authorities = this.authorityQuery.authorized(ResourceType.Interface, role) return interfaces.filter { i -> val authority = authorities.find { p -> i.id == p.resource } 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 8e3792a..0790f91 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 @@ -1,10 +1,10 @@ package com.synebula.zeus.query.impl.resouce -import com.synebula.gaea.mongo.query.MongoQuery +import com.synebula.gaea.mongodb.query.MongodbQuery import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType -import com.synebula.zeus.query.contr.resouce.IPageQuery import com.synebula.zeus.query.contr.IAuthorityQuery +import com.synebula.zeus.query.contr.resouce.IPageQuery import com.synebula.zeus.query.contr.resouce.ISystemQuery import com.synebula.zeus.query.view.resource.PageView import org.springframework.data.mongodb.core.MongoTemplate @@ -12,8 +12,7 @@ import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query class PageQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, var systemQuery: ISystemQuery) : - MongoQuery(template), IPageQuery { - private val clazz = PageView::class.java + MongodbQuery(PageView::class.java, template), IPageQuery { override fun authorized(role: String): List { return this.authorized(role, null) @@ -27,7 +26,7 @@ class PageQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, va } val params = mutableMapOf() if (system != null) params["system"] = system - val pages = this.list(params, this.clazz) + val pages = this.list(params) val authorities = this.authorityQuery.authorized(ResourceType.Page, role) return pages.filter { i -> val authority = authorities.find { p -> i.id == p.resource } 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 b84ac53..783e1ad 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 @@ -1,18 +1,18 @@ package com.synebula.zeus.query.impl.resouce -import com.synebula.gaea.mongo.query.MongoQuery +import com.synebula.gaea.mongodb.query.MongodbQuery import com.synebula.zeus.env.AuthorityType import com.synebula.zeus.env.ResourceType +import com.synebula.zeus.query.contr.IAuthorityQuery import com.synebula.zeus.query.contr.resouce.ISystemQuery -import com.synebula.zeus.query.impl.AuthorityQuery import com.synebula.zeus.query.view.resource.SystemView import org.springframework.data.mongodb.core.MongoTemplate -class SystemQuery(template: MongoTemplate, var authorityQuery: AuthorityQuery) : MongoQuery(template), ISystemQuery { - private val clazz = SystemView::class.java +class SystemQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery) : + MongodbQuery(SystemView::class.java, template), ISystemQuery { override fun authorized(role: String): List { - val systems = this.list(mapOf(), this.clazz) + val systems = this.list(mapOf()) val authorities = this.authorityQuery.authorized(ResourceType.System, role) return systems.filter { i -> authorities.find { p -> i.id == p.resource }?.authority == AuthorityType.Allow } } diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt index de2529d..c899320 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt @@ -1,8 +1,9 @@ package com.synebula.zeus.query.view -import com.synebula.gaea.query.annotation.Table -import com.synebula.gaea.query.annotation.Where -import com.synebula.gaea.query.type.Operator +import com.synebula.gaea.query.Operator +import com.synebula.gaea.query.Table +import com.synebula.gaea.query.Where + @Table("group") class GroupView { diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/RoleView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/RoleView.kt index 65b7409..0894ae2 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/RoleView.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/RoleView.kt @@ -1,6 +1,6 @@ package com.synebula.zeus.query.view -import com.synebula.gaea.query.annotation.Table +import com.synebula.gaea.query.Table @Table("role") class RoleView { diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/UserView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/UserView.kt index 364b97f..74de75c 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/UserView.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/UserView.kt @@ -1,8 +1,8 @@ package com.synebula.zeus.query.view -import com.synebula.gaea.query.annotation.Table -import com.synebula.gaea.query.annotation.Where -import com.synebula.gaea.query.type.Operator +import com.synebula.gaea.query.Operator +import com.synebula.gaea.query.Table +import com.synebula.gaea.query.Where @Table("user") class UserView { diff --git a/src/zeus.repository/build.gradle b/src/zeus.repository/build.gradle index 1754059..87ae0c6 100644 --- a/src/zeus.repository/build.gradle +++ b/src/zeus.repository/build.gradle @@ -1,7 +1,7 @@ dependencies { - compile project(":src:zeus.env") - compile project(":src:zeus.domain") - compile "com.synebula:gaea.mongo:$gaea_version" + api project(":src:zeus.env") + api project(":src:zeus.domain") + api "com.synebula:gaea.mongodb:$gaea_version" } publishing { diff --git a/src/zeus.repository/src/main/kotlin/com/synebula/zeus/repository/AuthorityRepository.kt b/src/zeus.repository/src/main/kotlin/com/synebula/zeus/repository/AuthorityRepository.kt index 9f9b3a6..6430e75 100644 --- a/src/zeus.repository/src/main/kotlin/com/synebula/zeus/repository/AuthorityRepository.kt +++ b/src/zeus.repository/src/main/kotlin/com/synebula/zeus/repository/AuthorityRepository.kt @@ -1,14 +1,15 @@ package com.synebula.zeus.repository -import com.synebula.gaea.mongo.repository.MongoRepository +import com.synebula.gaea.mongodb.repository.MongodbRepository import com.synebula.zeus.domain.model.rbac.Authority -import com.synebula.zeus.domain.repository.IAuthorityRepository +import com.synebula.zeus.domain.repository.rbac.IAuthorityRepository import com.synebula.zeus.env.ResourceType import org.springframework.data.mongodb.core.MongoTemplate import org.springframework.data.mongodb.core.query.Criteria import org.springframework.data.mongodb.core.query.Query -class AuthorityRepository(var template: MongoTemplate) : MongoRepository(template), IAuthorityRepository { +class AuthorityRepository(var template: MongoTemplate) : + MongodbRepository(Authority::class.java, template), IAuthorityRepository { override fun removeByResourceRole(type: ResourceType, resource: List, role: String) { this.template.remove( Query.query( From f1871925672a8619a0b592b4fd9b3556dcbc6551 Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 22 Aug 2022 15:42:36 +0800 Subject: [PATCH 13/14] =?UTF-8?q?0.9.0=20=E6=9B=B4=E6=96=B0GAEA=E5=BC=95?= =?UTF-8?q?=E7=94=A8=E5=B9=B6=E5=88=A0=E9=99=A4=E7=94=B1=E6=AD=A4=E9=80=A0?= =?UTF-8?q?=E6=88=90=E7=9A=84=E6=97=A0=E7=94=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 4 ++-- .../com/synebula/zeus/app/config/ZeusBeans.kt | 24 ++++++++++++++++++- .../zeus/app/controller/rbac/GroupApp.kt | 6 ++--- .../zeus/app/controller/rbac/RoleApp.kt | 6 ++--- .../repository/rbac/IGroupRepository.kt | 7 ------ .../domain/repository/rbac/IRoleRepository.kt | 7 ------ .../rbac/resource/IInterfaceRepository.kt | 7 ------ .../rbac/resource/IPageRepository.kt | 7 ------ .../rbac/resource/ISystemRepository.kt | 7 ------ .../service/contr/rbac/IAuthorityService.kt | 1 - .../service/contr/rbac/IGroupService.kt | 5 ++-- .../domain/service/contr/rbac/IRoleService.kt | 5 ++-- .../contr/rbac/resource/IInterfaceService.kt | 5 ++-- .../contr/rbac/resource/IPageService.kt | 5 ++-- .../contr/rbac/resource/ISystemService.kt | 5 ++-- .../domain/service/impl/rbac/UserService.kt | 6 ++--- .../synebula/zeus/query/contr/IGroupQuery.kt | 6 ----- .../synebula/zeus/query/contr/IRoleQuery.kt | 6 ----- 18 files changed, 44 insertions(+), 75 deletions(-) delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IGroupRepository.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IRoleRepository.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IInterfaceRepository.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IPageRepository.kt delete mode 100644 src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/ISystemRepository.kt delete mode 100644 src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IGroupQuery.kt delete mode 100644 src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IRoleQuery.kt diff --git a/build.gradle b/build.gradle index f181fbe..026906a 100644 --- a/build.gradle +++ b/build.gradle @@ -21,8 +21,8 @@ allprojects { subprojects { ext { - version '0.7.1' - gaea_version = '1.1.0' + version '0.9.0' + gaea_version = '1.2.0' spring_version = "2.7.0" } 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 9742d30..51a7a56 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 @@ -1,15 +1,37 @@ package com.synebula.zeus.app.config import com.google.gson.Gson +import com.synebula.gaea.app.component.security.WebSecurity import com.synebula.gaea.data.serialization.json.IJsonSerializer +import com.synebula.gaea.domain.repository.IRepositoryFactory +import com.synebula.gaea.mongodb.query.MongodbQueryFactory +import com.synebula.gaea.mongodb.repository.MongodbRepositoryFactory +import com.synebula.gaea.query.IQueryFactory import org.springframework.context.annotation.Bean import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.ComponentScan.Filter import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.FilterType +import org.springframework.data.mongodb.core.MongoTemplate @Configuration -@ComponentScan(basePackages = ["com.synebula.gaea.app.component"]) +@ComponentScan( + basePackages = ["com.synebula.gaea.app.component"], + excludeFilters = [Filter(type = FilterType.ASSIGNABLE_TYPE, classes = [WebSecurity::class])] +) class ZeusBeans { + + @Bean + fun repoFactory(template: MongoTemplate): IRepositoryFactory { + return MongodbRepositoryFactory(template) + } + + @Bean + fun queryFactory(template: MongoTemplate): IQueryFactory { + return MongodbQueryFactory(template) + } + @Bean fun gson(): Gson = Gson() 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 188f84f..5f4a327 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 @@ -2,9 +2,9 @@ package com.synebula.zeus.app.controller.rbac import com.synebula.gaea.app.Application import com.synebula.gaea.log.ILogger +import com.synebula.gaea.query.IQueryFactory import com.synebula.zeus.domain.service.cmd.rbac.GroupCmd import com.synebula.zeus.domain.service.contr.rbac.IGroupService -import com.synebula.zeus.query.contr.IGroupQuery import com.synebula.zeus.query.view.GroupView import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @@ -13,8 +13,8 @@ import org.springframework.web.bind.annotation.RestController @RequestMapping("/groups") class GroupApp( service: IGroupService, - query: IGroupQuery, + factory: IQueryFactory, logger: ILogger ) : Application( - "分组信息", service, query, logger + "分组信息", service, factory.createQuery(GroupView::class.java), logger ) \ No newline at end of file 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 b6dfa65..4198431 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 @@ -2,9 +2,9 @@ package com.synebula.zeus.app.controller.rbac import com.synebula.gaea.app.Application import com.synebula.gaea.log.ILogger +import com.synebula.gaea.query.IQueryFactory import com.synebula.zeus.domain.service.cmd.rbac.RoleCmd import com.synebula.zeus.domain.service.contr.rbac.IRoleService -import com.synebula.zeus.query.contr.IRoleQuery import com.synebula.zeus.query.view.RoleView import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController @@ -13,8 +13,8 @@ import org.springframework.web.bind.annotation.RestController @RequestMapping("/roles") class RoleApp( service: IRoleService, - query: IRoleQuery, + factory: IQueryFactory, logger: ILogger ) : Application( - "用户信息", service, query, logger + "用户信息", service, factory.createQuery(RoleView::class.java), logger ) \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IGroupRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IGroupRepository.kt deleted file mode 100644 index 209eda5..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IGroupRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.synebula.zeus.domain.repository.rbac - -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.zeus.domain.model.rbac.Group - -interface IGroupRepository : IRepository { -} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IRoleRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IRoleRepository.kt deleted file mode 100644 index b05f633..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/IRoleRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.synebula.zeus.domain.repository.rbac - -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.zeus.domain.model.rbac.Role - -interface IRoleRepository : IRepository { -} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IInterfaceRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IInterfaceRepository.kt deleted file mode 100644 index bbda35f..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IInterfaceRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.synebula.zeus.domain.repository.rbac.resource - -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.zeus.domain.model.rbac.resource.Interface - -interface IInterfaceRepository : IRepository { -} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IPageRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IPageRepository.kt deleted file mode 100644 index a89bd0d..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/IPageRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.synebula.zeus.domain.repository.rbac.resource - -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.zeus.domain.model.rbac.resource.Page - -interface IPageRepository : IRepository { -} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/ISystemRepository.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/ISystemRepository.kt deleted file mode 100644 index 42bf4ab..0000000 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/repository/rbac/resource/ISystemRepository.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.synebula.zeus.domain.repository.rbac.resource - -import com.synebula.gaea.domain.repository.IRepository -import com.synebula.zeus.domain.model.rbac.resource.System - -interface ISystemRepository : IRepository { -} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAuthorityService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAuthorityService.kt index 8c7e0bd..d9b698e 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAuthorityService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAuthorityService.kt @@ -1,7 +1,6 @@ package com.synebula.zeus.domain.service.contr.rbac import com.synebula.gaea.domain.service.IService -import com.synebula.zeus.domain.model.rbac.Authority import com.synebula.zeus.domain.service.cmd.rbac.AuthorityBatchAddCmd import com.synebula.zeus.env.ResourceType diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IGroupService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IGroupService.kt index 5a92a45..949f01f 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IGroupService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IGroupService.kt @@ -1,9 +1,8 @@ package com.synebula.zeus.domain.service.contr.rbac +import com.synebula.gaea.domain.service.Domain import com.synebula.gaea.domain.service.IService -import com.synebula.gaea.domain.service.ServiceDependency import com.synebula.zeus.domain.model.rbac.Group -import com.synebula.zeus.domain.repository.rbac.IGroupRepository -@ServiceDependency(clazz = Group::class, repo = IGroupRepository::class) +@Domain(clazz = Group::class) interface IGroupService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IRoleService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IRoleService.kt index b5726ed..6dc0960 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IRoleService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IRoleService.kt @@ -1,9 +1,8 @@ package com.synebula.zeus.domain.service.contr.rbac +import com.synebula.gaea.domain.service.Domain import com.synebula.gaea.domain.service.IService -import com.synebula.gaea.domain.service.ServiceDependency import com.synebula.zeus.domain.model.rbac.Role -import com.synebula.zeus.domain.repository.rbac.IRoleRepository -@ServiceDependency(clazz = Role::class, repo = IRoleRepository::class) +@Domain(clazz = Role::class) interface IRoleService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IInterfaceService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IInterfaceService.kt index f272d3d..9b713d8 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IInterfaceService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IInterfaceService.kt @@ -1,9 +1,8 @@ package com.synebula.zeus.domain.service.contr.rbac.resource +import com.synebula.gaea.domain.service.Domain import com.synebula.gaea.domain.service.IService -import com.synebula.gaea.domain.service.ServiceDependency import com.synebula.zeus.domain.model.rbac.resource.Interface -import com.synebula.zeus.domain.repository.rbac.resource.IInterfaceRepository -@ServiceDependency(clazz = Interface::class, repo = IInterfaceRepository::class) +@Domain(clazz = Interface::class) interface IInterfaceService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPageService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPageService.kt index efb5bbc..5cb9bf2 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPageService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/IPageService.kt @@ -1,9 +1,8 @@ package com.synebula.zeus.domain.service.contr.rbac.resource +import com.synebula.gaea.domain.service.Domain import com.synebula.gaea.domain.service.IService -import com.synebula.gaea.domain.service.ServiceDependency import com.synebula.zeus.domain.model.rbac.resource.Page -import com.synebula.zeus.domain.repository.rbac.resource.IPageRepository -@ServiceDependency(clazz = Page::class, repo = IPageRepository::class) +@Domain(clazz = Page::class) interface IPageService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/ISystemService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/ISystemService.kt index d3ca2ad..7f696d1 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/ISystemService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/resource/ISystemService.kt @@ -1,9 +1,8 @@ package com.synebula.zeus.domain.service.contr.rbac.resource +import com.synebula.gaea.domain.service.Domain import com.synebula.gaea.domain.service.IService -import com.synebula.gaea.domain.service.ServiceDependency import com.synebula.zeus.domain.model.rbac.resource.System -import com.synebula.zeus.domain.repository.rbac.resource.ISystemRepository -@ServiceDependency(clazz = System::class, repo = ISystemRepository::class) +@Domain(clazz = System::class) interface ISystemService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt index b6b1f1a..835b33e 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt @@ -3,22 +3,22 @@ package com.synebula.zeus.domain.service.impl.rbac import com.synebula.gaea.data.message.DataMessage import com.synebula.gaea.data.message.Status import com.synebula.gaea.data.serialization.IObjectMapper +import com.synebula.gaea.domain.repository.IRepositoryFactory import com.synebula.gaea.domain.service.ICommand import com.synebula.gaea.domain.service.Service import com.synebula.gaea.ext.toMd5 import com.synebula.gaea.log.ILogger import com.synebula.zeus.domain.model.rbac.User -import com.synebula.zeus.domain.repository.rbac.IUserRepository import com.synebula.zeus.domain.service.component.IUserNotifier import com.synebula.zeus.domain.service.contr.rbac.IUserService import java.util.* class UserService( - repository: IUserRepository, + factory: IRepositoryFactory, mapper: IObjectMapper, var userNotifier: IUserNotifier?, var logger: ILogger -) : Service(User::class.java, repository, mapper), IUserService { +) : Service(User::class.java, factory.createRepository(User::class.java), mapper), IUserService { // init { // groupService.addBeforeRemoveListener(this.clazz.name) { id -> diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IGroupQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IGroupQuery.kt deleted file mode 100644 index 7afc630..0000000 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IGroupQuery.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.synebula.zeus.query.contr - -import com.synebula.gaea.query.IQuery -import com.synebula.zeus.query.view.GroupView - -interface IGroupQuery : IQuery \ No newline at end of file diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IRoleQuery.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IRoleQuery.kt deleted file mode 100644 index bf85b45..0000000 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/contr/IRoleQuery.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.synebula.zeus.query.contr - -import com.synebula.gaea.query.IQuery -import com.synebula.zeus.query.view.RoleView - -interface IRoleQuery : IQuery \ No newline at end of file From cbe75da254516daf442e18907f3db302c7c810be Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 26 Aug 2022 10:43:25 +0800 Subject: [PATCH 14/14] =?UTF-8?q?=E6=9B=B4=E6=96=B0GAEA=E5=88=B0=E7=89=88?= =?UTF-8?q?=E6=9C=AC1.4.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 6 +-- .../synebula/zeus/app/config/ZeusServices.kt | 4 +- .../zeus/app/controller/SignInOutApp.kt | 2 +- .../zeus/app/controller/rbac/AuthorityApp.kt | 2 +- .../zeus/app/controller/rbac/GroupApp.kt | 2 +- .../zeus/app/controller/rbac/UserApp.kt | 2 +- .../controller/rbac/resource/InterfaceApp.kt | 2 +- .../app/controller/rbac/resource/PageApp.kt | 2 +- .../app/controller/rbac/resource/SystemApp.kt | 2 +- .../domain/service/impl/rbac/UserService.kt | 41 ++++++++++--------- .../zeus/query/impl/resouce/InterfaceQuery.kt | 2 +- .../zeus/query/impl/resouce/PageQuery.kt | 2 +- .../com/synebula/zeus/query/view/GroupView.kt | 2 +- .../com/synebula/zeus/query/view/UserView.kt | 2 +- 14 files changed, 36 insertions(+), 37 deletions(-) diff --git a/build.gradle b/build.gradle index 026906a..25ec641 100644 --- a/build.gradle +++ b/build.gradle @@ -14,15 +14,13 @@ buildscript { } } -allprojects { +subprojects { group 'com.synebula' version version -} -subprojects { ext { version '0.9.0' - gaea_version = '1.2.0' + gaea_version = '1.4.0' spring_version = "2.7.0" } diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt index 34f986c..b54c90d 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusServices.kt @@ -1,10 +1,10 @@ package com.synebula.zeus.app.config import com.synebula.gaea.app.autoconfig.service.ServiceScan -import com.synebula.gaea.mongodb.autoconfig.MongodbRepoScan +import com.synebula.gaea.mongodb.autoconfig.MongodbRepositoryScan import org.springframework.stereotype.Component @Component @ServiceScan(basePackages = ["com.synebula.zeus.domain.service"]) -@MongodbRepoScan(basePackages = ["com.synebula.zeus.domain.repository", "com.synebula.zeus.repository", "com.synebula.zeus.query"]) +@MongodbRepositoryScan(basePackages = ["com.synebula.zeus.domain.repository", "com.synebula.zeus.repository", "com.synebula.zeus.query"]) class ZeusServices \ No newline at end of file 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 b5ce5cc..54099d5 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 @@ -2,7 +2,7 @@ package com.synebula.zeus.app.controller import com.synebula.gaea.app.IApplication import com.synebula.gaea.app.component.security.TokenManager -import com.synebula.gaea.app.struct.HttpMessage +import com.synebula.gaea.data.message.HttpMessage import com.synebula.gaea.data.message.Status import com.synebula.gaea.data.serialization.json.IJsonSerializer import com.synebula.gaea.log.ILogger diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt index bbaed5c..5ddee5b 100644 --- a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/rbac/AuthorityApp.kt @@ -1,7 +1,7 @@ package com.synebula.zeus.app.controller.rbac import com.synebula.gaea.app.Application -import com.synebula.gaea.app.struct.HttpMessage +import com.synebula.gaea.data.message.HttpMessage import com.synebula.gaea.log.ILogger import com.synebula.gaea.spring.aop.annotation.Method import com.synebula.zeus.domain.service.cmd.rbac.AuthorityBatchAddCmd 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 5f4a327..d965d48 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 @@ -16,5 +16,5 @@ class GroupApp( factory: IQueryFactory, logger: ILogger ) : Application( - "分组信息", service, factory.createQuery(GroupView::class.java), logger + "用户组信息", service, factory.createQuery(GroupView::class.java), logger ) \ No newline at end of file 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 f2aeb3c..159e7d2 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.struct.HttpMessage +import com.synebula.gaea.data.message.HttpMessage import com.synebula.gaea.data.message.Status import com.synebula.gaea.data.serialization.json.IJsonSerializer import com.synebula.gaea.log.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 0a62685..10507d2 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.struct.HttpMessage +import com.synebula.gaea.data.message.HttpMessage import com.synebula.gaea.log.ILogger import com.synebula.gaea.spring.aop.annotation.Method import com.synebula.zeus.domain.service.cmd.rbac.resource.InterfaceCmd 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 76da845..e06928c 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,7 +1,7 @@ package com.synebula.zeus.app.controller.rbac.resource import com.synebula.gaea.app.Application -import com.synebula.gaea.app.struct.HttpMessage +import com.synebula.gaea.data.message.HttpMessage import com.synebula.gaea.log.ILogger import com.synebula.gaea.spring.aop.annotation.Method import com.synebula.gaea.spring.aop.annotation.Module 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 9829cde..40e6082 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.struct.HttpMessage +import com.synebula.gaea.data.message.HttpMessage import com.synebula.gaea.log.ILogger import com.synebula.gaea.spring.aop.annotation.Method import com.synebula.zeus.domain.service.cmd.rbac.resource.SystemCmd diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt index 835b33e..5b3fa5f 100644 --- a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/UserService.kt @@ -1,13 +1,18 @@ package com.synebula.zeus.domain.service.impl.rbac +import com.synebula.gaea.bus.Subscribe import com.synebula.gaea.data.message.DataMessage import com.synebula.gaea.data.message.Status import com.synebula.gaea.data.serialization.IObjectMapper +import com.synebula.gaea.domain.event.BeforeRemoveEvent import com.synebula.gaea.domain.repository.IRepositoryFactory import com.synebula.gaea.domain.service.ICommand import com.synebula.gaea.domain.service.Service +import com.synebula.gaea.exception.NoticeUserException import com.synebula.gaea.ext.toMd5 import com.synebula.gaea.log.ILogger +import com.synebula.zeus.domain.model.rbac.Group +import com.synebula.zeus.domain.model.rbac.Role import com.synebula.zeus.domain.model.rbac.User import com.synebula.zeus.domain.service.component.IUserNotifier import com.synebula.zeus.domain.service.contr.rbac.IUserService @@ -20,24 +25,17 @@ class UserService( var logger: ILogger ) : Service(User::class.java, factory.createRepository(User::class.java), mapper), IUserService { -// init { -// groupService.addBeforeRemoveListener(this.clazz.name) { id -> -// val msg = Message() -// if (this.repository.count(mapOf(Pair("group", id)), this.clazz) > 0) { -// msg.status = Status.Failure -// msg.message = "组下还有用户" -// } -// msg -// } -// roleService.addBeforeRemoveListener(this.clazz.name) { id -> -// val msg = Message() -// if (this.repository.count(mapOf(Pair("role", id)), this.clazz) > 0) { -// msg.status = Status.Failure -// msg.message = "角色下还有用户" -// } -// msg -// } -// } + @Subscribe(["groupBeforeRemoveEvent"]) + fun beforeRoleRemove(event: BeforeRemoveEvent) { + if (this.repository.count(mapOf(Pair("role", event.id!!))) > 0) + throw NoticeUserException("角色下还有用户") + } + + @Subscribe(["groupBeforeRemoveEvent"]) + fun beforeGroupRemove(event: BeforeRemoveEvent) { + if (this.repository.count(mapOf(Pair("group", event.id!!))) > 0) + throw NoticeUserException("用户组下还有用户") + } override fun add(command: ICommand): DataMessage { val user = this.map(command) @@ -65,7 +63,7 @@ class UserService( this.repository.update(user) DataMessage(Status.Success, "用户${user.name}激活成功") } else { - logger.warn(this, "用户${user.name}激活失败, {key: ${key}, token: ${token}") + logger.warn(this, "用户${user.name}激活失败, {key: ${key}, token: $token") DataMessage(Status.Failure, "用户${user.name}激活失败, 请从系统发送的邮件链接激活用户") } } @@ -93,7 +91,10 @@ class UserService( this.repository.update(user) DataMessage() } else { - logger.warn(this, "用户重置${user.name}密码失败, 系统密码修改令牌:${user.token}, {key: ${key} , token: ${token}") + logger.warn( + this, + "用户重置${user.name}密码失败, 系统密码修改令牌:${user.token}, {key: $key , token: $token" + ) DataMessage(Status.Failure, "用户重置密码失败, 如需重置密码请从系统发送的邮件链接中重置") } } 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 7bb15bb..a251713 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 @@ -26,7 +26,7 @@ class InterfaceQuery( if (authority == AuthorityType.Deny) return listOf() } - val params = mutableMapOf() + val params = mutableMapOf() if (system != null) params["system"] = system val interfaces = this.list(params) val authorities = this.authorityQuery.authorized(ResourceType.Interface, role) 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 0790f91..d9b9436 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 @@ -24,7 +24,7 @@ class PageQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, va if (authority == AuthorityType.Deny) return listOf() } - val params = mutableMapOf() + val params = mutableMapOf() if (system != null) params["system"] = system val pages = this.list(params) val authorities = this.authorityQuery.authorized(ResourceType.Page, role) diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt index c899320..91e601c 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/GroupView.kt @@ -9,7 +9,7 @@ import com.synebula.gaea.query.Where class GroupView { var id: String? = null - @Where(Operator.like) + @Where(Operator.Like) var name = "" var desc = "" diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/UserView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/UserView.kt index 74de75c..2ff38a1 100644 --- a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/UserView.kt +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/UserView.kt @@ -12,7 +12,7 @@ class UserView { var password: String = "" - @Where(Operator.like) + @Where(Operator.Like) var realName: String? = null var phone: String? = null