diff --git a/app/apis/controller/VehicleNewAlbumController.php b/app/apis/controller/VehicleNewAlbumController.php new file mode 100644 index 0000000..a2aaba8 --- /dev/null +++ b/app/apis/controller/VehicleNewAlbumController.php @@ -0,0 +1,81 @@ +errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/controller/VehicleNewAlbumTranslationController.php b/app/apis/controller/VehicleNewAlbumTranslationController.php new file mode 100644 index 0000000..aabecde --- /dev/null +++ b/app/apis/controller/VehicleNewAlbumTranslationController.php @@ -0,0 +1,81 @@ +errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/controller/VehicleNewAskedController.php b/app/apis/controller/VehicleNewAskedController.php new file mode 100644 index 0000000..6dc7395 --- /dev/null +++ b/app/apis/controller/VehicleNewAskedController.php @@ -0,0 +1,81 @@ +errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/controller/VehicleNewAskedTranslationController.php b/app/apis/controller/VehicleNewAskedTranslationController.php new file mode 100644 index 0000000..1284b03 --- /dev/null +++ b/app/apis/controller/VehicleNewAskedTranslationController.php @@ -0,0 +1,81 @@ +errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/controller/VehicleNewContentController.php b/app/apis/controller/VehicleNewContentController.php new file mode 100644 index 0000000..5669747 --- /dev/null +++ b/app/apis/controller/VehicleNewContentController.php @@ -0,0 +1,81 @@ +errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/controller/VehicleNewContentTranslationController.php b/app/apis/controller/VehicleNewContentTranslationController.php new file mode 100644 index 0000000..91636ef --- /dev/null +++ b/app/apis/controller/VehicleNewContentTranslationController.php @@ -0,0 +1,81 @@ +errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/controller/VehicleNewController.php b/app/apis/controller/VehicleNewController.php new file mode 100644 index 0000000..448c9ca --- /dev/null +++ b/app/apis/controller/VehicleNewController.php @@ -0,0 +1,154 @@ + $item['id'], + 'vin' => $item['vin'], + 'price' => $item['price'], + 'cover' => $item['cover'], + 'brand' => is_array($item['brand']) ? $item['brand']['translation']['brand_id'] : $item['brand'], + 'energy' => is_array($item['energy']) ? $item['energy']['translation']['energy_id'] : $item['energy'], + 'type' => isset($item['types']) ? $item['types']['translation']['type_id'] : $item['type'], + 'model' => isset($item['models']) ? $item['models']['translation']['model_id'] : $item['model'], + 'video' => $item['video'], + 'name' => isset($item['translation']) ? $item['translation']['name'] : '', + 'condition_desc' => isset($item['translation']) ? $item['translation']['condition_desc'] : '', + 'created_at' => date('Y-m-d H:i:s', $item['created_at']), + 'updated_at' => date('Y-m-d H:i:s', $item['updated_at']), + + 'brand_name' => is_array($item['brand']) ? $item['brand']['translation']['name'] : '', + 'energy_name' => is_array($item['energy']) ? $item['energy']['translation']['name'] : '', + 'type_name' => isset($item['types']) ? $item['types']['translation']['name'] : '', + 'model_name' => isset($item['models']) ? $item['models']['translation']['name'] : '', + ]; + if ($item['cover']) { + $result['cover_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['cover']); + } + if ($item['video']) { + $result['video_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['video']); + } + foreach ($item['asked'] as $asked) { + $askedRes['id'] = $asked['id']; + $askedRes['vehicle_id'] = $asked['vehicle_id']; + $askedRes['status'] = $asked['status']; + $askedRes['title'] = isset($asked['translation']) ? $asked['translation']['title']:''; + $askedRes['content'] = isset($asked['translation']) ? $asked['translation']['content']:''; + $result['asked'][] = $askedRes; + } + foreach ($item['trait'] as $trait) { + $traitRes['id'] = $trait['id']; + $traitRes['vehicle_id'] = $trait['vehicle_id']; + $traitRes['status'] = $trait['status']; + $traitRes['title'] = isset($trait['translation']) ? $trait['translation']['title']:''; + $traitRes['content'] = isset($trait['translation']) ? $trait['translation']['content']:''; + $result['trait'][] = $traitRes; + } + foreach ($item['album'] as $album) { + $albumRes['id'] = $album['id']; + $albumRes['vehicle_id'] = $album['vehicle_id']; + $albumRes['pic'] = $album['pic']; + $albumRes['status'] = $album['status']; + $albumRes['alt'] = isset($album['translation']) ? $album['translation']['alt']:''; + + if ($albumRes['pic']) { + $albumRes['pic_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($albumRes['pic']); + } + + $result['album'][] = $albumRes; + } + foreach ($item['content'] as $content) { + $contentRes['id'] = $content['id']; + $contentRes['vehicle_id'] = $content['vehicle_id']; + $contentRes['status'] = $content['status']; + $contentRes['content'] = isset($content['translation']) ? $content['translation']['content']:''; + $result['content'][] = $contentRes; + } + return $result; + } + + return $item; + } + + /** + * 参数预处理 (根据场景处理) + * @param Request $request + * @param string $scene + * @return array + */ + protected function prepareParams(Request $request, string $scene): array + { + $params = parent::prepareParams($request, $scene); + + if ($scene === 'default') { + + } + + return $params; + } + + /** + * 分页 + * + * @param Request $request 请求对象 + * @return Response 响应对象 + */ + public function index(Request $request, string $scene = 'default'): Response + { + try { + return parent::index($request, $scene); + } catch (\Throwable $th) { + return $this->errorResponse($th->getMessage()); + } + } + + public function detail(Request $request, int $id, string $scene = 'show'): Response + { + try { + $request->setGet(['id'=>$id]); + return parent::one($request, $scene); + } catch (\Throwable $th) { + return $this->errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/controller/VehicleNewTraitController.php b/app/apis/controller/VehicleNewTraitController.php new file mode 100644 index 0000000..33097b8 --- /dev/null +++ b/app/apis/controller/VehicleNewTraitController.php @@ -0,0 +1,81 @@ +errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/controller/VehicleNewTraitTranslationController.php b/app/apis/controller/VehicleNewTraitTranslationController.php new file mode 100644 index 0000000..035a18e --- /dev/null +++ b/app/apis/controller/VehicleNewTraitTranslationController.php @@ -0,0 +1,81 @@ +errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/controller/VehicleNewTranslationController.php b/app/apis/controller/VehicleNewTranslationController.php new file mode 100644 index 0000000..ed9d13c --- /dev/null +++ b/app/apis/controller/VehicleNewTranslationController.php @@ -0,0 +1,81 @@ +errorResponse($th->getMessage()); + } + } +} \ No newline at end of file diff --git a/app/apis/model/VehicleNewAlbumModel.php b/app/apis/model/VehicleNewAlbumModel.php new file mode 100644 index 0000000..8af56c5 --- /dev/null +++ b/app/apis/model/VehicleNewAlbumModel.php @@ -0,0 +1,76 @@ +hasOne(VehicleNewAlbumTranslationModel::class, 'album_id')->where('locale', locale()); + } + + /** + * 多条翻译 + */ + public function translations() + { + return $this->hasMany(VehicleNewAlbumTranslationModel::class, 'album_id'); + } + + const TRANS_FIELDS = [ + 'alt', + ]; +} \ No newline at end of file diff --git a/app/apis/model/VehicleNewAlbumTranslationModel.php b/app/apis/model/VehicleNewAlbumTranslationModel.php new file mode 100644 index 0000000..cd89e19 --- /dev/null +++ b/app/apis/model/VehicleNewAlbumTranslationModel.php @@ -0,0 +1,56 @@ +hasOne(VehicleNewAskedTranslationModel::class, 'asked_id')->where('locale', locale()); + } + + /** + * 多条翻译 + */ + public function translations() + { + return $this->hasMany(VehicleNewAskedTranslationModel::class, 'asked_id'); + } +} \ No newline at end of file diff --git a/app/apis/model/VehicleNewAskedTranslationModel.php b/app/apis/model/VehicleNewAskedTranslationModel.php new file mode 100644 index 0000000..45ba51c --- /dev/null +++ b/app/apis/model/VehicleNewAskedTranslationModel.php @@ -0,0 +1,56 @@ +hasOne(VehicleNewContentTranslationModel::class, 'content_id')->where('locale', locale()); + } + + /** + * 多条翻译 + */ + public function translations() + { + return $this->hasMany(VehicleNewContentTranslationModel::class, 'content_id'); + } +} \ No newline at end of file diff --git a/app/apis/model/VehicleNewContentTranslationModel.php b/app/apis/model/VehicleNewContentTranslationModel.php new file mode 100644 index 0000000..1d22fff --- /dev/null +++ b/app/apis/model/VehicleNewContentTranslationModel.php @@ -0,0 +1,56 @@ +hasOne(VehicleNewTranslationModel::class, 'vehicle_id')->where('locale', locale()); + } + + /** + * 多条翻译 + */ + public function translations() + { + return $this->hasMany(VehicleNewTranslationModel::class, 'vehicle_id'); + } + + public function brand() + { + return $this->belongsTo(BrandModel::class, 'brand'); + } + + public function models() + { + return $this->belongsTo(ModelModel::class, 'model'); + } + + public function location() + { + return $this->belongsTo(LocationModel::class, 'location'); + } + + public function types() + { + return $this->belongsTo(TypesModel::class, 'type', 'id'); + } + + public function energy() + { + return $this->belongsTo(EnergyModel::class, 'energy', 'id'); + } + + public function album() + { + return $this->hasMany(VehicleNewAlbumModel::class, 'vehicle_id', 'id'); + } + + public function asked() + { + return $this->hasMany(VehicleNewAskedModel::class, 'vehicle_id', 'id'); + } + + public function trait() + { + return $this->hasMany(VehicleNewTraitModel::class, 'vehicle_id', 'id'); + } + + public function content() + { + return $this->hasMany(VehicleNewContentModel::class, 'vehicle_id', 'id'); + } +} \ No newline at end of file diff --git a/app/apis/model/VehicleNewTraitModel.php b/app/apis/model/VehicleNewTraitModel.php new file mode 100644 index 0000000..94a5fb2 --- /dev/null +++ b/app/apis/model/VehicleNewTraitModel.php @@ -0,0 +1,72 @@ +hasOne(VehicleNewTraitTranslationModel::class, 'trait_id')->where('locale', locale()); + } + + /** + * 多条翻译 + */ + public function translations() + { + return $this->hasMany(VehicleNewTraitTranslationModel::class, 'trait_id'); + } +} \ No newline at end of file diff --git a/app/apis/model/VehicleNewTraitTranslationModel.php b/app/apis/model/VehicleNewTraitTranslationModel.php new file mode 100644 index 0000000..63d05d4 --- /dev/null +++ b/app/apis/model/VehicleNewTraitTranslationModel.php @@ -0,0 +1,56 @@ + function ($params) { + // $keyword = $params['keyword'] ?? ''; + // return [ + // 'filters' => [ + // ['field' => '***', 'operator' => '=', 'value' => '***'] + // ], + // 'fields' => ['id'], + // 'relations' => [], + // 'custom' => function(Builder $q) use ($keyword) { + // // 示例 + // if ($keyword) { + // $q->where(function($q2) use($keyword) { + // $q2->whereHas('***', function($q3) use($keyword) { + // $q3->where('***', 'like', "%{$keyword}%"); + // })->orWhereHas('***', function($q4) use($keyword) { + // $q4->where('***', 'like', "%{$keyword}%"); + // }); + // }); + // } + // }, + // 'sorts' => [ + // ['field' => 'created_at', 'direction' => 'desc'] + // ], + // 'pagination' => [ + // 'page' => $params['page'] ?? 1, + // 'per_page' => $params['per_page'] ?? 10, + // ] + // ]; + // } + ]; + } +} \ No newline at end of file diff --git a/app/apis/service/VehicleNewAlbumTranslationService.php b/app/apis/service/VehicleNewAlbumTranslationService.php new file mode 100644 index 0000000..b3e3123 --- /dev/null +++ b/app/apis/service/VehicleNewAlbumTranslationService.php @@ -0,0 +1,59 @@ + function ($params) { + // $keyword = $params['keyword'] ?? ''; + // return [ + // 'filters' => [ + // ['field' => '***', 'operator' => '=', 'value' => '***'] + // ], + // 'fields' => ['id'], + // 'relations' => [], + // 'custom' => function(Builder $q) use ($keyword) { + // // 示例 + // if ($keyword) { + // $q->where(function($q2) use($keyword) { + // $q2->whereHas('***', function($q3) use($keyword) { + // $q3->where('***', 'like', "%{$keyword}%"); + // })->orWhereHas('***', function($q4) use($keyword) { + // $q4->where('***', 'like', "%{$keyword}%"); + // }); + // }); + // } + // }, + // 'sorts' => [ + // ['field' => 'created_at', 'direction' => 'desc'] + // ], + // 'pagination' => [ + // 'page' => $params['page'] ?? 1, + // 'per_page' => $params['per_page'] ?? 10, + // ] + // ]; + // } + ]; + } +} \ No newline at end of file diff --git a/app/apis/service/VehicleNewAskedService.php b/app/apis/service/VehicleNewAskedService.php new file mode 100644 index 0000000..4310391 --- /dev/null +++ b/app/apis/service/VehicleNewAskedService.php @@ -0,0 +1,59 @@ + function ($params) { + // $keyword = $params['keyword'] ?? ''; + // return [ + // 'filters' => [ + // ['field' => '***', 'operator' => '=', 'value' => '***'] + // ], + // 'fields' => ['id'], + // 'relations' => [], + // 'custom' => function(Builder $q) use ($keyword) { + // // 示例 + // if ($keyword) { + // $q->where(function($q2) use($keyword) { + // $q2->whereHas('***', function($q3) use($keyword) { + // $q3->where('***', 'like', "%{$keyword}%"); + // })->orWhereHas('***', function($q4) use($keyword) { + // $q4->where('***', 'like', "%{$keyword}%"); + // }); + // }); + // } + // }, + // 'sorts' => [ + // ['field' => 'created_at', 'direction' => 'desc'] + // ], + // 'pagination' => [ + // 'page' => $params['page'] ?? 1, + // 'per_page' => $params['per_page'] ?? 10, + // ] + // ]; + // } + ]; + } +} \ No newline at end of file diff --git a/app/apis/service/VehicleNewAskedTranslationService.php b/app/apis/service/VehicleNewAskedTranslationService.php new file mode 100644 index 0000000..c78307a --- /dev/null +++ b/app/apis/service/VehicleNewAskedTranslationService.php @@ -0,0 +1,59 @@ + function ($params) { + // $keyword = $params['keyword'] ?? ''; + // return [ + // 'filters' => [ + // ['field' => '***', 'operator' => '=', 'value' => '***'] + // ], + // 'fields' => ['id'], + // 'relations' => [], + // 'custom' => function(Builder $q) use ($keyword) { + // // 示例 + // if ($keyword) { + // $q->where(function($q2) use($keyword) { + // $q2->whereHas('***', function($q3) use($keyword) { + // $q3->where('***', 'like', "%{$keyword}%"); + // })->orWhereHas('***', function($q4) use($keyword) { + // $q4->where('***', 'like', "%{$keyword}%"); + // }); + // }); + // } + // }, + // 'sorts' => [ + // ['field' => 'created_at', 'direction' => 'desc'] + // ], + // 'pagination' => [ + // 'page' => $params['page'] ?? 1, + // 'per_page' => $params['per_page'] ?? 10, + // ] + // ]; + // } + ]; + } +} \ No newline at end of file diff --git a/app/apis/service/VehicleNewContentService.php b/app/apis/service/VehicleNewContentService.php new file mode 100644 index 0000000..f4b023c --- /dev/null +++ b/app/apis/service/VehicleNewContentService.php @@ -0,0 +1,59 @@ + function ($params) { + // $keyword = $params['keyword'] ?? ''; + // return [ + // 'filters' => [ + // ['field' => '***', 'operator' => '=', 'value' => '***'] + // ], + // 'fields' => ['id'], + // 'relations' => [], + // 'custom' => function(Builder $q) use ($keyword) { + // // 示例 + // if ($keyword) { + // $q->where(function($q2) use($keyword) { + // $q2->whereHas('***', function($q3) use($keyword) { + // $q3->where('***', 'like', "%{$keyword}%"); + // })->orWhereHas('***', function($q4) use($keyword) { + // $q4->where('***', 'like', "%{$keyword}%"); + // }); + // }); + // } + // }, + // 'sorts' => [ + // ['field' => 'created_at', 'direction' => 'desc'] + // ], + // 'pagination' => [ + // 'page' => $params['page'] ?? 1, + // 'per_page' => $params['per_page'] ?? 10, + // ] + // ]; + // } + ]; + } +} \ No newline at end of file diff --git a/app/apis/service/VehicleNewContentTranslationService.php b/app/apis/service/VehicleNewContentTranslationService.php new file mode 100644 index 0000000..fad2d57 --- /dev/null +++ b/app/apis/service/VehicleNewContentTranslationService.php @@ -0,0 +1,59 @@ + function ($params) { + // $keyword = $params['keyword'] ?? ''; + // return [ + // 'filters' => [ + // ['field' => '***', 'operator' => '=', 'value' => '***'] + // ], + // 'fields' => ['id'], + // 'relations' => [], + // 'custom' => function(Builder $q) use ($keyword) { + // // 示例 + // if ($keyword) { + // $q->where(function($q2) use($keyword) { + // $q2->whereHas('***', function($q3) use($keyword) { + // $q3->where('***', 'like', "%{$keyword}%"); + // })->orWhereHas('***', function($q4) use($keyword) { + // $q4->where('***', 'like', "%{$keyword}%"); + // }); + // }); + // } + // }, + // 'sorts' => [ + // ['field' => 'created_at', 'direction' => 'desc'] + // ], + // 'pagination' => [ + // 'page' => $params['page'] ?? 1, + // 'per_page' => $params['per_page'] ?? 10, + // ] + // ]; + // } + ]; + } +} \ No newline at end of file diff --git a/app/apis/service/VehicleNewService.php b/app/apis/service/VehicleNewService.php new file mode 100644 index 0000000..dbba182 --- /dev/null +++ b/app/apis/service/VehicleNewService.php @@ -0,0 +1,99 @@ + function ($params) { + $keyword = $params['keyword'] ?? ''; + return [ + 'filters' => [ +// ['field' => '***', 'operator' => '=', 'value' => '***'] + ], + 'fields' => ['id', 'vin', 'brand', 'cover', 'price', 'type', 'energy', 'model', 'video', 'views', 'created_at', 'updated_at'], + 'relations' => [ + 'translation' => ['vehicle_id', 'locale', 'name', 'condition_desc', 'location'], + 'asked' => ['id', 'vehicle_id', 'status', 'sort'], + 'asked.translation' => ['id', 'asked_id', 'locale', 'title', 'content'], + 'trait' => ['id', 'vehicle_id', 'status', 'sort'], + 'trait.translation' => ['id', 'trait_id', 'locale', 'title', 'content'], + 'album' => ['id', 'vehicle_id', 'pic', 'status', 'sort'], + 'album.translation' => ['id', 'album_id', 'locale', 'alt'], + 'content' => ['id', 'vehicle_id', 'status', 'sort'], + 'content.translation' => ['id', 'content_id', 'locale', 'content'], + 'brand.translation' => ['brand_id', 'name'], + 'types.translation' => ['type_id', 'name'], + 'energy.translation' => ['energy_id', 'name'], + 'models.translation' => ['model_id', 'name'], + ], + 'sorts' => [ + ['field' => 'id', 'direction' => 'desc'] + ], + 'pagination' => [ + 'page' => $params['page'] ?? 1, + 'per_page' => $params['per_page'] ?? 10, + ] + ]; + }, + 'show' => function ($params) { + $keyword = $params['keyword'] ?? ''; + return [ + 'filters' => [ + ['field'=>'id', 'operator'=>'=', 'value'=> $params['id']], + ], + 'fields' => ['id', 'vin', 'brand', 'cover', 'price', 'type', 'energy', 'model', 'video', 'views', 'created_at', 'updated_at'], + 'relations' => [ + 'translation' => ['vehicle_id', 'locale', 'name', 'condition_desc', 'location'], + 'asked' => ['id', 'vehicle_id', 'status', 'sort'], + 'asked.translation' => ['id', 'asked_id', 'locale', 'title', 'content'], + 'trait' => ['id', 'vehicle_id', 'status', 'sort'], + 'trait.translation' => ['id', 'trait_id', 'locale', 'title', 'content'], + 'album' => ['id', 'vehicle_id', 'pic', 'status', 'sort'], + 'album.translation' => ['id', 'album_id', 'locale', 'alt'], + 'content' => ['id', 'vehicle_id', 'status', 'sort'], + 'content.translation' => ['id', 'content_id', 'locale', 'content'], + 'brand.translation' => ['brand_id', 'name'], + 'types.translation' => ['type_id', 'name'], + 'energy.translation' => ['energy_id', 'name'], + 'models.translation' => ['model_id', 'name'], + ], + 'sorts' => [ + ['field' => 'id', 'direction' => 'desc'] + ], + 'pagination' => [ + 'page' => $params['page'] ?? 1, + 'per_page' => $params['per_page'] ?? 10, + ] + ]; + } + ]; + } + + + // 声明需要多语言翻译 + protected array $translatable = [ + 'condition_desc','name', + ]; +} \ No newline at end of file diff --git a/app/apis/service/VehicleNewTraitService.php b/app/apis/service/VehicleNewTraitService.php new file mode 100644 index 0000000..b830dfa --- /dev/null +++ b/app/apis/service/VehicleNewTraitService.php @@ -0,0 +1,59 @@ + function ($params) { + // $keyword = $params['keyword'] ?? ''; + // return [ + // 'filters' => [ + // ['field' => '***', 'operator' => '=', 'value' => '***'] + // ], + // 'fields' => ['id'], + // 'relations' => [], + // 'custom' => function(Builder $q) use ($keyword) { + // // 示例 + // if ($keyword) { + // $q->where(function($q2) use($keyword) { + // $q2->whereHas('***', function($q3) use($keyword) { + // $q3->where('***', 'like', "%{$keyword}%"); + // })->orWhereHas('***', function($q4) use($keyword) { + // $q4->where('***', 'like', "%{$keyword}%"); + // }); + // }); + // } + // }, + // 'sorts' => [ + // ['field' => 'created_at', 'direction' => 'desc'] + // ], + // 'pagination' => [ + // 'page' => $params['page'] ?? 1, + // 'per_page' => $params['per_page'] ?? 10, + // ] + // ]; + // } + ]; + } +} \ No newline at end of file diff --git a/app/apis/service/VehicleNewTraitTranslationService.php b/app/apis/service/VehicleNewTraitTranslationService.php new file mode 100644 index 0000000..2a97e02 --- /dev/null +++ b/app/apis/service/VehicleNewTraitTranslationService.php @@ -0,0 +1,59 @@ + function ($params) { + // $keyword = $params['keyword'] ?? ''; + // return [ + // 'filters' => [ + // ['field' => '***', 'operator' => '=', 'value' => '***'] + // ], + // 'fields' => ['id'], + // 'relations' => [], + // 'custom' => function(Builder $q) use ($keyword) { + // // 示例 + // if ($keyword) { + // $q->where(function($q2) use($keyword) { + // $q2->whereHas('***', function($q3) use($keyword) { + // $q3->where('***', 'like', "%{$keyword}%"); + // })->orWhereHas('***', function($q4) use($keyword) { + // $q4->where('***', 'like', "%{$keyword}%"); + // }); + // }); + // } + // }, + // 'sorts' => [ + // ['field' => 'created_at', 'direction' => 'desc'] + // ], + // 'pagination' => [ + // 'page' => $params['page'] ?? 1, + // 'per_page' => $params['per_page'] ?? 10, + // ] + // ]; + // } + ]; + } +} \ No newline at end of file diff --git a/app/apis/service/VehicleNewTranslationService.php b/app/apis/service/VehicleNewTranslationService.php new file mode 100644 index 0000000..153299c --- /dev/null +++ b/app/apis/service/VehicleNewTranslationService.php @@ -0,0 +1,59 @@ + function ($params) { + // $keyword = $params['keyword'] ?? ''; + // return [ + // 'filters' => [ + // ['field' => '***', 'operator' => '=', 'value' => '***'] + // ], + // 'fields' => ['id'], + // 'relations' => [], + // 'custom' => function(Builder $q) use ($keyword) { + // // 示例 + // if ($keyword) { + // $q->where(function($q2) use($keyword) { + // $q2->whereHas('***', function($q3) use($keyword) { + // $q3->where('***', 'like', "%{$keyword}%"); + // })->orWhereHas('***', function($q4) use($keyword) { + // $q4->where('***', 'like', "%{$keyword}%"); + // }); + // }); + // } + // }, + // 'sorts' => [ + // ['field' => 'created_at', 'direction' => 'desc'] + // ], + // 'pagination' => [ + // 'page' => $params['page'] ?? 1, + // 'per_page' => $params['per_page'] ?? 10, + // ] + // ]; + // } + ]; + } +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewAlbumTranslationValidator.php b/app/apis/validate/VehicleNewAlbumTranslationValidator.php new file mode 100644 index 0000000..dbd3954 --- /dev/null +++ b/app/apis/validate/VehicleNewAlbumTranslationValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewAlbumValidator.php b/app/apis/validate/VehicleNewAlbumValidator.php new file mode 100644 index 0000000..269fbb0 --- /dev/null +++ b/app/apis/validate/VehicleNewAlbumValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewAskedTranslationValidator.php b/app/apis/validate/VehicleNewAskedTranslationValidator.php new file mode 100644 index 0000000..99f7fb3 --- /dev/null +++ b/app/apis/validate/VehicleNewAskedTranslationValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewAskedValidator.php b/app/apis/validate/VehicleNewAskedValidator.php new file mode 100644 index 0000000..db416fe --- /dev/null +++ b/app/apis/validate/VehicleNewAskedValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewContentTranslationValidator.php b/app/apis/validate/VehicleNewContentTranslationValidator.php new file mode 100644 index 0000000..fe6f3d9 --- /dev/null +++ b/app/apis/validate/VehicleNewContentTranslationValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewContentValidator.php b/app/apis/validate/VehicleNewContentValidator.php new file mode 100644 index 0000000..bb87038 --- /dev/null +++ b/app/apis/validate/VehicleNewContentValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewTraitTranslationValidator.php b/app/apis/validate/VehicleNewTraitTranslationValidator.php new file mode 100644 index 0000000..57d6263 --- /dev/null +++ b/app/apis/validate/VehicleNewTraitTranslationValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewTraitValidator.php b/app/apis/validate/VehicleNewTraitValidator.php new file mode 100644 index 0000000..d1800b6 --- /dev/null +++ b/app/apis/validate/VehicleNewTraitValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewTranslationValidator.php b/app/apis/validate/VehicleNewTranslationValidator.php new file mode 100644 index 0000000..23fe8c4 --- /dev/null +++ b/app/apis/validate/VehicleNewTranslationValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/apis/validate/VehicleNewValidator.php b/app/apis/validate/VehicleNewValidator.php new file mode 100644 index 0000000..1bdffd8 --- /dev/null +++ b/app/apis/validate/VehicleNewValidator.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/console/model/BrandBannerModel.php b/app/console/model/BrandBannerModel.php index ac59ff7..b2d1cf4 100644 --- a/app/console/model/BrandBannerModel.php +++ b/app/console/model/BrandBannerModel.php @@ -65,7 +65,7 @@ class BrandBannerModel extends Model */ public function translation() { - return $this->hasOne(BrandBannerTranslationModel::class, 'brand_id')->where('locale', locale()); + return $this->hasOne(BrandBannerTranslationModel::class, 'banner_id')->where('locale', locale()); } /** @@ -73,11 +73,11 @@ class BrandBannerModel extends Model */ public function translations() { - return $this->hasMany(VehicleDataTranslationModel::class, 'brand_id'); + return $this->hasMany(VehicleDataTranslationModel::class, 'banner_id'); } const TRANS_FIELDS = [ - 'name', 'condition_desc' + 'alt' ]; } \ No newline at end of file diff --git a/app/console/model/BrandTraitModel.php b/app/console/model/BrandTraitModel.php index 52a505a..cf4c671 100644 --- a/app/console/model/BrandTraitModel.php +++ b/app/console/model/BrandTraitModel.php @@ -79,6 +79,6 @@ class BrandTraitModel extends Model const TRANS_FIELDS = [ - 'name', 'condition_desc' + 'title', 'content' ]; } \ No newline at end of file diff --git a/app/console/model/VehicleNewAlbumModel.php b/app/console/model/VehicleNewAlbumModel.php index f22adaf..f5853c2 100644 --- a/app/console/model/VehicleNewAlbumModel.php +++ b/app/console/model/VehicleNewAlbumModel.php @@ -70,6 +70,9 @@ class VehicleNewAlbumModel extends Model return $this->hasMany(VehicleNewAlbumTranslationModel::class, 'album_id'); } + const VEHICLE_NEW_ALBUM_FIELDS = [ + 'pic', + ]; const TRANS_FIELDS = [ 'alt', ]; diff --git a/config/route.php b/config/route.php index 70021f3..1e2adba 100644 --- a/config/route.php +++ b/config/route.php @@ -42,6 +42,9 @@ Route::group('/apis', function() { Route::any('/agt/privacy', [\app\apis\controller\AgreementController::class, 'one']); // 品牌按字母查询 // Route::any('/brand/letterAll', [\app\apis\controller\BrandController::class, 'letterAll']); + // 新车管理 + Route::any('/vehicle/new/list', [\app\console\controller\VehicleNewController::class, 'index']); + Route::any('/vehicle/new/{id}/detail', [\app\console\controller\VehicleNewController::class, 'detail']); }); // ====== ====== ====== 网站 ====== ====== ======