linshuohong лет назад: 3
Родитель
Сommit
8b31c1f53d
52 измененных файлов с 2327 добавлено и 0 удалено
  1. 1 0
      .example.env
  2. 5 0
      .gitignore
  3. 42 0
      .travis.yml
  4. 32 0
      LICENSE.txt
  5. 1 0
      README.md
  6. 1 0
      app/.htaccess
  7. 22 0
      app/AppService.php
  8. 94 0
      app/BaseController.php
  9. 58 0
      app/ExceptionHandle.php
  10. 29 0
      app/Request.php
  11. 9 0
      app/common.php
  12. 24 0
      app/common/BaseRepository.php
  13. 107 0
      app/common/cart/CartRepository.php
  14. 29 0
      app/controller/Auth.php
  15. 10 0
      app/controller/Index.php
  16. 63 0
      app/controller/cart/Index.php
  17. 17 0
      app/event.php
  18. 12 0
      app/exceptions/AuthException.php
  19. 11 0
      app/middleware.php
  20. 51 0
      app/middleware/UserTokenMiddleware.php
  21. 10 0
      app/provider.php
  22. 9 0
      app/service.php
  23. 121 0
      app/services/ApiResponseService.php
  24. 64 0
      app/traits/Macro.php
  25. 19 0
      app/validate/CreateCart.php
  26. 47 0
      composer.json
  27. 973 0
      composer.lock
  28. 32 0
      config/app.php
  29. 41 0
      config/cache.php
  30. 9 0
      config/console.php
  31. 20 0
      config/cookie.php
  32. 63 0
      config/database.php
  33. 24 0
      config/filesystem.php
  34. 27 0
      config/lang.php
  35. 45 0
      config/log.php
  36. 8 0
      config/middleware.php
  37. 45 0
      config/route.php
  38. 19 0
      config/session.php
  39. 10 0
      config/trace.php
  40. 25 0
      config/view.php
  41. 2 0
      extend/.gitignore
  42. 8 0
      public/.htaccess
  43. BIN
      public/favicon.ico
  44. 24 0
      public/index.php
  45. 4 0
      public/nginx.htaccess
  46. 2 0
      public/robots.txt
  47. 19 0
      public/router.php
  48. 2 0
      public/static/.gitignore
  49. 24 0
      route/app.php
  50. 2 0
      runtime/.gitignore
  51. 10 0
      think
  52. 1 0
      view/README.md

+ 1 - 0
.example.env

@@ -0,0 +1 @@
1
+APP_DEBUG = true

[APP]
DEFAULT_TIMEZONE = Asia/Shanghai

[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1
DATABASE = test
USERNAME = username
PASSWORD = password
HOSTPORT = 3306
CHARSET = utf8
DEBUG = true

[LANG]
default_lang = zh-cn

+ 5 - 0
.gitignore

@@ -0,0 +1,5 @@
1
+/.idea
2
+/.vscode
3
+/vendor
4
+*.log
5
+.env

Разница между файлами не показана из-за своего большого размера
+ 42 - 0
.travis.yml


+ 32 - 0
LICENSE.txt

@@ -0,0 +1,32 @@
1
+
2
+ThinkPHP遵循Apache2开源协议发布,并提供免费使用。
3
+版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
4
+All rights reserved。
5
+ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
6
+
7
+Apache Licence是著名的非盈利开源组织Apache采用的协议。
8
+该协议和BSD类似,鼓励代码共享和尊重原作者的著作权,
9
+允许代码修改,再作为开源或商业软件发布。需要满足
10
+的条件: 
11
+1. 需要给代码的用户一份Apache Licence ;
12
+2. 如果你修改了代码,需要在被修改的文件中说明;
13
+3. 在延伸的代码中(修改和有源代码衍生的代码中)需要
14
+带有原来代码中的协议,商标,专利声明和其他原来作者规
15
+定需要包含的说明;
16
+4. 如果再发布的产品中包含一个Notice文件,则在Notice文
17
+件中需要带有本协议内容。你可以在Notice中增加自己的
18
+许可,但不可以表现为对Apache Licence构成更改。 
19
+具体的协议参考:http://www.apache.org/licenses/LICENSE-2.0
20
+
21
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
+FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
+COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
+ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+POSSIBILITY OF SUCH DAMAGE.

+ 1 - 0
README.md

@@ -0,0 +1 @@
1
+储蓄保订单

+ 1 - 0
app/.htaccess

@@ -0,0 +1 @@
1
+deny from all

+ 22 - 0
app/AppService.php

@@ -0,0 +1,22 @@
1
+<?php
2
+declare (strict_types = 1);
3
+
4
+namespace app;
5
+
6
+use think\Service;
7
+
8
+/**
9
+ * 应用服务类
10
+ */
11
+class AppService extends Service
12
+{
13
+    public function register()
14
+    {
15
+        // 服务注册
16
+    }
17
+
18
+    public function boot()
19
+    {
20
+        // 服务启动
21
+    }
22
+}

+ 94 - 0
app/BaseController.php

@@ -0,0 +1,94 @@
1
+<?php
2
+declare (strict_types = 1);
3
+
4
+namespace app;
5
+
6
+use think\App;
7
+use think\exception\ValidateException;
8
+use think\Validate;
9
+
10
+/**
11
+ * 控制器基础类
12
+ */
13
+abstract class BaseController
14
+{
15
+    /**
16
+     * Request实例
17
+     * @var \think\Request
18
+     */
19
+    protected $request;
20
+
21
+    /**
22
+     * 应用实例
23
+     * @var \think\App
24
+     */
25
+    protected $app;
26
+
27
+    /**
28
+     * 是否批量验证
29
+     * @var bool
30
+     */
31
+    protected $batchValidate = false;
32
+
33
+    /**
34
+     * 控制器中间件
35
+     * @var array
36
+     */
37
+    protected $middleware = [];
38
+
39
+    /**
40
+     * 构造方法
41
+     * @access public
42
+     * @param  App  $app  应用对象
43
+     */
44
+    public function __construct(App $app)
45
+    {
46
+        $this->app     = $app;
47
+        $this->request = $this->app->request;
48
+
49
+        // 控制器初始化
50
+        $this->initialize();
51
+    }
52
+
53
+    // 初始化
54
+    protected function initialize()
55
+    {}
56
+
57
+    /**
58
+     * 验证数据
59
+     * @access protected
60
+     * @param  array        $data     数据
61
+     * @param  string|array $validate 验证器名或者验证规则数组
62
+     * @param  array        $message  提示信息
63
+     * @param  bool         $batch    是否批量验证
64
+     * @return array|string|true
65
+     * @throws ValidateException
66
+     */
67
+    protected function validate(array $data, $validate, array $message = [], bool $batch = false)
68
+    {
69
+        if (is_array($validate)) {
70
+            $v = new Validate();
71
+            $v->rule($validate);
72
+        } else {
73
+            if (strpos($validate, '.')) {
74
+                // 支持场景
75
+                [$validate, $scene] = explode('.', $validate);
76
+            }
77
+            $class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);
78
+            $v     = new $class();
79
+            if (!empty($scene)) {
80
+                $v->scene($scene);
81
+            }
82
+        }
83
+
84
+        $v->message($message);
85
+
86
+        // 是否批量验证
87
+        if ($batch || $this->batchValidate) {
88
+            $v->batch(true);
89
+        }
90
+
91
+        return $v->failException(true)->check($data);
92
+    }
93
+
94
+}

+ 58 - 0
app/ExceptionHandle.php

@@ -0,0 +1,58 @@
1
+<?php
2
+namespace app;
3
+
4
+use think\db\exception\DataNotFoundException;
5
+use think\db\exception\ModelNotFoundException;
6
+use think\exception\Handle;
7
+use think\exception\HttpException;
8
+use think\exception\HttpResponseException;
9
+use think\exception\ValidateException;
10
+use think\Response;
11
+use Throwable;
12
+
13
+/**
14
+ * 应用异常处理类
15
+ */
16
+class ExceptionHandle extends Handle
17
+{
18
+    /**
19
+     * 不需要记录信息(日志)的异常类列表
20
+     * @var array
21
+     */
22
+    protected $ignoreReport = [
23
+        HttpException::class,
24
+        HttpResponseException::class,
25
+        ModelNotFoundException::class,
26
+        DataNotFoundException::class,
27
+        ValidateException::class,
28
+    ];
29
+
30
+    /**
31
+     * 记录异常信息(包括日志或者其它方式记录)
32
+     *
33
+     * @access public
34
+     * @param  Throwable $exception
35
+     * @return void
36
+     */
37
+    public function report(Throwable $exception): void
38
+    {
39
+        // 使用内置的方式记录异常日志
40
+        parent::report($exception);
41
+    }
42
+
43
+    /**
44
+     * Render an exception into an HTTP response.
45
+     *
46
+     * @access public
47
+     * @param \think\Request   $request
48
+     * @param Throwable $e
49
+     * @return Response
50
+     */
51
+    public function render($request, Throwable $e): Response
52
+    {
53
+        // 添加自定义异常处理机制
54
+
55
+        // 其他错误交给系统处理
56
+        return parent::render($request, $e);
57
+    }
58
+}

+ 29 - 0
app/Request.php

@@ -0,0 +1,29 @@
1
+<?php
2
+namespace app;
3
+
4
+// 应用请求对象类
5
+use app\traits\Macro;
6
+
7
+class Request extends \think\Request
8
+{
9
+    use Macro;
10
+
11
+    public function params(array $names, $filter = '')
12
+    {
13
+        $data = [];
14
+        $flag = false;
15
+        if ($filter === true) {
16
+            $filter = '';
17
+            $flag = true;
18
+        }
19
+        foreach ($names as $name) {
20
+            if (!is_array($name))
21
+                $data[$name] = $this->param($name, '', $filter);
22
+            else
23
+                $data[$name[0]] = $this->param($name[0], $name[1], $filter);
24
+        }
25
+
26
+        return $flag ? array_values($data) : $data;
27
+    }
28
+
29
+}

+ 9 - 0
app/common.php

@@ -0,0 +1,9 @@
1
+<?php
2
+// 应用公共文件
3
+//parseException
4
+if(!function_exists("parseException")){
5
+    function parseException($e): string
6
+    {
7
+        return $e->getFile().':'.$e->getLine().'【'.$e->getMessage().'】';
8
+    }
9
+}

