12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- <?php
- namespace app\sys\controller;
- use app\model\Backup as BackupModel;
- use think\facade\Request;
- /**
- * 获取表单缓存信息
- * Class Backup
- * @package app\sys\controller
- */
- class Backup
- {
- /**
- * 获取历史缓存
- * @return \think\response\Json
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function content(){
- $employee_id = request()->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]]);
- }
- }
|