优化代码
parent
e5359a27d3
commit
cfc748b259
|
@ -57,7 +57,7 @@ class DownloadController extends CController
|
|||
|
||||
$user_id = $this->uid();
|
||||
|
||||
//判断消息是否是当前用户发送(如果是则跳过权限验证)
|
||||
// 判断消息是否是当前用户发送(如果是则跳过权限验证)
|
||||
if ($recordsInfo->user_id != $user_id) {
|
||||
if ($recordsInfo->source == 1) {
|
||||
if ($recordsInfo->receive_id != $user_id) {
|
||||
|
@ -71,7 +71,7 @@ class DownloadController extends CController
|
|||
}
|
||||
|
||||
$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('文件不存在或没有下载权限...');
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class DownloadController extends CController
|
|||
->where('user_id', $this->uid())
|
||||
->first();
|
||||
|
||||
if (!$info) {
|
||||
if (!$info || !file_exists($uploadService->driver($info->save_dir))) {
|
||||
return $this->response->fail('文件不存在或没有下载权限...');
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,12 @@ SQL;
|
|||
->where('friend_id', $friend_id)
|
||||
->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([
|
||||
'user_id' => $user_id,
|
||||
'friend_id' => $friend_id,
|
||||
|
@ -86,15 +91,7 @@ SQL;
|
|||
]);
|
||||
|
||||
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