1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- namespace app\common\controller;
- use app\common\library\BlurUtils;
- use app\common\library\Gm;
- use think\facade\Config;
- class ZskkApiController extends Api
- {
-
- protected function initialize(): void
- {
- BlurUtils::setNotNeedBlur();
- }
- /**
- * $params $data
- */
- public function makeModelData($data,$mapping): array
- {
- $info = [];
- foreach ($data as $k=>$v)
- {
- if($info[$mapping[$k]] ?? '')
- {
- continue;
- }
- $info[$mapping[$k]] = $v;
- }
- return $info;
- }
- public function getDecryptData($data): array
- {
- $key = 'zLxapoeqWYpoeqWY';
- $info = Gm::decrypt($key,$data);
- return json_decode(base64_decode($info),true);
- }
- public function makeEncryptData($data)
- {
- // $key = Config::get('gm.key');
- $key = 'zLxapoeqWYpoeqWY';
- $info = Gm::encrypt($key,(base64_encode(json_encode($data))));
- return $info;
- }
- public function getHeaderToken(): string
- {
- $header = getallheaders();
- $auth = $header['Authorization'];
- $data = explode(' ',$auth);
- return $data[1];
- }
- }
|