Compare commits
16 Commits
f187192567
...
25062a9135
| Author | SHA1 | Date | |
|---|---|---|---|
| 25062a9135 | |||
| aad2aaea77 | |||
| fec580093b | |||
| c681dd9072 | |||
| 14093b1ce1 | |||
| 89b96fb053 | |||
| b58e4c9ad1 | |||
| 947853479b | |||
| 6f520513a2 | |||
| cbe75da254 | |||
| 34ff5ee65c | |||
| 72cb8cf5ca | |||
| 91710bebbe | |||
| c96dbea004 | |||
| 72ef467d09 | |||
| e3067edf53 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,5 +3,6 @@ gradlew*
|
||||
build
|
||||
gradle
|
||||
logs
|
||||
bin
|
||||
|
||||
!.gitignore
|
||||
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM gradle:8.10.1-jdk21-alpine AS build
|
||||
ENV GRADLE_USER_HOME=/.gradle
|
||||
USER root
|
||||
WORKDIR /src
|
||||
COPY --chown=gradle:gradle . .
|
||||
RUN --mount=type=cache,target=/.gradle gradle bootJar --no-daemon --build-cache
|
||||
|
||||
FROM openjdk:21-jdk-slim
|
||||
EXPOSE 80
|
||||
VOLUME /logs
|
||||
WORKDIR /app
|
||||
COPY --from=build /src/src/zeus.app/build/libs/*.jar ./spring-boot-application.jar
|
||||
ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-Djava.security.egd=file:/dev/./urandom","-jar","/app/spring-boot-application.jar"]
|
||||
34
build.gradle
34
build.gradle
@@ -1,11 +1,18 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
|
||||
buildscript {
|
||||
ext {
|
||||
kotlin_version = '1.6.10'
|
||||
jvm_version = '21'
|
||||
kotlin_version = '2.0.0'
|
||||
gaea_version = '1.7.0'
|
||||
spring_version = "3.3.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
|
||||
maven { url 'https://maven.aliyun.com/repository/central' }
|
||||
maven { url 'https://maven.aliyun.com/repository/public' }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
@@ -14,16 +21,12 @@ buildscript {
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
subprojects {
|
||||
group 'com.synebula'
|
||||
version version
|
||||
}
|
||||
|
||||
subprojects {
|
||||
ext {
|
||||
version '0.9.0'
|
||||
gaea_version = '1.2.0'
|
||||
spring_version = "2.7.0"
|
||||
version '1.0.0'
|
||||
}
|
||||
|
||||
buildscript {
|
||||
@@ -36,6 +39,7 @@ subprojects {
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven { url 'https://git.synebula.com/api/packages/alex/maven' }
|
||||
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
|
||||
mavenCentral()
|
||||
}
|
||||
@@ -51,13 +55,17 @@ subprojects {
|
||||
testApi group: 'junit', name: 'junit', version: '4.12'
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
/*** 指定 Java & Kotlin 语言编译目标JVM ***/
|
||||
sourceCompatibility = "$jvm_version"
|
||||
targetCompatibility = "$jvm_version"
|
||||
compileKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
compilerOptions {
|
||||
jvmTarget = JvmTarget.valueOf("JVM_$jvm_version")
|
||||
}
|
||||
}
|
||||
compileTestKotlin {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
compilerOptions {
|
||||
jvmTarget = JvmTarget.valueOf("JVM_$jvm_version")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
63
doc/db-init.js
Normal file
63
doc/db-init.js
Normal file
@@ -0,0 +1,63 @@
|
||||
db = db.getSiblingDB('zeus');
|
||||
db.createUser(
|
||||
{
|
||||
user: "root",
|
||||
pwd: "LcY221815",
|
||||
roles:[ { role: "dbOwner", db: "zeus" }]
|
||||
}
|
||||
)
|
||||
db.role.insertOne(
|
||||
{
|
||||
_id: "admin",
|
||||
name: "管理员"
|
||||
}
|
||||
);
|
||||
|
||||
db.group.insertOne(
|
||||
{
|
||||
_id: "1",
|
||||
name: "管理员"
|
||||
}
|
||||
);
|
||||
|
||||
db.user.insertOne({
|
||||
name: "admin",
|
||||
password: "1f22f6ce6e58a7326c5b5dd197973105",
|
||||
realName: "管理员",
|
||||
phone: "18654551561",
|
||||
role: "admin",
|
||||
group: "1",
|
||||
avalible: true,
|
||||
_class: "com.synebula.zeus.domain.model.rbac.User"
|
||||
});
|
||||
|
||||
db.system.insertOne({
|
||||
_id: "1",
|
||||
name: "web",
|
||||
uri: "",
|
||||
order: 1,
|
||||
})
|
||||
|
||||
db.page.insertMany([
|
||||
{ "_id": "1", "name": "groups", "uri": "/groups", "parent": "0", "system": "1", "order": 5, "icon": "group" },
|
||||
{ "_id": "2", "name": "roles", "uri": "/roles", "parent": "0", "system": "1", "order": 6, "icon": "manual" },
|
||||
{ "_id": "3", "name": "users", "uri": "/users", "parent": "0", "system": "1", "order": 7, "icon": "user" },
|
||||
{ "_id": "4", "name": "sheet", "uri": "/repair/sheets/all", "parent": "0", "system": "1", "order": 1, "icon": "sheet" },
|
||||
{ "_id": "5", "name": "sheet", "uri": "/repair/sheets/permission", "parent": "1", "system": "1", "order": 2, "icon": "sheet" },
|
||||
{ "_id": "6", "name": "spare", "uri": "/repair/spares/all", "parent": "1", "system": "1", "order": 3, "icon": "setting" },
|
||||
{ "_id": "7", "name": "spare", "uri": "/repair/spares/permission", "parent": "1", "system": "1", "order": 4, "icon": "setting" },
|
||||
{ "_id": "8", "name": "manual", "uri": "/manual", "parent": "0", "system": "1", "order": 8, "icon": "manual" }
|
||||
])
|
||||
|
||||
db.authority.insertMany([
|
||||
{ "role": "admin", "resource": "1", "type": "System", "authority": "Allow", "avalible": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "1", "type": "Page", "authority": "Allow", "avalible": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "2", "type": "Page", "authority": "Allow", "avalible": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "3", "type": "Page", "authority": "Allow", "avalible": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "4", "type": "Page", "authority": "Allow", "avalible": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "5", "type": "Page", "authority": "Allow", "avalible": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "6", "type": "Page", "authority": "Allow", "avalible": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "7", "type": "Page", "authority": "Allow", "avalible": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "8", "type": "Page", "authority": "Allow", "avalible": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
])
|
||||
|
||||
45
docker-compose.yml
Normal file
45
docker-compose.yml
Normal file
@@ -0,0 +1,45 @@
|
||||
services:
|
||||
app:
|
||||
image: com.synebula/zeus
|
||||
restart: always
|
||||
container_name: zeus.app
|
||||
build:
|
||||
context: ./
|
||||
dockerfile: ./Dockerfile
|
||||
volumes:
|
||||
- ./bin/logs:/app/logs
|
||||
- /etc/hosts:/etc/hosts
|
||||
- /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone
|
||||
ports:
|
||||
- 8080:80
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- DB_URL=mongodb://root:LcY221815@db/zeus
|
||||
|
||||
db:
|
||||
container_name: zeus.db
|
||||
image: mongo
|
||||
ports:
|
||||
- 27017:27017
|
||||
volumes:
|
||||
- ./bin/sct:/sct
|
||||
- ./bin/data:/data/db
|
||||
- ./bin/backup:/data/backup
|
||||
environment:
|
||||
- MONGO_INITDB_ROOT_USERNAME=root
|
||||
- MONGO_INITDB_ROOT_PASSWORD=LcY221815
|
||||
restart: unless-stopped
|
||||
|
||||
# ui:
|
||||
# image: nginx:mainline-alpine
|
||||
# restart: always
|
||||
# container_name: zeus.ui
|
||||
# links:
|
||||
# - app
|
||||
# volumes:
|
||||
# - ./conf/ui:/etc/nginx/conf.d/
|
||||
# - ./bin/ui:/app
|
||||
# - /usr/share/zoneinfo/Asia/Shanghai:/etc/timezone
|
||||
# ports:
|
||||
# - 80:80
|
||||
# - 443:443
|
||||
@@ -14,7 +14,7 @@ dependencies {
|
||||
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.app:$gaea_version")
|
||||
api "com.synebula:gaea.spring:$gaea_version"
|
||||
api "com.synebula:gaea.mongodb:$gaea_version"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
open class Application
|
||||
class Application
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
SpringApplication.run(Application::class.java, *args)
|
||||
|
||||
@@ -9,7 +9,10 @@ import org.springframework.stereotype.Component
|
||||
@Component
|
||||
class ZeusAspect : AppAspect() {
|
||||
|
||||
@Pointcut("target(com.synebula.gaea.app.IApplication)")
|
||||
/**
|
||||
* 切片执行所有继承[com.synebula.gaea.app.controller.IApplication]接口的类
|
||||
*/
|
||||
@Pointcut("target(com.synebula.gaea.app.controller.IApplication)")
|
||||
override fun func() {
|
||||
}
|
||||
}
|
||||
@@ -1,35 +1,28 @@
|
||||
package com.synebula.zeus.app.config
|
||||
|
||||
import com.google.gson.Gson
|
||||
import com.synebula.gaea.app.component.security.WebSecurity
|
||||
import com.synebula.gaea.data.message.HttpMessageFactory
|
||||
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
||||
import com.synebula.gaea.db.query.IQuery
|
||||
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 com.synebula.gaea.mongodb.db.MongodbQuery
|
||||
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.context.annotation.Primary
|
||||
import org.springframework.data.mongodb.core.MongoTemplate
|
||||
|
||||
|
||||
@Configuration
|
||||
@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)
|
||||
}
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
fun queryFactory(template: MongoTemplate): IQueryFactory {
|
||||
return MongodbQueryFactory(template)
|
||||
fun defaultQuery(template: MongoTemplate): IQuery {
|
||||
return MongodbQuery(template)
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -43,4 +36,9 @@ class ZeusBeans {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
fun httpMessageFactory(serializer: IJsonSerializer): HttpMessageFactory {
|
||||
return HttpMessageFactory(serializer)
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -1,8 +1,10 @@
|
||||
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.app.controller.IApplication
|
||||
import com.synebula.gaea.app.security.session.UserSession
|
||||
import com.synebula.gaea.app.security.session.UserSessionManager
|
||||
import com.synebula.gaea.data.message.HttpMessage
|
||||
import com.synebula.gaea.data.message.HttpMessageFactory
|
||||
import com.synebula.gaea.data.message.Status
|
||||
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
||||
import com.synebula.gaea.log.ILogger
|
||||
@@ -10,11 +12,10 @@ 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
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import org.springframework.security.core.context.SecurityContextHolder
|
||||
import org.springframework.web.bind.annotation.*
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/sign")
|
||||
@@ -27,11 +28,14 @@ class SignInOutApp(override var logger: ILogger) : IApplication {
|
||||
lateinit var userService: IUserService
|
||||
|
||||
@Autowired
|
||||
lateinit var tokenHelper: TokenManager
|
||||
lateinit var userSessionManager: UserSessionManager
|
||||
|
||||
@Autowired
|
||||
lateinit var serializer: IJsonSerializer
|
||||
|
||||
@Autowired
|
||||
override lateinit var httpMessageFactory: HttpMessageFactory
|
||||
|
||||
override var name: String = "用户登录管理"
|
||||
|
||||
@Method("用户登录")
|
||||
@@ -40,27 +44,41 @@ class SignInOutApp(override var logger: ILogger) : IApplication {
|
||||
return this.safeExecute("用户登录出现异常") {
|
||||
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
|
||||
val user = message.data!!
|
||||
val token = userSessionManager.signIn(user.uid, user)
|
||||
user.remember = remember ?: false
|
||||
user.token = token
|
||||
it.data = user
|
||||
} else {
|
||||
it.load(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Method("登录用户信息")
|
||||
@GetMapping("/user")
|
||||
fun signUser(): HttpMessage {
|
||||
val userSession = SecurityContextHolder.getContext().authentication.principal as UserSession
|
||||
return httpMessageFactory.create(userSession.user)
|
||||
}
|
||||
|
||||
@Method("用户登出")
|
||||
@PostMapping("/out")
|
||||
fun signOut(user: String): HttpMessage {
|
||||
return HttpMessage(user)
|
||||
fun signOut(): HttpMessage {
|
||||
val token = this.userSession()?.token
|
||||
return if (token != null) {
|
||||
userSessionManager.signOut(token)
|
||||
this.httpMessageFactory.create(token)
|
||||
} else
|
||||
this.httpMessageFactory.create(Status.Unauthorized, "")
|
||||
}
|
||||
|
||||
@Method("用户注册")
|
||||
@PostMapping("/up")
|
||||
fun signUp(@RequestBody command: UserCmd): HttpMessage {
|
||||
return this.safeExecute("用户注册出错, 用户信息: ${serializer.serialize(command)}") {
|
||||
val list = this.userQuery.list(mapOf(Pair("name", command.name)))
|
||||
val list = this.userQuery.list(mapOf(Pair("name", command.name)), UserView::class.java)
|
||||
if (list.isEmpty()) {
|
||||
val message = userService.add(command)
|
||||
it.data = message.data
|
||||
|
||||
@@ -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.app.controller.DomainApplication
|
||||
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
|
||||
@@ -18,14 +18,14 @@ class AuthorityApp(
|
||||
query: IAuthorityQuery,
|
||||
logger: ILogger,
|
||||
private var authorityService: IAuthorityService
|
||||
) : Application<AuthorityCmd, AuthorityView, String>(
|
||||
"权限信息", authorityService, query, logger
|
||||
) : DomainApplication<AuthorityCmd, AuthorityView, String>(
|
||||
"权限信息", authorityService, query, AuthorityView::class.java, logger
|
||||
) {
|
||||
@Method("批量添加权限信息")
|
||||
@PostMapping("/batch")
|
||||
fun add(@RequestBody cmd: AuthorityBatchAddCmd): HttpMessage {
|
||||
this.authorityService.add(cmd)
|
||||
return HttpMessage()
|
||||
return this.httpMessageFactory.create()
|
||||
}
|
||||
|
||||
@Method("根据资源和角色删除权限")
|
||||
@@ -36,6 +36,6 @@ class AuthorityApp(
|
||||
@RequestBody resource: List<String>
|
||||
): HttpMessage {
|
||||
this.authorityService.removeByResourceRole(type, resource, role)
|
||||
return HttpMessage()
|
||||
return this.httpMessageFactory.create()
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.synebula.zeus.app.controller.rbac
|
||||
|
||||
import com.synebula.gaea.app.Application
|
||||
import com.synebula.gaea.app.controller.DomainApplication
|
||||
import com.synebula.gaea.db.query.IQuery
|
||||
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.view.GroupView
|
||||
@@ -13,8 +13,8 @@ import org.springframework.web.bind.annotation.RestController
|
||||
@RequestMapping("/groups")
|
||||
class GroupApp(
|
||||
service: IGroupService,
|
||||
factory: IQueryFactory,
|
||||
query: IQuery,
|
||||
logger: ILogger
|
||||
) : Application<GroupCmd, GroupView, String>(
|
||||
"分组信息", service, factory.createQuery(GroupView::class.java), logger
|
||||
) : DomainApplication<GroupCmd, GroupView, String>(
|
||||
"用户组信息", service, query, GroupView::class.java, logger
|
||||
)
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.synebula.zeus.app.controller.rbac
|
||||
|
||||
import com.synebula.gaea.app.Application
|
||||
import com.synebula.gaea.app.controller.DomainApplication
|
||||
import com.synebula.gaea.db.query.IQuery
|
||||
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.view.RoleView
|
||||
@@ -13,8 +13,8 @@ import org.springframework.web.bind.annotation.RestController
|
||||
@RequestMapping("/roles")
|
||||
class RoleApp(
|
||||
service: IRoleService,
|
||||
factory: IQueryFactory,
|
||||
query: IQuery,
|
||||
logger: ILogger
|
||||
) : Application<RoleCmd, RoleView, String>(
|
||||
"用户信息", service, factory.createQuery(RoleView::class.java), logger
|
||||
) : DomainApplication<RoleCmd, RoleView, String>(
|
||||
"用户信息", service, query, RoleView::class.java, logger
|
||||
)
|
||||
@@ -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.app.controller.DomainApplication
|
||||
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
|
||||
@@ -18,8 +18,8 @@ class UserApp(
|
||||
service: IUserService,
|
||||
query: IUserQuery,
|
||||
logger: ILogger
|
||||
) : Application<UserCmd, UserView, String>(
|
||||
"用户信息", service, query, logger
|
||||
) : DomainApplication<UserCmd, UserView, String>(
|
||||
"用户信息", service, query, UserView::class.java, logger
|
||||
) {
|
||||
|
||||
@Autowired
|
||||
@@ -27,7 +27,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)))
|
||||
val list = this.query.list(mapOf(Pair("name", command.name)), UserView::class.java)
|
||||
if (list.isEmpty())
|
||||
it.from(super.add(command))
|
||||
else {
|
||||
@@ -53,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)))
|
||||
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))
|
||||
|
||||
|
||||
@@ -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.app.controller.DomainApplication
|
||||
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
|
||||
@@ -19,8 +19,8 @@ class InterfaceApp(
|
||||
service: IInterfaceService,
|
||||
logger: ILogger,
|
||||
var interfaceQuery: IInterfaceQuery
|
||||
) : Application<InterfaceCmd, InterfaceView, String>(
|
||||
"接口信息", service, interfaceQuery, logger
|
||||
) : DomainApplication<InterfaceCmd, InterfaceView, String>(
|
||||
"接口信息", service, interfaceQuery, InterfaceView::class.java, logger
|
||||
) {
|
||||
|
||||
@Method("获取角色系统下有权接口")
|
||||
|
||||
@@ -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.app.controller.DomainApplication
|
||||
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
|
||||
@@ -21,14 +21,14 @@ class PageApp(
|
||||
service: IPageService,
|
||||
logger: ILogger,
|
||||
var pageQuery: IPageQuery
|
||||
) : Application<PageCmd, PageView, String>(
|
||||
"页面信息", service, pageQuery, logger
|
||||
) : DomainApplication<PageCmd, PageView, String>(
|
||||
"页面信息", service, pageQuery, PageView::class.java, logger
|
||||
) {
|
||||
|
||||
@Method("获取角色系统下有权页面")
|
||||
@GetMapping("/in-system/{system}/authorized/{role}")
|
||||
fun authorized(@PathVariable system: String, @PathVariable role: String): HttpMessage {
|
||||
val msg = HttpMessage()
|
||||
val msg = this.httpMessageFactory.create()
|
||||
msg.data = this.pageQuery.authorized(role, system)
|
||||
return msg
|
||||
}
|
||||
|
||||
@@ -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.app.controller.DomainApplication
|
||||
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
|
||||
@@ -19,8 +19,8 @@ class SystemApp(
|
||||
service: ISystemService,
|
||||
logger: ILogger,
|
||||
var systemQuery: ISystemQuery
|
||||
) : Application<SystemCmd, SystemView, String>(
|
||||
"系统信息", service, systemQuery, logger
|
||||
) : DomainApplication<SystemCmd, SystemView, String>(
|
||||
"系统信息", service, systemQuery, SystemView::class.java, logger
|
||||
) {
|
||||
@Method("获取角色有权系统")
|
||||
@GetMapping("/authorized/{role}")
|
||||
|
||||
@@ -1,9 +1,36 @@
|
||||
server:
|
||||
port: 8080
|
||||
port: 80
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: gaea.app
|
||||
sign-in-url: /sign/in
|
||||
allow-multi-sign: ${ALLOW_MULTI_SIGN:false}
|
||||
data:
|
||||
mongodb:
|
||||
uri: mongodb://127.0.0.1/zeus
|
||||
uri: ${DB_URL:mongodb://root:LcY221815@127.0.0.1/zeus}
|
||||
mail:
|
||||
send: true
|
||||
target: ge.com
|
||||
sender: ${MAIL_SENDER:gehsrv@163.com}
|
||||
protocol: ${MAIL_SENDER:smtp}
|
||||
host: ${MAIL_HOST:smtp.163.com}
|
||||
port: ${MAIL_PORT:465}
|
||||
username: ${MAIL_USER:gehsrv@163.com}
|
||||
password: ${MAIL_PWD: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
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<root level="warn">
|
||||
<appender-ref ref="file"/>
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
</configuration>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.zeus.domain.model.rbac
|
||||
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
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<String>() {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.synebula.zeus.domain.model.rbac
|
||||
|
||||
import com.synebula.gaea.data.permission.PermissionType
|
||||
import com.synebula.gaea.domain.model.AggregateRoot
|
||||
|
||||
class Role(override var id: String? = null) : AggregateRoot<String>() {
|
||||
var name = ""
|
||||
var desc = ""
|
||||
var permissionType = PermissionType.Minimum
|
||||
}
|
||||
@@ -4,5 +4,5 @@ import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
|
||||
class Interface : Resource(), IAggregateRoot<String> {
|
||||
var system = ""
|
||||
override var alive = true
|
||||
override var avalible = true
|
||||
}
|
||||
@@ -16,6 +16,6 @@ class Page : Resource(), IAggregateRoot<String> {
|
||||
// 所属系统
|
||||
var system = ""
|
||||
|
||||
override var alive = true
|
||||
override var avalible = true
|
||||
|
||||
}
|
||||
@@ -3,5 +3,5 @@ package com.synebula.zeus.domain.model.rbac.resource
|
||||
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
|
||||
class System : Resource(), IAggregateRoot<String> {
|
||||
override var alive = true
|
||||
override var avalible = true
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.zeus.domain.service.cmd.rbac
|
||||
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.domain.service.Command
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.zeus.env.ResourceType
|
||||
|
||||
class AuthorityBatchAddCmd : Command() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.zeus.domain.service.cmd.rbac
|
||||
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.domain.service.Command
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.zeus.env.ResourceType
|
||||
|
||||
class AuthorityCmd : Command() {
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.synebula.zeus.domain.service.cmd.rbac
|
||||
|
||||
import com.synebula.gaea.data.permission.PermissionType
|
||||
import com.synebula.gaea.domain.service.Command
|
||||
|
||||
class RoleCmd : Command() {
|
||||
var id: String? = null
|
||||
var name = ""
|
||||
var desc = ""
|
||||
var permissionType = PermissionType.Minimum
|
||||
}
|
||||
@@ -10,6 +10,6 @@ class UserCmd : Command() {
|
||||
var phone: String? = null
|
||||
var role: String? = null
|
||||
var group: String = ""
|
||||
var alive: Boolean = false
|
||||
var avalible: Boolean = false
|
||||
var token: String? = null
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ package com.synebula.zeus.domain.service.cmd.rbac.resource
|
||||
|
||||
class InterfaceCmd : ResourceCmd() {
|
||||
var system = ""
|
||||
var alive = true
|
||||
var avalible = true
|
||||
}
|
||||
@@ -14,6 +14,6 @@ class PageCmd : ResourceCmd() {
|
||||
// 所属系统
|
||||
var system = ""
|
||||
|
||||
var alive = true
|
||||
var avalible = true
|
||||
|
||||
}
|
||||
@@ -2,5 +2,5 @@ package com.synebula.zeus.domain.service.cmd.rbac.resource
|
||||
|
||||
|
||||
class SystemCmd : ResourceCmd() {
|
||||
var alive = true
|
||||
var avalible = true
|
||||
}
|
||||
@@ -1,13 +1,18 @@
|
||||
package com.synebula.zeus.domain.service.impl.rbac
|
||||
|
||||
import com.synebula.gaea.bus.DomainSubscribe
|
||||
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,30 +25,23 @@ class UserService(
|
||||
var logger: ILogger
|
||||
) : Service<User, String>(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
|
||||
// }
|
||||
// }
|
||||
@DomainSubscribe(domainClass = Role::class, messageClass = BeforeRemoveEvent::class)
|
||||
fun beforeRoleRemove(event: BeforeRemoveEvent<Role, String>) {
|
||||
if (this.repository.count(mapOf(Pair("role", event.id!!))) > 0)
|
||||
throw NoticeUserException("角色下还有用户")
|
||||
}
|
||||
|
||||
@DomainSubscribe(BeforeRemoveEvent::class, Group::class)
|
||||
fun beforeGroupRemove(event: BeforeRemoveEvent<Group, String>) {
|
||||
if (this.repository.count(mapOf(Pair("group", event.id!!))) > 0)
|
||||
throw NoticeUserException("用户组下还有用户")
|
||||
}
|
||||
|
||||
override fun add(command: ICommand): DataMessage<String> {
|
||||
val user = this.map(command)
|
||||
user.password = user.password.toMd5()
|
||||
user.token = UUID.randomUUID().toString()
|
||||
user.alive = false
|
||||
user.avalible = false
|
||||
this.repository.add(user)
|
||||
userNotifier?.added(user.id!!, user.name, user.token!!)
|
||||
return DataMessage(user.id!!)
|
||||
@@ -56,16 +54,16 @@ class UserService(
|
||||
*/
|
||||
override fun active(key: String, token: String): DataMessage<Any> {
|
||||
val user = this.repository.get(key)!!
|
||||
return if (user.alive) {
|
||||
return if (user.avalible) {
|
||||
DataMessage("用户${user.name}无需重复激活")
|
||||
} else {
|
||||
if (token == user.token) {
|
||||
user.alive = true
|
||||
user.avalible = true
|
||||
user.token = null
|
||||
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,14 +91,17 @@ 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, "用户重置密码失败, 如需重置密码请从系统发送的邮件链接中重置")
|
||||
}
|
||||
}
|
||||
|
||||
override fun forgotPassword(key: String): DataMessage<String> {
|
||||
val user = this.repository.get(key)!!
|
||||
return if (user.alive) {
|
||||
return if (user.avalible) {
|
||||
user.token = UUID.randomUUID().toString()
|
||||
this.repository.update(user)
|
||||
userNotifier?.forgot(user.id!!, user.name, user.token!!)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.synebula.zeus.env
|
||||
|
||||
enum class AuthorityType {
|
||||
Default,
|
||||
Deny,
|
||||
Allow
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.synebula.zeus.env
|
||||
|
||||
/**
|
||||
* 资源类型
|
||||
*/
|
||||
enum class ResourceType {
|
||||
System,
|
||||
Page,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.synebula.zeus.query.contr
|
||||
|
||||
import com.synebula.gaea.query.IQuery
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.db.query.IQuery
|
||||
import com.synebula.zeus.env.ResourceType
|
||||
import com.synebula.zeus.query.view.AuthorityView
|
||||
|
||||
interface IAuthorityQuery : IQuery<AuthorityView, String> {
|
||||
interface IAuthorityQuery : IQuery {
|
||||
|
||||
/**
|
||||
* 获取角色已授权的资源
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.synebula.zeus.query.contr
|
||||
|
||||
import com.synebula.gaea.data.message.DataMessage
|
||||
import com.synebula.gaea.query.IQuery
|
||||
import com.synebula.gaea.db.query.IQuery
|
||||
import com.synebula.zeus.query.view.SignUserView
|
||||
import com.synebula.zeus.query.view.UserView
|
||||
|
||||
interface IUserQuery : IQuery<UserView, String> {
|
||||
interface IUserQuery : IQuery {
|
||||
/**
|
||||
* 登录接口
|
||||
*
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.synebula.zeus.query.contr.resouce
|
||||
|
||||
import com.synebula.gaea.query.IQuery
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.db.query.IQuery
|
||||
import com.synebula.zeus.query.view.resource.InterfaceView
|
||||
|
||||
interface IInterfaceQuery : IQuery<InterfaceView, String> {
|
||||
interface IInterfaceQuery : IQuery {
|
||||
|
||||
fun authorized(role: String): List<InterfaceView>
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package com.synebula.zeus.query.contr.resouce
|
||||
|
||||
import com.synebula.gaea.query.IQuery
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.db.query.IQuery
|
||||
import com.synebula.zeus.query.view.resource.PageView
|
||||
|
||||
interface IPageQuery : IQuery<PageView, String> {
|
||||
interface IPageQuery : IQuery {
|
||||
|
||||
fun authorized(role: String): List<PageView>
|
||||
|
||||
fun authorized(role: String, system: String? ): List<PageView>
|
||||
fun authorized(role: String, system: String?): List<PageView>
|
||||
|
||||
fun authorize(resource: String, role: String): AuthorityType?
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.synebula.zeus.query.contr.resouce
|
||||
|
||||
import com.synebula.gaea.query.IQuery
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.db.query.IQuery
|
||||
import com.synebula.zeus.query.view.resource.SystemView
|
||||
|
||||
interface ISystemQuery : IQuery<SystemView, String> {
|
||||
interface ISystemQuery : IQuery {
|
||||
|
||||
fun authorized(role: String): List<SystemView>
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.zeus.query.impl
|
||||
|
||||
import com.synebula.gaea.mongodb.query.MongodbQuery
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.mongodb.db.MongodbQuery
|
||||
import com.synebula.zeus.env.ResourceType
|
||||
import com.synebula.zeus.query.contr.IAuthorityQuery
|
||||
import com.synebula.zeus.query.view.AuthorityView
|
||||
@@ -10,15 +10,14 @@ import org.springframework.data.mongodb.core.query.Criteria
|
||||
import org.springframework.data.mongodb.core.query.Query
|
||||
|
||||
class AuthorityQuery(template: MongoTemplate) :
|
||||
MongodbQuery<AuthorityView, String>(AuthorityView::class.java, template), IAuthorityQuery {
|
||||
var collection = this.collection(this.clazz)
|
||||
MongodbQuery(template), IAuthorityQuery {
|
||||
|
||||
override fun authorized(resourceType: ResourceType, role: String): List<AuthorityView> {
|
||||
return this.template.find(
|
||||
Query.query(
|
||||
Criteria.where("type").`is`(resourceType)
|
||||
.and("role").`is`(role)
|
||||
), this.clazz, this.collection
|
||||
), AuthorityView::class.java, this.collection(AuthorityView::class.java)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -28,7 +27,7 @@ class AuthorityQuery(template: MongoTemplate) :
|
||||
Criteria.where("type").`is`(resourceType)
|
||||
.and("resource").`is`(resource)
|
||||
.and("role").`is`(role)
|
||||
), this.clazz, this.collection
|
||||
), AuthorityView::class.java, this.collection(AuthorityView::class.java)
|
||||
)
|
||||
return authority?.authority ?: AuthorityType.Default
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@ package com.synebula.zeus.query.impl
|
||||
|
||||
import com.synebula.gaea.data.message.DataMessage
|
||||
import com.synebula.gaea.data.message.Status
|
||||
import com.synebula.gaea.data.permission.PermissionType
|
||||
import com.synebula.gaea.ext.toMd5
|
||||
import com.synebula.gaea.mongodb.query.MongodbQuery
|
||||
import com.synebula.gaea.mongodb.db.MongodbQuery
|
||||
import com.synebula.gaea.mongodb.whereId
|
||||
import com.synebula.zeus.query.contr.IUserQuery
|
||||
import com.synebula.zeus.query.view.GroupView
|
||||
@@ -16,15 +17,15 @@ import org.springframework.data.mongodb.core.query.Query
|
||||
import org.springframework.data.mongodb.core.query.isEqualTo
|
||||
|
||||
class UserQuery(template: MongoTemplate) :
|
||||
MongodbQuery<UserView, String>(UserView::class.java, template), IUserQuery {
|
||||
MongodbQuery(template), IUserQuery {
|
||||
|
||||
override fun signIn(name: String, password: String): DataMessage<SignUserView> {
|
||||
val query = Query.query(
|
||||
Criteria.where("name").isEqualTo(name)
|
||||
.and("password").isEqualTo(password.toMd5())
|
||||
.and("alive").isEqualTo(true)
|
||||
.and("avalible").isEqualTo(true)
|
||||
)
|
||||
val user = this.template.findOne(query, this.clazz, "user")
|
||||
val user = this.template.findOne(query, UserView::class.java, "user")
|
||||
return if (user != null) {
|
||||
val role = this.template.findOne(whereId(user.role), RoleView::class.java, "role")
|
||||
val group = this.template.findOne(whereId(user.group), GroupView::class.java, "group")
|
||||
@@ -32,7 +33,8 @@ class UserQuery(template: MongoTemplate) :
|
||||
SignUserView(
|
||||
user.id, user.realName ?: "",
|
||||
user.role ?: "", role?.name ?: "",
|
||||
user.group ?: "", group?.name ?: ""
|
||||
user.group ?: "", group?.name ?: "",
|
||||
role?.permissionType ?: PermissionType.None
|
||||
)
|
||||
)
|
||||
} else
|
||||
@@ -41,6 +43,6 @@ class UserQuery(template: MongoTemplate) :
|
||||
|
||||
|
||||
override fun listUsers(idList: List<String>): List<UserView> {
|
||||
return this.template.find(Query.query(Criteria.where("_id").`in`(idList)), this.clazz, "user")
|
||||
return this.template.find(Query.query(Criteria.where("_id").`in`(idList)), UserView::class.java, "user")
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.zeus.query.impl.resouce
|
||||
|
||||
import com.synebula.gaea.mongodb.query.MongodbQuery
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.mongodb.db.MongodbQuery
|
||||
import com.synebula.zeus.env.ResourceType
|
||||
import com.synebula.zeus.query.contr.IAuthorityQuery
|
||||
import com.synebula.zeus.query.contr.resouce.IInterfaceQuery
|
||||
@@ -13,7 +13,7 @@ class InterfaceQuery(
|
||||
template: MongoTemplate,
|
||||
var authorityQuery: IAuthorityQuery,
|
||||
var systemQuery: ISystemQuery
|
||||
) : MongodbQuery<InterfaceView, String>(InterfaceView::class.java, template), IInterfaceQuery {
|
||||
) : MongodbQuery(template), IInterfaceQuery {
|
||||
|
||||
override fun authorized(role: String): List<InterfaceView> {
|
||||
return this.authorized(role, null)
|
||||
@@ -26,9 +26,9 @@ class InterfaceQuery(
|
||||
if (authority == AuthorityType.Deny)
|
||||
return listOf()
|
||||
}
|
||||
val params = mutableMapOf<String, Any>()
|
||||
val params = mutableMapOf<String, String>()
|
||||
if (system != null) params["system"] = system
|
||||
val interfaces = this.list(params)
|
||||
val interfaces = this.list(params, InterfaceView::class.java)
|
||||
val authorities = this.authorityQuery.authorized(ResourceType.Interface, role)
|
||||
return interfaces.filter { i ->
|
||||
val authority = authorities.find { p -> i.id == p.resource }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.zeus.query.impl.resouce
|
||||
|
||||
import com.synebula.gaea.mongodb.query.MongodbQuery
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.mongodb.db.MongodbQuery
|
||||
import com.synebula.zeus.env.ResourceType
|
||||
import com.synebula.zeus.query.contr.IAuthorityQuery
|
||||
import com.synebula.zeus.query.contr.resouce.IPageQuery
|
||||
@@ -12,7 +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) :
|
||||
MongodbQuery<PageView, String>(PageView::class.java, template), IPageQuery {
|
||||
MongodbQuery(template), IPageQuery {
|
||||
|
||||
override fun authorized(role: String): List<PageView> {
|
||||
return this.authorized(role, null)
|
||||
@@ -24,9 +24,9 @@ class PageQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, va
|
||||
if (authority == AuthorityType.Deny)
|
||||
return listOf()
|
||||
}
|
||||
val params = mutableMapOf<String, Any>()
|
||||
val params = mutableMapOf<String, String>()
|
||||
if (system != null) params["system"] = system
|
||||
val pages = this.list(params)
|
||||
val pages = this.list(params, PageView::class.java)
|
||||
val authorities = this.authorityQuery.authorized(ResourceType.Page, role)
|
||||
return pages.filter { i ->
|
||||
val authority = authorities.find { p -> i.id == p.resource }
|
||||
@@ -41,7 +41,7 @@ class PageQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, va
|
||||
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)
|
||||
PageView::class.java, this.collection(PageView::class.java)
|
||||
) ?: return null
|
||||
return this.authorize(page.id!!, role)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.zeus.query.impl.resouce
|
||||
|
||||
import com.synebula.gaea.mongodb.query.MongodbQuery
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.mongodb.db.MongodbQuery
|
||||
import com.synebula.zeus.env.ResourceType
|
||||
import com.synebula.zeus.query.contr.IAuthorityQuery
|
||||
import com.synebula.zeus.query.contr.resouce.ISystemQuery
|
||||
@@ -9,10 +9,10 @@ import com.synebula.zeus.query.view.resource.SystemView
|
||||
import org.springframework.data.mongodb.core.MongoTemplate
|
||||
|
||||
class SystemQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery) :
|
||||
MongodbQuery<SystemView, String>(SystemView::class.java, template), ISystemQuery {
|
||||
MongodbQuery(template), ISystemQuery {
|
||||
|
||||
override fun authorized(role: String): List<SystemView> {
|
||||
val systems = this.list(mapOf())
|
||||
val systems = this.list(mapOf(), SystemView::class.java)
|
||||
val authorities = this.authorityQuery.authorized(ResourceType.System, role)
|
||||
return systems.filter { i -> authorities.find { p -> i.id == p.resource }?.authority == AuthorityType.Allow }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.synebula.zeus.query.view
|
||||
|
||||
import com.synebula.zeus.env.AuthorityType
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.zeus.env.ResourceType
|
||||
|
||||
class AuthorityView() {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package com.synebula.zeus.query.view
|
||||
|
||||
import com.synebula.gaea.query.Operator
|
||||
import com.synebula.gaea.query.Table
|
||||
import com.synebula.gaea.query.Where
|
||||
import com.synebula.gaea.db.query.Operator
|
||||
import com.synebula.gaea.db.query.Table
|
||||
import com.synebula.gaea.db.query.Where
|
||||
|
||||
|
||||
@Table("group")
|
||||
class GroupView {
|
||||
var id: String? = null
|
||||
|
||||
@Where(Operator.like)
|
||||
@Where(Operator.Like)
|
||||
var name = ""
|
||||
|
||||
var desc = ""
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.synebula.zeus.query.view
|
||||
|
||||
import com.synebula.gaea.query.Table
|
||||
import com.synebula.gaea.data.permission.PermissionType
|
||||
import com.synebula.gaea.db.query.Table
|
||||
|
||||
@Table("role")
|
||||
class RoleView {
|
||||
var id: String? = null
|
||||
var name = ""
|
||||
var desc = ""
|
||||
var permissionType = PermissionType.Minimum
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.synebula.zeus.query.view
|
||||
|
||||
import com.synebula.gaea.data.permission.PermissionType
|
||||
|
||||
class SignUserView(
|
||||
/**
|
||||
* 用户id
|
||||
@@ -30,5 +32,7 @@ class SignUserView(
|
||||
* 组名称
|
||||
*/
|
||||
var gname: String = "",
|
||||
var remember: Boolean = false
|
||||
var permissionType: PermissionType = PermissionType.Minimum,
|
||||
var remember: Boolean = false,
|
||||
var token: String = ""
|
||||
)
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.synebula.zeus.query.view
|
||||
|
||||
import com.synebula.gaea.query.Operator
|
||||
import com.synebula.gaea.query.Table
|
||||
import com.synebula.gaea.query.Where
|
||||
import com.synebula.gaea.db.query.Operator
|
||||
import com.synebula.gaea.db.query.Table
|
||||
import com.synebula.gaea.db.query.Where
|
||||
|
||||
@Table("user")
|
||||
class UserView {
|
||||
@@ -12,7 +12,7 @@ class UserView {
|
||||
|
||||
var password: String = ""
|
||||
|
||||
@Where(Operator.like)
|
||||
@Where(Operator.Like)
|
||||
var realName: String? = null
|
||||
|
||||
var phone: String? = null
|
||||
@@ -23,5 +23,5 @@ class UserView {
|
||||
|
||||
var token: String? = null
|
||||
|
||||
var alive: Boolean? = null
|
||||
var avalible: Boolean? = null
|
||||
}
|
||||
@@ -2,5 +2,5 @@ package com.synebula.zeus.query.view.resource
|
||||
|
||||
class InterfaceView : ResourceView() {
|
||||
var system = ""
|
||||
var alive = true
|
||||
var avalible = true
|
||||
}
|
||||
@@ -14,6 +14,6 @@ class PageView : ResourceView() {
|
||||
// 所属系统
|
||||
var system = ""
|
||||
|
||||
var alive = true
|
||||
var avalible = true
|
||||
|
||||
}
|
||||
@@ -2,5 +2,5 @@ package com.synebula.zeus.query.view.resource
|
||||
|
||||
|
||||
class SystemView : ResourceView() {
|
||||
var alive = true
|
||||
var avalible = true
|
||||
}
|
||||
Reference in New Issue
Block a user