<?php

namespace app\model;

use support\exception\BusinessException;
use support\Model;

class SysSerial extends Model
{
    protected $table = 'sys_serial';

    protected $primaryKey = 'serial';

    const CREATED_AT = null;

    const UPDATED_AT = null;

    /**
     * @Desc 自增序列号
     * @Author Gorden
     * @Date 2024/3/11 10:45
     *
     * @return mixed
     * @throws BusinessException
     */
    public static function getSerial()
    {
        $model = new self();
        if ($model->save()) {
            return $model->serial;
        }

        throw new BusinessException("序列号生成失败~");
    }
}