+ 24 - 0
app/common/BaseRepository.php

@@ -0,0 +1,24 @@
1
+<?php
2
+
3
+namespace app\common;
4
+
5
+class BaseRepository
6
+{
7
+
8
+
9
+    public function getMessage($code): array
10
+    {
11
+        switch ($code){
12
+            case 101: return ['bool'=>false,'message'=>'购物车数量必须大于0'];
13
+            case 102: return ['bool'=>false,'message'=>'商品不存在'];
14
+            case 103: return ['bool'=>false,'message'=>'SKU不存在'];
15
+            case 104: return ['bool'=>false,'message'=>'数据不一致'];
16
+            case 105: return ['bool'=>false,'message'=>'积分商品不能加入购物车'];
17
+            case 106: return ['bool'=>false,'message'=>'秒杀商品不能加入购物车'];
18
+            case 107: return ['bool'=>false,'message'=>'添加购物车失败'];
19
+            case 108: return ['bool'=>false,'message'=>'修改购物车失败'];
20
+            case 109: return ['bool'=>false,'message'=>'购物车不存在'];
21
+            default : return ['bool'=>false,'message'=>'未知错误'];
22
+        }
23
+    }
24
+}

+ 107 - 0
app/common/cart/CartRepository.php

@@ -0,0 +1,107 @@
1
+<?php
2
+
3
+namespace app\common\cart;
4
+
5
+use app\common\BaseRepository;
6
+use think\exception\ValidateException;
7
+use think\facade\Db;
8
+use think\facade\Log;
9
+
10
+class CartRepository extends BaseRepository
11
+{
12
+    /**
13
+     * TODO 商品检测
14
+     * @param $data
15
+     * @return array
16
+     */
17
+    public function checkProduct($data): array
18
+    {
19
+
20
+        if( $data['cart_num'] < 0 ) return $this -> getMessage(101);
21
+        $productSelect = Db::query("select * from `rrx_store_product` where `product_id`=? limit 1", [$data['product_id']]);
22
+        if(!$productSelect) return $this -> getMessage(102);
23
+        $product = $productSelect[0];
24
+        $skuSelect = Db::query("select * from `rrx_store_product_attr_value` where `unique`=? and `product_id`=? limit 1", [$data['product_attr_unique'],$data['product_id']]);
25
+        $sku = $skuSelect[0];
26
+        if(!$sku) return $this -> getMessage(103);
27
+        if($sku['product_id'] != $data['product_id']) return $this -> getMessage(104);
28
+
29
+        //积分
30
+        if(isset($product['mer_id']) && $product['mer_id'] == '148' && !$data['is_new'])  return $this -> getMessage(105);
31
+
32
+        //秒杀
33
+        $nowTime = date("Y-m-d H:00:00");//当前小时
34
+        $seckill = Db::query("select * from `rrx_product_seckill` where `seckill_date`=? and `product_id`=? and `status`=1 limit 1",[$nowTime,$data['product_id']]);
35
+        if($seckill && !$data['is_new']) return $this -> getMessage(105);
36
+
37
+        return ['product' => $product,'sku' => $sku];
38
+    }
39
+
40
+    /**
41
+     * TODO 购物车检测
42
+     * @param $uid
43
+     * @param $product_attr_unique
44
+     * @return array|boolean
45
+     */
46
+    public function checkCart($uid,$product_attr_unique){
47
+//        ['is_del'=>0,'is_fail'=>0,'is_new'=>0,'is_pay'=>0,'uid' => $uid,'product_type' => 0,'product_attr_unique' => $sku];
48
+        $cartSelect = Db::query("select * from `rrx_store_cart` where `is_del`=? and `is_fail`=? and `is_new`=? 
49
+                                 and `is_pay`=? and `uid`=? and `product_type`=? and `product_attr_unique`=? limit 1",
50
+                                [0,0,0,0,$uid,0,$product_attr_unique]);
51
+        if($cartSelect) return $cartSelect[0];
52
+        return false;
53
+    }
54
+
55
+    /**
56
+     * TODO 购物车数量修改
57
+     * @param $cart_id
58
+     * @param $cart_num
59
+     */
60
+    public function updateCart($cart_id,$cart_num){
61
+        try {
62
+            Db::query("UPDATE `rrx_store_cart` SET `cart_num`=? WHERE `cart_id`=?",[$cart_num,$cart_id]);
63
+        }catch (\Exception $e){
64
+            log::error(parseException($e));
65
+            return $this -> getMessage(108);
66
+        }
67
+    }
68
+
69
+    /**
70
+     * TODO 商品检测
71
+     * @param $data
72
+     * @return array
73
+     */
74
+    public function createCart($data){
75
+        try {
76
+            Db::query("INSERT INTO `rrx_store_cart` SET 
77
+                            `product_id`=?, 
78
+                            `product_attr_unique`=?, 
79
+                            `cart_num`=?, 
80
+                            `is_new`=?, 
81
+                            `uid`=?, 
82
+                            `mer_id`=?, 
83
+                            `create_time`=?",
84
+                [$data['product_id'],$data['product_attr_unique'],$data['cart_num'],$data['is_new'],$data['uid'],$data['mer_id'],date("Y-m-d H:i:s")]);
85
+            //返回购物车ID
86
+            $cartId = Db::query("SELECT LAST_INSERT_ID()");
87
+            return ['cart_id'=>$cartId[0]['LAST_INSERT_ID()']];
88
+        }catch (\Exception $e){
89
+            log::error(parseException($e));
90
+            return $this -> getMessage(107);
91
+        }
92
+    }
93
+
94
+    /**
95
+     * TODO 获取单个购物车详情
96
+     * @param $cartId
97
+     * @param $uid
98
+     * @return array
99
+     */
100
+    public function getOne($cartId,$uid){
101
+        //'is_del'=>0,'is_fail'=>0,'is_new'=>0,'is_pay'=>0,'uid' => $uid];
102
+        $cartSelect = Db::query("select * from `rrx_store_cart` where `uid`=? and `cart_id`=? limit 1",[$uid,$cartId]);
103
+        if(!$cartSelect) return $this -> getMessage(109);
104
+        return $cartSelect[0];
105
+    }
106
+
107
+}

+ 29 - 0
app/controller/Auth.php

@@ -0,0 +1,29 @@
1
+<?php
2
+
3
+namespace app\controller;
4
+
5
+use app\exceptions\AuthException;
6
+use think\facade\Cache;
7
+use think\facade\Db;
8
+use think\facade\Log;
9
+
10
+class Auth
11
+{
12
+    //检查token
13
+    public static function checkToken($token,$param){
14
+
15
+        try {
16
+            //redis
17
+            $uid = Cache::get($token);
18
+            //如果redis不存在,则提示token不存在
19
+            if(!$uid) return false;
20
+
21
+            $userInfo = Db::query("select * from `rrx_user` where `uid`=? limit 1", [$uid]);
22
+            if (!$userInfo) return ['code'=>101];
23
+            return array('data'=>$param,'userInfo'=>$userInfo[0]);
24
+        } catch (\Exception $exception) {
25
+            Log::info('检查token出错'.parseException($exception));
26
+            return array('code'=>500);
27
+        }
28
+    }
29
+}

+ 10 - 0
app/controller/Index.php

@@ -0,0 +1,10 @@
1
+<?php
2
+namespace app\controller;
3
+
4
+use app\BaseController;
5
+
6
+class Index extends BaseController
7
+{
8
+
9
+
10
+}

+ 63 - 0
app/controller/cart/Index.php

@@ -0,0 +1,63 @@
1
+<?php
2
+
3
+namespace app\controller\cart;
4
+
5
+use app\BaseController;
6
+use app\common\cart\CartRepository;
7
+use app\validate\CreateCart;
8
+use think\exception\ValidateException;
9
+
10
+class Index extends BaseController
11
+{
12
+
13
+    public function createCart(){
14
+        $data = $this -> request -> param();
15
+        try {
16
+            validate(CreateCart::class)->check($data);
17
+        }catch (ValidateException $exception){
18
+            return app('json') -> fail($exception->getError());
19
+        }
20
+        $cartRepository = new CartRepository();
21
+        //商品检测
22
+        $product = $cartRepository -> checkProduct($data);
23
+        if(isset($product['bool']) && !$product['bool']) return app('json')->fail($product['message']);
24
+        //购物车检测
25
+        $cart = $cartRepository -> checkCart($this->request->uid(),$data['product_attr_unique']);
26
+        if(isset($cart['bool']) && !$cart['bool']) return app('json')->fail($cart['message']);
27
+        //不是立即购买,购物车存在
28
+        if (!$data['is_new'] && $cart) {
29
+            if ($product['sku']['stock'] < ($cart['cart_num'] + $data['cart_num']))
30
+                return app('json')->fail('库存不足');
31
+            //修改购物车数量
32
+            $res = $cartRepository -> updateCart($cart['cart_id'], $cart['cart_num'] + $data['cart_num']);
33
+            if(isset($res['bool']) && !$res['bool']) return app('json')->fail($res['message']);
34
+        }else{
35
+            if ($product['sku']['stock'] < $data['cart_num']) return app('json')->fail('库存不足');
36
+            $data['uid'] = $this->request->uid();
37
+            $data['mer_id'] = $product['product']['mer_id'];
38
+            $cart = $cartRepository->createCart($data);
39
+            if(isset($cart['bool']) && !$cart['bool']) return app('json')->fail($cart['message']);
40
+        }
41
+        return app('json')->success(['cart_id' => $cart['cart_id']]);
42
+    }
43
+
44
+    public function changeCart(){
45
+        $data = $this -> request -> param();
46
+        if (empty($data['cart_id'])) return app('json')->fail('cart_id不能为空');
47
+        if (empty($data['cart_num'])) return app('json')->fail('数量必须大于0');
48
+        $cartRepository = new CartRepository();
49
+        $cartInfo = $cartRepository -> getOne($data['cart_id'],$this->request->uid());
50
+        if(isset($cartInfo['bool']) && !$cartInfo['bool']) return app('json')->fail($cartInfo['message']);
51
+        //商品检测
52
+        $product = $cartRepository -> checkProduct([
53
+            "cart_num" => $data['cart_num'],
54
+            "product_id" => $cartInfo['product_id'],
55
+            "product_attr_unique"=>$cartInfo['product_attr_unique']
56
+        ]);
57
+        if(isset($product['bool']) && !$product['bool']) return app('json')->fail($product['message']);
58
+        //修改购物车数量
59
+        $res = $cartRepository -> updateCart($data['cart_id'], $data['cart_num']);
60
+        if(isset($res['bool']) && !$res['bool']) return app('json')->fail($res['message']);
61
+        return app('json')->success('修改成功');
62
+    }
63
+}

