Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
zhangjian1949
apollo
提交
1b7959d6
apollo
项目概览
zhangjian1949
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1b7959d6
编写于
6月 20, 2016
作者:
J
Jason Song
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add org information for app
上级
b1e05ca3
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
204 addition
and
33 deletion
+204
-33
apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java
...in/java/com/ctrip/framework/apollo/common/entity/App.java
+28
-5
apollo-core/src/main/java/com/ctrip/framework/apollo/core/dto/AppDTO.java
...main/java/com/ctrip/framework/apollo/core/dto/AppDTO.java
+20
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java
...rip/framework/apollo/portal/controller/AppController.java
+19
-16
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/OrganizationController.java
...work/apollo/portal/controller/OrganizationController.java
+37
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Organization.java
...ctrip/framework/apollo/portal/entity/vo/Organization.java
+25
-0
apollo-portal/src/main/resources/static/app.html
apollo-portal/src/main/resources/static/app.html
+12
-3
apollo-portal/src/main/resources/static/namespace.html
apollo-portal/src/main/resources/static/namespace.html
+1
-3
apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js
...esources/static/scripts/controller/CreateAppController.js
+29
-2
apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js
...esources/static/scripts/controller/NamespaceController.js
+11
-4
apollo-portal/src/main/resources/static/scripts/services/OrganizationService.js
.../resources/static/scripts/services/OrganizationService.js
+22
-0
未找到文件。
apollo-common/src/main/java/com/ctrip/framework/apollo/common/entity/App.java
浏览文件 @
1b7959d6
package
com.ctrip.framework.apollo.common.entity
;
import
com.ctrip.framework.apollo.common.entity.BaseEntity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
@Entity
@Table
(
name
=
"App"
)
@SQLDelete
(
sql
=
"Update App set isDeleted = 1 where id = ?"
)
...
...
@@ -21,6 +19,12 @@ public class App extends BaseEntity {
@Column
(
name
=
"AppId"
,
nullable
=
false
)
private
String
appId
;
@Column
(
name
=
"OrgId"
,
nullable
=
false
)
private
String
orgId
;
@Column
(
name
=
"OrgName"
,
nullable
=
false
)
private
String
orgName
;
@Column
(
name
=
"OwnerName"
,
nullable
=
false
)
private
String
ownerName
;
...
...
@@ -35,6 +39,14 @@ public class App extends BaseEntity {
return
name
;
}
public
String
getOrgId
()
{
return
orgId
;
}
public
String
getOrgName
()
{
return
orgName
;
}
public
String
getOwnerEmail
()
{
return
ownerEmail
;
}
...
...
@@ -51,6 +63,14 @@ public class App extends BaseEntity {
this
.
name
=
name
;
}
public
void
setOrgId
(
String
orgId
)
{
this
.
orgId
=
orgId
;
}
public
void
setOrgName
(
String
orgName
)
{
this
.
orgName
=
orgName
;
}
public
void
setOwnerEmail
(
String
ownerEmail
)
{
this
.
ownerEmail
=
ownerEmail
;
}
...
...
@@ -60,7 +80,10 @@ public class App extends BaseEntity {
}
public
String
toString
()
{
return
toStringHelper
().
add
(
"name"
,
name
).
add
(
"appId"
,
appId
).
add
(
"ownerName"
,
ownerName
)
return
toStringHelper
().
add
(
"name"
,
name
).
add
(
"appId"
,
appId
)
.
add
(
"orgId"
,
orgId
)
.
add
(
"orgName"
,
orgName
)
.
add
(
"ownerName"
,
ownerName
)
.
add
(
"ownerEmail"
,
ownerEmail
).
toString
();
}
}
apollo-core/src/main/java/com/ctrip/framework/apollo/core/dto/AppDTO.java
浏览文件 @
1b7959d6
...
...
@@ -8,6 +8,10 @@ public class AppDTO extends BaseDTO{
private
String
appId
;
private
String
orgId
;
private
String
orgName
;
private
String
ownerName
;
private
String
ownerEmail
;
...
...
@@ -28,6 +32,14 @@ public class AppDTO extends BaseDTO{
return
name
;
}
public
String
getOrgId
()
{
return
orgId
;
}
public
String
getOrgName
()
{
return
orgName
;
}
public
String
getOwnerEmail
()
{
return
ownerEmail
;
}
...
...
@@ -44,6 +56,14 @@ public class AppDTO extends BaseDTO{
this
.
name
=
name
;
}
public
void
setOrgId
(
String
orgId
)
{
this
.
orgId
=
orgId
;
}
public
void
setOrgName
(
String
orgName
)
{
this
.
orgName
=
orgName
;
}
public
void
setOwnerEmail
(
String
ownerEmail
)
{
this
.
ownerEmail
=
ownerEmail
;
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java
浏览文件 @
1b7959d6
package
com.ctrip.framework.apollo.portal.controller
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.http.MultiResponseEntity
;
import
com.ctrip.framework.apollo.common.http.RichResponseEntity
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.PortalSettings
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo
;
import
com.ctrip.framework.apollo.portal.listener.AppCreationEvent
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -12,15 +21,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.client.HttpClientErrorException
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.http.MultiResponseEntity
;
import
com.ctrip.framework.apollo.common.http.RichResponseEntity
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.PortalSettings
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo
;
import
com.ctrip.framework.apollo.portal.listener.AppCreationEvent
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
java.util.List
;
import
static
com
.
ctrip
.
framework
.
apollo
.
portal
.
util
.
RequestPrecondition
.
checkArgument
;
...
...
@@ -53,8 +53,8 @@ public class AppController {
response
.
addResponseEntity
(
RichResponseEntity
.
ok
(
appService
.
createEnvNavNode
(
env
,
appId
)));
}
catch
(
Exception
e
)
{
response
.
addResponseEntity
(
RichResponseEntity
.
error
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
"load env:"
+
env
.
name
()
+
" cluster error."
+
e
.
getMessage
()));
"load env:"
+
env
.
name
()
+
" cluster error."
+
e
.
getMessage
()));
}
}
return
response
;
...
...
@@ -68,7 +68,8 @@ public class AppController {
@RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
POST
)
public
ResponseEntity
<
Void
>
create
(
@RequestBody
App
app
)
{
checkArgument
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
app
.
getOwnerName
());
checkArgument
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
app
.
getOwnerName
(),
app
.
getOrgId
(),
app
.
getOrgName
());
appService
.
enrichUserInfo
(
app
);
App
createdApp
=
appService
.
createOrUpdateAppInLocal
(
app
);
...
...
@@ -78,10 +79,12 @@ public class AppController {
return
ResponseEntity
.
ok
().
build
();
}
@RequestMapping
(
value
=
"/envs/{env}"
,
method
=
RequestMethod
.
POST
,
consumes
=
{
"application/json"
})
@RequestMapping
(
value
=
"/envs/{env}"
,
method
=
RequestMethod
.
POST
,
consumes
=
{
"application/json"
})
public
ResponseEntity
<
Void
>
create
(
@PathVariable
String
env
,
@RequestBody
App
app
)
{
checkArgument
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
app
.
getOwnerName
());
checkArgument
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
app
.
getOwnerName
(),
app
.
getOrgId
(),
app
.
getOrgName
());
appService
.
createApp
(
Env
.
valueOf
(
env
),
app
);
...
...
@@ -107,8 +110,8 @@ public class AppController {
response
.
addResponseEntity
(
RichResponseEntity
.
ok
(
env
));
}
else
{
response
.
addResponseEntity
(
RichResponseEntity
.
error
(
HttpStatus
.
INTERNAL_SERVER_ERROR
,
String
.
format
(
"load appId:%s from env %s error."
,
appId
,
env
)
+
e
.
getMessage
()));
String
.
format
(
"load appId:%s from env %s error."
,
appId
,
env
)
+
e
.
getMessage
()));
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/OrganizationController.java
0 → 100644
浏览文件 @
1b7959d6
package
com.ctrip.framework.apollo.portal.controller
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.ctrip.framework.apollo.portal.entity.po.ServerConfig
;
import
com.ctrip.framework.apollo.portal.entity.vo.Organization
;
import
com.ctrip.framework.apollo.portal.repository.ServerConfigRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.lang.reflect.Type
;
import
java.util.List
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
@RestController
@RequestMapping
(
"/organizations"
)
public
class
OrganizationController
{
@Autowired
private
ServerConfigRepository
serverConfigRepository
;
@Autowired
private
Gson
gson
;
private
Type
responseType
=
new
TypeToken
<
List
<
Organization
>>()
{
}.
getType
();
@RequestMapping
public
List
<
Organization
>
loadOrganization
()
{
ServerConfig
config
=
serverConfigRepository
.
findByKey
(
"organizations"
);
return
gson
.
fromJson
(
config
.
getValue
(),
responseType
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Organization.java
0 → 100644
浏览文件 @
1b7959d6
package
com.ctrip.framework.apollo.portal.entity.vo
;
/**
* @author Jason Song(song_s@ctrip.com)
*/
public
class
Organization
{
private
String
orgId
;
private
String
orgName
;
public
String
getOrgId
()
{
return
orgId
;
}
public
void
setOrgId
(
String
orgId
)
{
this
.
orgId
=
orgId
;
}
public
String
getOrgName
()
{
return
orgName
;
}
public
void
setOrgName
(
String
orgName
)
{
this
.
orgName
=
orgName
;
}
}
apollo-portal/src/main/resources/static/app.html
浏览文件 @
1b7959d6
...
...
@@ -5,6 +5,7 @@
<!-- styles -->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"vendor/bootstrap/css/bootstrap.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"vendor/angular/angular-toastr-1.4.1.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"vendor/select2/select2.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
media=
'all'
href=
"vendor/angular/loading-bar.min.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styles/common-style.css"
>
<title>
新建项目
</title>
...
...
@@ -25,7 +26,13 @@
<div
class=
"panel-body"
>
<form
class=
"form-horizontal"
ng-controller=
"CreateAppController"
ng-submit=
"create()"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用ID
</label>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
部门
</label>
<div
class=
"col-sm-3"
>
<select
id=
"organization"
><option></option></select>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用AppId
</label>
<div
class=
"col-sm-3"
>
<input
type=
"text"
class=
"form-control"
name=
"appAppId"
ng-model=
"app.appId"
required
>
...
...
@@ -38,13 +45,13 @@
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用Owner
</label>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
应用负责人
</label>
<div
class=
"col-sm-3"
>
<input
type=
"text"
class=
"form-control"
name=
"appOwner"
ng-model=
"app.ownerName"
required
>
</div>
</div>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
邮箱地址
</label>
<label
class=
"col-sm-2 control-label"
><apollorequiredfiled></apollorequiredfiled>
邮箱地址
</label>
<div
class=
"col-sm-4"
>
<input
type=
"email"
class=
"form-control"
ng-model=
"app.ownerEmail"
required
>
</div>
...
...
@@ -74,6 +81,7 @@
<!-- jquery.js -->
<script
src=
"vendor/jquery.min.js"
type=
"text/javascript"
></script>
<script
src=
"vendor/select2/select2.min.js"
type=
"text/javascript"
></script>
<!-- bootstrap.js -->
<script
src=
"vendor/bootstrap/js/bootstrap.min.js"
type=
"text/javascript"
></script>
...
...
@@ -83,6 +91,7 @@
<script
type=
"application/javascript"
src=
"scripts/services/EnvService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/UserService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/AppUtils.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/services/OrganizationService.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/directive.js"
></script>
<script
type=
"application/javascript"
src=
"scripts/controller/CreateAppController.js"
></script>
...
...
apollo-portal/src/main/resources/static/namespace.html
浏览文件 @
1b7959d6
...
...
@@ -61,9 +61,7 @@
<div
class=
"form-group"
ng-show=
"type == 'link'"
>
<label
class=
"col-sm-3 control-label"
><font
style=
"color: red"
>
*
</font>
namespace
</label>
<div
class=
"col-sm-4"
>
<select
id=
"namespaces"
>
</select>
<select
id=
"namespaces"
><option></option></select>
</div>
</div>
...
...
apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js
浏览文件 @
1b7959d6
create_app_module
.
controller
(
'
CreateAppController
'
,
[
'
$scope
'
,
'
$window
'
,
'
toastr
'
,
'
AppService
'
,
'
AppUtil
'
,
function
(
$scope
,
$window
,
toastr
,
AppService
,
AppUtil
)
{
create_app_module
.
controller
(
'
CreateAppController
'
,
[
'
$scope
'
,
'
$window
'
,
'
toastr
'
,
'
AppService
'
,
'
AppUtil
'
,
'
OrganizationService
'
,
function
(
$scope
,
$window
,
toastr
,
AppService
,
AppUtil
,
OrganizationService
)
{
OrganizationService
.
find_organizations
().
then
(
function
(
result
)
{
var
organizations
=
[];
result
.
forEach
(
function
(
item
)
{
var
org
=
{};
org
.
id
=
item
.
orgId
;
org
.
text
=
item
.
orgName
+
'
(
'
+
item
.
orgId
+
'
)
'
;
organizations
.
push
(
org
);
});
$
(
'
#organization
'
).
select2
({
placeholder
:
'
请选择部门
'
,
width
:
'
100%
'
,
data
:
organizations
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
load organizations error
"
);
});
$scope
.
create
=
function
()
{
var
selectedOrg
=
$
(
'
#organization
'
).
select2
(
'
data
'
)[
0
];
if
(
!
selectedOrg
.
id
)
{
toastr
.
warning
(
"
请选择部门
"
);
return
;
}
$scope
.
app
.
orgId
=
selectedOrg
.
id
;
$scope
.
app
.
orgName
=
selectedOrg
.
text
;
AppService
.
create
(
$scope
.
app
).
then
(
function
(
result
)
{
toastr
.
success
(
'
添加成功!
'
);
setInterval
(
function
()
{
...
...
apollo-portal/src/main/resources/static/scripts/controller/NamespaceController.js
浏览文件 @
1b7959d6
...
...
@@ -17,9 +17,10 @@ namespace_module.controller("LinkNamespaceController",
publicNamespaces
.
push
(
namespace
);
});
$
(
'
#namespaces
'
).
select2
({
width
:
'
250px
'
,
data
:
publicNamespaces
});
placeholder
:
'
请选择Namespace
'
,
width
:
'
100%
'
,
data
:
publicNamespaces
});
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
load public namespace error
"
);
});
...
...
@@ -42,7 +43,13 @@ namespace_module.controller("LinkNamespaceController",
}
if
(
$scope
.
namespaceType
==
1
){
$scope
.
namespaceName
=
$
(
'
#namespaces
'
).
select2
(
'
data
'
)[
0
].
id
;
var
selectedNamespaceName
=
$
(
'
#namespaces
'
).
select2
(
'
data
'
)[
0
].
id
;
if
(
!
selectedNamespaceName
)
{
toastr
.
warning
(
"
请选择Namespace
"
);
return
;
}
$scope
.
namespaceName
=
selectedNamespaceName
;
}
var
namespaceCreationModels
=
[];
...
...
apollo-portal/src/main/resources/static/scripts/services/OrganizationService.js
0 → 100644
浏览文件 @
1b7959d6
appService
.
service
(
"
OrganizationService
"
,
[
'
$resource
'
,
'
$q
'
,
function
(
$resource
,
$q
)
{
var
organization_source
=
$resource
(
""
,
{},
{
find_organizations
:
{
method
:
'
GET
'
,
isArray
:
true
,
url
:
'
/organizations
'
}
});
return
{
find_organizations
:
function
()
{
var
d
=
$q
.
defer
();
organization_source
.
find_organizations
({},
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
d
.
reject
(
result
);
});
return
d
.
promise
;
}
}
}]);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录