drag-create-api/app/common/model/Customer/CustomerMessage.php

90 lines
2.3 KiB
PHP

<?php
namespace app\common\model\Customer;
use app\common\arw\adjfut\src\Validate;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\common\arw\adjfut\src\Excel;
use app\Request;
use app\common\exception\Tool;
use think\facade\Db;
class CustomerMessage extends BaseModel
{
use SoftDelete;
// 删除字段
protected $deleteTime = 'customer_message_delete_time';
// 设置主键名
protected $pk = 'customer_message_guid';
// 设置废弃字段
protected $disuse = [];
// 设置字段信息
protected $schema = [
'customer_message_id' => '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();
}
}