+ 17 - 0
app/event.php

@@ -0,0 +1,17 @@
1
+<?php
2
+// 事件定义文件
3
+return [
4
+    'bind'      => [
5
+    ],
6
+
7
+    'listen'    => [
8
+        'AppInit'  => [],
9
+        'HttpRun'  => [],
10
+        'HttpEnd'  => [],
11
+        'LogLevel' => [],
12
+        'LogWrite' => [],
13
+    ],
14
+
15
+    'subscribe' => [
16
+    ],
17
+];

+ 12 - 0
app/exceptions/AuthException.php

@@ -0,0 +1,12 @@
1
+<?php
2
+namespace app\exceptions;
3
+
4
+use think\exception\HttpResponseException;
5
+
6
+class AuthException extends HttpResponseException
7
+{
8
+    public function __construct($message, $code = 40000)
9
+    {
10
+        parent::__construct(app('json')->make($code, $message));
11
+    }
12
+}

+ 11 - 0
app/middleware.php

@@ -0,0 +1,11 @@
1
+<?php
2
+// 全局中间件定义文件
3
+return [
4
+    // 全局请求缓存
5
+    // \think\middleware\CheckRequestCache::class,
6
+    // 多语言加载
7
+    // \think\middleware\LoadLangPack::class,
8
+    // Session初始化
9
+    // \think\middleware\SessionInit::class
10
+    \think\middleware\AllowCrossDomain::class
11
+];

+ 51 - 0
app/middleware/UserTokenMiddleware.php

@@ -0,0 +1,51 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-03-24
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\middleware;
12
+
13
+use app\controller\Auth;
14
+use app\Request;
15
+use think\Response;
16
+use app\exceptions\AuthException;
17
+
18
+
19
+class UserTokenMiddleware
20
+{
21
+
22
+    public function handle(Request $request,\Closure $next)
23
+    {
24
+
25
+        $XToken = $request->header('X-Token');
26
+        if(!$XToken) throw new AuthException('token不存在');
27
+        $token = trim($request->header('X-Token'));
28
+        if (!$token) throw new AuthException('无效的token');
29
+        $data = Auth::checkToken($token,$request->param());
30
+        if(!$data) throw new AuthException('无效的token!');
31
+
32
+        if(isset($data['code']) && $data['code'] == 101) throw new AuthException('用户不存在');
33
+        if(isset($data['code']) && $data['code'] == 500) throw new AuthException('系统错误');
34
+
35
+        $request->macro('token', function () use (&$token) {
36
+            return $token;
37
+        });
38
+        $request->macro('userInfo', function () use (&$data) {
39
+            return $data['userInfo'];
40
+        });
41
+        $request->macro('uid', function () use (&$data) {
42
+            return $data['userInfo']['uid'];
43
+        });
44
+        return $next($request);
45
+    }
46
+
47
+    public function after(Response $response)
48
+    {
49
+        // TODO: Implement after() method.
50
+    }
51
+}

+ 10 - 0
app/provider.php

@@ -0,0 +1,10 @@
1
+<?php
2
+use app\ExceptionHandle;
3
+use app\Request;
4
+
5
+// 容器Provider定义文件
6
+return [
7
+    'think\Request'          => Request::class,
8
+    'think\exception\Handle' => ExceptionHandle::class,
9
+    'json' => \app\services\ApiResponseService::class,
10
+];

+ 9 - 0
app/service.php

@@ -0,0 +1,9 @@
1
+<?php
2
+
3
+use app\AppService;
4
+
5
+// 系统服务定义文件
6
+// 服务在完成全局初始化之后执行
7
+return [
8
+    AppService::class,
9
+];

+ 121 - 0
app/services/ApiResponseService.php

@@ -0,0 +1,121 @@
1
+<?php
2
+namespace app\services;
3
+
4
+use think\contract\Arrayable;
5
+use think\response\Json;
6
+
7
+class ApiResponseService
8
+{
9
+    protected $response;
10
+
11
+    const DEFAULT_SUCCESS_MESSAGE = 'success';
12
+    const DEFAULT_FAIL_MESSAGE = 'fail';
13
+
14
+    const DEFAULT_SUCCESS_CODE = 200;
15
+    const DEFAULT_FAIL_CODE = 400;
16
+
17
+    public function __construct(Json $response)
18
+    {
19
+        $this->response = $response;
20
+    }
21
+
22
+    public function code(int $code)
23
+    {
24
+        $this->response->code($code);
25
+
26
+        return $this;
27
+    }
28
+
29
+    /**
30
+     * @param $data
31
+     * @return array|string|null
32
+     */
33
+    private function parseData($data)
34
+    {
35
+        if ($data instanceof Arrayable)
36
+            return $data->toArray();
37
+        else
38
+            return $data;
39
+    }
40
+
41
+    /**
42
+     * @param int $code
43
+     * @param string $message
44
+     * @param array|Arrayable|null $data
45
+     * @return Json
46
+     */
47
+    public function make(int $code, string $message, $data = null): Json
48
+    {
49
+        $content = compact('code', 'message');
50
+        if (!is_null($data))
51
+            $content['data'] = $this->parseData($data);
52
+        $this->response->data($content);
53
+        return $this->response;
54
+    }
55
+
56
+    /**
57
+     * @param string|array|Arrayable $message
58
+     * @param array|Arrayable|null $data
59
+     * @return Json
60
+     */
61
+    public function success($message = self::DEFAULT_SUCCESS_MESSAGE, $data = null)
62
+    {
63
+        $message = $this->parseData($message);
64
+        if (is_array($message)) {
65
+            $data = $message;
66
+            $message = self::DEFAULT_SUCCESS_MESSAGE;
67
+        } else {
68
+            $data = $this->parseData($data);
69
+        }
70
+        return $this->make(self::DEFAULT_SUCCESS_CODE, $message, $data);
71
+    }
72
+
73
+    /**
74
+     * @param string|array|Arrayable $message
75
+     * @param array|Arrayable|null $data
76
+     * @return Json
77
+     */
78
+    public function fail($message = self::DEFAULT_FAIL_MESSAGE, $data = null)
79
+    {
80
+        $message = $this->parseData($message);
81
+        if (is_array($message)) {
82
+            $data = $message;
83
+            $message = self::DEFAULT_FAIL_MESSAGE;
84
+        } else {
85
+            $data = $this->parseData($data);
86
+        }
87
+        return $this->make(self::DEFAULT_FAIL_CODE, $message, $data);
88
+    }
89
+
90
+    /**
91
+     * @param $status
92
+     * @param string|array|Arrayable $message
93
+     * @param array|Arrayable $result
94
+     * @return Json
95
+     */
96
+    public function status($status, $message, $result = [])
97
+    {
98
+        $message = $this->parseData($message);
99
+        if (is_array($message)) {
100
+            $result = $message;
101
+            $message = self::DEFAULT_SUCCESS_MESSAGE;
102
+        } else {
103
+            $result = $this->parseData($result);
104
+        }
105
+        return $this->make(self::DEFAULT_SUCCESS_CODE, $message, compact('status', 'result'));
106
+    }
107
+
108
+    /**
109
+     * @param string $type
110
+     * @param $data
111
+     * @return Json
112
+     * @author xaboy
113
+     * @day 2020/6/13
114
+     */
115
+    public function message(string $type, $data)
116
+    {
117
+        $this->response->data(compact('type', 'data'));
118
+        return $this->response;
119
+    }
120
+
121
+}

+ 64 - 0
app/traits/Macro.php

@@ -0,0 +1,64 @@
1
+<?php
2
+/**
3
+ * @package merchant
4
+ *
5
+ * @author xaboy
6
+ * @day 2020-04-10
7
+ *
8
+ * 
9
+ */
10
+
11
+namespace app\traits;
12
+
13
+
14
+use BadMethodCallException;
15
+use Closure;
16
+
17
+trait Macro
18
+{
19
+    protected $macroList = [];
20
+
21
+    /**
22
+     * @param string $name
23
+     * @param $macro
24
+     */
25
+    public function macro(string $name, $macro)
26
+    {
27
+        $this->macroList[$name] = $macro;
28
+    }
29
+
30
+    /**
31
+     * @param array $names
32
+     * @param $macro
33
+     */
34
+    public function macros(array $names, $macro)
35
+    {
36
+        foreach ($names as $name) {
37
+            $this->macro($name, $macro);
38
+        }
39
+    }
40
+
41
+    /**
42
+     * @param string $name
43
+     * @return bool
44
+     */
45
+    public function hasMacro(string $name): bool
46
+    {
47
+        return isset($this->macroList[$name]);
48
+    }
49
+
50
+    public function __call($method, $parameters)
51
+    {
52
+        if (!$this->hasMacro($method)) {
53
+            throw new BadMethodCallException("Method {$method} does not exist.");
54
+        }
55
+
56
+        $macro = $this->macroList[$method];
57
+
58
+        if ($macro instanceof Closure) {
59
+            return call_user_func_array($macro->bindTo($this, static::class), $parameters);
60
+        }
61
+
62
+        return call_user_func_array($macro, $parameters);
63
+    }
64
+}

+ 19 - 0
app/validate/CreateCart.php

@@ -0,0 +1,19 @@
1
+<?php
2
+
3
+
4
+namespace app\validate;
5
+
6
+
7
+use think\Validate;
8
+
9
+class CreateCart extends Validate
10
+{
11
+    protected $rule = [
12
+        'product_id' =>  'require',//商品ID
13
+        'product_attr_unique' =>  'require',//商品unique
14
+        'cart_num' =>  'require',//商品数量
15
+        'is_new' =>  'require',//0加入购物车 1立即购买
16
+    ];
17
+
18
+
19
+}

+ 47 - 0
composer.json

