Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d67cf10600 | |||
| 54e4c61c3f | |||
| 25062a9135 | |||
| aad2aaea77 | |||
| b58e4c9ad1 | |||
| 34ff5ee65c |
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"]
|
||||
38
build.gradle
38
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.2'
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -19,9 +26,7 @@ subprojects {
|
||||
version version
|
||||
|
||||
ext {
|
||||
version '0.9.0'
|
||||
gaea_version = '1.5.1'
|
||||
spring_version = "2.7.0"
|
||||
version '1.1.1'
|
||||
}
|
||||
|
||||
buildscript {
|
||||
@@ -34,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()
|
||||
}
|
||||
@@ -49,13 +55,25 @@ 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")
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
db.role.insertMany([
|
||||
db = db.getSiblingDB('zeus');
|
||||
db.createUser(
|
||||
{
|
||||
user: "root",
|
||||
pwd: "LcY221815",
|
||||
roles:[ { role: "dbOwner", db: "zeus" }]
|
||||
}
|
||||
)
|
||||
db.role.insertOne(
|
||||
{
|
||||
_id: "admin",
|
||||
name: "管理员"
|
||||
},
|
||||
{
|
||||
_id: "VE",
|
||||
name: "Viewer"
|
||||
},
|
||||
{
|
||||
_id: "RE",
|
||||
name: "RE工程师"
|
||||
},
|
||||
{
|
||||
_id: "FE",
|
||||
name: "FE工程师"
|
||||
}
|
||||
]
|
||||
);
|
||||
|
||||
db.group.insertOne(
|
||||
@@ -32,7 +27,7 @@ db.user.insertOne({
|
||||
phone: "18654551561",
|
||||
role: "admin",
|
||||
group: "1",
|
||||
alive: true,
|
||||
avalible: true,
|
||||
_class: "com.synebula.zeus.domain.model.rbac.User"
|
||||
});
|
||||
|
||||
@@ -44,25 +39,16 @@ db.system.insertOne({
|
||||
})
|
||||
|
||||
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" }
|
||||
{ "_id": "1", "name": "groups", "uri": "/groups", "parent": "0", "system": "1", "order": 1, "icon": "group" },
|
||||
{ "_id": "2", "name": "roles", "uri": "/roles", "parent": "0", "system": "1", "order": 2, "icon": "manual" },
|
||||
{ "_id": "3", "name": "users", "uri": "/users", "parent": "0", "system": "1", "order": 3, "icon": "user" },
|
||||
{ "_id": "4", "name": "pages", "uri": "/pages", "parent": "0", "system": "1", "order": 4, "icon": "page" }})
|
||||
])
|
||||
|
||||
db.authority.insertMany([
|
||||
{ "role": "admin", "resource": "1", "type": "System", "authority": "Allow", "alive": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "1", "type": "Page", "authority": "Allow", "alive": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "2", "type": "Page", "authority": "Allow", "alive": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "3", "type": "Page", "authority": "Allow", "alive": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "4", "type": "Page", "authority": "Allow", "alive": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "5", "type": "Page", "authority": "Allow", "alive": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "6", "type": "Page", "authority": "Allow", "alive": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "7", "type": "Page", "authority": "Allow", "alive": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "role": "admin", "resource": "8", "type": "Page", "authority": "Allow", "alive": true, "_class": "com.synebula.zeus.domain.model.rbac.Authority" },
|
||||
{ "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": "67595cfcbbef24782f95a325", "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
|
||||
@@ -19,15 +19,3 @@ dependencies {
|
||||
api "com.synebula:gaea.mongodb:$gaea_version"
|
||||
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publish(MavenPublication) {
|
||||
group 'com.synebula'
|
||||
artifactId 'zeus.app'
|
||||
version "$version"
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,23 +3,26 @@ package com.synebula.zeus.app.config
|
||||
import com.google.gson.Gson
|
||||
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.Configuration
|
||||
import org.springframework.context.annotation.Primary
|
||||
import org.springframework.data.mongodb.core.MongoTemplate
|
||||
|
||||
@Configuration
|
||||
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
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.synebula.zeus.app.config
|
||||
|
||||
import com.synebula.gaea.app.autoconfig.service.ServiceScan
|
||||
import com.synebula.gaea.mongodb.autoconfig.MongodbRepositoryScan
|
||||
import com.synebula.gaea.mongodb.autoconfig.MongoDbRepositoryScan
|
||||
import org.springframework.stereotype.Component
|
||||
|
||||
@Component
|
||||
@ServiceScan(basePackages = ["com.synebula.zeus.domain.service"])
|
||||
@MongodbRepositoryScan(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
|
||||
@@ -12,6 +12,7 @@ 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.security.core.context.SecurityContextHolder
|
||||
import org.springframework.web.bind.annotation.*
|
||||
@@ -65,24 +66,24 @@ class SignInOutApp(override var logger: ILogger) : IApplication {
|
||||
@Method("用户登出")
|
||||
@PostMapping("/out")
|
||||
fun signOut(): HttpMessage {
|
||||
val token = this.userSession()?.token
|
||||
val token = this.session()?.token
|
||||
return if (token != null) {
|
||||
userSessionManager.signOut(token)
|
||||
this.httpMessageFactory.create(token)
|
||||
} else
|
||||
this.httpMessageFactory.create(Status.Unauthorized, "")
|
||||
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
|
||||
} else {
|
||||
it.status = Status.Failure
|
||||
it.status = Status.FAILURE
|
||||
it.message = "系统中已存在该用户"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.synebula.zeus.app.controller.rbac
|
||||
|
||||
import com.synebula.gaea.app.controller.Application
|
||||
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
|
||||
@@ -18,8 +18,8 @@ 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")
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.synebula.zeus.app.controller.rbac
|
||||
|
||||
import com.synebula.gaea.app.controller.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.controller.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,6 +1,6 @@
|
||||
package com.synebula.zeus.app.controller.rbac
|
||||
|
||||
import com.synebula.gaea.app.controller.Application
|
||||
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
|
||||
@@ -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,11 +27,11 @@ 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 {
|
||||
it.status = Status.Failure
|
||||
it.status = Status.FAILURE
|
||||
it.message = "系统中已存在该用户"
|
||||
}
|
||||
}
|
||||
@@ -53,12 +53,12 @@ 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))
|
||||
|
||||
} else {
|
||||
it.status = Status.Failure
|
||||
it.status = Status.FAILURE
|
||||
it.message = "找不到该用户信息"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.synebula.zeus.app.controller.rbac.resource
|
||||
|
||||
import com.synebula.gaea.app.controller.Application
|
||||
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
|
||||
@@ -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,6 +1,6 @@
|
||||
package com.synebula.zeus.app.controller.rbac.resource
|
||||
|
||||
import com.synebula.gaea.app.controller.Application
|
||||
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
|
||||
@@ -8,6 +8,7 @@ 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
|
||||
import com.synebula.zeus.query.view.SignUserView
|
||||
import com.synebula.zeus.query.view.resource.PageView
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
@@ -21,16 +22,16 @@ 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}")
|
||||
@GetMapping("/by-system/{system}/authorized/{role}")
|
||||
fun authorized(@PathVariable system: String, @PathVariable role: String): HttpMessage {
|
||||
val msg = this.httpMessageFactory.create()
|
||||
msg.data = this.pageQuery.authorized(role, system)
|
||||
return msg
|
||||
return this.safeExecute("获取有权资源列表失败") { msg ->
|
||||
msg.data = this.pageQuery.authorized(role, system)
|
||||
}
|
||||
}
|
||||
|
||||
@Method("获取角色全部有权页面")
|
||||
@@ -42,20 +43,22 @@ class PageApp(
|
||||
}
|
||||
|
||||
@Method("验证角色页面权限")
|
||||
@GetMapping("/{page}/authorize/{role}")
|
||||
fun authorize(@PathVariable page: String, @PathVariable role: String): HttpMessage {
|
||||
@GetMapping("/{page}/authorize")
|
||||
fun authorize(@PathVariable page: String): HttpMessage {
|
||||
val session = this.session()
|
||||
val rid = session?.user<SignUserView>()?.rid ?: ""
|
||||
return this.safeExecute("获取权限信息失败") { msg ->
|
||||
msg.data = this.pageQuery.authorize(page, role)
|
||||
msg.data = this.pageQuery.authorize(page, rid)
|
||||
}
|
||||
}
|
||||
|
||||
@Method("验证角色URL权限")
|
||||
@GetMapping("/authorize/{role}")
|
||||
fun uriAuthorize(@PathVariable role: String, uri: String): HttpMessage {
|
||||
@GetMapping("/authorize")
|
||||
fun uriAuthorize(uri: String): HttpMessage {
|
||||
val session = this.session()
|
||||
val rid = session?.user<SignUserView>()?.rid ?: ""
|
||||
return this.safeExecute("获取权限信息失败") { msg ->
|
||||
msg.data = this.pageQuery.uriAuthorize(uri, role)
|
||||
msg.data = this.pageQuery.uriAuthorize(uri, rid)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
package com.synebula.zeus.app.controller.rbac.resource
|
||||
|
||||
import com.synebula.gaea.app.controller.Application
|
||||
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
|
||||
import com.synebula.zeus.domain.service.contr.rbac.resource.ISystemService
|
||||
import com.synebula.zeus.query.contr.resouce.ISystemQuery
|
||||
import com.synebula.zeus.query.view.SignUserView
|
||||
import com.synebula.zeus.query.view.resource.SystemView
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.PathVariable
|
||||
@@ -19,8 +20,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}")
|
||||
@@ -31,10 +32,12 @@ class SystemApp(
|
||||
}
|
||||
|
||||
@Method("验证角色系统权限")
|
||||
@GetMapping("/{system}/authorize/{role}")
|
||||
fun authorize(@PathVariable system: String, @PathVariable role: String): HttpMessage {
|
||||
@GetMapping("/{system}/authorize")
|
||||
fun authorize(@PathVariable system: String): HttpMessage {
|
||||
val session = this.session()
|
||||
val rid = session?.user<SignUserView>()?.rid ?: ""
|
||||
return this.safeExecute("获取权限信息失败") { msg ->
|
||||
msg.data = this.systemQuery.authorize(system, role)
|
||||
msg.data = this.systemQuery.authorize(system, rid)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,26 @@
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
port: 80
|
||||
error:
|
||||
whitelabel:
|
||||
enabled: false
|
||||
spring:
|
||||
application:
|
||||
name: gaea.app
|
||||
sign-in-url: /sign/in
|
||||
allow-multi-sign: false
|
||||
allow-multi-sign: ${ALLOW_MULTI_SIGN:true}
|
||||
token-salt: ${TOKEN_SALT:7d25b8e5}
|
||||
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: gehsrv@163.com
|
||||
protocol: smtp
|
||||
host: smtp.163.com
|
||||
port: 465
|
||||
username: gehsrv@163.com
|
||||
password: SRBPJBLFFVVCPZLZ
|
||||
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:
|
||||
|
||||
@@ -2,15 +2,3 @@ dependencies {
|
||||
api project(":src:zeus.env")
|
||||
api "com.synebula:gaea:$gaea_version"
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publish(MavenPublication) {
|
||||
group 'com.synebula'
|
||||
artifactId 'zeus.domain'
|
||||
version "$version"
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,5 +4,5 @@ import com.synebula.gaea.domain.model.IAggregateRoot
|
||||
|
||||
class Interface : Resource(), IAggregateRoot<String> {
|
||||
var system = ""
|
||||
override var alive = true
|
||||
override var available = true
|
||||
}
|
||||
@@ -16,6 +16,6 @@ class Page : Resource(), IAggregateRoot<String> {
|
||||
// 所属系统
|
||||
var system = ""
|
||||
|
||||
override var alive = true
|
||||
override var available = 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 available = true
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -41,7 +41,7 @@ class UserService(
|
||||
val user = this.map(command)
|
||||
user.password = user.password.toMd5()
|
||||
user.token = UUID.randomUUID().toString()
|
||||
user.alive = false
|
||||
user.available = false
|
||||
this.repository.add(user)
|
||||
userNotifier?.added(user.id!!, user.name, user.token!!)
|
||||
return DataMessage(user.id!!)
|
||||
@@ -54,17 +54,17 @@ class UserService(
|
||||
*/
|
||||
override fun active(key: String, token: String): DataMessage<Any> {
|
||||
val user = this.repository.get(key)!!
|
||||
return if (user.alive) {
|
||||
return if (user.available) {
|
||||
DataMessage("用户${user.name}无需重复激活")
|
||||
} else {
|
||||
if (token == user.token) {
|
||||
user.alive = true
|
||||
user.available = true
|
||||
user.token = null
|
||||
this.repository.update(user)
|
||||
DataMessage(Status.Success, "用户${user.name}激活成功")
|
||||
DataMessage(Status.SUCCESS, "用户${user.name}激活成功")
|
||||
} else {
|
||||
logger.warn(this, "用户${user.name}激活失败, {key: ${key}, token: $token")
|
||||
DataMessage(Status.Failure, "用户${user.name}激活失败, 请从系统发送的邮件链接激活用户")
|
||||
DataMessage(Status.FAILURE, "用户${user.name}激活失败, 请从系统发送的邮件链接激活用户")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,7 +78,7 @@ class UserService(
|
||||
DataMessage()
|
||||
} else {
|
||||
logger.warn(this, "用户修改${user.name}密码失败, 旧密码验证不通过")
|
||||
DataMessage(Status.Failure, "用户修改密码失败, 旧密码验证不通过")
|
||||
DataMessage(Status.FAILURE, "用户修改密码失败, 旧密码验证不通过")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,18 +95,18 @@ class UserService(
|
||||
this,
|
||||
"用户重置${user.name}密码失败, 系统密码修改令牌:${user.token}, {key: $key , token: $token"
|
||||
)
|
||||
DataMessage(Status.Failure, "用户重置密码失败, 如需重置密码请从系统发送的邮件链接中重置")
|
||||
DataMessage(Status.FAILURE, "用户重置密码失败, 如需重置密码请从系统发送的邮件链接中重置")
|
||||
}
|
||||
}
|
||||
|
||||
override fun forgotPassword(key: String): DataMessage<String> {
|
||||
val user = this.repository.get(key)!!
|
||||
return if (user.alive) {
|
||||
return if (user.available) {
|
||||
user.token = UUID.randomUUID().toString()
|
||||
this.repository.update(user)
|
||||
userNotifier?.forgot(user.id!!, user.name, user.token!!)
|
||||
DataMessage()
|
||||
} else
|
||||
DataMessage(Status.Failure, "用户还未激活, 请先激活用户")
|
||||
DataMessage(Status.FAILURE, "用户还未激活, 请先激活用户")
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,3 @@
|
||||
dependencies {
|
||||
api "com.synebula:gaea:$gaea_version"
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publish(MavenPublication) {
|
||||
group 'com.synebula'
|
||||
artifactId 'zeus.env'
|
||||
version "$version"
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,3 @@ dependencies {
|
||||
api project(":src:zeus.env")
|
||||
api "com.synebula:gaea.mongodb:$gaea_version"
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publish(MavenPublication) {
|
||||
group 'com.synebula'
|
||||
artifactId 'zeus.query'
|
||||
version "$version"
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.synebula.zeus.query.contr
|
||||
|
||||
import com.synebula.gaea.data.permission.AuthorityType
|
||||
import com.synebula.gaea.query.IQuery
|
||||
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.data.permission.AuthorityType
|
||||
import com.synebula.gaea.query.IQuery
|
||||
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.data.permission.AuthorityType
|
||||
import com.synebula.gaea.query.IQuery
|
||||
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.data.permission.AuthorityType
|
||||
import com.synebula.gaea.query.IQuery
|
||||
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.data.permission.AuthorityType
|
||||
import com.synebula.gaea.mongodb.query.MongodbQuery
|
||||
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
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ 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
|
||||
@@ -17,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")
|
||||
@@ -38,11 +38,11 @@ class UserQuery(template: MongoTemplate) :
|
||||
)
|
||||
)
|
||||
} else
|
||||
DataMessage(Status.Failure, "用户名或密码错误")
|
||||
DataMessage(Status.FAILURE, "用户名或密码错误")
|
||||
}
|
||||
|
||||
|
||||
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.data.permission.AuthorityType
|
||||
import com.synebula.gaea.mongodb.query.MongodbQuery
|
||||
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)
|
||||
@@ -28,7 +28,7 @@ class InterfaceQuery(
|
||||
}
|
||||
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.data.permission.AuthorityType
|
||||
import com.synebula.gaea.mongodb.query.MongodbQuery
|
||||
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)
|
||||
@@ -26,7 +26,7 @@ class PageQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, va
|
||||
}
|
||||
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.data.permission.AuthorityType
|
||||
import com.synebula.gaea.mongodb.query.MongodbQuery
|
||||
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,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("group")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.synebula.zeus.query.view
|
||||
|
||||
import com.synebula.gaea.data.permission.PermissionType
|
||||
import com.synebula.gaea.query.Table
|
||||
import com.synebula.gaea.db.query.Table
|
||||
|
||||
@Table("role")
|
||||
class RoleView {
|
||||
|
||||
@@ -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 {
|
||||
@@ -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
|
||||
}
|
||||
@@ -3,15 +3,3 @@ dependencies {
|
||||
api project(":src:zeus.domain")
|
||||
api "com.synebula:gaea.mongodb:$gaea_version"
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
publish(MavenPublication) {
|
||||
group 'com.synebula'
|
||||
artifactId 'zeus.repository'
|
||||
version "$version"
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user