Skip to content

OwnerApiController fix issue#2316

Open
priyanshuvishwakarma273403 wants to merge 1 commit intospring-projects:mainfrom
priyanshuvishwakarma273403:feature/my-change
Open

OwnerApiController fix issue#2316
priyanshuvishwakarma273403 wants to merge 1 commit intospring-projects:mainfrom
priyanshuvishwakarma273403:feature/my-change

Conversation

@priyanshuvishwakarma273403
Copy link
Copy Markdown

No description provided.

@priyanshuvishwakarma273403
Copy link
Copy Markdown
Author

Title: Add REST API endpoints and modernize UI

Description:

Overview

Is Pull Request mein humne Spring PetClinic project mein REST API endpoints add kiye hain aur UI ko modernize kiya hain.

Changes Made

  1. REST API Controllers (New)

OwnerApiController (/api/owners)

  • GET /api/owners - Saare owners ko paginated list mein retrieve karo
  • GET /api/owners/{id} - Owner by ID fetch karo
  • GET /api/owners/search?lastName=xxx - Last name se owners search karo
  • POST /api/owners - Naya owner create karo
  • PUT /api/owners/{id} - Existing owner update karo
  • DELETE /api/owners/{id} - Owner delete karo

PetApiController (/api/pets)

  • GET /api/pets - Saare pets ki paginated list
  • GET /api/pets/{id} - Pet by ID fetch karo
  • GET /api/pets/owner/{ownerId} - Kisi owner ke saare pets
  • POST /api/pets/owner/{ownerId} - Owner ke liye naya pet create karo
  • PUT /api/pets/{id} - Pet update karo
  • DELETE /api/pets/{id} - Pet delete karo

VisitApiController (/api)

  • GET /api/visits - Saare visits
  • GET /api/pets/{petId}/visits - Kisi pet ki saari visits
  • POST /api/pets/{petId}/visits - Pet ke liye naya visit create karo
  • PUT /api/visits/{id} - Visit update karo
  • DELETE /api/visits/{id} - Visit delete karo
  1. New Repository Interfaces
  • PetRepository.java - Pet entity ke liye JPA repository
  • VisitRepository.java - Visit entity ke liye JPA repository
  1. Entity Enhancement
  • Visit.java mein ManyToOne Pet relationship add kiya - isse visits ko pets se link karna possible hua
  1. UI Improvements
  • Welcome Page: Modern hero section with gradient background, feature cards (Owners, Vets, Pets & Visits), aur stats section
  • Navigation Bar: Gradient styling add kiya aur brand logo include kiya
  • Footer: Clean modern footer with copyright
  • SCSS Styles: Tables, cards, buttons, forms, alerts, pagination - sabko modern styling di
  1. i18n Updates
  • messages.properties mein welcomeTitle aur welcomeSubtitle keys add kiye

Technical Details

┌────────────────┬────────────────────────────────────────────────────┐
│ Component │ Details │
├────────────────┼────────────────────────────────────────────────────┤
│ API Format │ JSON REST APIs │
├────────────────┼────────────────────────────────────────────────────┤
│ Pagination │ Default page size 10, customizable │
├────────────────┼────────────────────────────────────────────────────┤
│ Sorting │ Owners API supports sorting by any field │
├────────────────┼────────────────────────────────────────────────────┤
│ Validation │ Jakarta validation annotations on entities │
├────────────────┼────────────────────────────────────────────────────┤
│ Response Codes │ 200 OK, 201 Created, 404 Not Found, 204 No Content │
└────────────────┴────────────────────────────────────────────────────┘

API Response Examples

GET /api/owners
{
"owners": [...],
"currentPage": 0,
"totalItems": 25,
"totalPages": 3
}

POST /api/owners
{
"firstName": "John",
"lastName": "Doe",
"address": "123 Main St",
"city": "New York",
"telephone": "1234567890"
}

Benefits

  1. External applications ab PetClinic data use kar sakte hain via REST APIs
  2. Modern UI se user experience better hua
  3. Mobile apps ke liye API support available hain
  4. Proper pagination aur error handling implemented hain

Testing

  • All APIs return proper JSON responses
  • Project successfully compiles
  • Backward compatible - existing functionality unchanged

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.

1 participant