@@ -0,0 +1,47 @@
1
+{
2
+    "name": "topthink/think",
3
+    "description": "the new thinkphp framework",
4
+    "type": "project",
5
+    "keywords": [
6
+        "framework",
7
+        "thinkphp",
8
+        "ORM"
9
+    ],
10
+    "homepage": "https://www.thinkphp.cn/",
11
+    "license": "Apache-2.0",
12
+    "authors": [
13
+        {
14
+            "name": "liu21st",
15
+            "email": "liu21st@gmail.com"
16
+        },
17
+        {
18
+            "name": "yunwuxin",
19
+            "email": "448901948@qq.com"
20
+        }        
21
+    ],
22
+    "require": {
23
+        "php": ">=7.2.5",
24
+        "topthink/framework": "^6.0.0",
25
+        "topthink/think-orm": "^2.0"
26
+    },
27
+    "require-dev": {
28
+        "symfony/var-dumper": "^4.2"
29
+    },
30
+    "autoload": {
31
+        "psr-4": {
32
+            "app\\": "app"
33
+        },
34
+        "psr-0": {
35
+            "": "extend/"
36
+        }
37
+    },
38
+    "config": {
39
+        "preferred-install": "dist"
40
+    },
41
+    "scripts": {
42
+        "post-autoload-dump": [
43
+            "@php think service:discover",
44
+            "@php think vendor:publish"
45
+        ]
46
+    }
47
+}

+ 973 - 0
composer.lock

