[WIP] Add story and character API integration in Flutter app#8
Merged
Conversation
IfeyChan702
marked this pull request as ready for review
February 12, 2026 09:21
Copilot stopped work on behalf of
IfeyChan702 due to an error
February 12, 2026 09:21
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation Plan for Story & Character Features
image_pickerdependency topubspec.yamlstory_model.dartwith JSON serializationcharacter_model.dartwith JSON serializationconstants.dartwith Story and Character API endpointsapi_service.dartwith Story and Character API methodsstory_card.dartwidgetstories_screen.dart(list view)story_detail_screen.dart(detail view)generate_story_screen.dart(camera + AI generation)characters_screen.dart(character list)add_character_screen.dart(add/edit character)home_screen.dartto add Stories tab (5 tabs total)README.mdwith new featuresOriginal prompt
背景
后端 Spring Boot 已经完整实现了「拍照识别物品 → AI生成英语故事」的核心功能链路:
DeepseekApiClient.analyzeImage()- 调用 Vision API 识别图片中的物品StoryServiceImpl.generateStory()- 基于识别出的物品和角色生成英语故事StoryController- REST API 端点 (/api/story/*)CharacterController- 角色管理端点 (/api/character/*)但当前 main 分支的 Flutter 前端代码 完全缺少 Story/Character/拍照识别功能。
api_service.dart只有 Note、RAG、Review 的 API 调用,没有任何 story/character 方法。后端 API 详情
GenerateStoryRequest (后端 DTO)
Story Controller 端点 (
/api/story)POST /api/story/generate- 生成故事(接收 GenerateStoryRequest,包含图片和角色ID)GET /api/story/list- 获取故事列表(支持 characterId、isFavorite 过滤)GET /api/story/{id}- 获取故事详情PUT /api/story/{id}- 更新故事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(在ruoyi-admin/src/main/java/com/ruoyi/web/controller/story/下),提供:POST /api/character/add- 添加角色GET /api/character/list- 获取角色列表GET /api/character/{id}- 获取角色详情PUT /api/character/{id}- 更新角色DELETE /api/character/{id}- 删除角色Search Controller 端点 (
/api/search)POST /api/search/stories- 搜索故事POST /api/search/characters- 搜索角色POST /api/search/all- 全局搜索后端认证方式
JWT Bearer Token,所有 API 请求需要在 Header 中带
Authorization: Bearer {token}后端响应格式 (RuoYi 风格)
当前 Flutter 项目结构 (main 分支)
需要完成的具体任务
1. 添加
image_picker依赖到pubspec.yaml在 dependencies 中添加:
这个包用于从相机或相册选择图片。
2. 创建 Story Model (
flutter_app/lib/models/story_model.dart)字段对应后端 Story 实体:
int? idint? userIdString? titleString? contentint? characterIdString? characterNameString? identifiedObjects- 识别出的物品(逗号分隔)bool? isFavoriteString? shareTokenString? statusString? createdAtString? updatedAt需要
fromJson和toJson方法。3. 创建 Character Model (
flutter_app/lib/models/character_model.dart)字段对应后端 StoryCharacter 实体:
int? idint? userIdString nameString? nameEnString? descriptionString? personalityString? backgroundString? roleString? avatarUrlString? createdAtString? updatedAt需要
fromJson和toJson方法。4. 更新
flutter_app/lib/utils/constants.dart在
AppConstants类中添加 Story 和 Character 相关端点: