diff --git a/app/Admin/Controllers/ArticleController.php b/app/Admin/Controllers/ArticleController.php index 82e9b1a..c5defe6 100644 --- a/app/Admin/Controllers/ArticleController.php +++ b/app/Admin/Controllers/ArticleController.php @@ -83,6 +83,7 @@ class ArticleController extends AdminController amis()->Grid()->columns([ amis()->Wrapper()->body([ amis()->TextControl('title', __('admin.articles.title'))->required(true), + amis()->TextareaControl('description', __('admin.articles.description')), // Components::make()->parentControl(admin_url('api/keywords/tree-list?parent_name=article_category&has_owner=0'), 'category', __('admin.articles.category'), 'name', 'key'), // Components::make()->keywordsTagControl('t_ids', __('admin.articles.tags'), 'article_tag'), Components::make()->cropImageControl('cover', __('admin.articles.cover')), diff --git a/app/Http/Controllers/Api/NewsController.php b/app/Http/Controllers/Api/NewsController.php new file mode 100644 index 0000000..752d44d --- /dev/null +++ b/app/Http/Controllers/Api/NewsController.php @@ -0,0 +1,27 @@ +all(), ArticleFilter::class)->sort(); + $list = $query->show()->sort()->paginate($this->resolvePerPage('per_page', 20)); + + return $this->json(NewsResource::collection($list)); + } + public function show(Article $news){ + request()->merge(['include_content' => true]); + return $this->json(NewsResource::make($news)); + } +} \ No newline at end of file diff --git a/app/Http/Controllers/Api/TimelineController.php b/app/Http/Controllers/Api/TimelineController.php new file mode 100644 index 0000000..7bab78e --- /dev/null +++ b/app/Http/Controllers/Api/TimelineController.php @@ -0,0 +1,22 @@ +all(), TimelineFilter::class)->sort(); + $list = $query->show()->sort()->paginate($this->resolvePerPage('per_page', 20)); + + return $this->json(TimelineResource::collection($list)); + } +} \ No newline at end of file diff --git a/app/Http/Resources/HonorResource.php b/app/Http/Resources/HonorResource.php index 194f459..a1238d8 100644 --- a/app/Http/Resources/HonorResource.php +++ b/app/Http/Resources/HonorResource.php @@ -15,7 +15,7 @@ class HonorResource extends JsonResource public function toArray($request) { return [ - 'id' => $this->id, + // 'id' => $this->id, 'title' => $this->title, 'cover' => $this->cover, 'awarded_date' => $this->awarded_date, diff --git a/app/Http/Resources/NewsResource.php b/app/Http/Resources/NewsResource.php new file mode 100644 index 0000000..c4e2e81 --- /dev/null +++ b/app/Http/Resources/NewsResource.php @@ -0,0 +1,25 @@ + $this->id, + 'title' => $this->title, + 'cover' => $this->cover, + 'description' => $this->description, + 'content' => $this->when($request->boolean('include_content'), $this->content), + 'published_at' => $this->published_at->toDateTimeString() + ]; + } +} diff --git a/app/Http/Resources/TimelineResource.php b/app/Http/Resources/TimelineResource.php new file mode 100644 index 0000000..f971f6a --- /dev/null +++ b/app/Http/Resources/TimelineResource.php @@ -0,0 +1,25 @@ + $this->id, + 'title' => $this->title, + 'description' => $this->description, + 'cover' => $this->cover, + 'awarded_date' => $this->awarded_date, + ]; + } +} diff --git a/app/Models/Article.php b/app/Models/Article.php index 386874f..a582f75 100644 --- a/app/Models/Article.php +++ b/app/Models/Article.php @@ -32,6 +32,7 @@ class Article extends Model protected $fillable = [ 'title', + 'description', 'content', 'cover', 'category', diff --git a/database/migrations/2026_02_23_185611_add_description_to_articles.php b/database/migrations/2026_02_23_185611_add_description_to_articles.php new file mode 100644 index 0000000..db5b613 --- /dev/null +++ b/database/migrations/2026_02_23_185611_add_description_to_articles.php @@ -0,0 +1,30 @@ +text('description')->nullable()->comment('简介'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('articles', function (Blueprint $table) { + // + $table->dropColumn(['description']); + }); + } +}; diff --git a/lang/zh_CN/admin.php b/lang/zh_CN/admin.php index 1cf8e6c..3aa6f36 100644 --- a/lang/zh_CN/admin.php +++ b/lang/zh_CN/admin.php @@ -298,6 +298,7 @@ return [ 'sort' => '排序', 'appendixes' => '附件', 'published_at_remark' => '*若未设置发布时间且操作设置为显示,则默认生成发布时间', + 'description' => '简述', ], 'ads' => [ 'id' => 'ID', diff --git a/routes/api.php b/routes/api.php index b554ef1..9af7f4d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -38,8 +38,11 @@ Route::middleware('api')->group(function () { Route::get('/case_studies', [CaseStudyController::class, 'index']); Route::get('/case_studies/{case_study}', [CaseStudyController::class, 'show']); //企业资讯 - + Route::get('/news', [NewsController::class, 'index']); + Route::get('/news/{news}', [NewsController::class, 'show']); //荣誉资质 Route::get('/honor_cates', [HonorController::class, 'cates']); Route::get('/honors', [HonorController::class, 'index']); + //发展历程 + Route::get('/timelines', [TimelineController::class, 'index']); }); \ No newline at end of file