@@ -0,0 +1,973 @@
1
+{
2
+    "_readme": [
3
+        "This file locks the dependencies of your project to a known state",
4
+        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
5
+        "This file is @generated automatically"
6
+    ],
7
+    "content-hash": "d8d8d65c6459e310594e308ad5760f16",
8
+    "packages": [
9
+        {
10
+            "name": "league/flysystem",
11
+            "version": "1.1.10",
12
+            "source": {
13
+                "type": "git",
14
+                "url": "https://github.com/thephpleague/flysystem.git",
15
+                "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1"
16
+            },
17
+            "dist": {
18
+                "type": "zip",
19
+                "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/3239285c825c152bcc315fe0e87d6b55f5972ed1",
20
+                "reference": "3239285c825c152bcc315fe0e87d6b55f5972ed1",
21
+                "shasum": ""
22
+            },
23
+            "require": {
24
+                "ext-fileinfo": "*",
25
+                "league/mime-type-detection": "^1.3",
26
+                "php": "^7.2.5 || ^8.0"
27
+            },
28
+            "conflict": {
29
+                "league/flysystem-sftp": "<1.0.6"
30
+            },
31
+            "require-dev": {
32
+                "phpspec/prophecy": "^1.11.1",
33
+                "phpunit/phpunit": "^8.5.8"
34
+            },
35
+            "suggest": {
36
+                "ext-ftp": "Allows you to use FTP server storage",
37
+                "ext-openssl": "Allows you to use FTPS server storage",
38
+                "league/flysystem-aws-s3-v2": "Allows you to use S3 storage with AWS SDK v2",
39
+                "league/flysystem-aws-s3-v3": "Allows you to use S3 storage with AWS SDK v3",
40
+                "league/flysystem-azure": "Allows you to use Windows Azure Blob storage",
41
+                "league/flysystem-cached-adapter": "Flysystem adapter decorator for metadata caching",
42
+                "league/flysystem-eventable-filesystem": "Allows you to use EventableFilesystem",
43
+                "league/flysystem-rackspace": "Allows you to use Rackspace Cloud Files",
44
+                "league/flysystem-sftp": "Allows you to use SFTP server storage via phpseclib",
45
+                "league/flysystem-webdav": "Allows you to use WebDAV storage",
46
+                "league/flysystem-ziparchive": "Allows you to use ZipArchive adapter",
47
+                "spatie/flysystem-dropbox": "Allows you to use Dropbox storage",
48
+                "srmklive/flysystem-dropbox-v2": "Allows you to use Dropbox storage for PHP 5 applications"
49
+            },
50
+            "type": "library",
51
+            "extra": {
52
+                "branch-alias": {
53
+                    "dev-master": "1.1-dev"
54
+                }
55
+            },
56
+            "autoload": {
57
+                "psr-4": {
58
+                    "League\\Flysystem\\": "src/"
59
+                }
60
+            },
61
+            "notification-url": "https://packagist.org/downloads/",
62
+            "license": [
63
+                "MIT"
64
+            ],
65
+            "authors": [
66
+                {
67
+                    "name": "Frank de Jonge",
68
+                    "email": "info@frenky.net"
69
+                }
70
+            ],
71
+            "description": "Filesystem abstraction: Many filesystems, one API.",
72
+            "keywords": [
73
+                "Cloud Files",
74
+                "WebDAV",
75
+                "abstraction",
76
+                "aws",
77
+                "cloud",
78
+                "copy.com",
79
+                "dropbox",
80
+                "file systems",
81
+                "files",
82
+                "filesystem",
83
+                "filesystems",
84
+                "ftp",
85
+                "rackspace",
86
+                "remote",
87
+                "s3",
88
+                "sftp",
89
+                "storage"
90
+            ],
91
+            "support": {
92
+                "issues": "https://github.com/thephpleague/flysystem/issues",
93
+                "source": "https://github.com/thephpleague/flysystem/tree/1.1.10"
94
+            },
95
+            "funding": [
96
+                {
97
+                    "url": "https://offset.earth/frankdejonge",
98
+                    "type": "other"
99
+                }
100
+            ],
101
+            "time": "2022-10-04T09:16:37+00:00"
102
+        },
103
+        {
104
+            "name": "league/flysystem-cached-adapter",
105
+            "version": "1.1.0",
106
+            "source": {
107
+                "type": "git",
108
+                "url": "https://github.com/thephpleague/flysystem-cached-adapter.git",
109
+                "reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff"
110
+            },
111
+            "dist": {
112
+                "type": "zip",
113
+                "url": "https://api.github.com/repos/thephpleague/flysystem-cached-adapter/zipball/d1925efb2207ac4be3ad0c40b8277175f99ffaff",
114
+                "reference": "d1925efb2207ac4be3ad0c40b8277175f99ffaff",
115
+                "shasum": ""
116
+            },
117
+            "require": {
118
+                "league/flysystem": "~1.0",
119
+                "psr/cache": "^1.0.0"
120
+            },
121
+            "require-dev": {
122
+                "mockery/mockery": "~0.9",
123
+                "phpspec/phpspec": "^3.4",
124
+                "phpunit/phpunit": "^5.7",
125
+                "predis/predis": "~1.0",
126
+                "tedivm/stash": "~0.12"
127
+            },
128
+            "suggest": {
129
+                "ext-phpredis": "Pure C implemented extension for PHP"
130
+            },
131
+            "type": "library",
132
+            "autoload": {
133
+                "psr-4": {
134
+                    "League\\Flysystem\\Cached\\": "src/"
135
+                }
136
+            },
137
+            "notification-url": "https://packagist.org/downloads/",
138
+            "license": [
139
+                "MIT"
140
+            ],
141
+            "authors": [
142
+                {
143
+                    "name": "frankdejonge",
144
+                    "email": "info@frenky.net"
145
+                }
146
+            ],
147
+            "description": "An adapter decorator to enable meta-data caching.",
148
+            "support": {
149
+                "issues": "https://github.com/thephpleague/flysystem-cached-adapter/issues",
150
+                "source": "https://github.com/thephpleague/flysystem-cached-adapter/tree/master"
151
+            },
152
+            "time": "2020-07-25T15:56:04+00:00"
153
+        },
154
+        {
155
+            "name": "league/mime-type-detection",
156
+            "version": "1.11.0",
157
+            "source": {
158
+                "type": "git",
159
+                "url": "https://github.com/thephpleague/mime-type-detection.git",
160
+                "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd"
161
+            },
162
+            "dist": {
163
+                "type": "zip",
164
+                "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/ff6248ea87a9f116e78edd6002e39e5128a0d4dd",
165
+                "reference": "ff6248ea87a9f116e78edd6002e39e5128a0d4dd",
166
+                "shasum": ""
167
+            },
168
+            "require": {
169
+                "ext-fileinfo": "*",
170
+                "php": "^7.2 || ^8.0"
171
+            },
172
+            "require-dev": {
173
+                "friendsofphp/php-cs-fixer": "^3.2",
174
+                "phpstan/phpstan": "^0.12.68",
175
+                "phpunit/phpunit": "^8.5.8 || ^9.3"
176
+            },
177
+            "type": "library",
178
+            "autoload": {
179
+                "psr-4": {
180
+                    "League\\MimeTypeDetection\\": "src"
181
+                }
182
+            },
183
+            "notification-url": "https://packagist.org/downloads/",
184
+            "license": [
185
+                "MIT"
186
+            ],
187
+            "authors": [
188
+                {
189
+                    "name": "Frank de Jonge",
190
+                    "email": "info@frankdejonge.nl"
191
+                }
192
+            ],
193
+            "description": "Mime-type detection for Flysystem",
194
+            "support": {
195
+                "issues": "https://github.com/thephpleague/mime-type-detection/issues",
196
+                "source": "https://github.com/thephpleague/mime-type-detection/tree/1.11.0"
197
+            },
198
+            "funding": [
199
+                {
200
+                    "url": "https://github.com/frankdejonge",
201
+                    "type": "github"
202
+                },
203
+                {
204
+                    "url": "https://tidelift.com/funding/github/packagist/league/flysystem",
205
+                    "type": "tidelift"
206
+                }
207
+            ],
208
+            "time": "2022-04-17T13:12:02+00:00"
209
+        },
210
+        {
211
+            "name": "psr/cache",
212
+            "version": "1.0.1",
213
+            "source": {
214
+                "type": "git",
215
+                "url": "https://github.com/php-fig/cache.git",
216
+                "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
217
+            },
218
+            "dist": {
219
+                "type": "zip",
220
+                "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
221
+                "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
222
+                "shasum": ""
223
+            },
224
+            "require": {
225
+                "php": ">=5.3.0"
226
+            },
227
+            "type": "library",
228
+            "extra": {
229
+                "branch-alias": {
230
+                    "dev-master": "1.0.x-dev"
231
+                }
232
+            },
233
+            "autoload": {
234
+                "psr-4": {
235
+                    "Psr\\Cache\\": "src/"
236
+                }
237
+            },
238
+            "notification-url": "https://packagist.org/downloads/",
239
+            "license": [
240
+                "MIT"
241
+            ],
242
+            "authors": [
243
+                {
244
+                    "name": "PHP-FIG",
245
+                    "homepage": "http://www.php-fig.org/"
246
+                }
247
+            ],
248
+            "description": "Common interface for caching libraries",
249
+            "keywords": [
250
+                "cache",
251
+                "psr",
252
+                "psr-6"
253
+            ],
254
+            "support": {
255
+                "source": "https://github.com/php-fig/cache/tree/master"
256
+            },
257
+            "time": "2016-08-06T20:24:11+00:00"
258
+        },
259
+        {
260
+            "name": "psr/container",
261
+            "version": "1.1.2",
262
+            "source": {
263
+                "type": "git",
264
+                "url": "https://github.com/php-fig/container.git",
265
+                "reference": "513e0666f7216c7459170d56df27dfcefe1689ea"
266
+            },
267
+            "dist": {
268
+                "type": "zip",
269
+                "url": "https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea",
270
+                "reference": "513e0666f7216c7459170d56df27dfcefe1689ea",
271
+                "shasum": ""
272
+            },
273
+            "require": {
274
+                "php": ">=7.4.0"
275
+            },
276
+            "type": "library",
277
+            "autoload": {
278
+                "psr-4": {
279
+                    "Psr\\Container\\": "src/"
280
+                }
281
+            },
282
+            "notification-url": "https://packagist.org/downloads/",
283
+            "license": [
284
+                "MIT"
285
+            ],
286
+            "authors": [
287
+                {
288
+                    "name": "PHP-FIG",
289
+                    "homepage": "https://www.php-fig.org/"
290
+                }
291
+            ],
292
+            "description": "Common Container Interface (PHP FIG PSR-11)",
293
+            "homepage": "https://github.com/php-fig/container",
294
+            "keywords": [
295
+                "PSR-11",
296
+                "container",
297
+                "container-interface",
298
+                "container-interop",
299
+                "psr"
300
+            ],
301
+            "support": {
302
+                "issues": "https://github.com/php-fig/container/issues",
303
+                "source": "https://github.com/php-fig/container/tree/1.1.2"
304
+            },
305
+            "time": "2021-11-05T16:50:12+00:00"
306
+        },
307
+        {
308
+            "name": "psr/http-message",
309
+            "version": "1.0.1",
310
+            "source": {
311
+                "type": "git",
312
+                "url": "https://github.com/php-fig/http-message.git",
313
+                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
314
+            },
315
+            "dist": {
316
+                "type": "zip",
317
+                "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
318
+                "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
319
+                "shasum": ""
320
+            },
321
+            "require": {
322
+                "php": ">=5.3.0"
323
+            },
324
+            "type": "library",
325
+            "extra": {
326
+                "branch-alias": {
327
+                    "dev-master": "1.0.x-dev"
328
+                }
329
+            },
330
+            "autoload": {
331
+                "psr-4": {
332
+                    "Psr\\Http\\Message\\": "src/"
333
+                }
334
+            },
335
+            "notification-url": "https://packagist.org/downloads/",
336
+            "license": [
337
+                "MIT"
338
+            ],
339
+            "authors": [
340
+                {
341
+                    "name": "PHP-FIG",
342
+                    "homepage": "http://www.php-fig.org/"
343
+                }
344
+            ],
345
+            "description": "Common interface for HTTP messages",
346
+            "homepage": "https://github.com/php-fig/http-message",
347
+            "keywords": [
348
+                "http",
349
+                "http-message",
350
+                "psr",
351
+                "psr-7",
352
+                "request",
353
+                "response"
354
+            ],
355
+            "support": {
356
+                "source": "https://github.com/php-fig/http-message/tree/master"
357
+            },
358
+            "time": "2016-08-06T14:39:51+00:00"
359
+        },
360
+        {
361
+            "name": "psr/log",
362
+            "version": "1.1.4",
363
+            "source": {
364
+                "type": "git",
365
+                "url": "https://github.com/php-fig/log.git",
366
+                "reference": "d49695b909c3b7628b6289db5479a1c204601f11"
367
+            },
368
+            "dist": {
369
+                "type": "zip",
370
+                "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
371
+                "reference": "d49695b909c3b7628b6289db5479a1c204601f11",
372
+                "shasum": ""
373
+            },
374
+            "require": {
375
+                "php": ">=5.3.0"
376
+            },
377
+            "type": "library",
378
+            "extra": {
379
+                "branch-alias": {
380
+                    "dev-master": "1.1.x-dev"
381
+                }
382
+            },
383
+            "autoload": {
384
+                "psr-4": {
385
+                    "Psr\\Log\\": "Psr/Log/"
386
+                }
387
+            },
388
+            "notification-url": "https://packagist.org/downloads/",
389
+            "license": [
390
+                "MIT"
391
+            ],
392
+            "authors": [
393
+                {
394
+                    "name": "PHP-FIG",
395
+                    "homepage": "https://www.php-fig.org/"
396
+                }
397
+            ],
398
+            "description": "Common interface for logging libraries",
399
+            "homepage": "https://github.com/php-fig/log",
400
+            "keywords": [
401
+                "log",
402
+                "psr",
403
+                "psr-3"
404
+            ],
405
+            "support": {
406
+                "source": "https://github.com/php-fig/log/tree/1.1.4"
407
+            },
408
+            "time": "2021-05-03T11:20:27+00:00"
409
+        },
410
+        {
411
+            "name": "psr/simple-cache",
412
+            "version": "1.0.1",
413
+            "source": {
414
+                "type": "git",
415
+                "url": "https://github.com/php-fig/simple-cache.git",
416
+                "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b"
417
+            },
418
+            "dist": {
419
+                "type": "zip",
420
+                "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
421
+                "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b",
422
+                "shasum": ""
423
+            },
424
+            "require": {
425
+                "php": ">=5.3.0"
426
+            },
427
+            "type": "library",
428
+            "extra": {
429
+                "branch-alias": {
430
+                    "dev-master": "1.0.x-dev"
431
+                }
432
+            },
433
+            "autoload": {
434
+                "psr-4": {
435
+                    "Psr\\SimpleCache\\": "src/"
436
+                }
437
+            },
438
+            "notification-url": "https://packagist.org/downloads/",
439
+            "license": [
440
+                "MIT"
441
+            ],
442
+            "authors": [
443
+                {
444
+                    "name": "PHP-FIG",
445
+                    "homepage": "http://www.php-fig.org/"
446
+                }
447
+            ],
448
+            "description": "Common interfaces for simple caching",
449
+            "keywords": [
450
+                "cache",
451
+                "caching",
452
+                "psr",
453
+                "psr-16",
454
+                "simple-cache"
455
+            ],
456
+            "support": {
457
+                "source": "https://github.com/php-fig/simple-cache/tree/master"
458
+            },
459
+            "time": "2017-10-23T01:57:42+00:00"
460
+        },
461
+        {
462
+            "name": "topthink/framework",
463
+            "version": "v6.0.13",
464
+            "source": {
465
+                "type": "git",
466
+                "url": "https://github.com/top-think/framework.git",
467
+                "reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6"
468
+            },
469
+            "dist": {
470
+                "type": "zip",
471
+                "url": "https://api.github.com/repos/top-think/framework/zipball/126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6",
472
+                "reference": "126d5b2cbacb73d6e2a85cbc7a2c6ee59d0b3fa6",
473
+                "shasum": ""
474
+            },
475
+            "require": {
476
+                "ext-json": "*",
477
+                "ext-mbstring": "*",
478
+                "league/flysystem": "^1.1.4",
479
+                "league/flysystem-cached-adapter": "^1.0",
480
+                "php": ">=7.2.5",
481
+                "psr/container": "~1.0",
482
+                "psr/http-message": "^1.0",
483
+                "psr/log": "~1.0",
484
+                "psr/simple-cache": "^1.0",
485
+                "topthink/think-helper": "^3.1.1",
486
+                "topthink/think-orm": "^2.0"
487
+            },
488
+            "require-dev": {
489
+                "guzzlehttp/psr7": "^2.1.0",
490
+                "mikey179/vfsstream": "^1.6",
491
+                "mockery/mockery": "^1.2",
492
+                "phpunit/phpunit": "^7.0"
493
+            },
494
+            "type": "library",
495
+            "autoload": {
496
+                "files": [],
497
+                "psr-4": {
498
+                    "think\\": "src/think/"
499
+                }
500
+            },
501
+            "notification-url": "https://packagist.org/downloads/",
502
+            "license": [
503
+                "Apache-2.0"
504
+            ],
505
+            "authors": [
506
+                {
507
+                    "name": "liu21st",
508
+                    "email": "liu21st@gmail.com"
509
+                },
510
+                {
511
+                    "name": "yunwuxin",
512
+                    "email": "448901948@qq.com"
513
+                }
514
+            ],
515
+            "description": "The ThinkPHP Framework.",
516
+            "homepage": "http://thinkphp.cn/",
517
+            "keywords": [
518
+                "framework",
519
+                "orm",
520
+                "thinkphp"
521
+            ],
522
+            "support": {
523
+                "issues": "https://github.com/top-think/framework/issues",
524
+                "source": "https://github.com/top-think/framework/tree/v6.0.13"
525
+            },
526
+            "time": "2022-07-15T02:52:08+00:00"
527
+        },
528
+        {
529
+            "name": "topthink/think-helper",
530
+            "version": "v3.1.6",
531
+            "source": {
532
+                "type": "git",
533
+                "url": "https://github.com/top-think/think-helper.git",
534
+                "reference": "769acbe50a4274327162f9c68ec2e89a38eb2aff"
535
+            },
536
+            "dist": {
537
+                "type": "zip",
538
+                "url": "https://api.github.com/repos/top-think/think-helper/zipball/769acbe50a4274327162f9c68ec2e89a38eb2aff",
539
+                "reference": "769acbe50a4274327162f9c68ec2e89a38eb2aff",
540
+                "shasum": ""
541
+            },
542
+            "require": {
543
+                "php": ">=7.1.0"
544
+            },
545
+            "require-dev": {
546
+                "phpunit/phpunit": "^9.5"
547
+            },
548
+            "type": "library",
549
+            "autoload": {
550
+                "files": [
551
+                    "src/helper.php"
552
+                ],
553
+                "psr-4": {
554
+                    "think\\": "src"
555
+                }
556
+            },
557
+            "notification-url": "https://packagist.org/downloads/",
558
+            "license": [
559
+                "Apache-2.0"
560
+            ],
561
+            "authors": [
562
+                {
563
+                    "name": "yunwuxin",
564
+                    "email": "448901948@qq.com"
565
+                }
566
+            ],
567
+            "description": "The ThinkPHP6 Helper Package",
568
+            "support": {
569
+                "issues": "https://github.com/top-think/think-helper/issues",
570
+                "source": "https://github.com/top-think/think-helper/tree/v3.1.6"
571
+            },
572
+            "time": "2021-12-15T04:27:55+00:00"
573
+        },
574
+        {
575
+            "name": "topthink/think-orm",
576
+            "version": "v2.0.54",
577
+            "source": {
578
+                "type": "git",
579
+                "url": "https://github.com/top-think/think-orm.git",
580
+                "reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e"
581
+            },
582
+            "dist": {
583
+                "type": "zip",
584
+                "url": "https://api.github.com/repos/top-think/think-orm/zipball/97b061b47616301ff29fbd4c35ed9184e1162e4e",
585
+                "reference": "97b061b47616301ff29fbd4c35ed9184e1162e4e",
586
+                "shasum": ""
587
+            },
588
+            "require": {
589
+                "ext-json": "*",
590
+                "ext-pdo": "*",
591
+                "php": ">=7.1.0",
592
+                "psr/log": "^1.0|^2.0",
593
+                "psr/simple-cache": "^1.0|^2.0",
594
+                "topthink/think-helper": "^3.1"
595
+            },
596
+            "require-dev": {
597
+                "phpunit/phpunit": "^7|^8|^9.5"
598
+            },
599
+            "type": "library",
600
+            "autoload": {
601
+                "files": [
602
+                    "stubs/load_stubs.php"
603
+                ],
604
+                "psr-4": {
605
+                    "think\\": "src"
606
+                }
607
+            },
608
+            "notification-url": "https://packagist.org/downloads/",
609
+            "license": [
610
+                "Apache-2.0"
611
+            ],
612
+            "authors": [
613
+                {
614
+                    "name": "liu21st",
615
+                    "email": "liu21st@gmail.com"
616
+                }
617
+            ],
618
+            "description": "think orm",
619
+            "keywords": [
620
+                "database",
621
+                "orm"
622
+            ],
623
+            "support": {
624
+                "issues": "https://github.com/top-think/think-orm/issues",
625
+                "source": "https://github.com/top-think/think-orm/tree/v2.0.54"
626
+            },
627
+            "time": "2022-07-05T05:25:51+00:00"
628
+        }
629
+    ],
630
+    "packages-dev": [
631
+        {
632
+            "name": "symfony/polyfill-mbstring",
633
+            "version": "v1.26.0",
634
+            "source": {
635
+                "type": "git",
636
+                "url": "https://github.com/symfony/polyfill-mbstring.git",
637
+                "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e"
638
+            },
639
+            "dist": {
640
+                "type": "zip",
641
+                "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
642
+                "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e",
643
+                "shasum": ""
644
+            },
645
+            "require": {
646
+                "php": ">=7.1"
647
+            },
648
+            "provide": {
649
+                "ext-mbstring": "*"
650
+            },
651
+            "suggest": {
652
+                "ext-mbstring": "For best performance"
653
+            },
654
+            "type": "library",
655
+            "extra": {
656
+                "branch-alias": {
657
+                    "dev-main": "1.26-dev"
658
+                },
659
+                "thanks": {
660
+                    "name": "symfony/polyfill",
661
+                    "url": "https://github.com/symfony/polyfill"
662
+                }
663
+            },
664
+            "autoload": {
665
+                "files": [
666
+                    "bootstrap.php"
667
+                ],
668
+                "psr-4": {
669
+                    "Symfony\\Polyfill\\Mbstring\\": ""
670
+                }
671
+            },
672
+            "notification-url": "https://packagist.org/downloads/",
673
+            "license": [
674
+                "MIT"
675
+            ],
676
+            "authors": [
677
+                {
678
+                    "name": "Nicolas Grekas",
679
+                    "email": "p@tchwork.com"
680
+                },
681
+                {
682
+                    "name": "Symfony Community",
683
+                    "homepage": "https://symfony.com/contributors"
684
+                }
685
+            ],
686
+            "description": "Symfony polyfill for the Mbstring extension",
687
+            "homepage": "https://symfony.com",
688
+            "keywords": [
689
+                "compatibility",
690
+                "mbstring",
691
+                "polyfill",
692
+                "portable",
693
+                "shim"
694
+            ],
695
+            "support": {
696
+                "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0"
697
+            },
698
+            "funding": [
699
+                {
700
+                    "url": "https://symfony.com/sponsor",
701
+                    "type": "custom"
702
+                },
703
+                {
704
+                    "url": "https://github.com/fabpot",
705
+                    "type": "github"
706
+                },
707
+                {
708
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
709
+                    "type": "tidelift"
710
+                }
711
+            ],
712
+            "time": "2022-05-24T11:49:31+00:00"
713
+        },
714
+        {
715
+            "name": "symfony/polyfill-php72",
716
+            "version": "v1.26.0",
717
+            "source": {
718
+                "type": "git",
719
+                "url": "https://github.com/symfony/polyfill-php72.git",
720
+                "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2"
721
+            },
722
+            "dist": {
723
+                "type": "zip",
724
+                "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/bf44a9fd41feaac72b074de600314a93e2ae78e2",
725
+                "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2",
726
+                "shasum": ""
727
+            },
728
+            "require": {
729
+                "php": ">=7.1"
730
+            },
731
+            "type": "library",
732
+            "extra": {
733
+                "branch-alias": {
734
+                    "dev-main": "1.26-dev"
735
+                },
736
+                "thanks": {
737
+                    "name": "symfony/polyfill",
738
+                    "url": "https://github.com/symfony/polyfill"
739
+                }
740
+            },
741
+            "autoload": {
742
+                "files": [
743
+                    "bootstrap.php"
744
+                ],
745
+                "psr-4": {
746
+                    "Symfony\\Polyfill\\Php72\\": ""
747
+                }
748
+            },
749
+            "notification-url": "https://packagist.org/downloads/",
750
+            "license": [
751
+                "MIT"
752
+            ],
753
+            "authors": [
754
+                {
755
+                    "name": "Nicolas Grekas",
756
+                    "email": "p@tchwork.com"
757
+                },
758
+                {
759
+                    "name": "Symfony Community",
760
+                    "homepage": "https://symfony.com/contributors"
761
+                }
762
+            ],
763
+            "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions",
764
+            "homepage": "https://symfony.com",
765
+            "keywords": [
766
+                "compatibility",
767
+                "polyfill",
768
+                "portable",
769
+                "shim"
770
+            ],
771
+            "support": {
772
+                "source": "https://github.com/symfony/polyfill-php72/tree/v1.26.0"
773
+            },
774
+            "funding": [
775
+                {
776
+                    "url": "https://symfony.com/sponsor",
777
+                    "type": "custom"
778
+                },
779
+                {
780
+                    "url": "https://github.com/fabpot",
781
+                    "type": "github"
782
+                },
783
+                {
784
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
785
+                    "type": "tidelift"
786
+                }
787
+            ],
788
+            "time": "2022-05-24T11:49:31+00:00"
789
+        },
790
+        {
791
+            "name": "symfony/polyfill-php80",
792
+            "version": "v1.26.0",
793
+            "source": {
794
+                "type": "git",
795
+                "url": "https://github.com/symfony/polyfill-php80.git",
796
+                "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace"
797
+            },
798
+            "dist": {
799
+                "type": "zip",
800
+                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace",
801
+                "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace",
802
+                "shasum": ""
803
+            },
804
+            "require": {
805
+                "php": ">=7.1"
806
+            },
807
+            "type": "library",
808
+            "extra": {
809
+                "branch-alias": {
810
+                    "dev-main": "1.26-dev"
811
+                },
812
+                "thanks": {
813
+                    "name": "symfony/polyfill",
814
+                    "url": "https://github.com/symfony/polyfill"
815
+                }
816
+            },
817
+            "autoload": {
818
+                "files": [
819
+                    "bootstrap.php"
820
+                ],
821
+                "psr-4": {
822
+                    "Symfony\\Polyfill\\Php80\\": ""
823
+                },
824
+                "classmap": [
825
+                    "Resources/stubs"
826
+                ]
827
+            },
828
+            "notification-url": "https://packagist.org/downloads/",
829
+            "license": [
830
+                "MIT"
831
+            ],
832
+            "authors": [
833
+                {
834
+                    "name": "Ion Bazan",
835
+                    "email": "ion.bazan@gmail.com"
836
+                },
837
+                {
838
+                    "name": "Nicolas Grekas",
839
+                    "email": "p@tchwork.com"
840
+                },
841
+                {
842
+                    "name": "Symfony Community",
843
+                    "homepage": "https://symfony.com/contributors"
844
+                }
845
+            ],
846
+            "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
847
+            "homepage": "https://symfony.com",
848
+            "keywords": [
849
+                "compatibility",
850
+                "polyfill",
851
+                "portable",
852
+                "shim"
853
+            ],
854
+            "support": {
855
+                "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0"
856
+            },
857
+            "funding": [
858
+                {
859
+                    "url": "https://symfony.com/sponsor",
860
+                    "type": "custom"
861
+                },
862
+                {
863
+                    "url": "https://github.com/fabpot",
864
+                    "type": "github"
865
+                },
866
+                {
867
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
868
+                    "type": "tidelift"
869
+                }
870
+            ],
871
+            "time": "2022-05-10T07:21:04+00:00"
872
+        },
873
+        {
874
+            "name": "symfony/var-dumper",
875
+            "version": "v4.4.47",
876
+            "source": {
877
+                "type": "git",
878
+                "url": "https://github.com/symfony/var-dumper.git",
879
+                "reference": "1069c7a3fca74578022fab6f81643248d02f8e63"
880
+            },
881
+            "dist": {
882
+                "type": "zip",
883
+                "url": "https://api.github.com/repos/symfony/var-dumper/zipball/1069c7a3fca74578022fab6f81643248d02f8e63",
884
+                "reference": "1069c7a3fca74578022fab6f81643248d02f8e63",
885
+                "shasum": ""
886
+            },
887
+            "require": {
888
+                "php": ">=7.1.3",
889
+                "symfony/polyfill-mbstring": "~1.0",
890
+                "symfony/polyfill-php72": "~1.5",
891
+                "symfony/polyfill-php80": "^1.16"
892
+            },
893
+            "conflict": {
894
+                "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
895
+                "symfony/console": "<3.4"
896
+            },
897
+            "require-dev": {
898
+                "ext-iconv": "*",
899
+                "symfony/console": "^3.4|^4.0|^5.0",
900
+                "symfony/process": "^4.4|^5.0",
901
+                "twig/twig": "^1.43|^2.13|^3.0.4"
902
+            },
903
+            "suggest": {
904
+                "ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
905
+                "ext-intl": "To show region name in time zone dump",
906
+                "symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
907
+            },
908
+            "bin": [
909
+                "Resources/bin/var-dump-server"
910
+            ],
911
+            "type": "library",
912
+            "autoload": {
913
+                "files": [
914
+                    "Resources/functions/dump.php"
915
+                ],
916
+                "psr-4": {
917
+                    "Symfony\\Component\\VarDumper\\": ""
918
+                },
919
+                "exclude-from-classmap": [
920
+                    "/Tests/"
921
+                ]
922
+            },
923
+            "notification-url": "https://packagist.org/downloads/",
924
+            "license": [
925
+                "MIT"
926
+            ],
927
+            "authors": [
928
+                {
929
+                    "name": "Nicolas Grekas",
930
+                    "email": "p@tchwork.com"
931
+                },
932
+                {
933
+                    "name": "Symfony Community",
934
+                    "homepage": "https://symfony.com/contributors"
935
+                }
936
+            ],
937
+            "description": "Provides mechanisms for walking through any arbitrary PHP variable",
938
+            "homepage": "https://symfony.com",
939
+            "keywords": [
940
+                "debug",
941
+                "dump"
942
+            ],
943
+            "support": {
944
+                "source": "https://github.com/symfony/var-dumper/tree/v4.4.47"
945
+            },
946
+            "funding": [
947
+                {
948
+                    "url": "https://symfony.com/sponsor",
949
+                    "type": "custom"
950
+                },
951
+                {
952
+                    "url": "https://github.com/fabpot",
953
+                    "type": "github"
954
+                },
955
+                {
956
+                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
957
+                    "type": "tidelift"
958
+                }
959
+            ],
960
+            "time": "2022-10-03T15:15:11+00:00"
961
+        }
962
+    ],
963
+    "aliases": [],
964
+    "minimum-stability": "stable",
965
+    "stability-flags": [],
966
+    "prefer-stable": false,
967
+    "prefer-lowest": false,
968
+    "platform": {
969
+        "php": ">=7.2.5"
970
+    },
971
+    "platform-dev": [],
972
+    "plugin-api-version": "2.3.0"
973
+}

