diff --git a/app/Cache/FriendRemark.php b/app/Cache/FriendRemark.php index 14c7354..c4b6757 100644 --- a/app/Cache/FriendRemark.php +++ b/app/Cache/FriendRemark.php @@ -3,7 +3,7 @@ namespace App\Cache; use App\Cache\Repository\HashRedis; -use App\Model\Contact; +use App\Model\Contact\Contact; /** * 好友备注 - 缓存助手 diff --git a/app/Command/TestCommand.php b/app/Command/TestCommand.php index 996bfe2..c519ec2 100644 --- a/app/Command/TestCommand.php +++ b/app/Command/TestCommand.php @@ -5,7 +5,7 @@ namespace App\Command; use App\Cache\IpAddressCache; use App\Constants\RobotConstant; -use App\Model\Contact; +use App\Model\Contact\Contact; use App\Repository\ExampleRepository; use App\Repository\RobotRepository; use App\Service\RobotService; diff --git a/app/Controller/Api/V1/TalkMessageController.php b/app/Controller/Api/V1/Talk/MessageController.php similarity index 96% rename from app/Controller/Api/V1/TalkMessageController.php rename to app/Controller/Api/V1/Talk/MessageController.php index fd586ba..4e98938 100644 --- a/app/Controller/Api/V1/TalkMessageController.php +++ b/app/Controller/Api/V1/Talk/MessageController.php @@ -1,11 +1,12 @@ request->inputs(['talk_type', 'receiver_id', 'lang', 'code']); + $this->validate($params, [ 'talk_type' => 'required|in:1,2', 'receiver_id' => 'required|integer|min:1', @@ -83,6 +85,7 @@ class TalkMessageController extends CController ]); $user_id = $this->uid(); + if (!UserRelation::isFriendOrGroupMember($user_id, (int)$params['receiver_id'], (int)$params['talk_type'])) { return $this->response->fail('暂不属于好友关系或群聊成员,无法发送聊天消息!'); } @@ -92,9 +95,9 @@ class TalkMessageController extends CController 'user_id' => $user_id, 'receiver_id' => $params['receiver_id'], ], [ - 'user_id' => $user_id, - 'code_lang' => $params['lang'], - 'code' => $params['code'] + 'user_id' => $user_id, + 'lang' => $params['lang'], + 'code' => $params['code'] ]); if (!$isTrue) return $this->response->fail('消息发送失败!'); @@ -110,12 +113,14 @@ class TalkMessageController extends CController public function image(Filesystem $filesystem): ResponseInterface { $params = $this->request->inputs(['talk_type', 'receiver_id']); + $this->validate($params, [ 'talk_type' => 'required|in:1,2', 'receiver_id' => 'required|integer|min:1' ]); $user_id = $this->uid(); + if (!UserRelation::isFriendOrGroupMember($user_id, (int)$params['receiver_id'], (int)$params['talk_type'])) { return $this->response->fail('暂不属于好友关系或群聊成员,无法发送聊天消息!'); } @@ -163,6 +168,7 @@ class TalkMessageController extends CController public function file(Filesystem $filesystem): ResponseInterface { $params = $this->request->inputs(['talk_type', 'receiver_id', 'hash_name']); + $this->validate($params, [ 'talk_type' => 'required|in:1,2', 'receiver_id' => 'required|integer|min:1', @@ -314,11 +320,11 @@ class TalkMessageController extends CController }; if (isset($params['receive_user_ids']) && !empty($params['receive_user_ids'])) { - $receive_user_ids = $func($params['receive_user_ids'], TalkModeConstant::PRIVATE_CHAT); + $receive_user_ids = $func(parse_ids($params['receive_user_ids']), TalkModeConstant::PRIVATE_CHAT); } if (isset($params['receive_group_ids']) && !empty($params['receive_group_ids'])) { - $receive_group_ids = $func($params['receive_group_ids'], TalkModeConstant::GROUP_CHAT); + $receive_group_ids = $func(parse_ids($params['receive_group_ids']), TalkModeConstant::GROUP_CHAT); } // 需要转发的好友或者群组 @@ -326,7 +332,7 @@ class TalkMessageController extends CController $method = $params['forward_mode'] == 1 ? "multiSplitForward" : "multiMergeForward"; - $ids = $forwardService->{$method}($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], $params['records_ids'], $items); + $ids = $forwardService->{$method}($user_id, (int)$params['receiver_id'], (int)$params['talk_type'], parse_ids($params['records_ids']), $items); if (!$ids) return $this->response->fail('转发失败!'); @@ -434,6 +440,7 @@ class TalkMessageController extends CController public function handleVote(): ResponseInterface { $params = $this->request->inputs(['record_id', 'options']); + $this->validate($params, [ 'record_id' => 'required|integer|min:1', 'options' => 'required', diff --git a/app/Controller/Api/V1/Talk/RecordsController.php b/app/Controller/Api/V1/Talk/RecordsController.php new file mode 100644 index 0000000..556edd1 --- /dev/null +++ b/app/Controller/Api/V1/Talk/RecordsController.php @@ -0,0 +1,148 @@ +request->inputs(['talk_type', 'receiver_id', 'record_id']); + + $this->validate($params, [ + 'talk_type' => 'required|in:1,2', + 'receiver_id' => 'required|integer|min:1', + 'record_id' => 'required|integer|min:0', + ]); + + $user_id = $this->uid(); + + if ($params['talk_type'] == TalkModeConstant::GROUP_CHAT && !di()->get(GroupMemberService::class)->isMember((int)$params['receiver_id'], $user_id)) { + return $this->response->fail('暂不属于好友关系或群聊成员,无法查看聊天记录!'); + } + + $limit = 30; + $result = $this->talkService->getChatRecords( + $user_id, + intval($params['receiver_id']), + intval($params['talk_type']), + intval($params['record_id']), + $limit + ); + + return $this->response->success([ + 'rows' => $result, + 'record_id' => $result ? end($result)['id'] : 0, + 'limit' => $limit + ]); + } + + /** + * 查询聊天历史记录 + * + * @RequestMapping(path="history", methods="get") + */ + public function history(): ResponseInterface + { + $params = $this->request->inputs(['talk_type', 'receiver_id', 'record_id', 'msg_type']); + + $this->validate($params, [ + 'talk_type' => 'required|in:1,2', + 'receiver_id' => 'required|integer|min:1', + 'record_id' => 'required|integer|min:0', + 'msg_type' => 'required|integer', + ]); + + $user_id = $this->uid(); + + if ($params['talk_type'] == TalkModeConstant::GROUP_CHAT && !di()->get(GroupMemberService::class)->isMember((int)$params['receiver_id'], $user_id)) { + return $this->response->fail('暂不属于好友关系或群聊成员,无法查看聊天记录!'); + } + + $types = [ + TalkMessageType::TEXT_MESSAGE, + TalkMessageType::FILE_MESSAGE, + TalkMessageType::FORWARD_MESSAGE, + TalkMessageType::CODE_MESSAGE, + TalkMessageType::VOTE_MESSAGE + ]; + + if (in_array($params['msg_type'], $types)) { + $msg_type = [$params['msg_type']]; + } else { + $msg_type = $types; + } + + $limit = 30; + $result = $this->talkService->getChatRecords( + $user_id, + (int)$params['receiver_id'], + (int)$params['talk_type'], + (int)$params['record_id'], + $limit, + $msg_type + ); + + return $this->response->success([ + 'rows' => $result, + 'record_id' => $result ? end($result)['id'] : 0, + 'limit' => $limit + ]); + } + + /** + * 获取转发记录详情 + * + * @RequestMapping(path="forward", methods="get") + */ + public function forwards(): ResponseInterface + { + $params = $this->request->inputs(['record_id']); + + $this->validate($params, [ + 'record_id' => 'required|integer|min:1' + ]); + + $rows = $this->talkService->getForwardRecords($this->uid(), intval($params['record_id'])); + + return $this->response->success(['rows' => $rows]); + } +} diff --git a/app/Controller/Api/V1/TalkController.php b/app/Controller/Api/V1/Talk/TalkController.php similarity index 65% rename from app/Controller/Api/V1/TalkController.php rename to app/Controller/Api/V1/Talk/TalkController.php index 9ac033a..b305ff3 100644 --- a/app/Controller/Api/V1/TalkController.php +++ b/app/Controller/Api/V1/Talk/TalkController.php @@ -1,14 +1,18 @@ response->success(); } - - /** - * 获取对话面板中的聊天记录 - * @RequestMapping(path="records", methods="get") - */ - public function getChatRecords(): ResponseInterface - { - $params = $this->request->inputs(['talk_type', 'receiver_id', 'record_id']); - $this->validate($params, [ - 'talk_type' => 'required|in:1,2', - 'receiver_id' => 'required|integer|min:1', - 'record_id' => 'required|integer|min:0', - ]); - - $user_id = $this->uid(); - - if ($params['talk_type'] == TalkModeConstant::GROUP_CHAT && !di()->get(GroupMemberService::class)->isMember((int)$params['receiver_id'], $user_id)) { - return $this->response->fail('暂不属于好友关系或群聊成员,无法查看聊天记录!'); - } - - $limit = 30; - $result = $this->talkService->getChatRecords( - $user_id, - $params['receiver_id'], - $params['talk_type'], - $params['record_id'], - $limit - ); - - return $this->response->success([ - 'rows' => $result, - 'record_id' => $result ? end($result)['id'] : 0, - 'limit' => $limit - ]); - } - - /** - * 获取转发记录详情 - * @RequestMapping(path="get-forward-records", methods="get") - */ - public function getForwardRecords(): ResponseInterface - { - $params = $this->request->inputs(['record_id']); - $this->validate($params, [ - 'record_id' => 'required|integer|min:1' - ]); - - $rows = $this->talkService->getForwardRecords($this->uid(), $params['record_id']); - - return $this->response->success(['rows' => $rows]); - } - - /** - * 查询聊天记录 - * @RequestMapping(path="find-chat-records", methods="get") - */ - public function findChatRecords(): ResponseInterface - { - $params = $this->request->inputs(['talk_type', 'receiver_id', 'record_id', 'msg_type']); - $this->validate($params, [ - 'talk_type' => 'required|in:1,2', - 'receiver_id' => 'required|integer|min:1', - 'record_id' => 'required|integer|min:0', - 'msg_type' => 'required|integer', - ]); - - $user_id = $this->uid(); - if ($params['talk_type'] == TalkModeConstant::GROUP_CHAT && !di()->get(GroupMemberService::class)->isMember((int)$params['receiver_id'], $user_id)) { - return $this->response->fail('暂不属于好友关系或群聊成员,无法查看聊天记录!'); - } - - $types = [ - TalkMessageType::TEXT_MESSAGE, - TalkMessageType::FILE_MESSAGE, - TalkMessageType::FORWARD_MESSAGE, - TalkMessageType::CODE_MESSAGE, - TalkMessageType::VOTE_MESSAGE - ]; - - if (in_array($params['msg_type'], $types)) { - $msg_type = [$params['msg_type']]; - } else { - $msg_type = $types; - } - - $limit = 30; - $result = $this->talkService->getChatRecords( - $user_id, - $params['receiver_id'], - $params['talk_type'], - $params['record_id'], - $limit, - $msg_type - ); - - return $this->response->success([ - 'rows' => $result, - 'record_id' => $result ? end($result)['id'] : 0, - 'limit' => $limit - ]); - } } diff --git a/app/Model/Article/Article.php b/app/Model/Article/Article.php index 0bfd364..0ce9a98 100644 --- a/app/Model/Article/Article.php +++ b/app/Model/Article/Article.php @@ -30,6 +30,7 @@ class Article extends BaseModel protected $fillable = [ 'user_id', 'class_id', + 'tags_id', 'title', 'abstract', 'image', @@ -37,6 +38,7 @@ class Article extends BaseModel 'status', 'created_at', 'updated_at', + 'deleted_at', ]; protected $casts = [ diff --git a/app/Model/Article/ArticleAnnex.php b/app/Model/Article/ArticleAnnex.php index d54313e..1b2c547 100644 --- a/app/Model/Article/ArticleAnnex.php +++ b/app/Model/Article/ArticleAnnex.php @@ -9,17 +9,19 @@ use App\Model\BaseModel; /** * 笔记附件数据表模型 * - * @property integer $id 笔记附件ID - * @property integer $user_id 用户ID - * @property integer $article_id 笔记ID - * @property integer $drive 文件驱动 - * @property string $file_suffix 文件后缀名 - * @property int $file_size 文件大小 - * @property string $path 文件相对路径 - * @property string $original_name 文件原名 - * @property integer $status 文件状态 - * @property string $created_at 上传时间 - * @property string $deleted_at 删除时间 + * @property int $id 自增ID + * @property int $user_id 用户ID + * @property int $article_id 笔记ID + * @property int $drive 文件驱动 + * @property string $suffix 文件后缀名 + * @property int $size 文件大小 + * @property string $path 文件地址 + * @property string $original_name 文件原名 + * @property int $status 文件状态 + * @property string $created_at 创建时间 + * @property string $updated_at 更新时间 + * @property string $deleted_at 删除时间 + * * @package App\Model\Article */ class ArticleAnnex extends BaseModel diff --git a/app/Model/Article/ArticleClass.php b/app/Model/Article/ArticleClass.php index 6cbb804..93f1403 100644 --- a/app/Model/Article/ArticleClass.php +++ b/app/Model/Article/ArticleClass.php @@ -15,12 +15,12 @@ use App\Model\BaseModel; * @property integer $sort 排序[值越小越靠前] * @property integer $is_default 默认分类[1:是;0:不是] * @property string $created_at 创建时间 + * @property string $updated_at 更新时间 + * * @package App\Model\Article */ class ArticleClass extends BaseModel { - - protected $table = 'article_class'; public $timestamps = true; diff --git a/app/Model/Article/ArticleDetail.php b/app/Model/Article/ArticleDetail.php index d34714e..3329988 100644 --- a/app/Model/Article/ArticleDetail.php +++ b/app/Model/Article/ArticleDetail.php @@ -13,6 +13,7 @@ use App\Model\BaseModel; * @property integer $article_id 笔记ID * @property string $md_content 笔记MD格式内容 * @property string $content 笔记html格式内容 + * * @package App\Model\Article */ class ArticleDetail extends BaseModel diff --git a/app/Model/Article/ArticleTag.php b/app/Model/Article/ArticleTag.php index e4e47b9..b5115d5 100644 --- a/app/Model/Article/ArticleTag.php +++ b/app/Model/Article/ArticleTag.php @@ -14,6 +14,7 @@ use App\Model\BaseModel; * @property string $tag_name 标签名称 * @property integer $sort 标签排序 * @property integer $created_at 创建时间 + * @property integer $updated_at 更新时间 */ class ArticleTag extends BaseModel { diff --git a/app/Model/Contact.php b/app/Model/Contact/Contact.php similarity index 94% rename from app/Model/Contact.php rename to app/Model/Contact/Contact.php index 846b781..587950b 100644 --- a/app/Model/Contact.php +++ b/app/Model/Contact/Contact.php @@ -2,9 +2,9 @@ declare (strict_types=1); -namespace App\Model; +namespace App\Model\Contact; -use App\Cache\FriendRemark; +use App\Model\BaseModel; /** * 表情包收藏数据表模型 diff --git a/app/Model/ContactApply.php b/app/Model/Contact/ContactApply.php similarity index 92% rename from app/Model/ContactApply.php rename to app/Model/Contact/ContactApply.php index 4d6d8d5..6337a2a 100644 --- a/app/Model/ContactApply.php +++ b/app/Model/Contact/ContactApply.php @@ -2,7 +2,9 @@ declare (strict_types=1); -namespace App\Model; +namespace App\Model\Contact; + +use App\Model\BaseModel; /** * 好友添加申请数据表模型 @@ -23,7 +25,6 @@ class ContactApply extends BaseModel 'friend_id', 'remark', 'created_at', - 'updated_at' ]; protected $casts = [ diff --git a/app/Model/Group/Group.php b/app/Model/Group/Group.php index ce42439..4ab48cc 100644 --- a/app/Model/Group/Group.php +++ b/app/Model/Group/Group.php @@ -19,6 +19,7 @@ use App\Model\BaseModel; * @property integer $is_dismiss 是否已解散[0:否;1:是;] * @property string $created_at 创建时间 * @property string $dismissed_at 解散时间 + * * @package App\Model\Group */ class Group extends BaseModel diff --git a/app/Model/Talk/TalkRecordsCode.php b/app/Model/Talk/TalkRecordsCode.php index d3fe8b0..7b96490 100644 --- a/app/Model/Talk/TalkRecordsCode.php +++ b/app/Model/Talk/TalkRecordsCode.php @@ -12,7 +12,7 @@ use App\Model\BaseModel; * @property int $id 代码块ID * @property int $record_id 聊天记录ID * @property int $user_id 用户ID - * @property string $code_lang 代码语言 + * @property string $lang 代码语言 * @property string $code 代码详情 * @property string $created_at 创建时间 * @package App\Model\Chat @@ -24,7 +24,7 @@ class TalkRecordsCode extends BaseModel protected $fillable = [ 'record_id', 'user_id', - 'code_lang', + 'lang', 'code', 'created_at' ]; diff --git a/app/Model/Talk/TalkRecordsFile.php b/app/Model/Talk/TalkRecordsFile.php index d6ce715..3d44a0e 100644 --- a/app/Model/Talk/TalkRecordsFile.php +++ b/app/Model/Talk/TalkRecordsFile.php @@ -12,14 +12,13 @@ use App\Model\BaseModel; * @property int $id 文件消息ID * @property int $record_id 聊天记录ID * @property int $user_id 用户ID - * @property int $file_source 文件上传来源 - * @property int $file_type 文件类型 - * @property int $save_type 文件保存类型 + * @property int $source 文件上传来源 + * @property int $type 文件类型 + * @property int $drive 文件保存类型 * @property string $original_name 文件原始名称 - * @property string $file_suffix 文件后缀名 - * @property int $file_size 文件大小 - * @property string $save_dir 文件保存路径 - * @property int $is_delete 是否已删除 + * @property string $suffix 文件后缀名 + * @property int $size 文件大小 + * @property string $path 文件保存路径 * @property string $created_at 上传时间 * @package App\Model\Chat */ @@ -30,25 +29,23 @@ class TalkRecordsFile extends BaseModel protected $fillable = [ 'record_id', 'user_id', - 'file_source', - 'file_type', - 'save_type', + 'source', + 'type', + 'drive', 'original_name', - 'file_suffix', - 'file_size', - 'save_dir', - 'is_delete', + 'suffix', + 'size', + 'path', 'created_at' ]; protected $casts = [ - 'record_id' => 'integer', - 'user_id' => 'integer', - 'file_source' => 'integer', - 'file_type' => 'integer', - 'save_type' => 'integer', - 'file_size' => 'integer', - 'is_delete' => 'integer', - 'created_at' => 'datetime' + 'record_id' => 'integer', + 'user_id' => 'integer', + 'source' => 'integer', + 'type' => 'integer', + 'drive' => 'integer', + 'size' => 'integer', + 'created_at' => 'datetime' ]; } diff --git a/app/Process/RedisWebsocketSubscribe.php b/app/Process/RedisWebsocketSubscribe.php index ef0d45d..19492d9 100644 --- a/app/Process/RedisWebsocketSubscribe.php +++ b/app/Process/RedisWebsocketSubscribe.php @@ -50,6 +50,8 @@ class RedisWebsocketSubscribe extends AbstractProcess //echo PHP_EOL . "chan : $chan , msg : $message"; $data = json_decode($message, true); + var_dump("subscribe ====> {$message}"); + $this->handleService->handle($data); } } diff --git a/app/Service/ContactApplyService.php b/app/Service/ContactApplyService.php index 27c7550..28b1ad8 100644 --- a/app/Service/ContactApplyService.php +++ b/app/Service/ContactApplyService.php @@ -6,8 +6,8 @@ use App\Cache\FriendApply; use App\Constants\TalkEventConstant; use App\Event\TalkEvent; use App\Model\User; -use App\Model\Contact; -use App\Model\ContactApply; +use App\Model\Contact\Contact; +use App\Model\Contact\ContactApply; use App\Traits\PagingTrait; use Hyperf\DbConnection\Db; diff --git a/app/Service/Message/FormatMessageService.php b/app/Service/Message/FormatMessageService.php index 0f4db08..50adb6f 100644 --- a/app/Service/Message/FormatMessageService.php +++ b/app/Service/Message/FormatMessageService.php @@ -96,8 +96,8 @@ class FormatMessageService // 查询聊天文件信息 if ($files) { $files = TalkRecordsFile::whereIn('record_id', $files)->get([ - 'id', 'record_id', 'user_id', 'file_source', 'file_type', 'save_type', - 'original_name', 'file_suffix', 'file_size', 'save_dir' + 'id', 'record_id', 'user_id', 'source', 'type', 'drive', + 'original_name', 'suffix', 'size', 'path' ])->keyBy('record_id')->toArray(); } @@ -111,7 +111,7 @@ class FormatMessageService // 查询代码块消息 if ($codes) { $codes = TalkRecordsCode::whereIn('record_id', $codes)->get([ - 'record_id', 'code_lang', 'code' + 'record_id', 'lang', 'code' ])->keyBy('record_id')->toArray(); } @@ -149,7 +149,7 @@ class FormatMessageService case TalkMessageType::FILE_MESSAGE: $rows[$k]['file'] = $files[$row['id']] ?? []; if ($rows[$k]['file']) { - $rows[$k]['file']['file_url'] = get_media_url($rows[$k]['file']['save_dir']); + $rows[$k]['file']['file_url'] = get_media_url($rows[$k]['file']['path']); } break; diff --git a/app/Service/Message/SubscribeHandleService.php b/app/Service/Message/SubscribeHandleService.php index b7119a0..0704c5a 100644 --- a/app/Service/Message/SubscribeHandleService.php +++ b/app/Service/Message/SubscribeHandleService.php @@ -49,14 +49,14 @@ class SubscribeHandleService /** * @param array $data 数据 - *
-     * [
-     * 'uuid'    => '',
-     * 'event'   => '',
-     * 'data'    => '',
-     * 'options' => ''
-     * ];
-     * 
+ *
+     *                    [
+     *                    'uuid'    => '',
+     *                    'event'   => '',
+     *                    'data'    => '',
+     *                    'options' => ''
+     *                    ];
+     *                    
*/ public function handle(array $data) { @@ -120,7 +120,8 @@ class SubscribeHandleService if (!$result) return; $message = di()->get(FormatMessageService::class)->handleChatRecords([$result->toArray()])[0]; - $push = [ + + $this->push($fds, $this->toJson(TalkEventConstant::EVENT_TALK, [ 'sender_id' => $sender_id, 'receiver_id' => $receiver_id, 'talk_type' => $talk_type, @@ -128,9 +129,7 @@ class SubscribeHandleService 'group_name' => $groupInfo ? $groupInfo['group_name'] : '', 'group_avatar' => $groupInfo ? $groupInfo['avatar'] : '' ]) - ]; - - $this->push($fds, json_encode([TalkEventConstant::EVENT_TALK, $push])); + ])); } /** @@ -142,7 +141,7 @@ class SubscribeHandleService { $fds = $this->clientService->findUserFds($data['data']['receiver_id']); - $this->push($fds, json_encode([TalkEventConstant::EVENT_KEYBOARD, $data['data']])); + $this->push($fds, $this->toJson(TalkEventConstant::EVENT_KEYBOARD, $data['data'])); } /** @@ -166,11 +165,9 @@ class SubscribeHandleService $fds = array_unique(array_merge(...$fds)); - $this->push($fds, json_encode([ - TalkEventConstant::EVENT_ONLINE_STATUS, [ - 'user_id' => $user_id, - 'status' => $status - ] + $this->push($fds, $this->toJson(TalkEventConstant::EVENT_ONLINE_STATUS, [ + 'user_id' => $user_id, + 'status' => $status ])); } @@ -199,12 +196,12 @@ class SubscribeHandleService if (!$fds) return; - $this->push($fds, json_encode([TalkEventConstant::EVENT_REVOKE_TALK, [ + $this->push($fds, $this->toJson(TalkEventConstant::EVENT_REVOKE_TALK, [ 'talk_type' => $record->talk_type, 'sender_id' => $record->user_id, 'receiver_id' => $record->receiver_id, 'record_id' => $record->id, - ]])); + ])); } /** @@ -245,7 +242,12 @@ class SubscribeHandleService 'mobile' => $friendInfo->mobile, ]; - $this->push(array_unique($fds), json_encode([TalkEventConstant::EVENT_FRIEND_APPLY, $msg])); + $this->push(array_unique($fds), $this->toJson(TalkEventConstant::EVENT_FRIEND_APPLY, $msg)); + } + + private function toJson(string $event, array $data): string + { + return json_encode(["event" => $event, "content" => $data]); } /** diff --git a/app/Service/TalkForwardService.php b/app/Service/TalkForwardService.php index 86b1dbc..71bda73 100644 --- a/app/Service/TalkForwardService.php +++ b/app/Service/TalkForwardService.php @@ -206,7 +206,7 @@ class TalkForwardService extends BaseService $code[] = [ 'record_id' => $res->id, 'user_id' => $user_id, - 'code_lang' => $codeInfo['code_lang'], + 'code_lang' => $codeInfo['lang'], 'code' => $codeInfo['code'], 'created_at' => date('Y-m-d H:i:s') ]; diff --git a/app/Support/Response.php b/app/Support/Response.php index f3dbd71..67c3202 100644 --- a/app/Support/Response.php +++ b/app/Support/Response.php @@ -39,9 +39,10 @@ class Response $resp = [ "code" => ResponseCode::SUCCESS, "message" => $message, + "data" => $data, ]; - if ($data) $resp["data"] = $data; + // if ($data) $resp["data"] = $data; return $this->response->json($resp); }