commit 606747850f1e69ba3b29cdd4385d2d16c7bc2647 Author: alex Date: Mon May 18 14:08:22 2020 +0800 初始化项目 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..02cfcc9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.* +gradlew* +build +gradle + +!.gitignore \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..703cc99 --- /dev/null +++ b/build.gradle @@ -0,0 +1,64 @@ +buildscript { + ext { + kotlin_version = '1.3.41' + } + + repositories { + mavenLocal() + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + mavenCentral() + } + + dependencies { + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + } +} + +allprojects { + group 'com.synebula' + version version +} + +subprojects { + ext { + version '0.1.0' + gaea_version = '0.3.0' + spring_version = "2.3.0.RELEASE" + } + + buildscript { + repositories { + mavenLocal() + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + mavenCentral() + } + } + + repositories { + mavenLocal() + maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } + mavenCentral() + } + + apply plugin: 'idea' + apply plugin: 'java' + apply plugin: 'kotlin' + apply plugin: 'maven' + apply plugin: 'maven-publish' + + dependencies { + compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" + testCompile group: 'junit', name: 'junit', version: '4.12' + } + + sourceCompatibility = 1.8 + targetCompatibility = 1.8 + + compileKotlin { + kotlinOptions.jvmTarget = "1.8" + } + compileTestKotlin { + kotlinOptions.jvmTarget = "1.8" + } +} diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..52eaa30 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,6 @@ +rootProject.name = 'myths.zeus' + +include 'src:zeus.app' +include 'src:zeus.domain' +include 'src:zeus.query' + diff --git a/src/zeus.app/build.gradle b/src/zeus.app/build.gradle new file mode 100644 index 0000000..aea5e54 --- /dev/null +++ b/src/zeus.app/build.gradle @@ -0,0 +1,28 @@ +buildscript { + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:$spring_version") + } +} + +apply plugin: 'org.springframework.boot' + +jar.enabled = true //jar SKIPPED问题,不设置可能会无法打jar + +dependencies { + compile project(":src:zeus.domain") + compile project(":src:zeus.query") + compile "com.synebula:gaea.app:$gaea_version" + compile "com.synebula:gaea.mongo:$gaea_version" +} + +publishing { + publications { + mavenJava(MavenPublication) { + group 'com.synebula' + artifactId 'zeus.app' + version "$version" + from components.java + } + } +} + diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/Application.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/Application.kt new file mode 100644 index 0000000..1daad0e --- /dev/null +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/Application.kt @@ -0,0 +1,12 @@ +package com.synebula.zeus.app + +import org.springframework.boot.SpringApplication +import org.springframework.boot.autoconfigure.SpringBootApplication + + +@SpringBootApplication +open class Application + +fun main(args: Array) { + SpringApplication.run(Application::class.java, *args) +} \ No newline at end of file diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusBeans.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusBeans.kt new file mode 100644 index 0000000..bf9d1c8 --- /dev/null +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusBeans.kt @@ -0,0 +1,43 @@ +package com.synebula.zeus.app.config + +import com.synebula.gaea.domain.model.IAggregateRoot +import com.synebula.gaea.domain.repository.IRepository +import com.synebula.gaea.domain.repository.IRepositoryTyped +import com.synebula.gaea.log.ILogger +import com.synebula.gaea.query.IQuery +import com.synebula.gaea.query.IQueryTyped +import com.synebula.gaea.query.mongo.MongoQuery +import com.synebula.gaea.query.mongo.MongoQueryTyped +import com.synebula.gaea.repository.mongo.MongoRepository +import com.synebula.gaea.repository.mongo.MongoRepositoryTyped +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.data.mongodb.core.MongoTemplate + +@Configuration +open class ZeusBeans { + @Bean + open fun > repository(template: MongoTemplate) + : IRepository = MongoRepository(template) + + @Bean + open fun > typedRepository(template: MongoTemplate) + : IRepositoryTyped = MongoRepositoryTyped(template) + + @Bean + open fun typedQuery(template: MongoTemplate, logger: ILogger? = null) + : IQueryTyped = MongoQueryTyped(template, logger) + + @Bean + open fun query(template: MongoTemplate) + : IQuery = MongoQuery(template) + + @Bean + open fun mongoQuery(template: MongoTemplate) + : MongoQuery = MongoQuery(template) + + @Bean + open fun mongoTypedQuery(template: MongoTemplate, logger: ILogger? = null) + : MongoQueryTyped = MongoQueryTyped(template, logger) + +} \ No newline at end of file diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusSpring.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusSpring.kt new file mode 100644 index 0000000..59bed60 --- /dev/null +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/config/ZeusSpring.kt @@ -0,0 +1,18 @@ +package com.synebula.zeus.app.config + +import com.synebula.gaea.app.component.AllTypeFilter +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.ComponentScan.Filter +import org.springframework.context.annotation.FilterType +import org.springframework.stereotype.Component + +@Component +@ComponentScan( + basePackages = [ + "com.synebula.gaea.app.component", + "com.synebula.zeus.domain.service.impl", + "com.synebula.zeus.query.impl" + ], + includeFilters = [Filter(type = FilterType.CUSTOM, classes = [AllTypeFilter::class])] +) +class ZeusSpring \ No newline at end of file diff --git a/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/AccountApp.kt b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/AccountApp.kt new file mode 100644 index 0000000..db86516 --- /dev/null +++ b/src/zeus.app/src/main/kotlin/com/synebula/zeus/app/controller/AccountApp.kt @@ -0,0 +1,26 @@ +package com.synebula.zeus.app.controller + +import com.synebula.gaea.app.CommandApp +import com.synebula.gaea.app.QueryApp +import com.synebula.gaea.app.UnionApp +import com.synebula.gaea.app.UnionTypedApp +import com.synebula.gaea.app.component.HttpMessage +import com.synebula.gaea.domain.service.IService +import com.synebula.gaea.log.ILogger +import com.synebula.gaea.query.mongo.MongoQuery +import com.synebula.gaea.query.mongo.MongoQueryTyped +import com.synebula.zeus.domain.service.cmd.AccountCmd +import com.synebula.zeus.domain.service.contr.rbac.IAccountService +import com.synebula.zeus.query.view.AccountView +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/accounts") +class AccountApp( + service: IAccountService, + query: MongoQueryTyped, + logger: ILogger +) : UnionTypedApp("账户", AccountView::class.java, + service, query, logger) \ No newline at end of file diff --git a/src/zeus.app/src/main/resources/application.yml b/src/zeus.app/src/main/resources/application.yml new file mode 100644 index 0000000..7033b88 --- /dev/null +++ b/src/zeus.app/src/main/resources/application.yml @@ -0,0 +1,9 @@ +server: + port: 8080 + +spring: + application: + name: gaea.app + data: + mongodb: + uri: mongodb://127.0.0.1/zeus \ No newline at end of file diff --git a/src/zeus.app/src/main/resources/logbak.xml b/src/zeus.app/src/main/resources/logbak.xml new file mode 100644 index 0000000..0e6aed0 --- /dev/null +++ b/src/zeus.app/src/main/resources/logbak.xml @@ -0,0 +1,37 @@ + + + + true + + + + + + + + + + ${format} + + + + + + + + + + ${path}/log-%d{yyyy-MM-dd}.log + + 100 + + + + ${format} + + + + + + + diff --git a/src/zeus.domain/build.gradle b/src/zeus.domain/build.gradle new file mode 100644 index 0000000..e474561 --- /dev/null +++ b/src/zeus.domain/build.gradle @@ -0,0 +1,15 @@ +dependencies { + compile "com.synebula:gaea:$gaea_version" +} + +publishing { + publications { + mavenJava(MavenPublication) { + group 'com.synebula' + artifactId 'zeus.domain' + version "$version" + from components.java + } + } +} + diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Account.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Account.kt new file mode 100644 index 0000000..80945e2 --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/model/rbac/Account.kt @@ -0,0 +1,8 @@ +package com.synebula.zeus.domain.model.rbac + +import com.synebula.gaea.domain.model.AggregateRoot + +class Account(override var id: String? = null) : AggregateRoot() { + var name: String = "" + var password: String = "" +} \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/AccountCmd.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/AccountCmd.kt new file mode 100644 index 0000000..a45cd0c --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/cmd/AccountCmd.kt @@ -0,0 +1,10 @@ +package com.synebula.zeus.domain.service.cmd + +import com.synebula.gaea.domain.service.ICommand + +class AccountCmd : ICommand { + var id: String? = null + var name = "" + var password = "" + override var timestamp = 0L +} diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAccountService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAccountService.kt new file mode 100644 index 0000000..92232b9 --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/contr/rbac/IAccountService.kt @@ -0,0 +1,5 @@ +package com.synebula.zeus.domain.service.contr.rbac + +import com.synebula.gaea.domain.service.IService + +interface IAccountService : IService \ No newline at end of file diff --git a/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AccountService.kt b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AccountService.kt new file mode 100644 index 0000000..8001b13 --- /dev/null +++ b/src/zeus.domain/src/main/kotlin/com/synebula/zeus/domain/service/impl/rbac/AccountService.kt @@ -0,0 +1,13 @@ +package com.synebula.zeus.domain.service.impl.rbac + +import com.synebula.gaea.data.IObjectConverter +import com.synebula.gaea.domain.repository.IRepository +import com.synebula.gaea.domain.service.Service +import com.synebula.gaea.log.ILogger +import com.synebula.zeus.domain.model.rbac.Account +import com.synebula.zeus.domain.service.contr.rbac.IAccountService + +class AccountService(repository: IRepository, converter: IObjectConverter, logger: ILogger) : + Service(Account::class.java, repository, converter, logger), IAccountService { + +} \ No newline at end of file diff --git a/src/zeus.query/build.gradle b/src/zeus.query/build.gradle new file mode 100644 index 0000000..fbd930c --- /dev/null +++ b/src/zeus.query/build.gradle @@ -0,0 +1,15 @@ +dependencies { + compile "com.synebula:gaea.mongo:$gaea_version" +} + +publishing { + publications { + mavenJava(MavenPublication) { + group 'com.synebula' + artifactId 'zeus.view' + version "$version" + from components.java + } + } +} + diff --git a/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/AccountView.kt b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/AccountView.kt new file mode 100644 index 0000000..5dc7af9 --- /dev/null +++ b/src/zeus.query/src/main/kotlin/com/synebula/zeus/query/view/AccountView.kt @@ -0,0 +1,9 @@ +package com.synebula.zeus.query.view + +class AccountView { + var id: String = "" + + var name: String = "" + + var password: String = "" +} \ No newline at end of file