Browse Source

'影院类型管理+影片管理'

gorden 1 year ago
parent
commit
6261dddcfe

+ 4 - 1
.env.bak

@@ -9,4 +9,7 @@ DB_PREFIX =
 
 REDIS_HOST = 127.0.0.1
 REDIS_PORT = 6379
-REDIS_PASSWORD =
+REDIS_PASSWORD =
+
+#静态文件访问Domain
+STORAGE_DOMAIN = http://dev.wanyue.com/

+ 1 - 0
.gitignore

@@ -7,3 +7,4 @@
 /tests/tmp
 /tests/.phpunit.result.cache
 /composer.lock
+/public/*

+ 31 - 0
app/admin/controller/UploadFile.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace app\admin\controller;
+
+
+use Tinywan\Storage\Storage;
+
+class UploadFile
+{
+    /**
+     * @Desc 上传文件
+     * @Author Gorden
+     * @Date 2024/2/26 13:22
+     *
+     * @return \support\Response
+     */
+    public function upload()
+    {
+        $config = config('plugin.tinywan.storage.app.storage.local');
+        $config['single_limit'] = 123;
+        $res = Storage::uploadFile($config);
+        $data = [
+            'url' => $res[0]['url'],
+            'path' => 'storage/'.date('Ymd').'/'.$res[0]['save_name'],
+            'size' => $res[0]['size'],
+            'mime_type' => $res[0]['mime_type'],
+        ];
+
+        return json_success('上传成功', $data);
+    }
+}

+ 54 - 0
app/admin/controller/life/Cinema.php

@@ -0,0 +1,54 @@
+<?php
+
+namespace app\admin\controller\life;
+
+use app\admin\validate\life\CinemaValidate;
+use app\controller\Curd;
+use app\model\Cinema as CinemaModel;
+use support\Request;
+use support\Response;
+
+class Cinema extends Curd
+{
+
+    public function __construct()
+    {
+        $this->model = new CinemaModel();
+        $this->validate = true;
+        $this->validateClass = new CinemaValidate();
+    }
+
+    /**
+     * @Desc 影片列表
+     * @Author Gorden
+     * @Date 2024/2/26 13:42
+     *
+     * @param Request $request
+     * @return Response
+     * @throws \support\exception\BusinessException
+     */
+    public function select(Request $request): Response
+    {
+        [$where, $format, $limit, $field, $order] = $this->selectInput($request);
+        $where['cinema_is_del'] = 0;
+        $query = $this->doSelect($where, $field, $order);
+        return $this->doFormat($query, $format, $limit);
+    }
+
+    /**
+     * @Desc 影片软删除
+     * @Author Gorden
+     * @Date 2024/2/26 13:43
+     *
+     * @param Request $request
+     * @return Response
+     * @throws \support\exception\BusinessException
+     */
+    public function delete(Request $request): Response
+    {
+        $ids = $this->deleteInput($request);
+        $this->doSoftDelete($ids, ['cinema_is_del' => 1]);
+
+        return json_success('success');
+    }
+}

+ 45 - 0
app/admin/controller/life/CinemaIlk.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace app\admin\controller\life;
+
+use app\admin\validate\life\CinemaIlkValidate;
+use app\controller\Curd;
+use app\model\CinemaIlk as CinemaIlkModel;
+use support\Request;
+use support\Response;
+
+class CinemaIlk extends Curd
+{
+
+    public function __construct()
+    {
+        $this->model = new CinemaIlkModel();
+        $this->validate = true;
+        $this->validateClass = new CinemaIlkValidate();
+    }
+
+    public function select(Request $request): Response
+    {
+        [$where, $format, $limit, $field, $order] = $this->selectInput($request);
+        $where['ilk_is_del'] = 0;
+        $query = $this->doSelect($where, $field, $order);
+        return $this->doFormat($query, $format, $limit);
+    }
+
+    /**
+     * @Desc 删除类型
+     * @Author Gorden
+     * @Date 2024/2/26 9:40
+     *
+     * @param Request $request
+     * @return Response
+     * @throws \support\exception\BusinessException
+     */
+    public function delete(Request $request): Response
+    {
+        $ids = $this->deleteInput($request);
+        $this->doSoftDelete($ids, ['ilk_is_del' => 1]);
+
+        return json_success('success');
+    }
+}

