Browse Source

修改导出操作

邹景立 4 years ago
parent
commit
7cba7d7a14

+ 1 - 6
app/admin/controller/Oplog.php

@@ -46,12 +46,7 @@ class Oplog extends Controller
         $this->isSupper = AdminService::instance()->isSuper();
         $this->actions = $this->app->db->name($this->table)->distinct(true)->column('action');
         $query = $this->_query($this->table)->order('id desc');
-        $query->like('action,node,content,username,geoip')->dateBetween('create_at');
-        if (input('output') === 'json') {
-            $this->success('获取数据成功', $query->page(true, false));
-        } else {
-            $query->page();
-        }
+        $query->like('action,node,content,username,geoip')->dateBetween('create_at')->page();
     }
 
     /**

+ 0 - 4
app/data/controller/UserLevel.php

@@ -137,9 +137,7 @@ class UserLevel extends Controller
     /**
      * 状态变更处理
      * @auth true
-     * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
      */
     protected function _save_result()
     {
@@ -148,9 +146,7 @@ class UserLevel extends Controller
 
     /**
      * 删除结果处理
-     * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
      */
     protected function _delete_result()
     {

+ 2 - 2
app/data/controller/UserTransfer.php

@@ -31,12 +31,12 @@ class UserTransfer extends Controller
     public function index()
     {
         $this->title = '用户提现管理';
-        $query = $this->_query($this->table);
+        $query = $this->_query($this->table)->order('id desc');
         // 用户条件搜索
         $db = $this->_query('DataUser')->like('phone,username|nickname#nickname')->db();
         if ($db->getOptions('where')) $query->whereRaw("uid in {$db->field('id')->buildSql()}");
         // 数据列表处理
-        $query->equal('type,status')->dateBetween('create_at')->order('id desc')->page();
+        $query->equal('type,status')->dateBetween('create_at')->page();
     }
 
     /**

+ 1 - 6
app/wechat/controller/Fans.php

@@ -46,12 +46,7 @@ class Fans extends Controller
         $this->title = '微信用户管理';
         $this->where = ['appid' => WechatService::instance()->getAppid()];
         $query = $this->_query($this->table)->like('nickname')->equal('subscribe,is_black');
-        $query->dateBetween('subscribe_at')->where($this->where)->order('subscribe_time desc');
-        if (input('output') === 'json') {
-            $this->success('获取数据成功', $query->page(true, false));
-        } else {
-            $query->page();
-        }
+        $query->dateBetween('subscribe_at')->where($this->where)->order('subscribe_time desc')->page();
     }
 
     /**

+ 4 - 16
vendor/composer/installed.json

@@ -856,20 +856,8 @@
         "version_normalized": "6.0.9999999.9999999-dev",
         "source": {
             "type": "git",
-            "url": "https://github.com/zoujingli/ThinkLibrary.git",
-            "reference": "02dedcf2f5b8905cbd179a4c6651b819c0f5f854"
-        },
-        "dist": {
-            "type": "zip",
-            "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/02dedcf2f5b8905cbd179a4c6651b819c0f5f854",
-            "reference": "02dedcf2f5b8905cbd179a4c6651b819c0f5f854",
-            "shasum": "",
-            "mirrors": [
-                {
-                    "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
-                    "preferred": true
-                }
-            ]
+            "url": "https://gitee.com/zoujingli/ThinkLibrary",
+            "reference": "1fdad1dfac6b976c6e6ff878092e4dbf12e79e3f"
         },
         "require": {
             "ext-curl": "*",
@@ -879,7 +867,7 @@
             "ext-mbstring": "*",
             "topthink/framework": "^6.0"
         },
-        "time": "2021-01-26T05:49:46+00:00",
+        "time": "2021-01-29T08:07:24+00:00",
         "type": "library",
         "extra": {
             "think": {
@@ -888,7 +876,7 @@
                 ]
             }
         },
-        "installation-source": "dist",
+        "installation-source": "source",
         "autoload": {
             "files": [
                 "src/common.php"

+ 1 - 1
vendor/services.php

@@ -1,5 +1,5 @@
 <?php 
-// This file is automatically generated at:2021-01-28 16:01:32
+// This file is automatically generated at:2021-01-29 16:17:56
 declare (strict_types = 1);
 return array (
   0 => 'think\\admin\\Library',

+ 10 - 14
vendor/zoujingli/think-library/src/command/Database.php

@@ -18,6 +18,7 @@ declare (strict_types=1);
 namespace think\admin\command;
 
 use think\admin\Command;
+use think\admin\Exception;
 use think\console\Input;
 use think\console\input\Argument;
 use think\console\Output;
@@ -53,40 +54,34 @@ class Database extends Command
 
     /**
      * 修复数据表
-     * @throws \think\admin\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
+     * @throws Exception
      */
     protected function _repair(): void
     {
         $this->setQueueProgress("正在获取需要修复的数据表", 0);
-        [$total, $used] = [count($tables = $this->getTables()), 0];
+        [$total, $count] = [count($tables = $this->getTables()), 0];
         $this->setQueueProgress("总共需要修复 {$total} 张数据表", 0);
         foreach ($tables as $table) {
-            $this->queue->message($total, ++$used, "正在修复数据表 {$table}");
+            $this->queue->message($total, ++$count, "正在修复数据表 {$table}");
             $this->app->db->query("REPAIR TABLE `{$table}`");
-            $this->queue->message($total, $used, "完成修复数据表 {$table}", 1);
+            $this->queue->message($total, $count, "完成修复数据表 {$table}", 1);
         }
         $this->queue->success("已完成对 {$total} 张数据表修复操作");
     }
 
     /**
      * 优化所有数据表
-     * @throws \think\admin\Exception
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
+     * @throws Exception
      */
     protected function _optimize(): void
     {
         $this->setQueueProgress("正在获取需要优化的数据表", 0);
-        [$total, $used] = [count($tables = $this->getTables()), 0];
+        [$total, $count] = [count($tables = $this->getTables()), 0];
         $this->setQueueProgress("总共需要优化 {$total} 张数据表", 0);
         foreach ($tables as $table) {
-            $this->queue->message($total, ++$used, "正在优化数据表 {$table}");
+            $this->queue->message($total, ++$count, "正在优化数据表 {$table}");
             $this->app->db->query("OPTIMIZE TABLE `{$table}`");
-            $this->queue->message($total, $used, "完成优化数据表 {$table}", 1);
+            $this->queue->message($total, $count, "完成优化数据表 {$table}", 1);
         }
         $this->queue->success("已完成对 {$total} 张数据表优化操作");
     }
@@ -98,6 +93,7 @@ class Database extends Command
     protected function getTables(): array
     {
         $tables = [];
+        $this->app->db->getTable();
         foreach ($this->app->db->query("show tables") as $item) {
             $tables = array_merge($tables, array_values($item));
         }

+ 27 - 17
vendor/zoujingli/think-library/src/command/Install.php

@@ -101,7 +101,7 @@ class Install extends Command
     {
         $this->name = trim($input->getArgument('name'));
         if (empty($this->name)) {
-            $this->output->writeln('Module name of online installation cannot be empty');
+            $this->output->writeln('Module name of online install cannot be empty');
         } elseif ($this->name === 'all') {
             foreach ($this->bind as $bind) {
                 $this->rules = array_merge($this->rules, $bind['rules']);
@@ -113,35 +113,45 @@ class Install extends Command
             $this->ignore = $this->bind[$this->name]['ignore'] ?? [];
             [$this->installFile(), $this->installData()];
         } else {
-            $this->output->writeln("The specified module {$this->name} is not configured with installation rules");
+            $this->output->writeln("The specified module {$this->name} is not configured with install rules");
         }
     }
 
-    private function installFile()
+    /**
+     * 安装本地文件
+     * @return boolean
+     */
+    private function installFile(): bool
     {
         $module = ModuleService::instance();
         $data = $module->grenerateDifference($this->rules, $this->ignore);
         if (empty($data)) {
             $this->output->writeln('No need to update the file if the file comparison is consistent');
-        } else {
-            [$total, $used] = [count($data), 0];
-            foreach ($data as $file) {
-                [$state, $mode, $name] = $module->updateFileByDownload($file);
-                if ($state) {
-                    if ($mode === 'add') $this->queue->message($total, ++$used, "--- {$name} add successfully");
-                    if ($mode === 'mod') $this->queue->message($total, ++$used, "--- {$name} update successfully");
-                    if ($mode === 'del') $this->queue->message($total, ++$used, "--- {$name} delete successfully");
-                } else {
-                    if ($mode === 'add') $this->queue->message($total, ++$used, "--- {$name} add failed");
-                    if ($mode === 'mod') $this->queue->message($total, ++$used, "--- {$name} update failed");
-                    if ($mode === 'del') $this->queue->message($total, ++$used, "--- {$name} delete failed");
-                }
+            return false;
+        }
+        [$total, $count] = [count($data), 0];
+        foreach ($data as $file) {
+            [$state, $mode, $name] = $module->updateFileByDownload($file);
+            if ($state) {
+                if ($mode === 'add') $this->queue->message($total, ++$count, "--- {$name} add successfully");
+                if ($mode === 'mod') $this->queue->message($total, ++$count, "--- {$name} update successfully");
+                if ($mode === 'del') $this->queue->message($total, ++$count, "--- {$name} delete successfully");
+            } else {
+                if ($mode === 'add') $this->queue->message($total, ++$count, "--- {$name} add failed");
+                if ($mode === 'mod') $this->queue->message($total, ++$count, "--- {$name} update failed");
+                if ($mode === 'del') $this->queue->message($total, ++$count, "--- {$name} delete failed");
             }
         }
+        return true;
     }
 
-    protected function installData()
+    /**
+     * 安装数据库
+     * @return boolean
+     */
+    protected function installData(): bool
     {
+        return true;
     }
 
 }

+ 8 - 10
vendor/zoujingli/think-library/src/command/Queue.php

@@ -17,6 +17,7 @@ declare (strict_types=1);
 
 namespace think\admin\command;
 
+use Exception;
 use Psr\Log\NullLogger;
 use think\admin\Command;
 use think\Collection;
@@ -174,8 +175,7 @@ class Queue extends Command
 
     /**
      * 清理所有任务
-     * @throws \think\admin\Exception
-     * @throws \think\db\exception\DbException
+     * @throws Exception
      */
     protected function cleanAction()
     {
@@ -217,9 +217,7 @@ class Queue extends Command
 
     /**
      * 立即监听任务
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
+     * @throws Exception
      */
     protected function listenAction()
     {
@@ -242,7 +240,7 @@ class Queue extends Command
                     $this->process->create($command);
                     $this->output->writeln(">> Created new process -> [{$vo['code']}] {$vo['title']}");
                 }
-            } catch (\Exception $exception) {
+            } catch (Exception $exception) {
                 $this->app->db->name($this->table)->where(['code' => $vo['code']])->update([
                     'status' => 4, 'outer_time' => time(), 'exec_desc' => $exception->getMessage(),
                 ]);
@@ -254,7 +252,7 @@ class Queue extends Command
 
     /**
      * 执行任务内容
-     * @throws \think\db\exception\DbException
+     * @throws Exception
      */
     protected function doRunAction()
     {
@@ -297,7 +295,7 @@ class Queue extends Command
                     $this->updateQueue(3, $this->app->console->call(array_shift($attr), $attr)->fetch(), false);
                 }
             }
-        } catch (\Exception | \Error | \Throwable $exception) {
+        } catch (Exception | \Error | \Throwable $exception) {
             $code = $exception->getCode();
             if (intval($code) !== 3) $code = 4;
             $this->updateQueue($code, $exception->getMessage());
@@ -309,7 +307,7 @@ class Queue extends Command
      * @param integer $status 任务状态
      * @param string $message 消息内容
      * @param boolean $isSplit 是否分隔
-     * @throws \think\db\exception\DbException
+     * @throws Exception
      */
     protected function updateQueue(int $status, string $message, bool $isSplit = true)
     {
@@ -333,7 +331,7 @@ class Queue extends Command
         if (isset($this->queue->record['loops_time']) && $this->queue->record['loops_time'] > 0) {
             try {
                 $this->queue->initialize($this->code)->reset($this->queue->record['loops_time']);
-            } catch (\Exception | \Error | \Throwable $exception) {
+            } catch (Exception | \Error | \Throwable $exception) {
                 $this->app->log->error("Queue {$this->queue->record['code']} Loops Failed. {$exception->getMessage()}");
             }
         }

+ 7 - 7
vendor/zoujingli/think-library/src/command/Replace.php

@@ -17,6 +17,7 @@ declare (strict_types=1);
 
 namespace think\admin\command;
 
+use Exception;
 use think\admin\Command;
 use think\console\Input;
 use think\console\input\Argument;
@@ -43,8 +44,7 @@ class Replace extends Command
      * @param Input $input
      * @param Output $output
      * @return void
-     * @throws \think\db\exception\DbException
-     * @throws \think\admin\Exception
+     * @throws Exception
      */
     protected function execute(Input $input, Output $output)
     {
@@ -53,10 +53,10 @@ class Replace extends Command
         if ($search === '') $this->queue->error('查找替换字符内容不能为空!');
         if ($repalce === '') $this->queue->error('目标替换字符内容不能为空!');
 
-        [$count, $used] = [count($tables = $this->getTables()), 0];
+        [$total, $count] = [count($tables = $this->getTables()), 0];
         foreach ($tables as $table) {
             $data = [];
-            $this->queue->message($count, ++$used, sprintf("准备替换数据表 %s", Str::studly($table)));
+            $this->queue->message($total, ++$count, sprintf("准备替换数据表 %s", Str::studly($table)));
             foreach ($this->app->db->table($table)->getFields() as $field => $attrs) {
                 if (preg_match('/char|text/', $attrs['type'])) {
                     $data[$field] = $this->app->db->raw(sprintf('REPLACE(`%s`,"%s","%s")', $field, $search, $repalce));
@@ -64,12 +64,12 @@ class Replace extends Command
             }
             if (count($data) > 0) {
                 if ($this->app->db->table($table)->where('1=1')->update($data) !== false) {
-                    $this->queue->message($count, $used, sprintf("成功替换数据表 %s", Str::studly($table)), 1);
+                    $this->queue->message($total, $count, sprintf("成功替换数据表 %s", Str::studly($table)), 1);
                 } else {
-                    $this->queue->message($count, $used, sprintf("失败替换数据表 %s", Str::studly($table)), 1);
+                    $this->queue->message($total, $count, sprintf("失败替换数据表 %s", Str::studly($table)), 1);
                 }
             } else {
-                $this->queue->message($count, $used, sprintf("无需替换数据表 %s", Str::studly($table)), 1);
+                $this->queue->message($total, $count, sprintf("无需替换数据表 %s", Str::studly($table)), 1);
             }
         }
         $this->queue->success('批量替换成功');

+ 2 - 2
vendor/zoujingli/think-library/src/command/Version.php

@@ -41,7 +41,7 @@ class Version extends Command
      */
     protected function execute(Input $input, Output $output)
     {
-        $output->writeln('ThinkPHP ' . $this->app->version());
-        $output->writeln('ThinkLIB ' . $this->process->version());
+        $output->writeln("ThinkPHPCore {$this->app->version()}");
+        $output->writeln("ThinkLibrary {$this->process->version()}");
     }
 }

+ 3 - 1
vendor/zoujingli/think-library/src/extend/ExcelExtend.php

@@ -35,7 +35,9 @@ class ExcelExtend
         header('Content-Type: application/octet-stream');
         header("Content-Disposition: attachment; filename=" . iconv('utf-8', 'gbk//TRANSLIT', $name));
         $handle = fopen('php://output', 'w');
-        foreach ($headers as $key => $value) $headers[$key] = iconv("utf-8", "gbk//TRANSLIT", $value);
+        foreach ($headers as $key => $value) {
+            $headers[$key] = iconv("utf-8", "gbk//TRANSLIT", $value);
+        }
         fputcsv($handle, $headers);
         if (is_resource($handle)) {
             fclose($handle);

+ 5 - 1
vendor/zoujingli/think-library/src/helper/PageHelper.php

@@ -82,7 +82,11 @@ class PageHelper extends Helper
             $result = ['list' => $this->query->select()->toArray()];
         }
         if (false !== $this->class->callback('_page_filter', $result['list']) && $display) {
-            $this->class->fetch($template, $result);
+            if ($this->app->request->get('output') === 'json') {
+                $this->class->success('JSON-DATA', $result);
+            } else {
+                $this->class->fetch($template, $result);
+            }
         } else {
             return $result;
         }