Skip to content

Commit

Permalink
Merge pull request #2 from mycolorway/TWR002
Browse files Browse the repository at this point in the history
CHG: 调整接口调用的配置方式
  • Loading branch information
seandong authored Apr 23, 2023
2 parents aeaea28 + 9857105 commit e6fe1a4
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ Ones.configure do |config|
# Ones 应用中心配置
config.default_client_id = 'xxx' # 应用 client ID
config.default_client_secret = 'xxx' # 应用 client secret
config.app_center_base_url = 'http://localhost:3001' # Ones 应用中心 API 地址
config.app_center_base_url = 'http://localhost:3001/project/api/project/' # Ones 应用中心 API 地址

# Ones API 配置
config.api_base_url = 'http://localhost:3001' # Ones API 地址
config.api_base_url = 'http://localhost:3001/project/api/' # Ones API 地址

# 公共配置
config.http_timeout_options = { write: 2, connect: 5, read: 15 } # 请求的 timeout 参数(非必需)
Expand Down
6 changes: 3 additions & 3 deletions lib/ones/apis/attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Apis
module Attachment
# 上传资源
def create(team_uuid, params = {}, header = {})
post "project/api/project/team/#{team_uuid}/res/attachments/upload", {
post "project/team/#{team_uuid}/res/attachments/upload", {
type: :attachment,
ref_type: params[:ref_type].presence || :app,
ref_id: params[:ref_id].presence || client_id,
Expand Down Expand Up @@ -34,9 +34,9 @@ def upload(upload_url, token, file)
def fetch(team_uuid, attachment_uuid, header = {})
base_query = header.delete(:params) || {}
attachment_url = if base_query.present?
"project/api/project/team/#{team_uuid}/res/attachment/#{attachment_uuid}?#{base_query.to_query}"
"project/team/#{team_uuid}/res/attachment/#{attachment_uuid}?#{base_query.to_query}"
else
"project/api/project/team/#{team_uuid}/res/attachment/#{attachment_uuid}"
"project/team/#{team_uuid}/res/attachment/#{attachment_uuid}"
end
get attachment_url, header
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ones/apis/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Auth
# 获取 license 信息
# user.license_types 中 2 代表 wiki,16 代表 ones_task,该字段会变更为字符串
def token_info
get "project/api/project/auth/token_info"
get "project/auth/token_info"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ones/apis/org.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def grant_uuids(org_uuid)
# 当前团队的 Wiki 配置
# 主要关注:wps_config、wiz_config、wiki_config
def stamps_data(org_uuid)
post "project/api/project/organization/#{org_uuid}/stamps/data",
post "project/organization/#{org_uuid}/stamps/data",
{ "org_configs": 0 },
{ params: { t: :organization } }
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ones/apis/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def departments(team_uuid, user_uuids)
end

def queue_list(team_uuid)
get "project/api/project/team/#{team_uuid}/queues/list"
get "project/team/#{team_uuid}/queues/list"
end
end
end
Expand Down
20 changes: 10 additions & 10 deletions lib/ones/apis/wiki/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Page
# PageStructureStatusDeleted = 2
# PageStructureStatusInRecycler = 3
def list(team_uuid, space_uuid, status: 1)
get "project/api/wiki/team/#{team_uuid}/space/#{space_uuid}/pages?status=#{status}"
get "wiki/team/#{team_uuid}/space/#{space_uuid}/pages?status=#{status}"
end

# 检查页面状态
Expand All @@ -18,19 +18,19 @@ def list(team_uuid, space_uuid, status: 1)
# 页面删除
# 若参数中有不存在的页面 uuid,则会报 400 错误
def check_status(team_uuid, page_uuids = [])
post "project/api/wiki/team/#{team_uuid}/check_pages_status",
post "wiki/team/#{team_uuid}/check_pages_status",
{ "page_uuids": page_uuids }
end

# 创建 Wiki 协同页面
def create_wiz(team_uuid, title:, space_uuid:, parent_uuid:)
post "project/api/wiki/team/#{team_uuid}/online_pages/add",
post "wiki/team/#{team_uuid}/online_pages/add",
{ title: title, space_uuid: space_uuid, parent_uuid: parent_uuid }
end

# 创建 Wiki 页面
def create_wiki(team_uuid, title:, space_uuid:, parent_uuid:, content: '', src_type: 'template', src_uuid: '')
post "project/api/wiki/team/#{team_uuid}/space/#{space_uuid}/add_wiki_page",
post "wiki/team/#{team_uuid}/space/#{space_uuid}/add_wiki_page",
{
parent_page_uuid: parent_uuid,
title: title,
Expand All @@ -43,7 +43,7 @@ def create_wiki(team_uuid, title:, space_uuid:, parent_uuid:, content: '', src_t
# 创建 WPS 页面:文稿、表格、幻灯片
# 其中 src_uuid 取值: wps-word、wps-sheet、wps-ppt
def create_wps(team_uuid, title:, space_uuid:, parent_uuid:, src_type: 'template', src_uuid: 'wps-word')
post "project/api/wiki/team/#{team_uuid}/space/#{space_uuid}/page_add",
post "wiki/team/#{team_uuid}/space/#{space_uuid}/page_add",
{
page_uuid: parent_uuid,
title: title,
Expand All @@ -54,30 +54,30 @@ def create_wps(team_uuid, title:, space_uuid:, parent_uuid:, src_type: 'template

# 「异步接口」导入 Wiki 协同页面
def import_wiz(team_uuid, parent_uuid:, resource_uuid:)
post "project/api/wiki/team/#{team_uuid}/word/import",
post "wiki/team/#{team_uuid}/word/import",
{ type: :wiz, ref_id: parent_uuid, resource_uuids: [resource_uuid] }
end


# 「异步接口」导入 Wiki 页面
def import_wiki(team_uuid, parent_uuid:, resource_uuid:)
post "project/api/wiki/team/#{team_uuid}/word/import",
post "wiki/team/#{team_uuid}/word/import",
{ type: :word, ref_id: parent_uuid, resource_uuids: [resource_uuid] }
end


# 「同步接口」导入办公协同文件
def import_wps(team_uuid, space_uuid:, parent_uuid:, resource_uuid:)
post "project/api/wiki/team/#{team_uuid}/space/#{space_uuid}/import_wps",
post "wiki/team/#{team_uuid}/space/#{space_uuid}/import_wps",
{ resource_uuid: resource_uuid, page_uuid: parent_uuid }
end

# 获取与我共享的页面信息
def share_list(team_uuid, share_uuid: nil)
share_url = if share_uuid.present?
"project/api/wiki/team/#{team_uuid}/share/#{share_uuid}/pages"
"wiki/team/#{team_uuid}/share/#{share_uuid}/pages"
else
"project/api/wiki/team/#{team_uuid}/share_all_pages?include_sub_pages=false"
"wiki/team/#{team_uuid}/share_all_pages?include_sub_pages=false"
end
get share_url
end
Expand Down
4 changes: 2 additions & 2 deletions lib/ones/apis/wiki/space.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ module Apis
module Wiki
module Space
def list(team_uuid)
get "project/api/wiki/team/#{team_uuid}/my_spaces"
get "wiki/team/#{team_uuid}/my_spaces"
end

def templates(team_uuid, space_uuid)
get "project/api/wiki/team/#{team_uuid}/space/#{space_uuid}/templates"
get "wiki/team/#{team_uuid}/space/#{space_uuid}/templates"
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/ones/apis/wiki/team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@ module Team
# view_page: 查看权限
# create_page: 编辑权限
def evaluated_permissions(team_uuid)
get "project/api/wiki/team/#{team_uuid}/evaluated_permissions"
get "wiki/team/#{team_uuid}/evaluated_permissions"
end

# 全局模版
def templates(team_uuid)
get "project/api/wiki/team/#{team_uuid}/templates"
get "wiki/team/#{team_uuid}/templates"
end

# 最新使用模版
def recent_templates(team_uuid)
get "project/api/wiki/team/#{team_uuid}/recent_templates"
get "wiki/team/#{team_uuid}/recent_templates"
end

# 获取模版信息
def template(team_uuid, template_uuid)
get "project/api/wiki/team/#{team_uuid}/template/#{template_uuid}"
get "wiki/team/#{team_uuid}/template/#{template_uuid}"
end

# 团队创建页面的数量限制
def limit(team_uuid)
get "project/api/wiki/team/#{team_uuid}/team_space_limit"
get "wiki/team/#{team_uuid}/team_space_limit"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ones/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Ones
VERSION = '1.1.0'.freeze
VERSION = '1.2.0'.freeze
end
4 changes: 2 additions & 2 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
Ones.configure do |config|
config.default_client_id = 'some_client_id'
config.default_client_secret = 'this_is_a_client_secret'
config.app_center_base_url = 'http://localhost:3001'
config.app_center_base_url = 'http://localhost:3002/project/api/project/'

config.api_base_url = 'http://localhost:3002'
config.api_base_url = 'http://localhost:3002/project/api/'

config.http_timeout_options = { write: 2, connect: 5, read: 15 }
end
Expand Down

0 comments on commit e6fe1a4

Please sign in to comment.