<?php
namespace Base\Domain;

class Base {

    protected $appKey;
    protected $uid; // 账号ID

    public function __construct($appKey = null, $uid = null, $staffId = null) {
        $this->appKey = $appKey ? $appKey : \PhalApi\DI()->context->getAppKey();
        $this->uid = $uid ? $uid : \PhalApi\DI()->context->getUid();
    }

    protected function getAppKey() {
        return $this->appKey;
    }

    protected function getUid() {
        return $this->uid;
    }


    protected function prepareNewData($newData = array(), $isAddCreatedStaffId = false) {
        $newData['app_key'] = $this->getAppKey();
        $newData['admin_id'] = $this->getUid();
        $newData['add_time'] = date('Y-m-d H:i:s');
        $newData['update_time'] = date('Y-m-d H:i:s');

        return $newData;
    }

    protected function  prepareWhere($where = array()) {
        $where['app_key'] = $this->getAppKey();
        return $where;
    }

    protected function prepareWhereId($id) {
        return $this->prepareWhere(array('id' => $id));
    }


}
