Skip to content

Commit

Permalink
完善测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwenbo committed Nov 20, 2018
1 parent 0033832 commit e48ac7c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ $ttlock->lock->getKeyboardPwdVersion($lockId,$date);
$ttlock->lock->updateElectricQuantity($lockId,$electricQuantity,$date);
$ttlock->lock->transfer($receiverUsername,$lockIdList,$date);


// Passcode
$ttlock->passcode->get( int $lockId, int $keyboardPwdVersion, int $keyboardPwdType, int $startDate, int $endDate, int $date ) : array
$ttlock->passcode->delete( int $lockId, int $keyboardPwdId, int $deleteType, int $date ):array
$ttlock->passcode->change( int $lockId, int $keyboardPwdId, string $newKeyboardPwd, int $startDate, int $endDate, int $changeType, int $date )
$ttlock->passcode->add( int $lockId, string $keyboardPwd, int $startDate, int $endDate, int $addType, int $date )



// 其他接口本次开发没用上 后续有需要再完善


Expand Down
6 changes: 3 additions & 3 deletions src/Passcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function get( int $lockId, int $keyboardPwdVersion, int $keyboardPwdType,
* @throws \GuzzleHttp\Exception\GuzzleException | \Exception
* @author 韩文博
*/
public function delete( int $lockId, int $keyboardPwdId, int $deleteType, int $date )
public function delete( int $lockId, int $keyboardPwdId, int $deleteType, int $date ):array
{
$response = $this->client->request( 'POST', '/v3/keyboardPwd/get', [
'form_params' => [
Expand Down Expand Up @@ -100,7 +100,7 @@ public function delete( int $lockId, int $keyboardPwdId, int $deleteType, int $d
* @throws \GuzzleHttp\Exception\GuzzleException | \Exception
* @author 韩文博
*/
public function change( int $lockId, int $keyboardPwdId, string $newKeyboardPwd, int $startDate, int $endDate, int $changeType, int $date )
public function change( int $lockId, int $keyboardPwdId, string $newKeyboardPwd, int $startDate, int $endDate, int $changeType, int $date ) : array
{
$response = $this->client->request( 'POST', '/v3/keyboardPwd/get', [
'form_params' => [
Expand Down Expand Up @@ -135,7 +135,7 @@ public function change( int $lockId, int $keyboardPwdId, string $newKeyboardPwd,
* @throws \GuzzleHttp\Exception\GuzzleException | \Exception
* @author 韩文博
*/
public function add( int $lockId, string $keyboardPwd, int $startDate, int $endDate, int $addType, int $date )
public function add( int $lockId, string $keyboardPwd, int $startDate, int $endDate, int $addType, int $date ) : array
{
$response = $this->client->request( 'POST', '/v3/keyboardPwd/get', [
'form_params' => [
Expand Down
22 changes: 12 additions & 10 deletions src/TTLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ public function __construct( string $clientId, string $clientSecret )
protected $container = [];
protected $providers
= [
"user" => User::class,
"lock" => Lock::class,
"oauth2" => Oauth2::class,
"key" => Key::class,
"user" => User::class,
"lock" => Lock::class,
"oauth2" => Oauth2::class,
"key" => Key::class,
"passcode" => Passcode::class,
];

/**
Expand All @@ -75,18 +76,19 @@ public function __get( $name )
return $this->container["{$name}"];
}
}

/**
* 根据日期时间返回毫秒时间戳
* @param string$dateTime
* @param string $dateTime
* @return int
* @author 韩文博
*/
static function getDateTimeMillisecond(string $dateTime) : int
static function getDateTimeMillisecond( string $dateTime ) : int
{
$dateTime = $dateTime .".0";
list($usec, $sec) = explode(".", $dateTime);
$date = strtotime($usec);
$return_data = str_pad($date.$sec,13,"0",STR_PAD_RIGHT); //不足13位。右边补0
$dateTime = $dateTime.".0";
list( $usec, $sec ) = explode( ".", $dateTime );
$date = strtotime( $usec );
$return_data = str_pad( $date.$sec, 13, "0", STR_PAD_RIGHT ); //不足13位。右边补0
return (int)$return_data;
}
}

0 comments on commit e48ac7c

Please sign in to comment.