Class: TaskManager::Api::V1::TasksController
- Inherits:
-
TaskManager::ApplicationController
- Object
- ActionController::Base
- TaskManager::ApplicationController
- TaskManager::Api::V1::TasksController
- Defined in:
- app/controllers/task_manager/api/v1/tasks_controller.rb
Instance Method Summary collapse
-
#destroy ⇒ Object
删除任务.
-
#index ⇒ Object
查询任务.
Instance Method Details
#destroy ⇒ Object
删除任务
69 70 71 72 73 |
# File 'app/controllers/task_manager/api/v1/tasks_controller.rb', line 69 def destroy task.destroy head :no_content end |
#index ⇒ Object
查询任务
支持的查询属性有:
name 任务名
task_type 任务类型
deadline 截止时间
status 状态
updated_at 完成时间
支持的查询操作参见 github.com/ernie/ransack/wiki/Basic-Searching
分页查询参数:
page 请求的页码,缺省值1
limit 每页记录数,缺省值25
47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/task_manager/api/v1/tasks_controller.rb', line 47 def index tasks = TaskManager::Task.search(params[:q]).result.order('id DESC') result = { total: tasks.count, tasks: ActiveModel::ArraySerializer.new( tasks.page(params[:page]).per(params[:limit]) ).as_json } render json: result, status: :ok end |