浏览代码

代码注释

Anyon 4 年之前
父节点
当前提交
478229e5a1

+ 0 - 1
app/admin/controller/Login.php

@@ -84,7 +84,6 @@ class Login extends Controller
                 'login_num' => $this->app->db->raw('login_num+1'),
             ]);
             sysoplog('系统用户登录', '登录系统后台成功');
-            $GLOBALS['oplogs'] = [];
             $this->success('登录成功', sysuri('admin/index/index'));
         }
     }

+ 4 - 5
app/admin/controller/api/Plugs.php

@@ -113,8 +113,7 @@ class Plugs extends Controller
                 $this->app->db->name('SystemConfig')->insertAll($alldata);
             });
             $this->app->cache->delete('SystemConfig');
-            $GLOBALS['oplogs'] = [];
-            sysoplog('系统运维管理', '清理系统配置成功');
+            sysoplog('系统运维管理', '清理系统参数配置成功');
             $this->success('清理系统配置成功!');
         } catch (HttpResponseException $exception) {
             throw $exception;
@@ -134,7 +133,7 @@ class Plugs extends Controller
         if (AdminService::instance()->isSuper()) try {
             AdminService::instance()->clearCache();
             SystemService::instance()->pushRuntime();
-            sysoplog('系统运维管理', '网站缓存加速成功');
+            sysoplog('系统运维管理', '刷新并创建网站路由缓存');
             $this->success('网站缓存加速成功!');
         } catch (HttpResponseException $exception) {
             throw $exception;
@@ -154,8 +153,8 @@ class Plugs extends Controller
         if (AdminService::instance()->isSuper()) try {
             AdminService::instance()->clearCache();
             SystemService::instance()->clearRuntime();
-            sysoplog('系统运维管理', '清理网站缓存日志');
-            $this->success('清理网站缓存成功!');
+            sysoplog('系统运维管理', '清理网站日志及缓存数据');
+            $this->success('清理网站日志及缓存数据成功!');
         } catch (HttpResponseException $exception) {
             throw $exception;
         } catch (\Exception $exception) {

+ 11 - 7
app/admin/controller/api/Upload.php

@@ -21,6 +21,9 @@ use think\admin\storage\AliossStorage;
 use think\admin\storage\LocalStorage;
 use think\admin\storage\QiniuStorage;
 use think\admin\storage\TxcosStorage;
+use think\file\UploadedFile;
+use think\Response;
+use think\response\Json;
 
 /**
  * 文件上传接口
@@ -32,11 +35,12 @@ class Upload extends Controller
 
     /**
      * 文件上传JS支持
+     * @return Response
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function index()
+    public function index(): Response
     {
         $data = ['exts' => []];
         foreach (explode(',', sysconf('storage.allow_exts')) as $ext) {
@@ -93,13 +97,13 @@ class Upload extends Controller
     /**
      * 文件上传入口
      * @login true
-     * @return \think\response\Json
+     * @return Json
      * @throws \think\admin\Exception
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function file()
+    public function file(): Json
     {
         if (!($file = $this->getFile()) || empty($file)) {
             return json(['uploaded' => false, 'error' => ['message' => '文件上传异常,文件可能过大或未上传']]);
@@ -134,7 +138,7 @@ class Upload extends Controller
      * 获取文件上传类型
      * @return boolean
      */
-    private function getSafe()
+    private function getSafe(): bool
     {
         return boolval(input('safe', '0'));
     }
@@ -146,7 +150,7 @@ class Upload extends Controller
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    private function getType()
+    private function getType(): string
     {
         $this->uptype = strtolower(input('uptype', ''));
         if (!in_array($this->uptype, ['local', 'qiniu', 'alioss', 'txcos'])) {
@@ -157,9 +161,9 @@ class Upload extends Controller
 
     /**
      * 获取本地文件对象
-     * @return \think\file\UploadedFile
+     * @return UploadedFile
      */
-    private function getFile()
+    private function getFile(): UploadedFile
     {
         try {
             return $this->request->file('file');

+ 2 - 2
app/data/controller/api/Notify.php

@@ -22,7 +22,7 @@ class Notify extends Controller
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function wxpay(string $scene = 'order')
+    public function wxpay(string $scene = 'order'): string
     {
         $notify = ($payment = WechatService::WePayOrder())->getNotify();
         if ($notify['result_code'] == 'SUCCESS' && $notify['return_code'] == 'SUCCESS') {
@@ -47,7 +47,7 @@ class Notify extends Controller
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    private function setOrder(string $code, string $amount, string $paycode, string $paytype = 'wxpay')
+    private function setOrder(string $code, string $amount, string $paycode, string $paytype = 'wxpay'): bool
     {
         // 检查订单支付状态
         $map = ['order_no' => $code, 'payment_status' => 0, 'status' => 2];

+ 5 - 3
app/data/controller/api/Wxapp.php

@@ -5,6 +5,7 @@ namespace app\data\controller\api;
 use app\data\service\UserService;
 use think\admin\Controller;
 use think\exception\HttpResponseException;
+use think\Response;
 use WeMini\Crypt;
 use WeMini\Live;
 use WeMini\Qrcode;
@@ -41,6 +42,7 @@ class Wxapp extends Controller
 
     /**
      * 授权Code换取会话信息
+     * @throws \think\Exception
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
@@ -94,7 +96,7 @@ class Wxapp extends Controller
      * @param string $code 换取授权CODE
      * @return array [openid, sessionkey]
      */
-    private function _getSessionKey(string $code)
+    private function _getSessionKey(string $code): array
     {
         try {
             $cache = $this->app->cache->get($code, []);
@@ -120,7 +122,7 @@ class Wxapp extends Controller
     /**
      * 获取小程序码
      */
-    public function qrcode()
+    public function qrcode(): Response
     {
         try {
             $data = $this->_vali([
@@ -169,7 +171,7 @@ class Wxapp extends Controller
                 'start.default'   => 0,
                 'limit.default'   => 10,
                 'action.default'  => 'get_replay',
-                'room_id.require' => '直播间ID不能为空',
+                'room_id.require' => '直播间不能为空',
             ]);
             $result = Live::instance($this->config)->getLiveInfo($data);
             $this->success('获取回放视频成功!', $result);

+ 2 - 2
app/data/controller/api/auth/Address.php

@@ -124,12 +124,12 @@ class Address extends Auth
     /**
      * 获取指定的收货地址
      * @param string $code
-     * @return array
+     * @return null|array
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    private function _getAddress(string $code)
+    private function _getAddress(string $code): ?array
     {
         $map = ['code' => $code, 'uid' => $this->uuid, 'deleted' => 0];
         return $this->app->db->name($this->table)->withoutField('deleted')->where($map)->find();

+ 5 - 4
app/data/service/MessageService.php

@@ -25,15 +25,16 @@ class MessageService extends Service
 
     /**
      * 短信服务初始化
-     * @return MessageService|void
+     * @return MessageService
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    protected function initialize()
+    protected function initialize(): MessageService
     {
         $this->username = sysconf('zt.username');
         $this->password = sysconf('zt.password');
+        return $this;
     }
 
     /**
@@ -67,7 +68,7 @@ class MessageService extends Service
      * @param string $tplcode
      * @return boolean
      */
-    public function checkVerifyCode(string $code, string $phone, string $tplcode = 'zt.tplcode_register')
+    public function checkVerifyCode(string $code, string $phone, string $tplcode = 'zt.tplcode_register'): bool
     {
         $cache = $this->app->cache->get($ckey = md5("code-{$tplcode}-{$phone}"), []);
         return is_array($cache) && isset($cache['code']) && $cache['code'] == $code;
@@ -83,7 +84,7 @@ class MessageService extends Service
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function sendVerifyCode(string $phone, int $wait = 120, string $tplcode = 'zt.tplcode_register')
+    public function sendVerifyCode(string $phone, int $wait = 120, string $tplcode = 'zt.tplcode_register'): array
     {
         $content = sysconf($tplcode) ?: '您的短信验证码为{code},请在十分钟内完成操作!';
         $cache = $this->app->cache->get($ckey = md5("code-{$tplcode}-{$phone}"), []);

+ 1 - 1
app/data/service/TruckService.php

@@ -89,7 +89,7 @@ class TruckService extends Service
      * @return array
      * @throws \think\admin\Exception
      */
-    public function company()
+    public function company(): array
     {
         return $this->_getInterface()->doRequest('api.auth.express/getCompany');
     }