增加权限相关代码
This commit is contained in:
@@ -3,4 +3,4 @@ rootProject.name = 'myths.zeus'
|
||||
include 'src:zeus.app'
|
||||
include 'src:zeus.domain'
|
||||
include 'src:zeus.query'
|
||||
|
||||
include 'src:zeus.env'
|
||||
|
||||
@@ -8,24 +8,41 @@ 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.Configuration
|
||||
import org.springframework.context.annotation.Primary
|
||||
import org.springframework.data.mongodb.core.MongoTemplate
|
||||
|
||||
|
||||
@Configuration
|
||||
open class ZeusBeans {
|
||||
@Primary
|
||||
@Bean
|
||||
open fun <T : IAggregateRoot<String>> repository(template: MongoTemplate)
|
||||
: IRepository = MongoRepository(template)
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
open fun <T> mongoQuery(template: MongoTemplate, logger: ILogger? = null)
|
||||
open fun <T> query(template: MongoTemplate, logger: ILogger? = null)
|
||||
: IQuery = MongoQuery(template, logger)
|
||||
|
||||
@Bean
|
||||
open fun gson(): Gson = Gson()
|
||||
|
||||
@Bean
|
||||
open fun userNotifier(): IUserNotifier {
|
||||
return object : IUserNotifier {
|
||||
override fun added(id: String, name: String, token: String) {
|
||||
|
||||
}
|
||||
|
||||
override fun forgot(id: String, name: String, token: String) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
open fun serializer(gson: Gson): IJsonSerializer {
|
||||
return object : IJsonSerializer {
|
||||
|
||||
@@ -4,13 +4,17 @@ import com.synebula.gaea.app.IApplication
|
||||
import com.synebula.gaea.app.component.HttpMessage
|
||||
import com.synebula.gaea.log.ILogger
|
||||
import com.synebula.zeus.query.contr.IUserQuery
|
||||
import com.synebula.zeus.query.impl.UserQuery
|
||||
import org.springframework.data.mongodb.core.MongoTemplate
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sign")
|
||||
class SignInOutApp(var query: IUserQuery, override var logger: ILogger?) : IApplication {
|
||||
class SignInOutApp(template: MongoTemplate, override var logger: ILogger?) : IApplication {
|
||||
var query: IUserQuery = UserQuery(template)
|
||||
|
||||
override var name: String = "用户登录管理"
|
||||
|
||||
@PostMapping("/in")
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.view.GroupView
|
||||
import org.springframework.beans.factory.annotation.Qualifier
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.view.RoleView
|
||||
import org.springframework.beans.factory.annotation.Qualifier
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
|
||||
@@ -10,13 +10,14 @@ import com.synebula.zeus.domain.service.cmd.rbac.UserCmd
|
||||
import com.synebula.zeus.domain.service.contr.rbac.IUserService
|
||||
import com.synebula.zeus.query.view.UserView
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.beans.factory.annotation.Qualifier
|
||||
import org.springframework.web.bind.annotation.*
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/users")
|
||||
class UserApp(
|
||||
service: IUserService,
|
||||
query: IQuery,
|
||||
@Qualifier("query") query: IQuery,
|
||||
logger: ILogger
|
||||
) : Application<UserCmd, UserView, String>(
|
||||
"用户信息", UserView::class.java,
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
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.InterfaceCmd
|
||||
import com.synebula.zeus.domain.service.contr.rbac.resource.IInterfaceService
|
||||
import com.synebula.zeus.query.impl.resouce.InterfaceQuery
|
||||
import com.synebula.zeus.query.view.resource.InterfaceView
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/interfaces")
|
||||
class InterfaceApp(
|
||||
service: IInterfaceService,
|
||||
query: InterfaceQuery,
|
||||
logger: ILogger
|
||||
) : Application<InterfaceCmd, InterfaceView, String>(
|
||||
"接口信息", InterfaceView::class.java,
|
||||
service, query, logger
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
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.PageCmd
|
||||
import com.synebula.zeus.domain.service.contr.rbac.resource.IPageService
|
||||
import com.synebula.zeus.query.contr.resouce.IPageQuery
|
||||
import com.synebula.zeus.query.view.resource.PageView
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/pages")
|
||||
class PageApp(
|
||||
service: IPageService,
|
||||
query: IPageQuery,
|
||||
logger: ILogger
|
||||
) : Application<PageCmd, PageView, String>(
|
||||
"页面信息", PageView::class.java,
|
||||
service, query, logger
|
||||
)
|
||||
@@ -0,0 +1,25 @@
|
||||
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.PageCmd
|
||||
import com.synebula.zeus.domain.service.cmd.rbac.resource.PermissionCmd
|
||||
import com.synebula.zeus.domain.service.contr.rbac.resource.IPageService
|
||||
import com.synebula.zeus.domain.service.contr.rbac.resource.IPermissionService
|
||||
import com.synebula.zeus.query.contr.resouce.IPageQuery
|
||||
import com.synebula.zeus.query.contr.resouce.IPermissionQuery
|
||||
import com.synebula.zeus.query.view.resource.PageView
|
||||
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<PermissionCmd, PermissionView, String>(
|
||||
"权限信息", PermissionView::class.java,
|
||||
service, query, logger
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
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.SystemCmd
|
||||
import com.synebula.zeus.domain.service.contr.rbac.resource.ISystemService
|
||||
import com.synebula.zeus.query.contr.resouce.ISystemQuery
|
||||
import com.synebula.zeus.query.view.resource.SystemView
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/systems")
|
||||
class SystemApp(
|
||||
service: ISystemService,
|
||||
query: ISystemQuery,
|
||||
logger: ILogger
|
||||
) : Application<SystemCmd, SystemView, String>(
|
||||
"系统信息", SystemView::class.java,
|
||||
service, query, logger
|
||||
)
|
||||
@@ -6,4 +6,29 @@ spring:
|
||||
name: gaea.app
|
||||
data:
|
||||
mongodb:
|
||||
uri: mongodb://127.0.0.1/zeus
|
||||
uri: mongodb://127.0.0.1/zeus
|
||||
mail:
|
||||
send: true
|
||||
target: ge.com
|
||||
sender: gehsrv@163.com
|
||||
protocol: smtp
|
||||
host: smtp.163.com
|
||||
port: 465
|
||||
username: gehsrv@163.com
|
||||
password: SRBPJBLFFVVCPZLZ
|
||||
default-encoding: UTF-8
|
||||
properties:
|
||||
mail:
|
||||
imap:
|
||||
ssl:
|
||||
socketFactory:
|
||||
fallback: false
|
||||
smtp:
|
||||
auth: true
|
||||
ssl:
|
||||
enable: true
|
||||
socketFactory:
|
||||
class: com.fintech.modules.base.util.mail.MailSSLSocketFactory
|
||||
starttls:
|
||||
enable: true
|
||||
required: true
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
dependencies {
|
||||
compile project(":src:zeus.env")
|
||||
compile "com.synebula:gaea:$gaea_version"
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
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?) : AggregateRoot<String>() {
|
||||
var resource = ""
|
||||
var type: ResourceType? = null
|
||||
var authorization = PermissionType.Allow
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.synebula.zeus.domain.service.cmd.rbac.resource
|
||||
|
||||
import com.synebula.gaea.domain.service.Command
|
||||
import com.synebula.zeus.env.PermissionType
|
||||
import com.synebula.zeus.env.ResourceType
|
||||
|
||||
class PermissionCmd : Command() {
|
||||
var id: String? = null
|
||||
var resource = ""
|
||||
var type: ResourceType? = null
|
||||
var authorization = PermissionType.Allow
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.synebula.zeus.domain.service.cmd.rbac.resource
|
||||
|
||||
import com.synebula.gaea.domain.service.Command
|
||||
|
||||
abstract class ResourceCmd(var id: String? = null) {
|
||||
|
||||
abstract class ResourceCmd(var id: String? = null) : Command() {
|
||||
var name = ""
|
||||
var signature = ""
|
||||
val uri: String? = null
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.synebula.zeus.domain.service.contr.rbac.resource
|
||||
|
||||
import com.synebula.gaea.domain.service.IService
|
||||
|
||||
interface IPermissionService : IService<String> {
|
||||
|
||||
}
|
||||
@@ -20,9 +20,9 @@ class UserService(
|
||||
repository: IRepository,
|
||||
converter: IObjectConverter,
|
||||
logger: ILogger,
|
||||
var userNotifier: IUserNotifier,
|
||||
groupService: IGroupService,
|
||||
roleService: IRoleService
|
||||
roleService: IRoleService,
|
||||
var userNotifier: IUserNotifier
|
||||
) : Service<User, String>(User::class.java, repository, converter, logger), IUserService {
|
||||
|
||||
init {
|
||||
|
||||
15
src/zeus.env/build.gradle
Normal file
15
src/zeus.env/build.gradle
Normal file
@@ -0,0 +1,15 @@
|
||||
dependencies {
|
||||
compile "com.synebula:gaea:$gaea_version"
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publish(MavenPublication) {
|
||||
group 'com.synebula'
|
||||
artifactId 'zeus.env'
|
||||
version "$version"
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
6
src/zeus.env/src/main/kotlin/com/synebula/zeus/env/PermissionType.kt
vendored
Normal file
6
src/zeus.env/src/main/kotlin/com/synebula/zeus/env/PermissionType.kt
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
package com.synebula.zeus.env
|
||||
|
||||
enum class PermissionType {
|
||||
Deny,
|
||||
Allow
|
||||
}
|
||||
7
src/zeus.env/src/main/kotlin/com/synebula/zeus/env/ResourceType.kt
vendored
Normal file
7
src/zeus.env/src/main/kotlin/com/synebula/zeus/env/ResourceType.kt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
package com.synebula.zeus.env
|
||||
|
||||
enum class ResourceType {
|
||||
System,
|
||||
Page,
|
||||
Interface
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
dependencies {
|
||||
compile project(":src:zeus.env")
|
||||
compile "com.synebula:gaea.mongo:$gaea_version"
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.synebula.zeus.query.contr.resouce
|
||||
|
||||
import com.synebula.gaea.query.IQuery
|
||||
|
||||
interface IInterfaceQuery : IQuery {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.synebula.zeus.query.contr.resouce
|
||||
|
||||
import com.synebula.gaea.query.IQuery
|
||||
|
||||
interface IPageQuery : IQuery {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.synebula.zeus.query.contr.resouce
|
||||
|
||||
import com.synebula.gaea.query.IQuery
|
||||
|
||||
interface IPermissionQuery : IQuery {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.synebula.zeus.query.contr.resouce
|
||||
|
||||
import com.synebula.gaea.query.IQuery
|
||||
|
||||
interface ISystemQuery : IQuery {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.synebula.zeus.query.impl.resouce
|
||||
|
||||
import com.synebula.gaea.mongo.query.MongoQuery
|
||||
import com.synebula.zeus.query.contr.resouce.IInterfaceQuery
|
||||
import org.springframework.data.mongodb.core.MongoTemplate
|
||||
|
||||
class InterfaceQuery(template: MongoTemplate) : MongoQuery(template), IInterfaceQuery {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.synebula.zeus.query.impl.resouce
|
||||
|
||||
import com.synebula.gaea.mongo.query.MongoQuery
|
||||
import com.synebula.zeus.query.contr.resouce.IPageQuery
|
||||
import org.springframework.data.mongodb.core.MongoTemplate
|
||||
|
||||
class PageQuery(template: MongoTemplate) : MongoQuery(template), IPageQuery {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.synebula.zeus.query.impl.resouce
|
||||
|
||||
import com.synebula.gaea.mongo.query.MongoQuery
|
||||
import com.synebula.zeus.query.contr.resouce.IPermissionQuery
|
||||
import com.synebula.zeus.query.contr.resouce.ISystemQuery
|
||||
import org.springframework.data.mongodb.core.MongoTemplate
|
||||
|
||||
class PermissionQuery(template: MongoTemplate) : MongoQuery(template), IPermissionQuery
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.synebula.zeus.query.impl.resouce
|
||||
|
||||
import com.synebula.gaea.mongo.query.MongoQuery
|
||||
import com.synebula.zeus.query.contr.resouce.ISystemQuery
|
||||
import org.springframework.data.mongodb.core.MongoTemplate
|
||||
|
||||
class SystemQuery(template: MongoTemplate) : MongoQuery(template), ISystemQuery
|
||||
@@ -0,0 +1,11 @@
|
||||
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 resource = ""
|
||||
var type: ResourceType? = null
|
||||
var authorization = PermissionType.Allow
|
||||
}
|
||||
Reference in New Issue
Block a user