+ 32 - 0
config/app.php

@@ -0,0 +1,32 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | 应用设置
4
+// +----------------------------------------------------------------------
5
+
6
+return [
7
+    // 应用地址
8
+    'app_host'         => env('app.host', ''),
9
+    // 应用的命名空间
10
+    'app_namespace'    => '',
11
+    // 是否启用路由
12
+    'with_route'       => true,
13
+    // 默认应用
14
+    'default_app'      => 'index',
15
+    // 默认时区
16
+    'default_timezone' => 'Asia/Shanghai',
17
+
18
+    // 应用映射(自动多应用模式有效)
19
+    'app_map'          => [],
20
+    // 域名绑定(自动多应用模式有效)
21
+    'domain_bind'      => [],
22
+    // 禁止URL访问的应用列表(自动多应用模式有效)
23
+    'deny_app_list'    => [],
24
+
25
+    // 异常页面的模板文件
26
+    'exception_tmpl'   => app()->getThinkPath() . 'tpl/think_exception.tpl',
27
+
28
+    // 错误显示信息,非调试模式有效
29
+    'error_message'    => '页面错误!请稍后再试~',
30
+    // 显示错误信息
31
+    'show_error_msg'   => false,
32
+];

+ 41 - 0
config/cache.php

@@ -0,0 +1,41 @@
1
+<?php
2
+
3
+// +----------------------------------------------------------------------
4
+// | 缓存设置
5
+// +----------------------------------------------------------------------
6
+
7
+return [
8
+    // 默认缓存驱动
9
+    'default' => env('cache.driver', 'redis'),
10
+
11
+    // 缓存连接方式配置
12
+    'stores'  => [
13
+        'file' => [
14
+            // 驱动方式
15
+            'type'       => 'File',
16
+            // 缓存保存目录
17
+            'path'       => '',
18
+            // 缓存前缀
19
+            'prefix'     => '',
20
+            // 缓存有效期 0表示永久缓存
21
+            'expire'     => 0,
22
+            // 缓存标签前缀
23
+            'tag_prefix' => 'tag:',
24
+            // 序列化机制 例如 ['serialize', 'unserialize']
25
+            'serialize'  => [],
26
+        ],
27
+        // 更多的缓存连接
28
+        'redis' => [
29
+            // 驱动方式
30
+            'type'       => 'Redis',
31
+            // 服务器地址
32
+            'host'       => env('redis.redis_hostname','127.0.0.1'),
33
+            // 端口
34
+            'port'       => env('redis.port', '6379'),
35
+            // 密码
36
+            'password'   => env('redis.redis_password', ''),
37
+            // 数据库 0号数据库
38
+            'select'     => env('redis.select', 0),
39
+        ],
40
+    ],
41
+];

