<?php

namespace app\common\model\Enrol;

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 EnrolIntro extends BaseModel
{
    use SoftDelete;
    // 删除字段
    protected $deleteTime = 'enrol_intro_delete_time';
    // 设置主键名
    protected $pk = 'enrol_intro_guid';
    // 设置废弃字段
    protected $disuse = [];
    // 设置字段信息
    protected $schema = [

        "enrol_intro_id" => "int",

        "enrol_intro_guid" => "string",

        "enrol_intro_title" => "string",

        "enrol_intro_cover" => "string",

        "enrol_intro_content" => "string",

        "enrol_intro_sort" => "int",

        "enrol_intro_create_time" => "datetime",

        "enrol_intro_create_user_guid" => "string",

        "enrol_intro_update_time" => "datetime",

        "enrol_intro_update_user_guid" => "string",

        "enrol_intro_delete_time" => "datetime",

        "enrol_intro_delete_user_guid" => "string",

    ];
    // 设置json类型字段
    protected $json = [''];
    // 开启自动写入时间戳字段
    protected $autoWriteTimestamp = 'datetime';
    // 创建时间
    protected $createTime = 'enrol_intro_create_time';
    // 修改时间
    protected $updateTime = 'enrol_intro_update_time';



    //排序字段
    public $order_field = 'enrol_intro_sort';

    /**
     * 新增前
     */
    public static function onBeforeInsert(self $model): void
    {
        Tool::sortInsertProc(
            self::class,
            $model->enrol_intro_sort,
        );
        $model->completeCreateField();
    }

    /**
     * 更新前
     */
    public static function onBeforeUpdate(self $model): void
    {
        Tool::sortEditProc(
            self::class,
            $model->enrol_intro_guid,
            $model->enrol_intro_sort,
        );
        $model->completeUpdateField();
    }
}
