feat: 1.0.0 重构gaea引用; 增加docker编译部署方式
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,5 +3,6 @@ gradlew*
|
|||||||
build
|
build
|
||||||
gradle
|
gradle
|
||||||
logs
|
logs
|
||||||
|
bin
|
||||||
|
|
||||||
!.gitignore
|
!.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"]
|
||||||
30
build.gradle
30
build.gradle
@@ -1,11 +1,18 @@
|
|||||||
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext {
|
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 {
|
repositories {
|
||||||
mavenLocal()
|
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()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,9 +26,7 @@ subprojects {
|
|||||||
version version
|
version version
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
version '0.9.0'
|
version '1.0.0'
|
||||||
gaea_version = '1.5.1'
|
|
||||||
spring_version = "2.7.0"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
@@ -34,6 +39,7 @@ subprojects {
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
|
maven { url 'https://git.synebula.com/api/packages/alex/maven' }
|
||||||
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
|
maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
@@ -49,13 +55,17 @@ subprojects {
|
|||||||
testApi group: 'junit', name: 'junit', version: '4.12'
|
testApi group: 'junit', name: 'junit', version: '4.12'
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
/*** 指定 Java & Kotlin 语言编译目标JVM ***/
|
||||||
targetCompatibility = 1.8
|
sourceCompatibility = "$jvm_version"
|
||||||
|
targetCompatibility = "$jvm_version"
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
compilerOptions {
|
||||||
|
jvmTarget = JvmTarget.valueOf("JVM_$jvm_version")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
compileTestKotlin {
|
compileTestKotlin {
|
||||||
kotlinOptions.jvmTarget = "1.8"
|
compilerOptions {
|
||||||
|
jvmTarget = JvmTarget.valueOf("JVM_$jvm_version")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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",
|
_id: "admin",
|
||||||
name: "管理员"
|
name: "管理员"
|
||||||
},
|
|
||||||
{
|
|
||||||
_id: "VE",
|
|
||||||
name: "Viewer"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
_id: "RE",
|
|
||||||
name: "RE工程师"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
_id: "FE",
|
|
||||||
name: "FE工程师"
|
|
||||||
}
|
}
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
db.group.insertOne(
|
db.group.insertOne(
|
||||||
@@ -32,7 +27,7 @@ db.user.insertOne({
|
|||||||
phone: "18654551561",
|
phone: "18654551561",
|
||||||
role: "admin",
|
role: "admin",
|
||||||
group: "1",
|
group: "1",
|
||||||
alive: true,
|
avalible: true,
|
||||||
_class: "com.synebula.zeus.domain.model.rbac.User"
|
_class: "com.synebula.zeus.domain.model.rbac.User"
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -55,14 +50,14 @@ db.page.insertMany([
|
|||||||
])
|
])
|
||||||
|
|
||||||
db.authority.insertMany([
|
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": "System", "authority": "Allow", "avalible": 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": "1", "type": "Page", "authority": "Allow", "avalible": 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": "2", "type": "Page", "authority": "Allow", "avalible": 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": "3", "type": "Page", "authority": "Allow", "avalible": 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": "4", "type": "Page", "authority": "Allow", "avalible": 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": "5", "type": "Page", "authority": "Allow", "avalible": 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": "6", "type": "Page", "authority": "Allow", "avalible": 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": "7", "type": "Page", "authority": "Allow", "avalible": 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": "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
|
||||||
@@ -3,23 +3,26 @@ package com.synebula.zeus.app.config
|
|||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
import com.synebula.gaea.data.message.HttpMessageFactory
|
import com.synebula.gaea.data.message.HttpMessageFactory
|
||||||
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
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.domain.repository.IRepositoryFactory
|
||||||
import com.synebula.gaea.mongodb.query.MongodbQueryFactory
|
|
||||||
import com.synebula.gaea.mongodb.repository.MongodbRepositoryFactory
|
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.Bean
|
||||||
import org.springframework.context.annotation.Configuration
|
import org.springframework.context.annotation.Configuration
|
||||||
|
import org.springframework.context.annotation.Primary
|
||||||
import org.springframework.data.mongodb.core.MongoTemplate
|
import org.springframework.data.mongodb.core.MongoTemplate
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
class ZeusBeans {
|
class ZeusBeans {
|
||||||
|
@Bean
|
||||||
fun repoFactory(template: MongoTemplate): IRepositoryFactory {
|
fun repoFactory(template: MongoTemplate): IRepositoryFactory {
|
||||||
return MongodbRepositoryFactory(template)
|
return MongodbRepositoryFactory(template)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Primary
|
||||||
@Bean
|
@Bean
|
||||||
fun queryFactory(template: MongoTemplate): IQueryFactory {
|
fun defaultQuery(template: MongoTemplate): IQuery {
|
||||||
return MongodbQueryFactory(template)
|
return MongodbQuery(template)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.synebula.zeus.app.config
|
package com.synebula.zeus.app.config
|
||||||
|
|
||||||
import com.synebula.gaea.app.autoconfig.service.ServiceScan
|
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
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@ServiceScan(basePackages = ["com.synebula.zeus.domain.service"])
|
@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
|
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.cmd.rbac.UserCmd
|
||||||
import com.synebula.zeus.domain.service.contr.rbac.IUserService
|
import com.synebula.zeus.domain.service.contr.rbac.IUserService
|
||||||
import com.synebula.zeus.query.contr.IUserQuery
|
import com.synebula.zeus.query.contr.IUserQuery
|
||||||
|
import com.synebula.zeus.query.view.UserView
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.security.core.context.SecurityContextHolder
|
import org.springframework.security.core.context.SecurityContextHolder
|
||||||
import org.springframework.web.bind.annotation.*
|
import org.springframework.web.bind.annotation.*
|
||||||
@@ -77,7 +78,7 @@ class SignInOutApp(override var logger: ILogger) : IApplication {
|
|||||||
@PostMapping("/up")
|
@PostMapping("/up")
|
||||||
fun signUp(@RequestBody command: UserCmd): HttpMessage {
|
fun signUp(@RequestBody command: UserCmd): HttpMessage {
|
||||||
return this.safeExecute("用户注册出错, 用户信息: ${serializer.serialize(command)}") {
|
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()) {
|
if (list.isEmpty()) {
|
||||||
val message = userService.add(command)
|
val message = userService.add(command)
|
||||||
it.data = message.data
|
it.data = message.data
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.synebula.zeus.app.controller.rbac
|
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.HttpMessage
|
||||||
import com.synebula.gaea.log.ILogger
|
import com.synebula.gaea.log.ILogger
|
||||||
import com.synebula.gaea.spring.aop.annotation.Method
|
import com.synebula.gaea.spring.aop.annotation.Method
|
||||||
@@ -18,8 +18,8 @@ class AuthorityApp(
|
|||||||
query: IAuthorityQuery,
|
query: IAuthorityQuery,
|
||||||
logger: ILogger,
|
logger: ILogger,
|
||||||
private var authorityService: IAuthorityService
|
private var authorityService: IAuthorityService
|
||||||
) : Application<AuthorityCmd, AuthorityView, String>(
|
) : DomainApplication<AuthorityCmd, AuthorityView, String>(
|
||||||
"权限信息", authorityService, query, logger
|
"权限信息", authorityService, query, AuthorityView::class.java, logger
|
||||||
) {
|
) {
|
||||||
@Method("批量添加权限信息")
|
@Method("批量添加权限信息")
|
||||||
@PostMapping("/batch")
|
@PostMapping("/batch")
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.synebula.zeus.app.controller.rbac
|
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.log.ILogger
|
||||||
import com.synebula.gaea.query.IQueryFactory
|
|
||||||
import com.synebula.zeus.domain.service.cmd.rbac.GroupCmd
|
import com.synebula.zeus.domain.service.cmd.rbac.GroupCmd
|
||||||
import com.synebula.zeus.domain.service.contr.rbac.IGroupService
|
import com.synebula.zeus.domain.service.contr.rbac.IGroupService
|
||||||
import com.synebula.zeus.query.view.GroupView
|
import com.synebula.zeus.query.view.GroupView
|
||||||
@@ -13,8 +13,8 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
@RequestMapping("/groups")
|
@RequestMapping("/groups")
|
||||||
class GroupApp(
|
class GroupApp(
|
||||||
service: IGroupService,
|
service: IGroupService,
|
||||||
factory: IQueryFactory,
|
query: IQuery,
|
||||||
logger: ILogger
|
logger: ILogger
|
||||||
) : Application<GroupCmd, GroupView, String>(
|
) : DomainApplication<GroupCmd, GroupView, String>(
|
||||||
"用户组信息", service, factory.createQuery(GroupView::class.java), logger
|
"用户组信息", service, query, GroupView::class.java, logger
|
||||||
)
|
)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.synebula.zeus.app.controller.rbac
|
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.log.ILogger
|
||||||
import com.synebula.gaea.query.IQueryFactory
|
|
||||||
import com.synebula.zeus.domain.service.cmd.rbac.RoleCmd
|
import com.synebula.zeus.domain.service.cmd.rbac.RoleCmd
|
||||||
import com.synebula.zeus.domain.service.contr.rbac.IRoleService
|
import com.synebula.zeus.domain.service.contr.rbac.IRoleService
|
||||||
import com.synebula.zeus.query.view.RoleView
|
import com.synebula.zeus.query.view.RoleView
|
||||||
@@ -13,8 +13,8 @@ import org.springframework.web.bind.annotation.RestController
|
|||||||
@RequestMapping("/roles")
|
@RequestMapping("/roles")
|
||||||
class RoleApp(
|
class RoleApp(
|
||||||
service: IRoleService,
|
service: IRoleService,
|
||||||
factory: IQueryFactory,
|
query: IQuery,
|
||||||
logger: ILogger
|
logger: ILogger
|
||||||
) : Application<RoleCmd, RoleView, String>(
|
) : DomainApplication<RoleCmd, RoleView, String>(
|
||||||
"用户信息", service, factory.createQuery(RoleView::class.java), logger
|
"用户信息", service, query, RoleView::class.java, logger
|
||||||
)
|
)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.synebula.zeus.app.controller.rbac
|
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.HttpMessage
|
||||||
import com.synebula.gaea.data.message.Status
|
import com.synebula.gaea.data.message.Status
|
||||||
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
import com.synebula.gaea.data.serialization.json.IJsonSerializer
|
||||||
@@ -18,8 +18,8 @@ class UserApp(
|
|||||||
service: IUserService,
|
service: IUserService,
|
||||||
query: IUserQuery,
|
query: IUserQuery,
|
||||||
logger: ILogger
|
logger: ILogger
|
||||||
) : Application<UserCmd, UserView, String>(
|
) : DomainApplication<UserCmd, UserView, String>(
|
||||||
"用户信息", service, query, logger
|
"用户信息", service, query, UserView::class.java, logger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -27,7 +27,7 @@ class UserApp(
|
|||||||
|
|
||||||
override fun add(command: UserCmd): HttpMessage {
|
override fun add(command: UserCmd): HttpMessage {
|
||||||
return this.safeExecute("查询重复用户信息出错, 用户信息: ${serializer.serialize(command)}") {
|
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())
|
if (list.isEmpty())
|
||||||
it.from(super.add(command))
|
it.from(super.add(command))
|
||||||
else {
|
else {
|
||||||
@@ -53,7 +53,7 @@ class UserApp(
|
|||||||
@GetMapping("/{name}/forgot")
|
@GetMapping("/{name}/forgot")
|
||||||
fun forgot(@PathVariable name: String): HttpMessage {
|
fun forgot(@PathVariable name: String): HttpMessage {
|
||||||
return this.safeExecute("遗忘用户密码出现异常") {
|
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()) {
|
if (users.isNotEmpty()) {
|
||||||
it.load((this.service as IUserService).forgotPassword(users[0].id))
|
it.load((this.service as IUserService).forgotPassword(users[0].id))
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.synebula.zeus.app.controller.rbac.resource
|
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.data.message.HttpMessage
|
||||||
import com.synebula.gaea.log.ILogger
|
import com.synebula.gaea.log.ILogger
|
||||||
import com.synebula.gaea.spring.aop.annotation.Method
|
import com.synebula.gaea.spring.aop.annotation.Method
|
||||||
@@ -19,8 +19,8 @@ class InterfaceApp(
|
|||||||
service: IInterfaceService,
|
service: IInterfaceService,
|
||||||
logger: ILogger,
|
logger: ILogger,
|
||||||
var interfaceQuery: IInterfaceQuery
|
var interfaceQuery: IInterfaceQuery
|
||||||
) : Application<InterfaceCmd, InterfaceView, String>(
|
) : DomainApplication<InterfaceCmd, InterfaceView, String>(
|
||||||
"接口信息", service, interfaceQuery, logger
|
"接口信息", service, interfaceQuery, InterfaceView::class.java, logger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Method("获取角色系统下有权接口")
|
@Method("获取角色系统下有权接口")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.synebula.zeus.app.controller.rbac.resource
|
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.data.message.HttpMessage
|
||||||
import com.synebula.gaea.log.ILogger
|
import com.synebula.gaea.log.ILogger
|
||||||
import com.synebula.gaea.spring.aop.annotation.Method
|
import com.synebula.gaea.spring.aop.annotation.Method
|
||||||
@@ -21,8 +21,8 @@ class PageApp(
|
|||||||
service: IPageService,
|
service: IPageService,
|
||||||
logger: ILogger,
|
logger: ILogger,
|
||||||
var pageQuery: IPageQuery
|
var pageQuery: IPageQuery
|
||||||
) : Application<PageCmd, PageView, String>(
|
) : DomainApplication<PageCmd, PageView, String>(
|
||||||
"页面信息", service, pageQuery, logger
|
"页面信息", service, pageQuery, PageView::class.java, logger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Method("获取角色系统下有权页面")
|
@Method("获取角色系统下有权页面")
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.synebula.zeus.app.controller.rbac.resource
|
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.data.message.HttpMessage
|
||||||
import com.synebula.gaea.log.ILogger
|
import com.synebula.gaea.log.ILogger
|
||||||
import com.synebula.gaea.spring.aop.annotation.Method
|
import com.synebula.gaea.spring.aop.annotation.Method
|
||||||
@@ -19,8 +19,8 @@ class SystemApp(
|
|||||||
service: ISystemService,
|
service: ISystemService,
|
||||||
logger: ILogger,
|
logger: ILogger,
|
||||||
var systemQuery: ISystemQuery
|
var systemQuery: ISystemQuery
|
||||||
) : Application<SystemCmd, SystemView, String>(
|
) : DomainApplication<SystemCmd, SystemView, String>(
|
||||||
"系统信息", service, systemQuery, logger
|
"系统信息", service, systemQuery, SystemView::class.java, logger
|
||||||
) {
|
) {
|
||||||
@Method("获取角色有权系统")
|
@Method("获取角色有权系统")
|
||||||
@GetMapping("/authorized/{role}")
|
@GetMapping("/authorized/{role}")
|
||||||
|
|||||||
@@ -1,23 +1,23 @@
|
|||||||
server:
|
server:
|
||||||
port: 8080
|
port: 80
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
name: gaea.app
|
name: gaea.app
|
||||||
sign-in-url: /sign/in
|
sign-in-url: /sign/in
|
||||||
allow-multi-sign: false
|
allow-multi-sign: ${ALLOW_MULTI_SIGN:false}
|
||||||
data:
|
data:
|
||||||
mongodb:
|
mongodb:
|
||||||
uri: mongodb://127.0.0.1/zeus
|
uri: ${DB_URL:mongodb://root:LcY221815@127.0.0.1/zeus}
|
||||||
mail:
|
mail:
|
||||||
send: true
|
send: true
|
||||||
target: ge.com
|
target: ge.com
|
||||||
sender: gehsrv@163.com
|
sender: ${MAIL_SENDER:gehsrv@163.com}
|
||||||
protocol: smtp
|
protocol: ${MAIL_SENDER:smtp}
|
||||||
host: smtp.163.com
|
host: ${MAIL_HOST:smtp.163.com}
|
||||||
port: 465
|
port: ${MAIL_PORT:465}
|
||||||
username: gehsrv@163.com
|
username: ${MAIL_USER:gehsrv@163.com}
|
||||||
password: SRBPJBLFFVVCPZLZ
|
password: ${MAIL_PWD:SRBPJBLFFVVCPZLZ}
|
||||||
default-encoding: UTF-8
|
default-encoding: UTF-8
|
||||||
properties:
|
properties:
|
||||||
mail:
|
mail:
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ import com.synebula.gaea.domain.model.IAggregateRoot
|
|||||||
|
|
||||||
class Interface : Resource(), IAggregateRoot<String> {
|
class Interface : Resource(), IAggregateRoot<String> {
|
||||||
var system = ""
|
var system = ""
|
||||||
override var alive = true
|
override var avalible = true
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,6 @@ class Page : Resource(), IAggregateRoot<String> {
|
|||||||
// 所属系统
|
// 所属系统
|
||||||
var system = ""
|
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
|
import com.synebula.gaea.domain.model.IAggregateRoot
|
||||||
|
|
||||||
class System : Resource(), IAggregateRoot<String> {
|
class System : Resource(), IAggregateRoot<String> {
|
||||||
override var alive = true
|
override var avalible = true
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,6 @@ class UserCmd : Command() {
|
|||||||
var phone: String? = null
|
var phone: String? = null
|
||||||
var role: String? = null
|
var role: String? = null
|
||||||
var group: String = ""
|
var group: String = ""
|
||||||
var alive: Boolean = false
|
var avalible: Boolean = false
|
||||||
var token: String? = null
|
var token: String? = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,5 +2,5 @@ package com.synebula.zeus.domain.service.cmd.rbac.resource
|
|||||||
|
|
||||||
class InterfaceCmd : ResourceCmd() {
|
class InterfaceCmd : ResourceCmd() {
|
||||||
var system = ""
|
var system = ""
|
||||||
var alive = true
|
var avalible = true
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,6 @@ class PageCmd : ResourceCmd() {
|
|||||||
// 所属系统
|
// 所属系统
|
||||||
var system = ""
|
var system = ""
|
||||||
|
|
||||||
var alive = true
|
var avalible = true
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,5 @@ package com.synebula.zeus.domain.service.cmd.rbac.resource
|
|||||||
|
|
||||||
|
|
||||||
class SystemCmd : ResourceCmd() {
|
class SystemCmd : ResourceCmd() {
|
||||||
var alive = true
|
var avalible = true
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ class UserService(
|
|||||||
val user = this.map(command)
|
val user = this.map(command)
|
||||||
user.password = user.password.toMd5()
|
user.password = user.password.toMd5()
|
||||||
user.token = UUID.randomUUID().toString()
|
user.token = UUID.randomUUID().toString()
|
||||||
user.alive = false
|
user.avalible = false
|
||||||
this.repository.add(user)
|
this.repository.add(user)
|
||||||
userNotifier?.added(user.id!!, user.name, user.token!!)
|
userNotifier?.added(user.id!!, user.name, user.token!!)
|
||||||
return DataMessage(user.id!!)
|
return DataMessage(user.id!!)
|
||||||
@@ -54,11 +54,11 @@ class UserService(
|
|||||||
*/
|
*/
|
||||||
override fun active(key: String, token: String): DataMessage<Any> {
|
override fun active(key: String, token: String): DataMessage<Any> {
|
||||||
val user = this.repository.get(key)!!
|
val user = this.repository.get(key)!!
|
||||||
return if (user.alive) {
|
return if (user.avalible) {
|
||||||
DataMessage("用户${user.name}无需重复激活")
|
DataMessage("用户${user.name}无需重复激活")
|
||||||
} else {
|
} else {
|
||||||
if (token == user.token) {
|
if (token == user.token) {
|
||||||
user.alive = true
|
user.avalible = true
|
||||||
user.token = null
|
user.token = null
|
||||||
this.repository.update(user)
|
this.repository.update(user)
|
||||||
DataMessage(Status.Success, "用户${user.name}激活成功")
|
DataMessage(Status.Success, "用户${user.name}激活成功")
|
||||||
@@ -101,7 +101,7 @@ class UserService(
|
|||||||
|
|
||||||
override fun forgotPassword(key: String): DataMessage<String> {
|
override fun forgotPassword(key: String): DataMessage<String> {
|
||||||
val user = this.repository.get(key)!!
|
val user = this.repository.get(key)!!
|
||||||
return if (user.alive) {
|
return if (user.avalible) {
|
||||||
user.token = UUID.randomUUID().toString()
|
user.token = UUID.randomUUID().toString()
|
||||||
this.repository.update(user)
|
this.repository.update(user)
|
||||||
userNotifier?.forgot(user.id!!, user.name, user.token!!)
|
userNotifier?.forgot(user.id!!, user.name, user.token!!)
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package com.synebula.zeus.query.contr
|
package com.synebula.zeus.query.contr
|
||||||
|
|
||||||
import com.synebula.gaea.data.permission.AuthorityType
|
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.env.ResourceType
|
||||||
import com.synebula.zeus.query.view.AuthorityView
|
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
|
package com.synebula.zeus.query.contr
|
||||||
|
|
||||||
import com.synebula.gaea.data.message.DataMessage
|
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.SignUserView
|
||||||
import com.synebula.zeus.query.view.UserView
|
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
|
package com.synebula.zeus.query.contr.resouce
|
||||||
|
|
||||||
import com.synebula.gaea.data.permission.AuthorityType
|
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
|
import com.synebula.zeus.query.view.resource.InterfaceView
|
||||||
|
|
||||||
interface IInterfaceQuery : IQuery<InterfaceView, String> {
|
interface IInterfaceQuery : IQuery {
|
||||||
|
|
||||||
fun authorized(role: String): List<InterfaceView>
|
fun authorized(role: String): List<InterfaceView>
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package com.synebula.zeus.query.contr.resouce
|
package com.synebula.zeus.query.contr.resouce
|
||||||
|
|
||||||
import com.synebula.gaea.data.permission.AuthorityType
|
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
|
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): 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?
|
fun authorize(resource: String, role: String): AuthorityType?
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.synebula.zeus.query.contr.resouce
|
package com.synebula.zeus.query.contr.resouce
|
||||||
|
|
||||||
import com.synebula.gaea.data.permission.AuthorityType
|
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
|
import com.synebula.zeus.query.view.resource.SystemView
|
||||||
|
|
||||||
interface ISystemQuery : IQuery<SystemView, String> {
|
interface ISystemQuery : IQuery {
|
||||||
|
|
||||||
fun authorized(role: String): List<SystemView>
|
fun authorized(role: String): List<SystemView>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.synebula.zeus.query.impl
|
package com.synebula.zeus.query.impl
|
||||||
|
|
||||||
import com.synebula.gaea.data.permission.AuthorityType
|
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.env.ResourceType
|
||||||
import com.synebula.zeus.query.contr.IAuthorityQuery
|
import com.synebula.zeus.query.contr.IAuthorityQuery
|
||||||
import com.synebula.zeus.query.view.AuthorityView
|
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
|
import org.springframework.data.mongodb.core.query.Query
|
||||||
|
|
||||||
class AuthorityQuery(template: MongoTemplate) :
|
class AuthorityQuery(template: MongoTemplate) :
|
||||||
MongodbQuery<AuthorityView, String>(AuthorityView::class.java, template), IAuthorityQuery {
|
MongodbQuery(template), IAuthorityQuery {
|
||||||
var collection = this.collection(this.clazz)
|
|
||||||
|
|
||||||
override fun authorized(resourceType: ResourceType, role: String): List<AuthorityView> {
|
override fun authorized(resourceType: ResourceType, role: String): List<AuthorityView> {
|
||||||
return this.template.find(
|
return this.template.find(
|
||||||
Query.query(
|
Query.query(
|
||||||
Criteria.where("type").`is`(resourceType)
|
Criteria.where("type").`is`(resourceType)
|
||||||
.and("role").`is`(role)
|
.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)
|
Criteria.where("type").`is`(resourceType)
|
||||||
.and("resource").`is`(resource)
|
.and("resource").`is`(resource)
|
||||||
.and("role").`is`(role)
|
.and("role").`is`(role)
|
||||||
), this.clazz, this.collection
|
), AuthorityView::class.java, this.collection(AuthorityView::class.java)
|
||||||
)
|
)
|
||||||
return authority?.authority ?: AuthorityType.Default
|
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.message.Status
|
||||||
import com.synebula.gaea.data.permission.PermissionType
|
import com.synebula.gaea.data.permission.PermissionType
|
||||||
import com.synebula.gaea.ext.toMd5
|
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.gaea.mongodb.whereId
|
||||||
import com.synebula.zeus.query.contr.IUserQuery
|
import com.synebula.zeus.query.contr.IUserQuery
|
||||||
import com.synebula.zeus.query.view.GroupView
|
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
|
import org.springframework.data.mongodb.core.query.isEqualTo
|
||||||
|
|
||||||
class UserQuery(template: MongoTemplate) :
|
class UserQuery(template: MongoTemplate) :
|
||||||
MongodbQuery<UserView, String>(UserView::class.java, template), IUserQuery {
|
MongodbQuery(template), IUserQuery {
|
||||||
|
|
||||||
override fun signIn(name: String, password: String): DataMessage<SignUserView> {
|
override fun signIn(name: String, password: String): DataMessage<SignUserView> {
|
||||||
val query = Query.query(
|
val query = Query.query(
|
||||||
Criteria.where("name").isEqualTo(name)
|
Criteria.where("name").isEqualTo(name)
|
||||||
.and("password").isEqualTo(password.toMd5())
|
.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) {
|
return if (user != null) {
|
||||||
val role = this.template.findOne(whereId(user.role), RoleView::class.java, "role")
|
val role = this.template.findOne(whereId(user.role), RoleView::class.java, "role")
|
||||||
val group = this.template.findOne(whereId(user.group), GroupView::class.java, "group")
|
val group = this.template.findOne(whereId(user.group), GroupView::class.java, "group")
|
||||||
@@ -43,6 +43,6 @@ class UserQuery(template: MongoTemplate) :
|
|||||||
|
|
||||||
|
|
||||||
override fun listUsers(idList: List<String>): List<UserView> {
|
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
|
package com.synebula.zeus.query.impl.resouce
|
||||||
|
|
||||||
import com.synebula.gaea.data.permission.AuthorityType
|
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.env.ResourceType
|
||||||
import com.synebula.zeus.query.contr.IAuthorityQuery
|
import com.synebula.zeus.query.contr.IAuthorityQuery
|
||||||
import com.synebula.zeus.query.contr.resouce.IInterfaceQuery
|
import com.synebula.zeus.query.contr.resouce.IInterfaceQuery
|
||||||
@@ -13,7 +13,7 @@ class InterfaceQuery(
|
|||||||
template: MongoTemplate,
|
template: MongoTemplate,
|
||||||
var authorityQuery: IAuthorityQuery,
|
var authorityQuery: IAuthorityQuery,
|
||||||
var systemQuery: ISystemQuery
|
var systemQuery: ISystemQuery
|
||||||
) : MongodbQuery<InterfaceView, String>(InterfaceView::class.java, template), IInterfaceQuery {
|
) : MongodbQuery(template), IInterfaceQuery {
|
||||||
|
|
||||||
override fun authorized(role: String): List<InterfaceView> {
|
override fun authorized(role: String): List<InterfaceView> {
|
||||||
return this.authorized(role, null)
|
return this.authorized(role, null)
|
||||||
@@ -28,7 +28,7 @@ class InterfaceQuery(
|
|||||||
}
|
}
|
||||||
val params = mutableMapOf<String, String>()
|
val params = mutableMapOf<String, String>()
|
||||||
if (system != null) params["system"] = system
|
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)
|
val authorities = this.authorityQuery.authorized(ResourceType.Interface, role)
|
||||||
return interfaces.filter { i ->
|
return interfaces.filter { i ->
|
||||||
val authority = authorities.find { p -> i.id == p.resource }
|
val authority = authorities.find { p -> i.id == p.resource }
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.synebula.zeus.query.impl.resouce
|
package com.synebula.zeus.query.impl.resouce
|
||||||
|
|
||||||
import com.synebula.gaea.data.permission.AuthorityType
|
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.env.ResourceType
|
||||||
import com.synebula.zeus.query.contr.IAuthorityQuery
|
import com.synebula.zeus.query.contr.IAuthorityQuery
|
||||||
import com.synebula.zeus.query.contr.resouce.IPageQuery
|
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
|
import org.springframework.data.mongodb.core.query.Query
|
||||||
|
|
||||||
class PageQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, var systemQuery: ISystemQuery) :
|
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> {
|
override fun authorized(role: String): List<PageView> {
|
||||||
return this.authorized(role, null)
|
return this.authorized(role, null)
|
||||||
@@ -26,7 +26,7 @@ class PageQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery, va
|
|||||||
}
|
}
|
||||||
val params = mutableMapOf<String, String>()
|
val params = mutableMapOf<String, String>()
|
||||||
if (system != null) params["system"] = system
|
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)
|
val authorities = this.authorityQuery.authorized(ResourceType.Page, role)
|
||||||
return pages.filter { i ->
|
return pages.filter { i ->
|
||||||
val authority = authorities.find { p -> i.id == p.resource }
|
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? {
|
override fun uriAuthorize(path: String, role: String): AuthorityType? {
|
||||||
val page = this.template.findOne(
|
val page = this.template.findOne(
|
||||||
Query.query(Criteria.where("uri").`is`(path)),
|
Query.query(Criteria.where("uri").`is`(path)),
|
||||||
this.clazz, this.collection(this.clazz)
|
PageView::class.java, this.collection(PageView::class.java)
|
||||||
) ?: return null
|
) ?: return null
|
||||||
return this.authorize(page.id!!, role)
|
return this.authorize(page.id!!, role)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.synebula.zeus.query.impl.resouce
|
package com.synebula.zeus.query.impl.resouce
|
||||||
|
|
||||||
import com.synebula.gaea.data.permission.AuthorityType
|
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.env.ResourceType
|
||||||
import com.synebula.zeus.query.contr.IAuthorityQuery
|
import com.synebula.zeus.query.contr.IAuthorityQuery
|
||||||
import com.synebula.zeus.query.contr.resouce.ISystemQuery
|
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
|
import org.springframework.data.mongodb.core.MongoTemplate
|
||||||
|
|
||||||
class SystemQuery(template: MongoTemplate, var authorityQuery: IAuthorityQuery) :
|
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> {
|
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)
|
val authorities = this.authorityQuery.authorized(ResourceType.System, role)
|
||||||
return systems.filter { i -> authorities.find { p -> i.id == p.resource }?.authority == AuthorityType.Allow }
|
return systems.filter { i -> authorities.find { p -> i.id == p.resource }?.authority == AuthorityType.Allow }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.synebula.zeus.query.view
|
package com.synebula.zeus.query.view
|
||||||
|
|
||||||
import com.synebula.gaea.query.Operator
|
import com.synebula.gaea.db.query.Operator
|
||||||
import com.synebula.gaea.query.Table
|
import com.synebula.gaea.db.query.Table
|
||||||
import com.synebula.gaea.query.Where
|
import com.synebula.gaea.db.query.Where
|
||||||
|
|
||||||
|
|
||||||
@Table("group")
|
@Table("group")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.synebula.zeus.query.view
|
package com.synebula.zeus.query.view
|
||||||
|
|
||||||
import com.synebula.gaea.data.permission.PermissionType
|
import com.synebula.gaea.data.permission.PermissionType
|
||||||
import com.synebula.gaea.query.Table
|
import com.synebula.gaea.db.query.Table
|
||||||
|
|
||||||
@Table("role")
|
@Table("role")
|
||||||
class RoleView {
|
class RoleView {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.synebula.zeus.query.view
|
package com.synebula.zeus.query.view
|
||||||
|
|
||||||
import com.synebula.gaea.query.Operator
|
import com.synebula.gaea.db.query.Operator
|
||||||
import com.synebula.gaea.query.Table
|
import com.synebula.gaea.db.query.Table
|
||||||
import com.synebula.gaea.query.Where
|
import com.synebula.gaea.db.query.Where
|
||||||
|
|
||||||
@Table("user")
|
@Table("user")
|
||||||
class UserView {
|
class UserView {
|
||||||
@@ -23,5 +23,5 @@ class UserView {
|
|||||||
|
|
||||||
var token: String? = null
|
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() {
|
class InterfaceView : ResourceView() {
|
||||||
var system = ""
|
var system = ""
|
||||||
var alive = true
|
var avalible = true
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,6 @@ class PageView : ResourceView() {
|
|||||||
// 所属系统
|
// 所属系统
|
||||||
var system = ""
|
var system = ""
|
||||||
|
|
||||||
var alive = true
|
var avalible = true
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,5 @@ package com.synebula.zeus.query.view.resource
|
|||||||
|
|
||||||
|
|
||||||
class SystemView : ResourceView() {
|
class SystemView : ResourceView() {
|
||||||
var alive = true
|
var avalible = true
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user