Skip to content

[WIP] Update Flutter app to integrate Story and Character controllers#10

Merged
IfeyChan702 merged 1 commit into
mainfrom
copilot/update-flutter-app-controllers
Feb 12, 2026
Merged

[WIP] Update Flutter app to integrate Story and Character controllers#10
IfeyChan702 merged 1 commit into
mainfrom
copilot/update-flutter-app-controllers

Conversation

Copilot AI commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

Implementation Plan for Story, Character, and Search Features

Phase 1: Dependencies and Constants

  • Update pubspec.yaml to add image_picker dependency
  • Update lib/utils/constants.dart with Story, Character, and Search API endpoints

Phase 2: Models

  • Create lib/models/story_model.dart
  • Create lib/models/character_model.dart
  • Create lib/models/generate_story_request.dart
  • Create lib/models/generate_story_response.dart

Phase 3: API Service

  • Add Story API methods to lib/services/api_service.dart (generate, list, get, update, delete, favorite, share)
  • Add Character API methods to lib/services/api_service.dart (CRUD operations)
  • Add Search API methods to lib/services/api_service.dart (searchStories, searchCharacters, searchAll)

Phase 4: Widgets

  • Create lib/widgets/story_card.dart
  • Create lib/widgets/character_card.dart

Phase 5: Screens

  • Create lib/screens/stories_screen.dart (Story list with filter)
  • Create lib/screens/story_detail_screen.dart (View, edit, favorite, share, delete)
  • Create lib/screens/generate_story_screen.dart (Image picker + character selection)
  • Create lib/screens/characters_screen.dart (Character list)
  • Create lib/screens/add_character_screen.dart (Add/Edit character)
  • Update lib/screens/home_screen.dart to add Stories tab

Phase 6: Platform Configuration

  • Update Android permissions in AndroidManifest.xml
  • Update iOS permissions in Info.plist

Phase 7: Testing and Validation

  • Run flutter pub get
  • Run flutter analyze
  • Verify app builds successfully
Original prompt

背景

Spring 后端已经创建好了 Story(故事)、Character(主角)、Search(统一搜索)等 Controller,但 flutter_app/ 下的前端代码还是旧的,缺少这些功能模块。需要更新 Flutter 前端代码,使其能完整对接后端所有 API。

后端已有 API 端点

Story Controller (/api/story)

  • POST /api/story/generate - 生成故事(上传图片+选择主角,AI 识别图片物品并生成英语故事)
  • GET /api/story/list - 获取故事列表(支持 characterId、isFavorite 筛选)
  • GET /api/story/{id} - 获取故事详情
  • PUT /api/story/{id} - 更新故事(title, content)
  • DELETE /api/story/{id} - 删除故事
  • POST /api/story/{id}/favorite - 收藏故事
  • DELETE /api/story/{id}/favorite - 取消收藏故事
  • POST /api/story/{id}/share - 生成分享链接
  • GET /api/story/shared/{shareToken} - 通过分享链接查看故事

Character Controller (/api/character)(推断自 CharacterController.java,5 个端点)

  • CRUD 操作用于管理故事主角

Search Controller (/api/search)

  • POST /api/search/stories - 搜索故事(keyword, threshold, maxResults)
  • POST /api/search/characters - 搜索主角
  • POST /api/search/all - 全局搜索(故事+主角)

故事生成请求格式 (GenerateStoryRequest)

{
  "image": "base64编码或URL",
  "imageType": "base64",
  "characterId": 1,
  "title": "可选标题"
}

DeepseekApiClient 图片识别

  • analyzeImage(imageBase64, imageType) - 识别图片中的物品,返回英语名词列表
  • 然后基于物品列表 + 主角名字生成英语学习故事

当前 Flutter 前端状态

已有文件(保留不变):

  • lib/main.dart - 入口文件
  • lib/services/api_service.dart - API 服务(只有 Note/RAG/Review)
  • lib/services/auth_service.dart - 认证服务
  • lib/services/storage_service.dart - 本地存储
  • lib/models/note_model.dart - 笔记模型
  • lib/models/rag_response_model.dart - RAG 响应模型
  • lib/models/review_record_model.dart - 复习记录模型
  • lib/screens/login_screen.dart - 登录页
  • lib/screens/home_screen.dart - 主页(目前4个tab)
  • lib/screens/notes_list_screen.dart - 笔记列表
  • lib/screens/note_detail_screen.dart - 笔记详情
  • lib/screens/add_note_screen.dart - 添加笔记
  • lib/screens/rag_search_screen.dart - RAG 搜索
  • lib/screens/review_screen.dart - 复习
  • lib/screens/profile_screen.dart - 个人中心
  • lib/widgets/note_card.dart - 笔记卡片
  • lib/widgets/rag_result_card.dart - RAG 结果卡片
  • lib/widgets/review_item_card.dart - 复习项卡片
  • lib/utils/constants.dart - 常量(目前只有 Note/RAG/Review 端点)
  • lib/utils/validators.dart
  • lib/utils/helpers.dart
  • lib/config/app_constants.dart
  • pubspec.yaml - 依赖配置

