优化代码
parent
e5359a27d3
commit
cfc748b259
|
@ -71,7 +71,7 @@ class DownloadController extends CController
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileInfo = ChatRecordsFile::select(['save_dir', 'original_name'])->where('record_id', $params['cr_id'])->first();
|
$fileInfo = ChatRecordsFile::select(['save_dir', 'original_name'])->where('record_id', $params['cr_id'])->first();
|
||||||
if (!$fileInfo) {
|
if (!$fileInfo || !file_exists($uploadService->driver($fileInfo->save_dir))) {
|
||||||
return $this->response->fail('文件不存在或没有下载权限...');
|
return $this->response->fail('文件不存在或没有下载权限...');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class DownloadController extends CController
|
||||||
->where('user_id', $this->uid())
|
->where('user_id', $this->uid())
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (!$info) {
|
if (!$info || !file_exists($uploadService->driver($info->save_dir))) {
|
||||||
return $this->response->fail('文件不存在或没有下载权限...');
|
return $this->response->fail('文件不存在或没有下载权限...');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,12 @@ SQL;
|
||||||
->where('friend_id', $friend_id)
|
->where('friend_id', $friend_id)
|
||||||
->orderBy('id', 'desc')->first();
|
->orderBy('id', 'desc')->first();
|
||||||
|
|
||||||
if (!$result) {
|
if ($result && $result->status == 0) {
|
||||||
|
$result->remarks = $remarks;
|
||||||
|
$result->updated_at = date('Y-m-d H:i:s');
|
||||||
|
$result->save();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
$result = UsersFriendsApply::create([
|
$result = UsersFriendsApply::create([
|
||||||
'user_id' => $user_id,
|
'user_id' => $user_id,
|
||||||
'friend_id' => $friend_id,
|
'friend_id' => $friend_id,
|
||||||
|
@ -86,15 +91,7 @@ SQL;
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $result ? true : false;
|
return $result ? true : false;
|
||||||
} else if ($result->status == 0) {
|
|
||||||
$result->remarks = $remarks;
|
|
||||||
$result->updated_at = date('Y-m-d H:i:s');
|
|
||||||
$result->save();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue