73 lines
2.3 KiB
Markdown
73 lines
2.3 KiB
Markdown
You are working in a Go project named ginimageApi.
|
|
|
|
Goal:
|
|
Implement admin panel user management endpoints for the existing application structure.
|
|
|
|
Project details:
|
|
- Go version: 1.26
|
|
- Framework: Gin
|
|
- ORM: Gorm
|
|
- Existing packages already installed include gin, gorm, mysql/sqlite drivers, jwt, redis, swagger, bcrypt/crypto, etc.
|
|
|
|
Current structure:
|
|
- main.go
|
|
- .env
|
|
- app/
|
|
- accounts/
|
|
- handlers/user.go
|
|
- models/accounts.go
|
|
- settings/
|
|
- handlers/settings.go
|
|
- models/setting.go
|
|
- models/hero.go
|
|
- models/cors.go
|
|
- shop/
|
|
- handlers/shop.go
|
|
- models/product.go
|
|
- models/cart.go
|
|
- blog/
|
|
- handlers/blog.go
|
|
- models/blog.go
|
|
- config/
|
|
- db.go
|
|
- redis.go
|
|
- router/router.go
|
|
|
|
Task:
|
|
Create admin user management endpoints suitable for an admin panel. Use the existing architecture and keep the implementation consistent with the project structure.
|
|
|
|
Expected endpoints:
|
|
- GET /admin/users
|
|
- GET /admin/users/:id
|
|
- POST /admin/users
|
|
- PUT /admin/users/:id
|
|
- PATCH /admin/users/:id/status
|
|
- DELETE /admin/users/:id
|
|
|
|
Requirements:
|
|
- Follow Gin handler patterns already used in the project.
|
|
- Use Gorm for database operations.
|
|
- Add request/response DTOs if needed.
|
|
- Validate inputs properly.
|
|
- Hash passwords securely.
|
|
- Do not return sensitive fields such as password hashes.
|
|
- Add middleware/auth guard assumptions if needed, but keep integration minimal and compatible with the existing codebase.
|
|
- Keep code clean, modular, and idiomatic.
|
|
- If admin role support does not exist yet, introduce it in the least disruptive way.
|
|
- Prepare router wiring under the existing router structure.
|
|
- If model changes are required, update the relevant accounts model carefully.
|
|
- If migrations are needed, provide the code changes in a way compatible with SQLite and MySQL.
|
|
|
|
Implementation notes:
|
|
- Prefer small, focused changes.
|
|
- Reuse existing user/account model if possible.
|
|
- Include filtering, pagination, and search support in list endpoint if practical.
|
|
- Make sure error responses are consistent.
|
|
- If helpful, add service/helper functions, but keep the structure aligned with the current app layout.
|
|
|
|
Deliverables:
|
|
- Updated model(s) if needed
|
|
- New/updated admin user handler(s)
|
|
- Router registration
|
|
- Any supporting helper/DTO code
|
|
- Brief documentation comments if useful |