Module: JPSClient::API::Category

Included in:
Client
Defined in:
lib/jpsclient/api/category.rb

Overview

Category 相关 API 通用分类管理接口 (/api/category,分类 controller)

Instance Method Summary collapse

Instance Method Details

#create_category(params: {}) ⇒ Hash

创建分类

Parameters:

  • params (Hash) (defaults to: {})

    CategoryCreateDto: type*, name*, parentId, priority, description, medias, platform

Returns:

  • (Hash)

    API响应,data: Category

Raises:



37
38
39
40
41
42
43
44
# File 'lib/jpsclient/api/category.rb', line 37

def create_category(params: {})
  config = @request_config && @request_config["category_create"]
  raise JPSClient::ExceptionError, "Missing config for category_create" unless config && config["url"]

  path = config["url"]

  return request_with_auth(:post, path, body: params)
end

#delete_category(params: {}) ⇒ Hash

删除分类

Parameters:

  • params (Hash) (defaults to: {})

    BaseIdDtoInteger: id*

Returns:

  • (Hash)

    API响应

Raises:



63
64
65
66
67
68
69
70
# File 'lib/jpsclient/api/category.rb', line 63

def delete_category(params: {})
  config = @request_config && @request_config["category_delete"]
  raise JPSClient::ExceptionError, "Missing config for category_delete" unless config && config["url"]

  path = config["url"]

  return request_with_auth(:post, path, body: params)
end

#get_category_list(params: {}) ⇒ Hash

分类列表

Parameters:

  • params (Hash) (defaults to: {})

    CategoryListDto: type(分类类型), platforms(平台,可多个)

Returns:

  • (Hash)

    API响应,data: { list: [Category], count }

Raises:



11
12
13
14
15
16
17
18
# File 'lib/jpsclient/api/category.rb', line 11

def get_category_list(params: {})
  config = @request_config && @request_config["category_list"]
  raise JPSClient::ExceptionError, "Missing config for category_list" unless config && config["url"]

  path = config["url"]

  return request_with_auth(:get, path, params: params)
end

#get_category_tree(params: {}) ⇒ Hash

分类树

Parameters:

  • params (Hash) (defaults to: {})

    CategoryListDto: type(分类类型), platforms(平台,可多个)

Returns:

  • (Hash)

    API响应,data: [CategoryTreeVo]

Raises:



24
25
26
27
28
29
30
31
# File 'lib/jpsclient/api/category.rb', line 24

def get_category_tree(params: {})
  config = @request_config && @request_config["category_tree"]
  raise JPSClient::ExceptionError, "Missing config for category_tree" unless config && config["url"]

  path = config["url"]

  return request_with_auth(:get, path, params: params)
end

#sort_categories(params: []) ⇒ Hash

分类排序

Parameters:

  • params (Array) (defaults to: [])

    CategorySortDto 数组,每项: id*, weight*, parentId(前端以裸数组体提交)

Returns:

  • (Hash)

    API响应

Raises:



76
77
78
79
80
81
82
83
# File 'lib/jpsclient/api/category.rb', line 76

def sort_categories(params: [])
  config = @request_config && @request_config["category_sort"]
  raise JPSClient::ExceptionError, "Missing config for category_sort" unless config && config["url"]

  path = config["url"]

  return request_with_auth(:post, path, body: params)
end

#update_category(params: {}) ⇒ Hash

更新分类

Parameters:

  • params (Hash) (defaults to: {})

    CategoryUpdateDto: id*, parentId, priority, name, weight, medias, description

Returns:

  • (Hash)

    API响应,data: Category

Raises:



50
51
52
53
54
55
56
57
# File 'lib/jpsclient/api/category.rb', line 50

def update_category(params: {})
  config = @request_config && @request_config["category_update"]
  raise JPSClient::ExceptionError, "Missing config for category_update" unless config && config["url"]

  path = config["url"]

  return request_with_auth(:post, path, body: params)
end