esd-projects / esd-server

⚡️ EasySwoole Distributed
https://www.kancloud.cn/tmtbe/goswoole/1067764
Apache License 2.0
257 stars 14 forks source link

Model内使用@Validated(required=true)报错 #17

Closed eaglering closed 5 years ago

eaglering commented 5 years ago

使用命令生成实体类

php start_server.php entity -t mx_test

实体类如下:

<?php
namespace App\Model\Entity;

use ESD\Go\GoModel;
use ESD\Plugins\Validate\Annotation\Filter;
use ESD\Plugins\Validate\Annotation\Validated;

/**
 * 测试表
 *
 * Class Test
 */
class Test extends GoModel
{

    /**
     * id
     * @Validated(required=true, number=true)
     * @var integer
     */
    public $id;

    /**
     * 名称
     * @Validated(required=true, length=true, max=255)
     * @var string
     */
    public $name;

    /**
     * 创建时间
     * @Validated(required=true, number=true)
     * @var integer
     */
    public $create_at;

    /**
     * 更新时间
     * @Validated(required=true, number=true)
     * @var integer
     */
    public $updated_at;

    /**
     * 获取数据库表名
     *
     * @return string
     */
    public static function getTableName(): string
    {
        return "test";
    }

    /**
     * 获取主键名
     *
     * @return string
     */
    public static function getPrimaryKey(): string
    {
        return "id";
    }
}

执行代码如下:

    /**
     * @GetMapping("/")
     */
    public function index()
    {
        $test = Test::select(1);
    }

报错如下:

parameter create at is required!