employee->id; $where[] = ['employee_id', '=', $employee_id]; $type = input('type', '', 'trim'); if (empty($type)) return json(['code'=> 0, 'data'=> [], 'msg'=> '获取成功']); $where[] = ['pipe_type', '=', $type]; $find = BackupModel::where($where)->findOrEmpty(); $content = []; if (!$find->isEmpty()){ $content = $find['content']; } return json(['code'=> 0, 'msg'=> '获取成功', 'data'=> $content]); } /** * 缓存 */ public function save(){ $employee_id = request()->employee->id; $where[] = ['employee_id', '=', $employee_id]; $type = input('type', '', 'trim'); if (empty($type)) return json(['code'=> 0, 'msg'=> '操作成功']); $where[] = ['pipe_type', '=', $type]; $find = BackupModel::where($where)->findOrEmpty(); $content = input('content', '', 'trim'); if ($find->isEmpty()) { $data['employee_id'] = $employee_id; $data['pipe_type'] = $type; $data['content'] = $content; BackupModel::create($data); } else { $find->content = $content; $find->addtime = date('Y-m-d H:i:s'); $find->save(); } return json(['code'=> 0, 'msg'=> '操作成功']); } /** * 文件备份上传 */ public function upload(){ $ali_oss_bindurl = config('app.ali_oss_bindurl'); $url = 'https://' . $ali_oss_bindurl . '/' . Request::param('file'); return json(['code' => 0, 'data' => ['src' => $url]]); } }