+ 9 - 0
config/console.php

@@ -0,0 +1,9 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | 控制台配置
4
+// +----------------------------------------------------------------------
5
+return [
6
+    // 指令定义
7
+    'commands' => [
8
+    ],
9
+];

+ 20 - 0
config/cookie.php

@@ -0,0 +1,20 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | Cookie设置
4
+// +----------------------------------------------------------------------
5
+return [
6
+    // cookie 保存时间
7
+    'expire'    => 0,
8
+    // cookie 保存路径
9
+    'path'      => '/',
10
+    // cookie 有效域名
11
+    'domain'    => '',
12
+    //  cookie 启用安全传输
13
+    'secure'    => false,
14
+    // httponly设置
15
+    'httponly'  => false,
16
+    // 是否使用 setcookie
17
+    'setcookie' => true,
18
+    // samesite 设置,支持 'strict' 'lax'
19
+    'samesite'  => '',
20
+];

+ 63 - 0
config/database.php

@@ -0,0 +1,63 @@
1
+<?php
2
+
3
+return [
4
+    // 默认使用的数据库连接配置
5
+    'default'         => env('database.driver', 'mysql'),
6
+
7
+    // 自定义时间查询规则
8
+    'time_query_rule' => [],
9
+
10
+    // 自动写入时间戳字段
11
+    // true为自动识别类型 false关闭
12
+    // 字符串则明确指定时间字段类型 支持 int timestamp datetime date
13
+    'auto_timestamp'  => true,
14
+
15
+    // 时间字段取出后的默认时间格式
16
+    'datetime_format' => 'Y-m-d H:i:s',
17
+
18
+    // 时间字段配置 配置格式:create_time,update_time
19
+    'datetime_field'  => '',
20
+
21
+    // 数据库连接配置信息
22
+    'connections'     => [
23
+        'mysql' => [
24
+            // 数据库类型
25
+            'type'            => env('database.type', 'mysql'),
26
+            // 服务器地址
27
+            'hostname'        => env('database.hostname', '127.0.0.1'),
28
+            // 数据库名
29
+            'database'        => env('database.database', ''),
30
+            // 用户名
31
+            'username'        => env('database.username', 'root'),
32
+            // 密码
33
+            'password'        => env('database.password', ''),
34
+            // 端口
35
+            'hostport'        => env('database.hostport', '3306'),
36
+            // 数据库连接参数
37
+            'params'          => [],
38
+            // 数据库编码默认采用utf8
39
+            'charset'         => env('database.charset', 'utf8'),
40
+            // 数据库表前缀
41
+            'prefix'          => env('database.prefix', ''),
42
+
43
+            // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
44
+            'deploy'          => 0,
45
+            // 数据库读写是否分离 主从式有效
46
+            'rw_separate'     => false,
47
+            // 读写分离后 主服务器数量
48
+            'master_num'      => 1,
49
+            // 指定从服务器序号
50
+            'slave_no'        => '',
51
+            // 是否严格检查字段是否存在
52
+            'fields_strict'   => true,
53
+            // 是否需要断线重连
54
+            'break_reconnect' => false,
55
+            // 监听SQL
56
+            'trigger_sql'     => env('app_debug', true),
57
+            // 开启字段缓存
58
+            'fields_cache'    => false,
59
+        ],
60
+
61
+        // 更多的数据库配置信息
62
+    ],
63
+];

+ 24 - 0
config/filesystem.php

@@ -0,0 +1,24 @@
1
+<?php
2
+
3
+return [
4
+    // 默认磁盘
5
+    'default' => env('filesystem.driver', 'local'),
6
+    // 磁盘列表
7
+    'disks'   => [
8
+        'local'  => [
9
+            'type' => 'local',
10
+            'root' => app()->getRuntimePath() . 'storage',
11
+        ],
12
+        'public' => [
13
+            // 磁盘类型
14
+            'type'       => 'local',
15
+            // 磁盘路径
16
+            'root'       => app()->getRootPath() . 'public/storage',
17
+            // 磁盘路径对应的外部URL路径
18
+            'url'        => '/storage',
19
+            // 可见性
20
+            'visibility' => 'public',
21
+        ],
22
+        // 更多的磁盘配置信息
23
+    ],
24
+];

+ 27 - 0
config/lang.php

