-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6fce231
Showing
125 changed files
with
7,846 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.idea/ | ||
target/ | ||
data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
language: scala | ||
scala: | ||
- 2.11.8 | ||
script: | ||
- sbt clean test | ||
jdk: | ||
- oraclejdk8 | ||
sudo: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
biplatform | ||
----------- | ||
|
||
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/06eb6fd6cfa948b3b7a2480b154c5cf6)](https://www.codacy.com/app/souo/biplatform?utm_source=github.com&utm_medium=referral&utm_content=souo/biplatform&utm_campaign=badger) | ||
[![Build Status](https://travis-ci.org/souo/biplatform.svg?branch=master)](https://travis-ci.org/souo/biplatform) | ||
|
||
基于scala 、akka实现了一个简单的报表工具。该项目是个玩具项目,用于个人学习scala和akka。 | ||
|
||
核心功能 | ||
======= | ||
* 使用scala语言开发,基于akka-http, akka-stream,akka-cluster等新技术构建。 | ||
* 支持多核并发,异步无阻赛 (akka) | ||
* 每个用户、每张报表均作为独立的actor, 通过akka Persistence持久化各个节点的状态,并额外获得一个可自动更新的分布式缓存。 | ||
* 对长时间未使用的节点 可以自动下线,以释放系统资源 | ||
* 高可用,可横向扩展至多节点。完全去中心化,无单点故障。失败可异地恢复 (akka-cluster)。 | ||
* 使用kryo序列化消息 | ||
* 流控 Back-Pressure, 避免OutOfMemory(akka-stream). | ||
|
||
接口文档 | ||
======== | ||
[戳这里查看接口文档](doc/api.md) | ||
|
||
|
||
system designer | ||
=============== | ||
|
||
![designer](doc/designer.png) | ||
|
||
|
||
Build and Run | ||
============ | ||
|
||
* 运行`sbt clean zip` 或者 `sbt clean tgz` 在 `target/universal`目录下会生成 相应的zip或tgz包。 | ||
|
||
* 复制到服务器上 解压, 在安装目录下 运行 `./bin/run.sh` 启动服务 | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import com.typesafe.sbt.SbtNativePackager.autoImport.NativePackagerHelper._ | ||
import com.typesafe.sbt.SbtScalariform.ScalariformKeys | ||
|
||
import scalariform.formatter.preferences._ | ||
|
||
enablePlugins(JavaAppPackaging) | ||
//coverageEnabled := true | ||
val mySetting = Seq( | ||
organization := "com.souo", | ||
version := "0.0.1", | ||
scalaVersion := "2.11.8" | ||
) ++ universalSettings | ||
|
||
lazy val universalSettings = commonSettings ++ testSettings | ||
|
||
lazy val compileScalastyle = taskKey[Unit]("compileScalastyle") | ||
|
||
lazy val commonSettings = SbtScalariform.scalariformSettings ++ Seq( | ||
ScalariformKeys.preferences := ScalariformKeys.preferences.value | ||
.setPreference(DoubleIndentClassDeclaration, true) | ||
.setPreference(PreserveSpaceBeforeArguments, true) | ||
.setPreference(CompactControlReadability, true) | ||
.setPreference(AlignArguments, true) | ||
.setPreference(AlignParameters, true) | ||
.setPreference(AlignSingleLineCaseStatements, true) | ||
.setPreference(SpacesAroundMultiImports, false) | ||
.setPreference(RewriteArrowSymbols, true), | ||
|
||
compileScalastyle := org.scalastyle.sbt.ScalastylePlugin.scalastyle | ||
.in(Compile) | ||
.toTask("") | ||
.value, | ||
(compile in Compile) := ((compile in Compile) dependsOn compileScalastyle).value, | ||
scalacOptions ++= Seq( | ||
"-deprecation", | ||
"-unchecked", | ||
"-feature", | ||
"encode", "utf-8", | ||
"-language:implicitConversions", | ||
"-language:postfixOps", | ||
"-language:existentials", | ||
"-language:higherKinds", | ||
"-Ywarn-dead-code") | ||
) | ||
|
||
|
||
lazy val testSettings = Seq( | ||
parallelExecution in Test := false, | ||
fork in Test := true, | ||
concurrentRestrictions in Global := Seq( | ||
Tags.limit(Tags.CPU, 1), | ||
Tags.limit(Tags.Test, 1), | ||
Tags.limitSum(1, Tags.Test, Tags.Untagged)) | ||
) | ||
|
||
//enable our settings | ||
mySetting | ||
//library dependencies | ||
libraryDependencies ++= Dependencies.designer | ||
//libraryDependencies += "org.sangria-graphql" %% "sangria" % "1.2.1" | ||
|
||
compile in Compile := { | ||
val compilationResult = (compile in Compile).value | ||
IO.touch(target.value / "compilationFinished") | ||
compilationResult | ||
} | ||
|
||
//define assembly jar name | ||
assemblyJarName in assembly := "biplatform.jar" | ||
|
||
//skip test | ||
test in assembly := {} | ||
|
||
//wartremoverErrors in (Compile, compile) ++= Warts.all | ||
//wartremoverWarnings in (Compile, compile) ++= Warts.all | ||
|
||
mappings in Universal := { | ||
// universalMappings: Seq[(File,String)] | ||
val universalMappings = (mappings in Universal).value | ||
val fatJar = (assembly in Compile).value | ||
// removing means filtering | ||
val filtered = universalMappings filter { | ||
case (file, name) => !name.endsWith(".jar") | ||
} | ||
//the fat jar | ||
filtered :+ (fatJar -> ("lib/" + fatJar.getName)) | ||
} | ||
|
||
//add our script | ||
mappings in Universal ++= { | ||
contentOf("script").map { s => s._1 -> ("bin/" + s._2) } | ||
} | ||
|
||
scriptClasspath := Seq((assemblyJarName in assembly).value) | ||
|
||
//Skip packageDoc task on stage | ||
mappings in(Compile, packageDoc) := Seq() | ||
|
||
|
||
assemblyMergeStrategy in assembly := { | ||
case PathList("javax", "servlet", xs@_*) => MergeStrategy.first | ||
case PathList("com", "fasterxml", "jackson", xs@_*) => MergeStrategy.first | ||
case PathList("com", "google", "protobuf", xs@_*) => MergeStrategy.first | ||
case PathList("org", "apache", "calcite", xs@_*) => MergeStrategy.first | ||
case PathList("org", "apache", "commons", xs@_*) => MergeStrategy.first | ||
case PathList("org", "slf4j", xs@_*) => MergeStrategy.first | ||
case PathList(ps@_*) if ps.last endsWith ".html" => MergeStrategy.first | ||
case "application.conf" => MergeStrategy.concat | ||
case "unwanted.txt" => MergeStrategy.discard | ||
case x => | ||
val oldStrategy = (assemblyMergeStrategy in assembly).value | ||
oldStrategy(x) | ||
} | ||
|
||
addCommandAlias("zip", "universal:packageBin") | ||
addCommandAlias("tgz", "universal:packageZipTarball") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Apis | ||
|
||
- [user](api/user.md) | ||
- [数据源](api/datasource.md) | ||
- [cube](api/cube.md) | ||
- [报表管理](api/report-manager.md) | ||
- [报表](api/report.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,216 @@ | ||
# cube api | ||
|
||
## 创建cube | ||
``` | ||
POST /api/cubes | ||
``` | ||
|
||
输入: application/json | ||
|
||
输出: application/json | ||
|
||
|
||
Body: | ||
|
||
- cubeName: String (必须) cube 名 | ||
- schema: Schema (必须) cube结构 | ||
- tableName: String (必须) | ||
- dimensions: List[Dimension] (必须) | ||
- name: String (必须) | ||
- caption: string (必须) 中文名 | ||
- description: Option[String] 描述 | ||
- dataType: String (必须)[STRING | NUMERIC | DATE] | ||
- measures: List[Dimension] (必须) | ||
- name: String (必须) | ||
- caption: string (必须) 中文名 | ||
- description: Option[String] 描述 | ||
- dataType: String (必须) | ||
- dataSourceId: UUID (必须) | ||
|
||
|
||
输入: | ||
|
||
``` | ||
{ | ||
"cubeName": "test", | ||
"schema": { | ||
"tableName": "test", | ||
"dimensions": [ | ||
{ | ||
"name": "sex", | ||
"caption": "性别", | ||
"dataType": "STRING" | ||
} | ||
], | ||
"measures": [ | ||
{ | ||
"name": "degree", | ||
"caption": "得分", | ||
"dataType": "NUMERIC" | ||
} | ||
], | ||
"dataSourceId":"fc8dfd07-6dfb-4fe3-8937-1c1be9c69e1d" | ||
} | ||
} | ||
``` | ||
|
||
输出: | ||
|
||
``` | ||
{ | ||
"status": 200, | ||
"message": "OK", | ||
"data": null | ||
} | ||
``` | ||
|
||
``` | ||
{ | ||
"status": 5000, | ||
"message": "错误", | ||
"moreInfo": "已经存在名为test的Cube" | ||
} | ||
``` | ||
## 列出所有cube | ||
|
||
``` | ||
GET /api/cubes?pageNo=&pageSize= | ||
``` | ||
|
||
Paramters | ||
- query 查询串 | ||
- pageNo 页码 | ||
- pageSize 分页大小 | ||
|
||
``` | ||
{ | ||
"status": 200, | ||
"message": "OK", | ||
"data": { | ||
"totalCount":10, | ||
"cubes":[ | ||
{ | ||
"cubeId": "1416ef1f-31b4-4aa8-adde-c8c9c9815e35", | ||
"cubeName": "test", | ||
"createBy": "admin", | ||
"modifyBy": null, | ||
"latModifyTime": "2017-05-10 13:03:00", | ||
"visible": true | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## 获取CUBE | ||
|
||
``` | ||
GET /api/cubes/{{id}} | ||
``` | ||
|
||
Paramters | ||
|
||
- id(required): cube Id | ||
|
||
``` | ||
{ | ||
"status": 200, | ||
"message": "OK", | ||
"data": { | ||
{ | ||
"cubeName": "string", | ||
"schema": { | ||
"tableName": "string", | ||
"dimensions": [ | ||
{ | ||
"name": "string", | ||
"caption": "string", | ||
"description": "string", | ||
"dataType": "string" | ||
} | ||
], | ||
"measures": [ | ||
{ | ||
"name": "string", | ||
"caption": "string", | ||
"description": "string", | ||
"dataType": "string" | ||
} | ||
], | ||
"dataSourceId": "string" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|
||
## 更新cube | ||
|
||
``` | ||
PUT /api/cubes/{{id}} | ||
``` | ||
|
||
Paramters | ||
|
||
- id(required): cube Id | ||
|
||
Body | ||
|
||
- 同创建cube | ||
|
||
输入: | ||
|
||
``` | ||
{ | ||
"cubeName": "rename", | ||
"schema": { | ||
"tableName": "test", | ||
"dimensions": [ | ||
{ | ||
"name": "sex", | ||
"caption": "性别", | ||
"dataType": "STRING" | ||
} | ||
], | ||
"measures": [ | ||
{ | ||
"name": "degree", | ||
"caption": "得分", | ||
"dataType": "NUMERIC" | ||
} | ||
], | ||
"dataSourceId":"fc8dfd07-6dfb-4fe3-8937-1c1be9c69e1d" | ||
} | ||
} | ||
``` | ||
|
||
输出: | ||
|
||
``` | ||
{ | ||
"status": 200, | ||
"message": "OK", | ||
"data": null | ||
} | ||
``` | ||
|
||
|
||
## 删除cube | ||
|
||
``` | ||
DELETE /api/cubes/{{id}} | ||
``` | ||
|
||
Paramters | ||
|
||
- id(required): cube Id | ||
|
||
``` | ||
{ | ||
"status": 200, | ||
"message": "OK", | ||
"data": null | ||
} | ||
``` |
Oops, something went wrong.