需要新增/修改的内容:

1. pubspec.yaml - 添加依赖

  • 添加 image_picker 依赖(用于拍照/选择相册图片)
  • 添加 image_cropper 或类似依赖(可选)

2. lib/utils/constants.dart - 添加新端点常量

// Story endpoints
static const String storyGenerateEndpoint = '$apiPrefix/story/generate';
static const String storyListEndpoint = '$apiPrefix/story/list';
static const String storyGetEndpoint = '$apiPrefix/story'; // /{id}
static const String storyUpdateEndpoint = '$apiPrefix/story'; // /{id}
static const String storyDeleteEndpoint = '$apiPrefix/story'; // /{id}
static const String storyFavoriteEndpoint = '$apiPrefix/story'; // /{id}/favorite
static const String storyShareEndpoint = '$apiPrefix/story'; // /{id}/share
static const String storySharedEndpoint = '$apiPrefix/story/shared'; // /{shareToken}

// Character endpoints
static const String characterListEndpoint = '$apiPrefix/character/list';
static const String characterAddEndpoint = '$apiPrefix/character/add';
static const String characterGetEndpoint = '$apiPrefix/character'; // /{id}
static const String characterUpdateEndpoint = '$apiPrefix/character'; // /{id}
static const String characterDeleteEndpoint = '$apiPrefix/character'; // /{id}

// Search endpoints
static const String searchStoriesEndpoint = '$apiPrefix/search/stories';
static const String searchCharactersEndpoint = '$apiPrefix/search/characters';
static const String searchAllEndpoint = '$apiPrefix/search/all';

3. 新增 Models

  • lib/models/story_model.dart - 故事模型(id, userId, characterId, title, content, isFavorite, shareToken, createdAt, updatedAt)
  • lib/models/character_model.dart - 主角模型(id, userId, name, description, createdAt)
  • lib/models/generate_story_request.dart - 生成故事请求模型
  • lib/models/generate_story_response.dart - 生成故事响应模型

4. lib/services/api_service.dart - 添加新 API 方法

  • Story CRUD + generate + favorite + share
  • Character CRUD
  • Search APIs

5. 新增 Screens

  • lib/screens/stories_screen.dart - 故事列表页(显示所有故事,支持筛选收藏)
  • lib/screens/story_detail_screen.dart - 故事详情页(显示完整故事内容,支持收藏/分享/删除)
  • lib/screens/generate_story_screen.dart - 生成故事页(拍照/选择图片 → 选择主角 → 生成故事)
  • lib/screens/characters_screen.dart - 主角管理页(列表+增删改)
  • lib/screens/add_character_screen.dart - 添加/编辑主角页

6. 新增 Widgets

  • lib/widgets/story_card.dart - 故事卡片(显示标题、摘要、收藏状态、创建时间)
  • lib/widgets/character_card.dart - 主角卡片

7. lib/screens/home_screen.dart - 修改底部导航

  • 从 4 个 tab 改为 5 个 tab:Notes, Stories, Search, Review, Profile
  • 或者在现有 Search tab 中整合故事搜索

8. Android/iOS 配置

  • Android: 确保 AndroidManifest.xml 有相机和存储权限
  • iOS: 确保 Info.plist 有相机和相册权限描述

重要注意事项

  1. 保持现有代码不变:不要删除或破坏现有的 Note/RAG/Review 功能
  2. 遵循现有代码风格:使用相同的架构模式(Service Layer Pattern)、相同的错误处理方式
  3. RuoYi 响应格式:后端使用 RuoYi 框架,响应格式为 { "code": 200, "msg": "...", "data": {...} } 或 `{ "code": 200, "rows": [...], "tota...

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@IfeyChan702
IfeyChan702 marked this pull request as ready for review February 12, 2026 10:07
@IfeyChan702
IfeyChan702 merged commit 15ad956 into main Feb 12, 2026
1 check failed
Copilot AI requested a review from IfeyChan702 February 12, 2026 10:08
Copilot stopped work on behalf of IfeyChan702 due to an error February 12, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants