加解密
This commit is contained in:
@@ -30,6 +30,7 @@ class JsonResponseFormatter extends \yii\web\JsonResponseFormatter
|
||||
'doctor',
|
||||
'accept_tel',
|
||||
'patient',
|
||||
'accept_name',
|
||||
'patient_mobile'
|
||||
];
|
||||
private static $param = [
|
||||
@@ -41,16 +42,14 @@ class JsonResponseFormatter extends \yii\web\JsonResponseFormatter
|
||||
|
||||
public static function formatData($data, $errno = 0, $msg = '')
|
||||
{
|
||||
|
||||
// if(empty($data)) $data = new \stdClass();
|
||||
// TODO 加密后续再完善
|
||||
// if (empty($data)) {
|
||||
// $data = [];
|
||||
// } else {
|
||||
// if (array_key_exists('list', $data)) {
|
||||
// $data['list'] = self::aseEncode($data['list']);
|
||||
// }
|
||||
// }
|
||||
if (empty($data)) {
|
||||
$data = [];
|
||||
} else {
|
||||
if (array_key_exists('list', $data)) {
|
||||
$data['list'] = self::aseEncode($data['list']);
|
||||
}
|
||||
}
|
||||
$result['data'] = $data;
|
||||
$result['msg'] = $msg;
|
||||
$result['errcode'] = $errno;
|
||||
@@ -59,19 +58,19 @@ class JsonResponseFormatter extends \yii\web\JsonResponseFormatter
|
||||
|
||||
private static function aseEncode($data)
|
||||
{
|
||||
return $data;
|
||||
// if (is_array($data)) {
|
||||
// foreach ($data as $key => &$value) {
|
||||
// if (is_array($value)) {
|
||||
// $value = self::aseEncode($value); // 递归处理子数组
|
||||
// } else {
|
||||
// if (in_array($key, self::$arr)) {
|
||||
// $value = ase_encode($value); // 加密指定键值
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return $data;
|
||||
if (is_array($data)) {
|
||||
foreach ($data as $key => &$value) {
|
||||
if (is_array($value)) {
|
||||
$value = self::aseEncode($value); // 递归处理子数组
|
||||
} else {
|
||||
if (in_array($key, self::$arr)) {
|
||||
$value = ase_encode($value); // 加密指定键值
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public $encrypt = true; //是不加密
|
||||
|
||||
Reference in New Issue
Block a user