|
@@ -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
|