初始化项目
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.*
|
||||
gradlew*
|
||||
build
|
||||
gradle
|
||||
|
||||
!.gitignore
|
||||
64
build.gradle
Normal file
64
build.gradle
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
6
settings.gradle
Normal file
6
settings.gradle
Normal file
@@ -0,0 +1,6 @@
|
||||
rootProject.name = 'myths.zeus'
|
||||
|
||||
include 'src:zeus.app'
|
||||
include 'src:zeus.domain'
|
||||
include 'src:zeus.query'
|
||||
|
||||
28
src/zeus.app/build.gradle
Normal file
28
src/zeus.app/build.gradle
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String>) {
|
||||
SpringApplication.run(Application::class.java, *args)
|
||||
}
|
||||
@@ -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 <T : IAggregateRoot<String>> repository(template: MongoTemplate)
|
||||
: IRepository<T, String> = MongoRepository(template)
|
||||
|
||||
@Bean
|
||||
open fun <T : IAggregateRoot<String>> typedRepository(template: MongoTemplate)
|
||||
: IRepositoryTyped = MongoRepositoryTyped(template)
|
||||
|
||||
@Bean
|
||||
open fun <T> typedQuery(template: MongoTemplate, logger: ILogger? = null)
|
||||
: IQueryTyped = MongoQueryTyped(template, logger)
|
||||
|
||||
@Bean
|
||||
open fun <T> query(template: MongoTemplate)
|
||||
: IQuery<T, String> = MongoQuery(template)
|
||||
|
||||
@Bean
|
||||
open fun <T> mongoQuery(template: MongoTemplate)
|
||||
: MongoQuery<T> = MongoQuery(template)
|
||||
|
||||
@Bean
|
||||
open fun <T> mongoTypedQuery(template: MongoTemplate, logger: ILogger? = null)
|
||||
: MongoQueryTyped = MongoQueryTyped(template, logger)
|
||||
|
||||
}
|
||||
@@ -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
|
||||
@@ -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<AccountCmd, AccountView, String>("账户", AccountView::class.java,
|
||||
service, query, logger)
|
||||
9
src/zeus.app/src/main/resources/application.yml
Normal file
9
src/zeus.app/src/main/resources/application.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
server:
|
||||
port: 8080
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: gaea.app
|
||||
data:
|
||||
mongodb:
|
||||
uri: mongodb://127.0.0.1/zeus
|
||||
37
src/zeus.app/src/main/resources/logbak.xml
Normal file
37
src/zeus.app/src/main/resources/logbak.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="1 seconds">
|
||||
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
|
||||
<resetJUL>true</resetJUL>
|
||||
</contextListener>
|
||||
<jmxConfigurator/>
|
||||
<!-- 文件输出格式 -->
|
||||
<property name="format" value="%-12(%d{yyyy-MM-dd HH:mm:ss.SSS}) |-%-5level [%thread] %c [%L] -| %msg%n"/>
|
||||
<!--日志路径-->
|
||||
<property name="path" value="./logs/evaluation"/>
|
||||
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>${format}</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- 每天产生一个文件 -->
|
||||
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<!-- 文件路径 -->
|
||||
<!--<file>${path}</file>-->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 文件名称 -->
|
||||
<fileNamePattern>${path}/log-%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 文件最大保存历史数量 -->
|
||||
<MaxHistory>100</MaxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>${format}</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="file"/>
|
||||
</root>
|
||||
</configuration>
|
||||
15
src/zeus.domain/build.gradle
Normal file
15
src/zeus.domain/build.gradle
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<String>() {
|
||||
var name: String = ""
|
||||
var password: String = ""
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.synebula.zeus.domain.service.contr.rbac
|
||||
|
||||
import com.synebula.gaea.domain.service.IService
|
||||
|
||||
interface IAccountService : IService<String>
|
||||
@@ -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<Account, String>, converter: IObjectConverter, logger: ILogger) :
|
||||
Service<Account, String>(Account::class.java, repository, converter, logger), IAccountService {
|
||||
|
||||
}
|
||||
15
src/zeus.query/build.gradle
Normal file
15
src/zeus.query/build.gradle
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.synebula.zeus.query.view
|
||||
|
||||
class AccountView {
|
||||
var id: String = ""
|
||||
|
||||
var name: String = ""
|
||||
|
||||
var password: String = ""
|
||||
}
|
||||
Reference in New Issue
Block a user