gorden 11 месяцев назад
Родитель
Сommit
78f22d9601

+ 60 - 0
app/admin/controller/life/CinemaController.php

@@ -5,6 +5,7 @@ namespace app\admin\controller\life;
 use app\admin\validate\life\CinemaValidate;
 use app\controller\Curd;
 use app\model\Cinema as CinemaModel;
+use support\exception\BusinessException;
 use support\Request;
 use support\Response;
 
@@ -35,6 +36,65 @@ class CinemaController extends Curd
         return $this->doFormat($query, $format, $limit);
     }
 
+    /**
+     * @Desc 查询后数据处理
+     * @Author Gorden
+     * @Date 2024/3/21 14:13
+     *
+     * @param $items
+     * @return void
+     */
+    public function afterQuery($items)
+    {
+        foreach ($items as &$item){
+            $item->cinema_img = getenv('STORAGE_DOMAIN').$item->cinema_img;
+            $item->cinema_video = getenv('STORAGE_DOMAIN').$item->cinema_video;
+            $item->cinema_time = date('Y-m-d H:i:s',strtotime($item->cinema_time));
+            $item->cinema_label = !empty($item->cinema_label) ? explode(',',$item->cinema_label) : '';
+            $item->cinema_mold = !empty($item->cinema_mold) ? explode(',',$item->cinema_mold) : '';
+            $item->cinema_director = !empty($item->cinema_director) ? array_map('intval',explode(',',$item->cinema_director)) : '';
+            $item->cinema_star = !empty($item->cinema_star) ? array_map('intval',explode(',',$item->cinema_star)) : '';
+            $item->cinema_performers = !empty($item->cinema_performers) ? array_map('intval',explode(',',$item->cinema_performers)) : '';
+        }
+
+        return $items;
+    }
+
+    /**
+     * @Desc 新增数据处理
+     * @Author Gorden
+     * @Date 2024/3/21 14:11
+     *
+     * @param Request $request
+     * @return array
+     * @throws \support\exception\BusinessException
+     */
+    protected function insertInput(Request $request): array
+    {
+        $data = $this->inputFilter($request->post());
+        $data['cinema_img'] = str_replace(getenv('STORAGE_DOMAIN'),'',$data['cinema_img']);
+        $data['cinema_video'] = str_replace(getenv('STORAGE_DOMAIN'),'',$data['cinema_video']);
+
+        return $data;
+    }
+
+    protected function updateInput(Request $request): array
+    {
+        $primary_key = $this->model->getKeyName();
+        $id = $request->post($primary_key);
+        $data = $this->inputFilter($request->post());
+        $data['cinema_img'] = str_replace(getenv('STORAGE_DOMAIN'),'',$data['cinema_img']);
+        $data['cinema_video'] = str_replace(getenv('STORAGE_DOMAIN'),'',$data['cinema_video']);
+
+        $model = $this->model->find($id);
+        if (!$model) {
+            throw new BusinessException('记录不存在', 2);
+        }
+
+        unset($data[$primary_key]);
+        return [$id, $data];
+    }
+
     /**
      * @Desc 影片软删除
      * @Author Gorden

+ 9 - 0
app/admin/controller/life/CinemaIlkController.php

@@ -18,6 +18,15 @@ class CinemaIlkController extends Curd
         $this->validateClass = new CinemaIlkValidate();
     }
 
+    /**
+     * @Desc 查询列表
+     * @Author Gorden
+     * @Date 2024/3/21 9:58
+     *
+     * @param Request $request
+     * @return Response
+     * @throws \support\exception\BusinessException
+     */
     public function select(Request $request): Response
     {
         [$where, $format, $limit, $field, $order] = $this->selectInput($request);

+ 77 - 0
app/admin/controller/life/CinemaPerformersController.php

@@ -5,13 +5,90 @@ namespace app\admin\controller\life;
 use app\admin\validate\life\CinemaPerformersValidate;
 use app\model\CinemaPerformers as CinemaPerformersModel;
 use app\controller\Curd;
+use support\exception\BusinessException;
+use support\Request;
+use support\Response;
 
 class CinemaPerformersController extends Curd
 {
+    const PERFORMERS_TYPE = [
+        1 => '导演',
+        2 => '演员'
+    ];
+
     public function __construct()
     {
         $this->model = new CinemaPerformersModel();
         $this->validate = true;
         $this->validateClass = new CinemaPerformersValidate();
     }
+
+    /**
+     * @Desc 人员列表
+     * @Author Gorden
+     * @Date 2024/3/21 9:11
+     *
+     * @param Request $request
+     * @return Response
+     * @throws BusinessException
+     */
+    public function select(Request $request): Response
+    {
+        [$where, $format, $limit, $field, $order] = $this->selectInput($request);
+        $where['performers_is_del'] = 0;
+        $query = $this->doSelect($where, $field, $order);
+        return $this->doFormat($query, $format, $limit);
+    }
+
+    protected function afterQuery($items)
+    {
+        foreach ($items as &$item) {
+            $item->performers_type_text = self::PERFORMERS_TYPE[$item->performers_type];
+            $item->performers_img = getenv("STORAGE_DOMAIN") . $item->performers_img;
+        }
+
+        return $items;
+    }
+
+    /**
+     * @Desc 新增数据处理
+     * @Author Gorden
+     * @Date 2024/3/21 8:59
+     *
+     * @param Request $request
+     * @return array
+     * @throws \support\exception\BusinessException
+     */
+    protected function insertInput(Request $request): array
+    {
+        $data = $this->inputFilter($request->post());
+        $data['performers_img'] = str_replace(getenv("STORAGE_DOMAIN"), '', $data['performers_img']);
+
+        return $data;
+    }
+
+    /**
+     * @Desc 更新数据处理
+     * @Author Gorden
+     * @Date 2024/3/21 9:02
+     *
+     * @param Request $request
+     * @return array
+     * @throws BusinessException
+     */
+    protected function updateInput(Request $request): array
+    {
+        $primary_key = $this->model->getKeyName();
+        $id = $request->post($primary_key);
+        $data = $this->inputFilter($request->post());
+        $data['performers_img'] = str_replace(getenv("STORAGE_DOMAIN"), '', $data['performers_img']);
+        // 验证是否存在
+        $model = $this->model->find($id);
+        if (!$model) {
+            throw new BusinessException('记录不存在', 2);
+        }
+
+        unset($data[$primary_key]);
+        return [$id, $data];
+    }
 }

+ 1 - 0
app/admin/service/sys_manage/UploadService.php

@@ -19,6 +19,7 @@ class UploadService
         try {
             $res = Storage::uploadFile($config);
             $data = [
+                'fileName'=>$res[0]['origin_name'],
                 'url' => getenv("STORAGE_DOMAIN").$config['uri'] . date('Ymd') . '/' . $res[0]['save_name'],
                 'path' => $config['uri'] . date('Ymd') . '/' . $res[0]['save_name'],
                 'size' => $res[0]['size'],

+ 1 - 1
app/admin/validate/life/CinemaPerformersValidate.php

@@ -8,7 +8,7 @@ class CinemaPerformersValidate extends Validate
 {
     protected $rule = [
         'performers_name' => 'require|chsDash',
-        'performers_img' => 'regex:/^[0-9a-zA-Z\.]+$/',
+        'performers_img' => 'url',
         'performers_type' => 'require|in:1,2',
         'performers_introduction' => 'chsDash',
         'performers_is_del' => 'in:0,1'

+ 7 - 7
app/admin/validate/life/CinemaValidate.php

@@ -9,20 +9,20 @@ 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_img' => 'url',
+        'cinema_video' => 'url',
         '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_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_performers' => 'regex:/^[0-9\,]+$/',
         'cinema_is_del' => 'integer',
         'cinema_status' => 'integer',
     ];

+ 6 - 2
app/model/CinemaIlk.php

@@ -10,9 +10,13 @@ class CinemaIlk extends Model
 
     public $primaryKey = 'ilk_id';
 
-    public const CREATED_AT = 'ilk_addtime';
+    public const CREATED_AT = 'ilk_add_time';
 
-    public const UPDATED_AT = 'ilk_updatetime';
+    public const UPDATED_AT = 'ilk_update_time';
 
     protected $dateFormat = 'U';
+
+    public function getIlkAddTimeAttribute($value){
+        return date('Y-m-d H:i:s',strtotime($value));
+    }
 }