Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
superrain51
apollo
提交
108034f4
apollo
项目概览
superrain51
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
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,发现更多精彩内容 >>
提交
108034f4
编写于
4月 20, 2016
作者:
L
lepdou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit log service & create app 表单优化
上级
24db89d0
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
190 addition
and
330 deletion
+190
-330
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Commit.java
...biz/src/main/java/com/ctrip/apollo/biz/entity/Commit.java
+76
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/CommitRepository.java
...ava/com/ctrip/apollo/biz/repository/CommitRepository.java
+14
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/CommitService.java
...main/java/com/ctrip/apollo/biz/service/CommitService.java
+24
-0
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ItemSetService.java
...ain/java/com/ctrip/apollo/biz/service/ItemSetService.java
+3
-0
apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppConfigVO.java
.../src/main/java/com/ctrip/apollo/core/dto/AppConfigVO.java
+0
-181
apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppDTO.java
...-core/src/main/java/com/ctrip/apollo/core/dto/AppDTO.java
+7
-38
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemChangeSets.java
...c/main/java/com/ctrip/apollo/core/dto/ItemChangeSets.java
+4
-0
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java
...core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java
+9
-54
apollo-core/src/main/java/com/ctrip/apollo/core/dto/NamespaceDTO.java
...src/main/java/com/ctrip/apollo/core/dto/NamespaceDTO.java
+10
-11
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ReleaseDTO.java
...e/src/main/java/com/ctrip/apollo/core/dto/ReleaseDTO.java
+9
-10
apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java
...ain/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java
+3
-3
apollo-portal/src/main/java/com/ctrip/apollo/portal/entity/form/NamespaceTextModel.java
...m/ctrip/apollo/portal/entity/form/NamespaceTextModel.java
+9
-0
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java
...n/java/com/ctrip/apollo/portal/service/ConfigService.java
+4
-7
apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js
...esources/static/scripts/controller/CreateAppController.js
+1
-5
apollo-portal/src/main/resources/static/scripts/controller/app/AppConfigController.js
...rces/static/scripts/controller/app/AppConfigController.js
+7
-6
apollo-portal/src/main/resources/static/scripts/services/ConfigService.js
...c/main/resources/static/scripts/services/ConfigService.js
+2
-1
apollo-portal/src/main/resources/static/views/app.html
apollo-portal/src/main/resources/static/views/app.html
+1
-1
apollo-portal/src/main/resources/static/views/create-app.html
...lo-portal/src/main/resources/static/views/create-app.html
+4
-5
apollo-portal/src/test/java/com/ctrip/apollo/portal/ConfigServiceTest.java
.../test/java/com/ctrip/apollo/portal/ConfigServiceTest.java
+3
-8
未找到文件。
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Commit.java
0 → 100644
浏览文件 @
108034f4
package
com.ctrip.apollo.biz.entity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
@Entity
@Table
(
name
=
"commit"
)
@SQLDelete
(
sql
=
"Update commit set isDeleted = 1 where id = ?"
)
@Where
(
clause
=
"isDeleted = 0"
)
public
class
Commit
extends
BaseEntity
{
@Column
(
name
=
"ChangeSets"
,
nullable
=
false
)
private
String
changeSets
;
@Column
(
name
=
"AppId"
,
nullable
=
false
)
private
String
appId
;
@Column
(
name
=
"ClusterName"
,
nullable
=
false
)
private
String
clusterName
;
@Column
(
name
=
"NamespaceName"
,
nullable
=
false
)
private
String
namespaceName
;
@Column
(
name
=
"Comment"
)
private
String
comment
;
public
String
getChangeSets
()
{
return
changeSets
;
}
public
void
setChangeSets
(
String
changeSets
)
{
this
.
changeSets
=
changeSets
;
}
public
String
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
public
String
getClusterName
()
{
return
clusterName
;
}
public
void
setClusterName
(
String
clusterName
)
{
this
.
clusterName
=
clusterName
;
}
public
String
getNamespaceName
()
{
return
namespaceName
;
}
public
void
setNamespaceName
(
String
namespaceName
)
{
this
.
namespaceName
=
namespaceName
;
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
@Override
public
String
toString
()
{
return
toStringHelper
().
add
(
"changeSets"
,
changeSets
).
add
(
"appId"
,
appId
).
add
(
"clusterName"
,
clusterName
)
.
add
(
"namespaceName"
,
namespaceName
).
add
(
"comment"
,
comment
).
toString
();
}
}
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/CommitRepository.java
0 → 100644
浏览文件 @
108034f4
package
com.ctrip.apollo.biz.repository
;
import
com.ctrip.apollo.biz.entity.Commit
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.List
;
public
interface
CommitRepository
extends
PagingAndSortingRepository
<
Commit
,
Long
>
{
List
<
Commit
>
findByAppIdAndClusterNameAndNamespaceName
(
String
appId
,
String
clusterName
,
String
namespaceName
);
}
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/CommitService.java
0 → 100644
浏览文件 @
108034f4
package
com.ctrip.apollo.biz.service
;
import
com.ctrip.apollo.biz.entity.Commit
;
import
com.ctrip.apollo.biz.repository.CommitRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
@Service
public
class
CommitService
{
@Autowired
private
CommitRepository
commitRepository
;
public
void
save
(
Commit
commit
,
String
user
){
commit
.
setDataChangeCreatedBy
(
user
);
commit
.
setDataChangeCreatedTime
(
new
Date
());
commitRepository
.
save
(
commit
);
}
}
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ItemSetService.java
浏览文件 @
108034f4
...
...
@@ -11,6 +11,8 @@ import com.ctrip.apollo.common.utils.BeanUtils;
import
com.ctrip.apollo.core.dto.ItemChangeSets
;
import
com.ctrip.apollo.core.dto.ItemDTO
;
import
java.util.Date
;
@Service
public
class
ItemSetService
{
...
...
@@ -25,6 +27,7 @@ public class ItemSetService {
if
(
changeSet
.
getCreateItems
()
!=
null
)
{
for
(
ItemDTO
item
:
changeSet
.
getCreateItems
())
{
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
entity
.
setDataChangeCreatedTime
(
new
Date
());
entity
.
setDataChangeCreatedBy
(
owner
);
entity
.
setDataChangeLastModifiedBy
(
owner
);
itemRepository
.
save
(
entity
);
...
...
apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppConfigVO.java
已删除
100644 → 0
浏览文件 @
24db89d0
package
com.ctrip.apollo.core.dto
;
import
com.ctrip.apollo.core.enums.Env
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
AppConfigVO
{
private
String
appId
;
private
Env
env
;
/**
* latest version if version is zero, or is release version
*/
private
long
versionId
;
/**
* default cluster and app self’s configs
*/
private
List
<
ItemDTO
>
defaultClusterConfigs
;
/**
* default cluster and override other app configs
*/
private
List
<
OverrideAppConfig
>
overrideAppConfigs
;
/**
* configs in different cluster maybe different.
* overrideClusterConfigs only save diff configs from default cluster.
* For example:
* default cluster has 3 configs:
* {a -> A, b -> B, c -> C}
*
* cluster1 has 1 config
* {b -> D}
*
* if client read cluster1 configs will return {a -> A, b -> D, c -> C}
*/
private
List
<
OverrideClusterConfig
>
overrideClusterConfigs
;
public
AppConfigVO
()
{
}
public
static
AppConfigVO
newInstance
(
String
appId
,
long
versionId
)
{
AppConfigVO
instance
=
new
AppConfigVO
();
instance
.
setAppId
(
appId
);
instance
.
setVersionId
(
versionId
);
instance
.
setDefaultClusterConfigs
(
new
LinkedList
<>());
instance
.
setOverrideAppConfigs
(
new
LinkedList
<>());
instance
.
setOverrideClusterConfigs
(
new
LinkedList
<>());
return
instance
;
}
public
boolean
isLatestVersion
()
{
return
versionId
==
0
;
}
public
static
class
OverrideAppConfig
{
private
String
appId
;
private
List
<
ItemDTO
>
configs
;
public
OverrideAppConfig
()
{
}
public
String
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
public
List
<
ItemDTO
>
getConfigs
()
{
return
configs
;
}
public
void
setConfigs
(
List
<
ItemDTO
>
configs
)
{
this
.
configs
=
configs
;
}
public
void
addConfig
(
ItemDTO
config
)
{
if
(
configs
==
null
)
{
configs
=
new
LinkedList
<>();
}
configs
.
add
(
config
);
}
}
public
static
class
OverrideClusterConfig
{
private
String
clusterName
;
private
List
<
ItemDTO
>
configs
;
public
OverrideClusterConfig
()
{
}
public
String
getClusterName
()
{
return
clusterName
;
}
public
void
setClusterName
(
String
clusterName
)
{
this
.
clusterName
=
clusterName
;
}
public
List
<
ItemDTO
>
getConfigs
()
{
return
configs
;
}
public
void
setConfigs
(
List
<
ItemDTO
>
configs
)
{
this
.
configs
=
configs
;
}
}
public
String
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
public
Env
getEnv
()
{
return
env
;
}
public
void
setEnv
(
Env
env
)
{
this
.
env
=
env
;
}
public
long
getVersionId
()
{
return
versionId
;
}
public
void
setVersionId
(
long
versionId
)
{
this
.
versionId
=
versionId
;
}
public
List
<
ItemDTO
>
getDefaultClusterConfigs
()
{
return
defaultClusterConfigs
;
}
public
void
setDefaultClusterConfigs
(
List
<
ItemDTO
>
defaultClusterConfigs
)
{
this
.
defaultClusterConfigs
=
defaultClusterConfigs
;
}
public
List
<
OverrideAppConfig
>
getOverrideAppConfigs
()
{
return
overrideAppConfigs
;
}
public
void
setOverrideAppConfigs
(
List
<
OverrideAppConfig
>
overrideAppConfigs
)
{
this
.
overrideAppConfigs
=
overrideAppConfigs
;
}
public
List
<
OverrideClusterConfig
>
getOverrideClusterConfigs
()
{
return
overrideClusterConfigs
;
}
public
void
setOverrideClusterConfigs
(
List
<
OverrideClusterConfig
>
overrideClusterConfigs
)
{
this
.
overrideClusterConfigs
=
overrideClusterConfigs
;
}
@Override
public
String
toString
()
{
return
"Config4PortalDTO{"
+
"appId="
+
appId
+
", env="
+
env
+
", versionId="
+
versionId
+
", defaultClusterConfigs="
+
defaultClusterConfigs
+
", overrideAppConfigs="
+
overrideAppConfigs
+
", overrideClusterConfigs="
+
overrideClusterConfigs
+
'}'
;
}
}
apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppDTO.java
浏览文件 @
108034f4
package
com.ctrip.apollo.core.dto
;
import
java.util.Date
;
public
class
AppDTO
{
private
long
id
;
private
String
name
;
private
String
appId
;
...
...
@@ -14,20 +12,18 @@ public class AppDTO {
private
String
ownerEmail
;
p
rivate
String
dataChangeCreatedBy
;
private
Date
dataChangeCreatedTime
;
p
ublic
long
getId
()
{
return
id
;
}
private
String
dataChangeLastModifiedBy
;
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getAppId
()
{
return
appId
;
}
public
long
getId
()
{
return
id
;
}
public
String
getName
()
{
return
name
;
}
...
...
@@ -44,10 +40,6 @@ public class AppDTO {
this
.
appId
=
appId
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
...
...
@@ -60,27 +52,4 @@ public class AppDTO {
this
.
ownerName
=
ownerName
;
}
public
String
getDataChangeCreatedBy
()
{
return
dataChangeCreatedBy
;
}
public
void
setDataChangeCreatedBy
(
String
dataChangeCreatedBy
)
{
this
.
dataChangeCreatedBy
=
dataChangeCreatedBy
;
}
public
Date
getDataChangeCreatedTime
()
{
return
dataChangeCreatedTime
;
}
public
void
setDataChangeCreatedTime
(
Date
dataChangeCreatedTime
)
{
this
.
dataChangeCreatedTime
=
dataChangeCreatedTime
;
}
public
String
getDataChangeLastModifiedBy
()
{
return
dataChangeLastModifiedBy
;
}
public
void
setDataChangeLastModifiedBy
(
String
dataChangeLastModifiedBy
)
{
this
.
dataChangeLastModifiedBy
=
dataChangeLastModifiedBy
;
}
}
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemChangeSets.java
浏览文件 @
108034f4
...
...
@@ -24,6 +24,10 @@ public class ItemChangeSets {
deleteItems
.
add
(
item
);
}
public
boolean
isEmpty
(){
return
createItems
.
isEmpty
()
&&
updateItems
.
isEmpty
()
&&
deleteItems
.
isEmpty
();
}
public
List
<
ItemDTO
>
getCreateItems
()
{
return
createItems
;
}
...
...
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java
浏览文件 @
108034f4
package
com.ctrip.apollo.core.dto
;
import
java.util.Date
;
public
class
ItemDTO
{
public
class
ItemDTO
{
private
long
id
;
...
...
@@ -16,14 +14,6 @@ public class ItemDTO{
private
int
lineNum
;
private
String
dataChangeCreatedBy
;
private
Date
dataChangeCreatedTime
;
private
String
dataChangeLastModifiedBy
;
private
Date
dataChangeLastModifiedTime
;
public
ItemDTO
()
{
}
...
...
@@ -35,14 +25,18 @@ public class ItemDTO{
this
.
lineNum
=
lineNum
;
}
public
String
getComment
()
{
return
comment
;
}
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getComment
()
{
return
comment
;
}
public
String
getKey
()
{
return
key
;
}
...
...
@@ -59,10 +53,6 @@ public class ItemDTO{
this
.
comment
=
comment
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
}
...
...
@@ -83,37 +73,6 @@ public class ItemDTO{
this
.
lineNum
=
lineNum
;
}
public
String
getDataChangeLastModifiedBy
()
{
return
dataChangeLastModifiedBy
;
}
public
void
setDataChangeLastModifiedBy
(
String
dataChangeLastModifiedBy
)
{
this
.
dataChangeLastModifiedBy
=
dataChangeLastModifiedBy
;
}
public
Date
getDataChangeLastModifiedTime
()
{
return
dataChangeLastModifiedTime
;
}
public
void
setDataChangeLastModifiedTime
(
Date
dataChangeLastModifiedTime
)
{
this
.
dataChangeLastModifiedTime
=
dataChangeLastModifiedTime
;
}
public
String
getDataChangeCreatedBy
()
{
return
dataChangeCreatedBy
;
}
public
void
setDataChangeCreatedBy
(
String
dataChangeCreatedBy
)
{
this
.
dataChangeCreatedBy
=
dataChangeCreatedBy
;
}
public
Date
getDataChangeCreatedTime
()
{
return
dataChangeCreatedTime
;
}
public
void
setDataChangeCreatedTime
(
Date
dataChangeCreatedTime
)
{
this
.
dataChangeCreatedTime
=
dataChangeCreatedTime
;
}
@Override
public
String
toString
()
{
...
...
@@ -124,10 +83,6 @@ public class ItemDTO{
", value='"
+
value
+
'\''
+
", comment='"
+
comment
+
'\''
+
", lineNum="
+
lineNum
+
", dataChangeCreatedBy='"
+
dataChangeCreatedBy
+
'\''
+
", dataChangeCreatedTime="
+
dataChangeCreatedTime
+
", dataChangeLastModifiedBy='"
+
dataChangeLastModifiedBy
+
'\''
+
", dataChangeLastModifiedTime="
+
dataChangeLastModifiedTime
+
'}'
;
}
}
apollo-core/src/main/java/com/ctrip/apollo/core/dto/NamespaceDTO.java
浏览文件 @
108034f4
package
com.ctrip.apollo.core.dto
;
public
class
NamespaceDTO
{
public
class
NamespaceDTO
{
private
long
id
;
private
String
appId
;
private
String
clusterName
;
private
String
namespaceName
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getAppId
()
{
return
appId
;
}
...
...
@@ -18,10 +25,6 @@ public class NamespaceDTO {
return
clusterName
;
}
public
long
getId
()
{
return
id
;
}
public
String
getNamespaceName
()
{
return
namespaceName
;
}
...
...
@@ -34,10 +37,6 @@ public class NamespaceDTO {
this
.
clusterName
=
clusterName
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setNamespaceName
(
String
namespaceName
)
{
this
.
namespaceName
=
namespaceName
;
}
...
...
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ReleaseDTO.java
浏览文件 @
108034f4
package
com.ctrip.apollo.core.dto
;
public
class
ReleaseDTO
{
public
class
ReleaseDTO
{
private
long
id
;
private
String
name
;
...
...
@@ -16,6 +15,14 @@ public class ReleaseDTO {
private
String
comment
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getAppId
()
{
return
appId
;
}
...
...
@@ -32,10 +39,6 @@ public class ReleaseDTO {
return
configurations
;
}
public
long
getId
()
{
return
id
;
}
public
String
getName
()
{
return
name
;
}
...
...
@@ -60,10 +63,6 @@ public class ReleaseDTO {
this
.
configurations
=
configurations
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java
浏览文件 @
108034f4
...
...
@@ -157,15 +157,15 @@ public class AdminServiceAPI {
HttpEntity
<
MultiValueMap
<
String
,
String
>>
entity
=
new
HttpEntity
<
MultiValueMap
<
String
,
String
>>(
parameters
,
null
);
ResponseEntity
<
ReleaseDTO
>
response
=
restTemplate
.
postForEntity
(
getAdminServiceHost
(
env
)
+
String
.
format
(
"apps/%s/clusters/%s/namespaces/%s/releases"
,
appId
,
clusterName
,
namespace
),
entity
,
ReleaseDTO
.
class
);
format
(
"apps/%s/clusters/%s/namespaces/%s/releases"
,
appId
,
clusterName
,
namespace
),
entity
,
ReleaseDTO
.
class
);
if
(
response
!=
null
&&
response
.
getStatusCode
()
==
HttpStatus
.
OK
){
return
response
.
getBody
();
}
else
{
logger
.
error
(
"createRelease fail.id:{}, env:{}, clusterName:{}, namespace:{},releaseBy{}"
,
appId
,
env
,
clusterName
,
namespace
,
releaseBy
);
throw
new
ServiceException
(
"call create createRelease api error."
);
throw
new
ServiceException
(
"
call create createRelease api error."
);
}
}
}
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/entity/form/NamespaceTextModel.java
浏览文件 @
108034f4
...
...
@@ -13,6 +13,7 @@ public class NamespaceTextModel implements FormModel{
private
int
namespaceId
;
private
String
configText
;
private
String
modifyBy
;
private
String
comment
;
@Override
public
boolean
isInvalid
(){
...
...
@@ -73,4 +74,12 @@ public class NamespaceTextModel implements FormModel{
public
void
setModifyBy
(
String
modifyBy
)
{
this
.
modifyBy
=
modifyBy
;
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
}
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java
浏览文件 @
108034f4
...
...
@@ -146,22 +146,19 @@ public class ConfigService {
ItemChangeSets
changeSets
=
resolver
.
resolve
(
namespaceId
,
configText
,
itemAPI
.
findItems
(
appId
,
env
,
clusterName
,
namespaceName
));
if
(
changeSets
.
isEmpty
()){
return
;
}
try
{
enrichChangeSetBaseInfo
(
changeSets
);
itemAPI
.
updateItems
(
appId
,
env
,
clusterName
,
namespaceName
,
changeSets
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"itemAPI.updateItems error. appId{},env:{},clusterName:{},namespaceName:{}"
,
appId
,
env
,
clusterName
,
namespaceName
);
throw
new
ServiceException
(
"oops! call admin service config error. "
);
throw
new
ServiceException
(
e
.
getMessage
()
);
}
}
private
void
enrichChangeSetBaseInfo
(
ItemChangeSets
changeSets
)
{
for
(
ItemDTO
item
:
changeSets
.
getCreateItems
())
{
item
.
setDataChangeCreatedTime
(
new
Date
());
}
}
/**
* createRelease config items
...
...
apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js
浏览文件 @
108034f4
...
...
@@ -8,11 +8,7 @@ create_app_module.controller('CreateAppController', ['$scope', '$window', 'toast
$window
.
location
.
href
=
'
/views/app.html?#appid=
'
+
result
.
appId
;
},
1000
);
},
function
(
result
)
{
if
(
result
.
status
==
400
){
toastr
.
error
(
'
params error
'
,
'
添加失败!
'
);
}
else
{
toastr
.
error
(
'
server error
'
,
'
添加失败!
'
);
}
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
'
添加失败!
'
);
});
};
...
...
apollo-portal/src/main/resources/static/scripts/controller/app/AppConfigController.js
浏览文件 @
108034f4
...
...
@@ -3,7 +3,7 @@ application_module.controller("AppConfigController",
function
(
$scope
,
$location
,
toastr
,
AppService
,
ConfigService
)
{
var
appId
=
$location
.
$$url
.
split
(
"
=
"
)[
1
];
var
currentUser
=
'
lepdou
'
;
var
currentUser
=
'
test_user
'
;
var
pageContext
=
{
appId
:
appId
,
env
:
'
LOCAL
'
,
...
...
@@ -49,7 +49,7 @@ application_module.controller("AppConfigController",
}
});
},
function
(
result
)
{
toastr
.
error
(
"
加载导航出错:
"
+
result
);
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
"
加载导航出错
"
);
});
/////////// namespace ////////////
...
...
@@ -84,7 +84,7 @@ application_module.controller("AppConfigController",
}
},
function
(
result
)
{
toastr
.
error
(
"
加载配置信息出错
"
);
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
"
加载配置信息出错
"
);
});
}
...
...
@@ -127,11 +127,12 @@ application_module.controller("AppConfigController",
$scope
.
draft
=
namespace
;
};
$scope
.
commitComment
=
''
;
//更新配置
$scope
.
commitChange
=
function
()
{
ConfigService
.
modify_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
env
,
$scope
.
pageContext
.
clusterName
,
$scope
.
draft
.
namespace
.
namespaceName
,
$scope
.
draft
.
text
,
$scope
.
draft
.
namespace
.
id
,
'
lepdou
'
).
then
(
$scope
.
draft
.
namespace
.
id
,
$scope
.
commitComment
,
currentUser
).
then
(
function
(
result
)
{
toastr
.
success
(
"
更新成功
"
);
//refresh all namespace items
...
...
@@ -141,7 +142,7 @@ application_module.controller("AppConfigController",
$scope
.
toggleTextEditStatus
(
$scope
.
draft
);
},
function
(
result
)
{
toastr
.
error
(
result
.
data
.
message
,
"
更新失败
"
);
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
"
更新失败
"
);
}
);
...
...
@@ -189,7 +190,7 @@ application_module.controller("AppConfigController",
refreshNamespaces
();
},
function
(
result
)
{
toastr
.
error
(
result
.
data
.
message
,
"
发布失败
"
);
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
"
发布失败
"
);
}
);
...
...
apollo-portal/src/main/resources/static/scripts/services/ConfigService.js
浏览文件 @
108034f4
...
...
@@ -30,7 +30,7 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
return
d
.
promise
;
},
modify_items
:
function
(
appId
,
env
,
clusterName
,
namespaceName
,
configText
,
namespaceId
,
modifyBy
)
{
modify_items
:
function
(
appId
,
env
,
clusterName
,
namespaceName
,
configText
,
namespaceId
,
comment
,
modifyBy
)
{
var
d
=
$q
.
defer
();
config_source
.
modify_items
({
appId
:
appId
,
...
...
@@ -41,6 +41,7 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
{
configText
:
configText
,
namespaceId
:
namespaceId
,
comment
:
comment
,
modifyBy
:
modifyBy
},
function
(
result
)
{
d
.
resolve
(
result
);
...
...
apollo-portal/src/main/resources/static/views/app.html
浏览文件 @
108034f4
...
...
@@ -241,7 +241,7 @@
<h4
class=
"modal-title"
id=
"myModalLabel2"
>
Commit changes
</h4>
</div>
<div
class=
"modal-body"
>
<textarea
rows=
"4"
class=
"form-control"
style=
"width:570px;"
placeholder=
"input change log...."
></textarea>
<textarea
rows=
"4"
class=
"form-control"
style=
"width:570px;"
placeholder=
"input change log...."
ng-model=
"commitComment"
></textarea>
</div>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
ng-click=
"commitChange()"
>
提交
</button>
...
...
apollo-portal/src/main/resources/static/views/create-app.html
浏览文件 @
108034f4
...
...
@@ -38,17 +38,16 @@
<input
type=
"text"
class=
"form-control"
name=
"appName"
ng-model=
"app.name"
required
>
</div>
</div>
<!--接入sso之后将会去除-->
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
Owner
</label>
<label
class=
"col-sm-2 control-label"
>
<font
style=
"color: red"
>
*
</font>
应用
Owner
</label>
<div
class=
"col-sm-3"
>
<input
type=
"text"
class=
"form-control"
name=
"appOwner"
ng-model=
"app.ownerName"
>
<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"
>
邮箱地址
</label>
<label
class=
"col-sm-2 control-label"
>
<font
style=
"color: red"
>
*
</font>
邮箱地址
</label>
<div
class=
"col-sm-4"
>
<input
type=
"email"
class=
"form-control"
ng-model=
"app.ownerEmail"
>
<input
type=
"email"
class=
"form-control"
ng-model=
"app.ownerEmail"
required
>
</div>
</div>
...
...
apollo-portal/src/test/java/com/ctrip/apollo/portal/ConfigServiceTest.java
浏览文件 @
108034f4
...
...
@@ -5,7 +5,6 @@ import com.ctrip.apollo.core.dto.ItemDTO;
import
com.ctrip.apollo.core.dto.NamespaceDTO
;
import
com.ctrip.apollo.core.dto.ReleaseDTO
;
import
com.ctrip.apollo.core.enums.Env
;
import
com.ctrip.apollo.core.exception.ServiceException
;
import
com.ctrip.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.apollo.portal.entity.NamespaceVO
;
import
com.ctrip.apollo.portal.entity.form.NamespaceTextModel
;
...
...
@@ -101,22 +100,18 @@ public class ConfigServiceTest extends AbstractPortalTest{
model
.
setNamespaceName
(
namespaceName
);
model
.
setClusterName
(
clusterName
);
model
.
setAppId
(
appId
);
model
.
setConfigText
(
"a=b\nb=c\nc=d"
);
model
.
setConfigText
(
"a=b\nb=c\nc=d\nd=e"
);
List
<
ItemDTO
>
itemDTOs
=
mockBaseItemHas3Key
();
ItemChangeSets
changeSets
=
new
ItemChangeSets
();
changeSets
.
addCreateItem
(
new
ItemDTO
(
"d"
,
"c"
,
""
,
4
));
when
(
itemAPI
.
findItems
(
appId
,
Env
.
DEV
,
clusterName
,
namespaceName
)).
thenReturn
(
itemDTOs
);
when
(
resolver
.
resolve
(
0
,
model
.
getConfigText
(),
itemDTOs
)).
thenReturn
(
changeSets
);
try
{
// 调用itemAPI.updateConfig 会抛出ServiceException.
// itemAPI.updateConfig ut 放在admin service.
// 所以只要在调用itemAPI.updateConfig前全部通过,此ut应该通过.
configService
.
updateConfigItemByText
(
model
);
}
catch
(
Exception
e
){
Assert
.
assertTrue
(
e
instanceof
ServiceException
);
Assert
.
fail
(
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录