'int', 'customer_message_guid' => 'string', 'customer_message_title' => 'string', 'customer_message_content' => 'string', 'customer_message_postscript' => 'string', 'customer_message_reading_status' => 'int', 'customer_guid' => 'string', 'customer_message_create_time' => 'datetime', 'customer_message_create_user_guid' => 'string', 'customer_message_update_time' => 'datetime', 'customer_message_update_user_guid' => 'string', 'customer_message_delete_time' => 'datetime', 'customer_message_delete_user_guid' => 'string', ]; // 设置json类型字段 protected $json = ['']; // 开启自动写入时间戳字段 protected $autoWriteTimestamp = 'datetime'; // 创建时间 protected $createTime = 'customer_message_create_time'; // 修改时间 protected $updateTime = 'customer_message_update_time'; // 字典 public static $dictionaryMap = [ 'customer_message_reading_status' => [ self::HAVE_READ => '已读', self::UNREAD => '未读' ], ]; // 阅读状态 已读 const HAVE_READ = 1; // 阅读状态 未读 const UNREAD = 2; /** * 新增前 */ public static function onBeforeInsert(self $model): void { $model->customer_message_reading_status = self::UNREAD; $model->completeCreateField(); } /** * 更新前 */ public static function onBeforeUpdate(self $model): void { $model->completeUpdateField(); } /** * 删除前 */ public static function onBeforeDelete(self $model): void { $model->completeDeleteField(); } }