优化代码
parent
0f18655569
commit
c1465d9963
|
@ -9,7 +9,7 @@ Lumen-IM 是一个网页版在线即时聊天项目,前端使用 Element-ui +
|
|||
- 基于 Swoole WebSocket 服务做消息即时推送
|
||||
- 支持私聊及群聊
|
||||
- 支持聊天消息类型有文本、代码块、图片及其它类型文件,并支持文件下载
|
||||
- 支持聊天消息撤回、删除或批量删除、转发消息(逐条转发、合并转发)
|
||||
- 支持聊天消息撤回、删除或批量删除、转发消息(逐条转发、合并转发)及群投票功能
|
||||
- 支持编写个人笔记、支持笔记分享(好友或群)
|
||||
|
||||
## 2、项目DEMO
|
||||
|
|
|
@ -35,7 +35,7 @@ class AppExceptionHandler extends ExceptionHandler
|
|||
$data = json_encode([
|
||||
'code' => ResponseCode::SERVER_ERROR,
|
||||
'error' => $isDev ? $throwable->getMessage() : 'Internal Server Error.',
|
||||
'traces' => $isDev ? $throwable->getTrace() : [],
|
||||
'traces' => $isDev ? $throwable->getLine() : [],
|
||||
], JSON_UNESCAPED_UNICODE);
|
||||
|
||||
!$isDev && $this->sendAdminEmail($throwable);
|
||||
|
|
|
@ -12,7 +12,6 @@ use App\Constants\TalkMessageType;
|
|||
use App\Constants\TalkModeConstant;
|
||||
use App\Event\TalkEvent;
|
||||
use App\Model\Group\GroupMember;
|
||||
use App\Model\Talk\TalkList;
|
||||
use App\Model\Talk\TalkRecordsCode;
|
||||
use App\Model\Talk\TalkRecordsLogin;
|
||||
use App\Model\Talk\TalkRecordsVote;
|
||||
|
@ -32,7 +31,7 @@ class TalkMessageService
|
|||
* @param array $message
|
||||
* @return bool
|
||||
*/
|
||||
public function insertTextMessage(array $message)
|
||||
public function insertTextMessage(array $message): bool
|
||||
{
|
||||
$message['msg_type'] = TalkMessageType::TEXT_MESSAGE;
|
||||
$message['content'] = htmlspecialchars($message['content']);
|
||||
|
@ -70,7 +69,7 @@ class TalkMessageService
|
|||
* @param array $code
|
||||
* @return bool
|
||||
*/
|
||||
public function insertCodeMessage(array $message, array $code)
|
||||
public function insertCodeMessage(array $message, array $code): bool
|
||||
{
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
|
@ -117,7 +116,7 @@ class TalkMessageService
|
|||
* @param array $file
|
||||
* @return bool
|
||||
*/
|
||||
public function insertFileMessage(array $message, array $file)
|
||||
public function insertFileMessage(array $message, array $file): bool
|
||||
{
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
|
@ -165,7 +164,7 @@ class TalkMessageService
|
|||
* @param array $vote
|
||||
* @return bool
|
||||
*/
|
||||
public function insertVoteMessage(array $message, array $vote)
|
||||
public function insertVoteMessage(array $message, array $vote): bool
|
||||
{
|
||||
$answer_num = GroupMember::where('group_id', $message['receiver_id'])->where('is_quit', 0)->count();
|
||||
|
||||
|
@ -216,7 +215,7 @@ class TalkMessageService
|
|||
*
|
||||
* @param int $user_id
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @return array
|
||||
*/
|
||||
public function handleVote(int $user_id, array $params): array
|
||||
{
|
||||
|
@ -230,7 +229,7 @@ class TalkMessageService
|
|||
'vote.id as vote_id', 'vote.answer_mode', 'vote.answer_option', 'vote.answer_num', 'vote.status as vote_status'
|
||||
]);
|
||||
|
||||
if (!$record) return false;
|
||||
if (!$record) return [false, []];
|
||||
|
||||
if ($record->msg_type != TalkMessageType::VOTE_MESSAGE) {
|
||||
return [false, []];
|
||||
|
@ -294,7 +293,7 @@ class TalkMessageService
|
|||
* @param array $loginParams
|
||||
* @return bool
|
||||
*/
|
||||
public function insertLoginMessage(array $message, array $loginParams)
|
||||
public function insertLoginMessage(array $message, array $loginParams): bool
|
||||
{
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
|
|
|
@ -16,7 +16,7 @@ class CreateArticleTable extends Migration
|
|||
$table->unsignedInteger('id', true)->comment('笔记ID');
|
||||
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
|
||||
$table->unsignedInteger('class_id')->default(0)->comment('分类ID');
|
||||
$table->string('tags_id', 20)->default('')->comment('笔记关联标签');
|
||||
$table->string('tags_id', 100)->default('')->comment('笔记关联标签');
|
||||
$table->string('title', 80)->default('')->charset('utf8mb4')->comment('笔记标题');
|
||||
$table->string('abstract', 200)->default('')->charset('utf8mb4')->comment('笔记摘要');
|
||||
$table->string('image', 255)->default('')->comment('笔记首图');
|
||||
|
|
Loading…
Reference in New Issue