Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
superrain51
apollo
提交
a91fce64
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,发现更多精彩内容 >>
提交
a91fce64
编写于
8月 11, 2016
作者:
L
lepdou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
open api item 用key当主键
上级
03609414
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
27 addition
and
22 deletion
+27
-22
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java
...ramework/apollo/openapi/v1/controller/ItemController.java
+22
-18
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+3
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ItemService.java
...om/ctrip/framework/apollo/portal/service/ItemService.java
+2
-2
未找到文件。
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java
浏览文件 @
a91fce64
...
...
@@ -35,8 +35,7 @@ public class ItemController {
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName)"
)
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
method
=
RequestMethod
.
POST
)
public
OpenItemDTO
createItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestBody
OpenItemDTO
item
,
HttpServletRequest
request
)
{
RequestPrecondition
.
checkArguments
(
...
...
@@ -60,48 +59,53 @@ public class ItemController {
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName)"
)
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{
itemId
}"
,
method
=
RequestMethod
.
PUT
)
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{
key:.+
}"
,
method
=
RequestMethod
.
PUT
)
public
void
updateItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
long
itemId
,
@RequestBody
OpenItemDTO
item
,
HttpServletRequest
request
)
{
@PathVariable
String
key
,
@RequestBody
OpenItemDTO
item
,
HttpServletRequest
request
)
{
RequestPrecondition
.
checkArguments
(
item
!=
null
,
"item payload can not be empty"
);
RequestPrecondition
.
checkArguments
(
item
!=
null
&&
item
.
getId
()
>
0
&&
itemId
==
item
.
getId
(),
"item data error"
);
RequestPrecondition
.
checkArguments
(
!
StringUtils
.
isContainEmpty
(
item
.
getKey
(),
item
.
getValue
(),
item
.
getDataChangeLastModifiedBy
()),
!
StringUtils
.
isContainEmpty
(
item
.
getKey
(),
item
.
getValue
(),
item
.
getDataChangeLastModifiedBy
()),
"key,value,dataChangeLastModifiedBy 字段不能为空"
);
RequestPrecondition
.
checkArguments
(
item
.
getKey
().
equals
(
key
),
"item payload can not be empty"
);
if
(
userService
.
findByUserId
(
item
.
getDataChangeLastModifiedBy
())
==
null
)
{
throw
new
BadRequestException
(
"用户不存在
.
"
);
throw
new
BadRequestException
(
"用户不存在"
);
}
ItemDTO
toUpdateItem
=
itemService
.
loadItem
(
Env
.
fromString
(
env
),
itemId
);
ItemDTO
toUpdateItem
=
itemService
.
loadItem
(
Env
.
fromString
(
env
),
appId
,
clusterName
,
namespaceName
,
item
.
getKey
()
);
if
(
toUpdateItem
==
null
)
{
throw
new
BadRequestException
(
"item
not exist
"
);
throw
new
BadRequestException
(
"item
不存在
"
);
}
//protect. only value,comment,lastModifiedBy can be modified
toUpdateItem
.
setComment
(
item
.
getComment
());
toUpdateItem
.
setValue
(
item
.
getValue
());
toUpdateItem
.
setDataChangeLastModifiedBy
(
item
.
getDataChangeLastModifiedBy
());
itemService
.
updateItem
(
appId
,
Env
.
fromString
(
env
),
clusterName
,
namespaceName
,
toUpdateItem
);
itemService
.
updateItem
(
appId
,
Env
.
fromString
(
env
),
clusterName
,
namespaceName
,
toUpdateItem
);
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName)"
)
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{
itemId
}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{
key:.+
}"
,
method
=
RequestMethod
.
DELETE
)
public
void
deleteItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
long
itemId
,
@RequestParam
String
operator
,
@PathVariable
String
key
,
@RequestParam
String
operator
,
HttpServletRequest
request
)
{
if
(
userService
.
findByUserId
(
operator
)
==
null
)
{
throw
new
BadRequestException
(
"用户不存在."
);
throw
new
BadRequestException
(
"用户不存在"
);
}
ItemDTO
toDeletedItem
=
itemService
.
loadItem
(
Env
.
valueOf
(
env
),
appId
,
clusterName
,
namespaceName
,
key
);
if
(
toDeletedItem
==
null
){
throw
new
BadRequestException
(
"item不存在"
);
}
itemService
.
deleteItem
(
Env
.
fromString
(
env
),
itemId
,
operator
);
itemService
.
deleteItem
(
Env
.
fromString
(
env
),
toDeletedItem
.
getId
(),
operator
);
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
浏览文件 @
a91fce64
...
...
@@ -90,8 +90,9 @@ public class AdminServiceAPI {
return
Arrays
.
asList
(
itemDTOs
);
}
public
ItemDTO
loadItem
(
Env
env
,
long
itemId
)
{
return
restTemplate
.
get
(
env
,
"/items/{itemId}"
,
ItemDTO
.
class
,
itemId
);
public
ItemDTO
loadItem
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
,
String
key
)
{
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key}"
,
ItemDTO
.
class
,
appId
,
clusterName
,
namespaceName
,
key
);
}
public
void
updateItemsByChangeSet
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespace
,
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ItemService.java
浏览文件 @
a91fce64
...
...
@@ -114,8 +114,8 @@ public class ItemService {
return
itemAPI
.
findItems
(
appId
,
env
,
clusterName
,
namespaceName
);
}
public
ItemDTO
loadItem
(
Env
env
,
long
itemId
)
{
return
itemAPI
.
loadItem
(
env
,
itemId
);
public
ItemDTO
loadItem
(
Env
env
,
String
appId
,
String
clusterName
,
String
namespaceName
,
String
key
)
{
return
itemAPI
.
loadItem
(
env
,
appId
,
clusterName
,
namespaceName
,
key
);
}
public
void
syncItems
(
List
<
NamespaceIdentifier
>
comparedNamespaces
,
List
<
ItemDTO
>
sourceItems
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录