@@ -0,0 +1,27 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | 多语言设置
4
+// +----------------------------------------------------------------------
5
+
6
+return [
7
+    // 默认语言
8
+    'default_lang'    => env('lang.default_lang', 'zh-cn'),
9
+    // 允许的语言列表
10
+    'allow_lang_list' => [],
11
+    // 多语言自动侦测变量名
12
+    'detect_var'      => 'lang',
13
+    // 是否使用Cookie记录
14
+    'use_cookie'      => true,
15
+    // 多语言cookie变量
16
+    'cookie_var'      => 'think_lang',
17
+    // 多语言header变量
18
+    'header_var'      => 'think-lang',
19
+    // 扩展语言包
20
+    'extend_list'     => [],
21
+    // Accept-Language转义为对应语言包名称
22
+    'accept_language' => [
23
+        'zh-hans-cn' => 'zh-cn',
24
+    ],
25
+    // 是否支持语言分组
26
+    'allow_group'     => false,
27
+];

+ 45 - 0
config/log.php

@@ -0,0 +1,45 @@
1
+<?php
2
+
3
+// +----------------------------------------------------------------------
4
+// | 日志设置
5
+// +----------------------------------------------------------------------
6
+return [
7
+    // 默认日志记录通道
8
+    'default'      => env('log.channel', 'file'),
9
+    // 日志记录级别
10
+    'level'        => [],
11
+    // 日志类型记录的通道 ['error'=>'email',...]
12
+    'type_channel' => [],
13
+    // 关闭全局日志写入
14
+    'close'        => false,
15
+    // 全局日志处理 支持闭包
16
+    'processor'    => null,
17
+
18
+    // 日志通道列表
19
+    'channels'     => [
20
+        'file' => [
21
+            // 日志记录方式
22
+            'type'           => 'File',
23
+            // 日志保存目录
24
+            'path'           => '',
25
+            // 单文件日志写入
26
+            'single'         => false,
27
+            // 独立日志级别
28
+            'apart_level'    => [],
29
+            // 最大日志文件数量
30
+            'max_files'      => 0,
31
+            // 使用JSON格式记录
32
+            'json'           => false,
33
+            // 日志处理
34
+            'processor'      => null,
35
+            // 关闭通道日志写入
36
+            'close'          => false,
37
+            // 日志输出格式化
38
+            'format'         => '[%s][%s] %s',
39
+            // 是否实时写入
40
+            'realtime_write' => false,
41
+        ],
42
+        // 其它日志通道配置
43
+    ],
44
+
45
+];

+ 8 - 0
config/middleware.php

@@ -0,0 +1,8 @@
1
+<?php
2
+// 中间件配置
3
+return [
4
+    // 别名或分组
5
+    'alias'    => [],
6
+    // 优先级设置,此数组中的中间件会按照数组中的顺序优先执行
7
+    'priority' => [],
8
+];

+ 45 - 0
config/route.php

@@ -0,0 +1,45 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | 路由设置
4
+// +----------------------------------------------------------------------
5
+
6
+return [
7
+    // pathinfo分隔符
8
+    'pathinfo_depr'         => '/',
9
+    // URL伪静态后缀
10
+    'url_html_suffix'       => 'html',
11
+    // URL普通方式参数 用于自动生成
12
+    'url_common_param'      => true,
13
+    // 是否开启路由延迟解析
14
+    'url_lazy_route'        => false,
15
+    // 是否强制使用路由
16
+    'url_route_must'        => false,
17
+    // 合并路由规则
18
+    'route_rule_merge'      => false,
19
+    // 路由是否完全匹配
20
+    'route_complete_match'  => false,
21
+    // 访问控制器层名称
22
+    'controller_layer'      => 'controller',
23
+    // 空控制器名
24
+    'empty_controller'      => 'Error',
25
+    // 是否使用控制器后缀
26
+    'controller_suffix'     => false,
27
+    // 默认的路由变量规则
28
+    'default_route_pattern' => '[\w\.]+',
29
+    // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则
30
+    'request_cache_key'     => false,
31
+    // 请求缓存有效期
32
+    'request_cache_expire'  => null,
33
+    // 全局请求缓存排除规则
34
+    'request_cache_except'  => [],
35
+    // 默认控制器名
36
+    'default_controller'    => 'Index',
37
+    // 默认操作名
38
+    'default_action'        => 'index',
39
+    // 操作方法后缀
40
+    'action_suffix'         => '',
41
+    // 默认JSONP格式返回的处理方法
42
+    'default_jsonp_handler' => 'jsonpReturn',
43
+    // 默认JSONP处理方法
44
+    'var_jsonp_handler'     => 'callback',
45
+];

+ 19 - 0
config/session.php

@@ -0,0 +1,19 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | 会话设置
4
+// +----------------------------------------------------------------------
5
+
6
+return [
7
+    // session name
8
+    'name'           => 'PHPSESSID',
9
+    // SESSION_ID的提交变量,解决flash上传跨域
10
+    'var_session_id' => '',
11
+    // 驱动方式 支持file cache
12
+    'type'           => 'file',
13
+    // 存储连接标识 当type使用cache的时候有效
14
+    'store'          => null,
15
+    // 过期时间
16
+    'expire'         => 1440,
17
+    // 前缀
18
+    'prefix'         => '',
19
+];

+ 10 - 0
config/trace.php

@@ -0,0 +1,10 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | Trace设置 开启调试模式后有效
4
+// +----------------------------------------------------------------------
5
+return [
6
+    // 内置Html和Console两种方式 支持扩展
7
+    'type'    => 'Html',
8
+    // 读取的日志通道名
9
+    'channel' => '',
10
+];

+ 25 - 0
config/view.php

@@ -0,0 +1,25 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | 模板设置
4
+// +----------------------------------------------------------------------
5
+
6
+return [
7
+    // 模板引擎类型使用Think
8
+    'type'          => 'Think',
9
+    // 默认模板渲染规则 1 解析为小写+下划线 2 全部转换小写 3 保持操作方法
10
+    'auto_rule'     => 1,
11
+    // 模板目录名
12
+    'view_dir_name' => 'view',
13
+    // 模板后缀
14
+    'view_suffix'   => 'html',
15
+    // 模板文件名分隔符
16
+    'view_depr'     => DIRECTORY_SEPARATOR,
17
+    // 模板引擎普通标签开始标记
18
+    'tpl_begin'     => '{',
19
+    // 模板引擎普通标签结束标记
20
+    'tpl_end'       => '}',
21
+    // 标签库标签开始标记
22
+    'taglib_begin'  => '{',
23
+    // 标签库标签结束标记
24
+    'taglib_end'    => '}',
25
+];

+ 2 - 0
extend/.gitignore

@@ -0,0 +1,2 @@
1
+*
2
+!.gitignore

+ 8 - 0
public/.htaccess

@@ -0,0 +1,8 @@
1
+<IfModule mod_rewrite.c>
2
+  Options +FollowSymlinks -Multiviews
3
+  RewriteEngine On
4
+
5
+  RewriteCond %{REQUEST_FILENAME} !-d
6
+  RewriteCond %{REQUEST_FILENAME} !-f
7
+  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
8
+</IfModule>

BIN
public/favicon.ico


+ 24 - 0
public/index.php

@@ -0,0 +1,24 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
4
+// +----------------------------------------------------------------------
5
+// | Copyright (c) 2006-2019 http://thinkphp.cn All rights reserved.
6
+// +----------------------------------------------------------------------
7
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
+// +----------------------------------------------------------------------
9
+// | Author: liu21st <liu21st@gmail.com>
10
+// +----------------------------------------------------------------------
11
+
12
+// [ 应用入口文件 ]
13
+namespace think;
14
+
15
+require __DIR__ . '/../vendor/autoload.php';
16
+
17
+// 执行HTTP应用并响应
18
+$http = (new App())->http;
19
+
20
+$response = $http->run();
21
+
22
+$response->send();
23
+
24
+$http->end($response);

+ 4 - 0
public/nginx.htaccess

@@ -0,0 +1,4 @@
1
+if (!-e $request_filename) {
2
+	rewrite  ^(.*)$  /index.php?s=/$1  last;
3
+	break;
4
+}

+ 2 - 0
public/robots.txt

@@ -0,0 +1,2 @@
1
+User-agent: *
2
+Disallow:

+ 19 - 0
public/router.php

@@ -0,0 +1,19 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
4
+// +----------------------------------------------------------------------
5
+// | Copyright (c) 2006~2019 http://thinkphp.cn All rights reserved.
6
+// +----------------------------------------------------------------------
7
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
+// +----------------------------------------------------------------------
9
+// | Author: liu21st <liu21st@gmail.com>
10
+// +----------------------------------------------------------------------
11
+// $Id$
12
+
13
+if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) {
14
+    return false;
15
+} else {
16
+    $_SERVER["SCRIPT_FILENAME"] = __DIR__ . '/index.php';
17
+
18
+    require __DIR__ . "/index.php";
19
+}

+ 2 - 0
public/static/.gitignore

@@ -0,0 +1,2 @@
1
+*
2
+!.gitignore

+ 24 - 0
route/app.php

@@ -0,0 +1,24 @@
1
+<?php
2
+// +----------------------------------------------------------------------
3
+// | ThinkPHP [ WE CAN DO IT JUST THINK ]
4
+// +----------------------------------------------------------------------
5
+// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
6
+// +----------------------------------------------------------------------
7
+// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
8
+// +----------------------------------------------------------------------
9
+// | Author: liu21st <liu21st@gmail.com>
10
+// +----------------------------------------------------------------------
11
+use think\facade\Route;
12
+
13
+Route::miss('system.Main/miss');
14
+Route::miss(function () {
15
+    header('Status: 401 Unauthorized');
16
+    return "接口不存在";
17
+});
18
+
19
+Route::group('orders',function (){
20
+
21
+    Route::post('createCart','cart.Index/createCart');//创建购物车
22
+    Route::post('changeCart','cart.Index/changeCart');//修改购物车数量
23
+
24
+})->middleware(\app\middleware\UserTokenMiddleware::class);

+ 2 - 0
runtime/.gitignore

@@ -0,0 +1,2 @@
1
+*
2
+!.gitignore

+ 10 - 0
think

@@ -0,0 +1,10 @@
1
+#!/usr/bin/env php
2
+<?php
3
+namespace think;
4
+
5
+// 命令行入口文件
6
+// 加载基础文件
7
+require __DIR__ . '/vendor/autoload.php';
8
+
9
+// 应用初始化
10
+(new App())->console->run();

+ 1 - 0
view/README.md

@@ -0,0 +1 @@
1
+如果不使用模板,可以删除该目录