+ 14 - 0
app/admin/validate/life/CinemaIlkValidate.php

@@ -0,0 +1,14 @@
+<?php
+
+namespace app\admin\validate\life;
+
+use think\Validate;
+
+class CinemaIlkValidate extends Validate
+{
+    protected $rule = [
+        'ilk_name' => 'chsDash',
+    ];
+
+    protected $message = [];
+}

+ 37 - 0
app/admin/validate/life/CinemaValidate.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace app\admin\validate\life;
+
+use think\Validate;
+
+class CinemaValidate extends Validate
+{
+    protected $rule = [
+        'cinema_id' => 'integer',
+        'cinema_name' => 'chsDash',
+        'cinema_img' => 'regex:/^[A-Za-z0-9\-\_\.\/\\\]+$/',
+        'cinema_video' => 'regex:/^[A-Za-z0-9\-\_\.\/\\\]+$/',
+        'cinema_price' => 'float',
+        'cinema_seat' => 'integer',
+        'cinema_join' => 'integer',
+        'cinema_length' => 'integer',
+        'cinema_week' => 'integer',
+        'cinema_time' => '',
+        'cinema_label' => 'regex:/^[0-9\,]+$/',
+        'cinema_mold' => 'regex:/^[0-9\,]+$/',
+        'cinema_director' => 'integer',
+        'cinema_star' => 'regex:/^[0-9\,]+$/',
+        'cinema_introduction' => 'chsDash',
+        'cinema_performers' => 'regex:/^[0-9\,]+$/',
+        'cinema_is_del' => 'integer',
+        'cinema_status' => 'integer',
+    ];
+
+    protected $message = [];
+
+    protected $scene = [
+        'add' => ['cinema_name', 'cinema_img', 'cinema_video', 'cinema_price', 'cinema_seat', 'cinema_join', 'cinema_length', 'cinema_week', 'cinema_label', 'cinema_director', 'cinema_star', 'cinema_introduction', 'cinema_performers'],
+        'update' => ['cinema_name', 'cinema_img', 'cinema_video', 'cinema_price', 'cinema_seat', 'cinema_join', 'cinema_length', 'cinema_week', 'cinema_label', 'cinema_director', 'cinema_star', 'cinema_introduction', 'cinema_performers'],
+
+    ];
+}

+ 35 - 0
app/controller/Curd.php

@@ -102,6 +102,23 @@ class Curd
         return json_success('success');
     }
 
