/** * 任务状态修改 * PUT /task/1 * @method PUT_info * @author NewFuture */ public function PUT_infoAction($id = 0) { $userid = $this->auth(); if ($Task = TaskModel::where('use_id', $userid)->where('status', 1)->find(intval($id))) { $task = TaskModel::create('put'); if ($Task->update($task)) { $this->response(1, '成功修改'); } else { $this->response(0, '修改失败'); } } else { $this->response(0, '该任务不存在'); } }
/** * 删除 * POST /share/123/print * @method 添加打印任务 * @author NewFuture */ public function POST_printAction($id = 0) { $userid = $this->auth(); $response['status'] = 0; if (!($share = ShareModel::where('status', '>', 0)->field('name,url')->find())) { $response['info'] = '此分享已经删除!'; } elseif (!Input::post('pid', $pid, 'int')) { $response['info'] = '请选择打印店!'; } else { $task = TaskModel::create('post'); $task['use_id'] = $userid; $task['pid'] = $pid; $task['url'] = File::addTask($share['url']); $task['name'] = $share['name']; if (!($tid = TaskModel::insert($task))) { $response['info'] = '任务添加失败'; } else { $response['status'] = 1; $response['info'] = ['msg' => '任务添加成功', 'id' => $tid]; } } $this->response = $response; }
/** * 打印文件 * POST /file/:id/print * @method */ public function POST_printAction($id) { $userid = $this->auth(); $response['status'] = 0; if (!($id = intval($id))) { $response['info'] = '未选择文件'; } elseif (!Input::post('pid', $pid, 'int')) { $response['info'] = '未选择打印店'; } elseif (!($file = FileModel::where('use_id', $userid)->where('status', '>', 0)->field('url,name,status')->find($id))) { $response['info'] = '没有该文件或者此文件已经删除'; } else { $task = TaskModel::create('post'); $task['name'] = $file['name']; $task['use_id'] = $userid; $task['pri_id'] = $pid; if (!($task['url'] = File::addTask($file['url']))) { $response['info'] = '文件转换出错'; } elseif (!($tid = TaskModel::insert($task))) { $response['info'] = '任务添加失败'; } else { $response['status'] = 1; $response['info'] = ['msg' => '打印任务添加成功', 'id' => $tid, 'name' => $file['name']]; } } $this->response = $response; }