Implement CLI application with JDBC + repository pattern#17
Implement CLI application with JDBC + repository pattern#17
Conversation
and what to do.
AccountRepository with login and crud operations.
mission repository with list, getById, and countByYear
wrapper for JDBC connections
mission results
|
Caution Review failedThe pull request is closed. WalkthroughThis PR introduces a complete data access layer with JDBC repositories for account and moon mission management, adds a simple DataSource implementation, and expands the Main application with an interactive console-driven menu system for user authentication, account operations, and mission queries. Changes
Sequence DiagramsequenceDiagram
actor User
participant Main
participant Scanner as Input Handler
participant AccountRepo as JdbcAccountRepository
participant DB as Database
participant MissionRepo as JdbcMoonMissionRepository
User->>Main: Start application
Main->>Scanner: Prompt for username/password
User->>Scanner: Enter credentials
Scanner->>Main: Return credentials
Main->>AccountRepo: login(username, password)
AccountRepo->>DB: SELECT from accounts table
DB-->>AccountRepo: Query result
alt Authentication Success
AccountRepo-->>Main: true
Main->>User: Display main menu
loop Menu Selection
User->>Scanner: Select option (1-6)
Scanner->>Main: Return choice
alt List Missions
Main->>MissionRepo: listSpacecraft()
MissionRepo->>DB: SELECT spacecraft FROM moon_mission
DB-->>MissionRepo: Results
MissionRepo-->>Main: List<String>
Main->>User: Display missions
else Get Mission by ID
Main->>Scanner: Prompt for mission ID
User->>Scanner: Enter ID
Scanner->>Main: Return ID
Main->>MissionRepo: getMissionById(id)
MissionRepo->>DB: SELECT mission data by ID
DB-->>MissionRepo: Mission object
MissionRepo-->>Main: Mission
Main->>User: Display mission details
else Count by Year
Main->>Scanner: Prompt for year
User->>Scanner: Enter year
Scanner->>Main: Return year
Main->>MissionRepo: countByYear(year)
MissionRepo->>DB: SELECT COUNT where YEAR(launch_date)=?
DB-->>MissionRepo: Count
MissionRepo-->>Main: int count
Main->>User: Display count
else Account Operations
Main->>Scanner: Prompt for account operation details
User->>Scanner: Enter details
Scanner->>Main: Return details
alt Create Account
Main->>AccountRepo: create(first, last, ssn, password)
AccountRepo->>DB: INSERT into accounts
DB-->>AccountRepo: Generated key
else Update Password
Main->>AccountRepo: updatePassword(userId, newPassword)
AccountRepo->>DB: UPDATE accounts
else Delete Account
Main->>AccountRepo: delete(userId)
AccountRepo->>DB: DELETE from accounts
end
AccountRepo-->>Main: Operation result
Main->>User: Confirmation message
end
end
else Authentication Failure
AccountRepo-->>Main: false
Main->>User: Display error, exit
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (10)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.