+    /**
+     * @Desc 软删除
+     * @Author Gorden
+     * @Date 2024/2/26 9:27
+     *
+     * @param Request $request
+     * @return Response
+     * @throws BusinessException
+     */
+    public function softDelete(Request $request): Response
+    {
+        $ids = $this->deleteInput($request);
+        $this->doSoftDelete($ids,['is_del'=>1]);
+
+        return json_success('success');
+    }
+
     /**
      * 查询前置
      * @param Request $request
@@ -388,6 +405,24 @@ class Curd
         $this->model->whereIn($primary_key, $ids)->delete();
     }
 
+    /**
+     * @Desc 执行软删除
+     * @Author Gorden
+     * @Date 2024/2/26 9:27
+     *
+     * @param array $ids
+     * @return void
+     */
+    protected function doSoftDelete(array $ids, $data)
+    {
+        if (!$ids) {
+            return;
+        }
+
+        $primary_key = $this->model->getKeyName();
+        $this->model->whereIn($primary_key, $ids)->update($data);
+    }
+
     /**
      * 格式化树
      * @param $items

+ 18 - 0
app/model/Cinema.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace app\model;
+
+use support\Model;
+
+class Cinema extends Model
+{
+    protected $table = 'cinema';
+
+    protected $primaryKey = 'cinema_id';
+
+    public const CREATED_AT = 'cinema_addTime';
+
+    public const UPDATED_AT = 'cinema_updateTime';
+
+    protected $dateFormat = 'U';
+}

+ 18 - 0
app/model/CinemaIlk.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace app\model;
+
+use support\Model;
+
+class CinemaIlk extends Model
+{
+    public $table = 'cinema_ilk';
+
+    public $primaryKey = 'ilk_id';
+
+    public const CREATED_AT = 'ilk_addtime';
+
+    public const UPDATED_AT = 'ilk_updatetime';
+
+    protected $dateFormat = 'U';
+}

+ 2 - 1
composer.json

@@ -35,7 +35,8 @@
     "illuminate/redis": "^8.83",
     "topthink/think-validate": "^2.0",
     "symfony/translation": "^5.4",
-    "tinywan/jwt": "^1.9.1"
+    "tinywan/jwt": "^1.9.1",
+    "tinywan/storage": "^1.0"
   },
   "suggest": {
     "ext-event": "For better performance. "

+ 62 - 0
config/plugin/tinywan/storage/app.php

@@ -0,0 +1,62 @@
+<?php
+/**
+ * @desc app.php 描述信息
+ *
+ * @author Tinywan(ShaoBo Wan)
+ * @date 2022/3/10 19:46
+ */
+
+return [
+    'enable' => true,
+    'storage' => [
+        'default' => 'local', // local:本地 oss:阿里云 cos:腾讯云 qos:七牛云
+        'single_limit' => 1024 * 1024 * 200, // 单个文件的大小限制,默认200M 1024 * 1024 * 200
+        'total_limit' => 1024 * 1024 * 200, // 所有文件的大小限制,默认200M 1024 * 1024 * 200
+        'nums' => 10, // 文件数量限制,默认10
+        'include' => ['jpg', 'jpeg', 'png', 'gif','mp4'], // 被允许的文件类型列表
+        'exclude' => [], // 不被允许的文件类型列表
+        // 本地对象存储
+        'local' => [
+            'adapter' => \Tinywan\Storage\Adapter\LocalAdapter::class,
+            'root' => public_path() . '/storage/',
+            'dirname' => function () {
+                return date('Ymd');
+            },
+            'domain' => getenv('STORAGE_DOMAIN', 'http://127.0.0.1:8787'),
+            'uri' => '/storage/', // 如果 domain + uri 不在 public 目录下,请做好软链接,否则生成的url无法访问
+            'algo' => 'sha1',
+        ],
+        // 阿里云对象存储
+        'oss' => [
+            'adapter' => \Tinywan\Storage\Adapter\OssAdapter::class,
+            'accessKeyId' => 'xxxxxxxxxxxx',
+            'accessKeySecret' => 'xxxxxxxxxxxx',
+            'bucket' => 'resty-webman',
+            'dirname' => function () {
+                return 'storage';
+            },
+            'domain' => 'http://webman.oss.tinywan.com',
+            'endpoint' => 'oss-cn-hangzhou.aliyuncs.com',
+            'algo' => 'sha1',
+        ],
+        // 腾讯云对象存储
+        'cos' => [
+            'adapter' => \Tinywan\Storage\Adapter\CosAdapter::class,
+            'secretId' => 'xxxxxxxxxxxxx',
+            'secretKey' => 'xxxxxxxxxxxx',
+            'bucket' => 'resty-webman-xxxxxxxxx',
+            'dirname' => 'storage',
+            'domain' => 'http://webman.oss.tinywan.com',
+            'region' => 'ap-shanghai',
+        ],
+        // 七牛云对象存储
+        'qiniu' => [
+            'adapter' => \Tinywan\Storage\Adapter\QiniuAdapter::class,
+            'accessKey' => 'xxxxxxxxxxxxx',
+            'secretKey' => 'xxxxxxxxxxxxx',
+            'bucket' => 'resty-webman',
+            'dirname' => 'storage',
+            'domain' => 'http://webman.oss.tinywan.com',
+        ],
+    ],
+];

+ 40 - 0
index.html

