更新
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
/**
|
||||
* 企业微信会话存档消息
|
||||
*
|
||||
* 数据来源为「会话内容存档」SDK 拉取后解密落库,msgid 官方唯一。
|
||||
* 消息体字段根据 msgtype 有不同含义,统一用 content(摘要/文本)+ raw(原始 JSON)组合存储,
|
||||
* 具体渲染放到业务层(前端或 Logic)再按需展开。
|
||||
*/
|
||||
class QywxMsgArchive extends BaseModel
|
||||
{
|
||||
protected $name = 'qywx_msg_archive';
|
||||
protected $autoWriteTimestamp = 'int';
|
||||
|
||||
protected $type = [
|
||||
'send_time' => 'integer',
|
||||
'seq' => 'integer',
|
||||
'file_size' => 'integer',
|
||||
'play_length' => 'integer',
|
||||
];
|
||||
|
||||
/** JSON 反序列化 to_list 访问器,便于业务层直接拿数组 */
|
||||
public function getToListAttr($value): array
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return [];
|
||||
}
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
$decoded = json_decode((string) $value, true);
|
||||
return is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
|
||||
public function setToListAttr($value): string
|
||||
{
|
||||
if (is_string($value)) {
|
||||
return $value;
|
||||
}
|
||||
return json_encode($value ?? [], JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user