src/Leevel/Database/Ddd/Entity.php
public function id()
    {
        $result = [];

        foreach (($keys = $this->primaryKeys()) as $value) {
            if (!($tmp = $this->__get($value))) {
                continue;
            }

            $result[$value] = $tmp;
        }

        if (!$result) {
            return;
        }

        // 复合主键，但是数据不完整则忽略
        if (count($keys) > 1 && count($keys) !== count($result)) {
            return;
        }

        if (1 === count($result)) {
            $result = reset($result);
        }

        return $result;
    }
public function id()
    {
        $result = [];

        foreach (($keys = $this->primaryKeys()) as $value) {
            if (!($tmp = $this->__get($value))) {
                continue;
            }

            $result[$value] = $tmp;
        }

        if (!$result) {
            return;
        }

        // 复合主键，但是数据不完整则忽略
        if (count($keys) > 1 && count($keys) !== count($result)) {
            return;
        }

        if (1 === count($result)) {
            $result = reset($result);
        }

        return $result;
    }
获取主键
唯一标识符.

@return mixed