@@ -0,0 +1,40 @@
+<!doctype html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>恭喜,站点创建成功!</title>
+    <style>
+
+        .container {
+            width: 60%;
+            margin: 10% auto 0;
+            background-color: #f0f0f0;
+            padding: 2% 5%;
+            border-radius: 10px
+        }
+
+        ul {
+            padding-left: 20px;
+        }
+
+            ul li {
+                line-height: 2.3
+            }
+
+        a {
+            color: #20a53a
+        }
+    </style>
+</head>
+<body>
+    <div class="container">
+        <h1>恭喜, 站点创建成功!</h1>
+        <h3>这是默认index.html,本页面由系统自动生成</h3>
+        <ul>
+            <li>本页面在FTP根目录下的index.html</li>
+            <li>您可以修改、删除或覆盖本页面</li>
+            <li>FTP相关信息,请到“面板系统后台 > FTP” 查看</li>
+        </ul>
+    </div>
+</body>
+</html>

+ 20 - 6
public/404.html

@@ -1,12 +1,26 @@
+<!doctype html>
 <html>
 <head>
-    <title>404 Not Found - webman</title>
+<meta charset="utf-8">
+<meta http-equiv="X-UA-Compatible" content="IE=edge">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+<title>404</title>
+<style>
+	body{
+		background-color:#444;
+		font-size:14px;
+	}
+	h3{
+		font-size:60px;
+		color:#eee;
+		text-align:center;
+		padding-top:30px;
+		font-weight:normal;
+	}
+</style>
 </head>
+
 <body>
-<center>
-    <h1>404 Not Found</h1>
-</center>
-<hr>
-<center>webman</center>
+<h3>404锛屾偍璇锋眰鐨勬枃浠朵笉瀛樺湪!</h3>
 </body>
 </html>

+ 23 - 4
route/api.php

@@ -3,6 +3,9 @@
 use Webman\Route;
 
 Route::group('/admin', function () {
+    Route::post('/upload', [\app\admin\controller\UploadFile::class, 'upload'])->middleware([
+        \app\middleware\AdminAuthCheck::class
+    ]);
     /* 鉴权 */
     Route::group('/auth', function () {
         Route::post('/login', [\app\admin\controller\auth\Auth::class, 'login']);
@@ -86,10 +89,26 @@ Route::group('/admin', function () {
     /* 业务支撑 */
     Route::group('/life', function () {
         Route::group('/cinemaPerformers', function () {
-            Route::get('/list',[\app\admin\controller\life\CinemaPerformers::class,'select']);
-            Route::post('/add',[\app\admin\controller\life\CinemaPerformers::class,'insert']);
-            Route::post('/update',[\app\admin\controller\life\CinemaPerformers::class,'insert']);
-            Route::delete('/delete',[\app\admin\controller\life\CinemaPerformers::class,'delete']);
+            Route::get('/list', [\app\admin\controller\life\CinemaPerformers::class, 'select']);
+            Route::post('/add', [\app\admin\controller\life\CinemaPerformers::class, 'insert']);
+            Route::post('/update', [\app\admin\controller\life\CinemaPerformers::class, 'update']);
+            Route::delete('/delete', [\app\admin\controller\life\CinemaPerformers::class, 'delete']);
+        })->middleware([
+            \app\middleware\AdminAuthCheck::class
+        ]);
+        Route::group('/cinemaIlk', function () {
+            Route::get('/list', [\app\admin\controller\life\CinemaIlk::class, 'select']);
+            Route::post('/add', [\app\admin\controller\life\CinemaIlk::class, 'insert']);
+            Route::post('/update', [\app\admin\controller\life\CinemaIlk::class, 'update']);
+            Route::delete('/delete', [\app\admin\controller\life\CinemaIlk::class, 'delete']);
+        })->middleware([
+            \app\middleware\AdminAuthCheck::class
+        ]);
+        Route::group('/cinema', function () {
+            Route::get('/list', [\app\admin\controller\life\Cinema::class, 'select']);
+            Route::post('/add', [\app\admin\controller\life\Cinema::class, 'insert']);
+            Route::post('/update', [\app\admin\controller\life\Cinema::class, 'update']);
+            Route::delete('/delete', [\app\admin\controller\life\Cinema::class, 'delete']);
         })->middleware([
             \app\middleware\AdminAuthCheck::class
         ]);