|
@@ -14,45 +14,32 @@ class JRFIDServerService extends Service
|
|
list($status, $msg) = $this->getToken($data);
|
|
list($status, $msg) = $this->getToken($data);
|
|
if(! $status) return [false, $msg];
|
|
if(! $status) return [false, $msg];
|
|
|
|
|
|
- return [true, ['token' => $msg]];
|
|
|
|
|
|
+ return [true, ['data' => $msg]];
|
|
}
|
|
}
|
|
|
|
|
|
public function getToken($data){
|
|
public function getToken($data){
|
|
$account = $data['name'];
|
|
$account = $data['name'];
|
|
$password = $data['password'];
|
|
$password = $data['password'];
|
|
- $token_key = config("j_rfid.login_redis_topic");
|
|
|
|
- $token_key = $token_key . $account . $password;
|
|
|
|
- $token = Redis::get($token_key);
|
|
|
|
-
|
|
|
|
- if(! $token){
|
|
|
|
- $url = config("j_rfid.login");
|
|
|
|
- $expire_time = config("j_rfid.login_expire_time");
|
|
|
|
- $post = [
|
|
|
|
- "name" => $account,
|
|
|
|
- "password" => $password,
|
|
|
|
- "rememberMe" => true
|
|
|
|
- ];
|
|
|
|
- $header = ['Content-Type:application/json'];
|
|
|
|
- list($status, $result) = $this->post_helper($url,json_encode($post), $header);
|
|
|
|
- if(! $status) return [false, $result];
|
|
|
|
-
|
|
|
|
- //登录失败
|
|
|
|
- if(! empty($result['errorMessage'])) return [false, $result['errorMessage']];
|
|
|
|
-
|
|
|
|
- //登录成功
|
|
|
|
- $token = $result['token'];
|
|
|
|
- Redis::set($token_key,$token);
|
|
|
|
- Redis::expire($token_key, $expire_time);
|
|
|
|
-
|
|
|
|
- return [true, $token];
|
|
|
|
- }
|
|
|
|
|
|
|
|
- return [true, $token];
|
|
|
|
|
|
+ $url = config("j_rfid.login");
|
|
|
|
+ $post = [
|
|
|
|
+ "name" => $account,
|
|
|
|
+ "password" => $password,
|
|
|
|
+ "rememberMe" => true
|
|
|
|
+ ];
|
|
|
|
+ $header = ['Content-Type:application/json'];
|
|
|
|
+ list($status, $result) = $this->post_helper($url,json_encode($post), $header);
|
|
|
|
+ if(! $status) return [false, $result];
|
|
|
|
+
|
|
|
|
+ //登录失败
|
|
|
|
+ if(! empty($result['errorMessage'])) return [false, $result['errorMessage']];
|
|
|
|
+
|
|
|
|
+ return [true, $result];
|
|
}
|
|
}
|
|
|
|
|
|
- public function getSite($data, $param){
|
|
|
|
|
|
+ public function getSite($data){
|
|
$url = config("j_rfid.site");
|
|
$url = config("j_rfid.site");
|
|
- list($status,$result) = $this->get_helper($url,$param['header']);
|
|
|
|
|
|
+ list($status,$result) = $this->get_helper($url);
|
|
if(! $status) return [false, $result];
|
|
if(! $status) return [false, $result];
|
|
|
|
|
|
if(! empty($result['errorMessage'])) return [false, $result['errorMessage']];
|
|
if(! empty($result['errorMessage'])) return [false, $result['errorMessage']];
|
|
@@ -100,13 +87,15 @@ class JRFIDServerService extends Service
|
|
if(empty($data['type'])) return [false, '打印数据类型不能为空'];
|
|
if(empty($data['type'])) return [false, '打印数据类型不能为空'];
|
|
|
|
|
|
$rsaService = new RsaEncryptionService();
|
|
$rsaService = new RsaEncryptionService();
|
|
- $dataToEncrypt = $data['id'];
|
|
|
|
- $encryptedData = $rsaService->encrypt($dataToEncrypt);
|
|
|
|
|
|
+ $dataToEncrypt = [
|
|
|
|
+ 'id' => $data['id'],
|
|
|
|
+ 'type' => $data['type'],
|
|
|
|
+ ];
|
|
|
|
+ $encryptedData = $rsaService->encrypt(json_encode($dataToEncrypt));
|
|
|
|
|
|
$url = config("j_rfid.get_print_data");
|
|
$url = config("j_rfid.get_print_data");
|
|
$post = [
|
|
$post = [
|
|
'encrypted_data' => $encryptedData,
|
|
'encrypted_data' => $encryptedData,
|
|
- 'type' => $data['type'],
|
|
|
|
];
|
|
];
|
|
|
|
|
|
list($status,$result) = $this->post_helper($url,json_encode($post),['Content-Type:application/json']);
|
|
list($status,$result) = $this->post_helper($url,json_encode($post),['Content-Type:application/json']);
|