zdjava137-project's Introduction
zdjava137-project's People
zdjava137-project's Issues
ProductController
Products
-
@GET("/products/{id}") #getProduct(long id)
->Response<Product>
-
@GET("/products") #getProducts(Pageable pageable)
->Collection<Product>
-
@GET("/products/category/{category}")
->productService.getProductsByCategory(category)
ResponseEntity.ok(products) -
@POST("/products") #create(ProductAddDTO dto)
->Response<Product>
-201
-
@PUT("/products/{id}") #update(ProductUpdateDTO dto)
->Response<Product>
-
@DELETE("/products/{id}") #remove(long id)
->Response<void>
UserController
Users
-
@GET("/users/{id}") #getUser(long id)
->Response<User>
-
@POST("/users") #register(CreateUserDTO dto)
->Response<User>
-201
-
@GET("/users") #fetch(Pageable pageable)
->Response<Collection<User>>
-403
if not ADMIN / SUPER_ADMIN -
@PATCH("/users/{id}") update(long id, UserUpdateDTO dto)
->Response<User>
- with password change -
@DELETE("/users/{id}") delete(long id)
-> Response<?> -204
Login
-
@POST("/login") #login(String user, String password)
->Response<SessionToken>
-
@GET("/login") #check(String token)
->Response<SessionToken>
UserRepository
-
#getUserByUsername(String)
->User
/Optional<User>
-
#getUserById(long)
->User
/Optional<User>
-
#createUser(User)
->User
-
#updateUser(User)
->User
-
#removeUserById(long)
->void
throws someException
- Admins Only -
low priority
-
#listUsers(Pageable)
->Collections<User>
-
Backend
Endpoints
Basics
Account
-
/api/account
- POST (
RegisterUser
) - 201 -"redirect:/register/complete"
- DELETE (
token: String
) - 204 -void
[ 403 -InvalidTokenException
, 404 -SessionExpiredException
]
- POST (
-
/api/account/login
- GET (
token: String
) - 200 -SessionToken
[ 403 -InvalidTokenException
] - POST (
username: String
,password: String
) - 201 -SessionToken
[ 401 -InvalidAuthorizationException
]
- GET (
-
/api/account/verify
(token: String
) [POST] - 201 -SessionToken
[ 404 -ExpiredException
, 403 -InvalidTokenException
] -
/api/account/logout
(token: String
) - [PATCH] - 204 -void
[ 403 -InvalidTokenException
, 404 -SessionExpiredException
]
Cart
-
/api/cart
- GET - 200 -
Collection<CartItemDetail>
- PUT (
Collection<CartItem>
) - 201 -Collection<CartItemDetail>
-quantity == 0
removes item
- GET - 200 -
-
/api/checkout
(CheckoutData
) [POST] - 201"redirect:/pay/{id}"
-
/api/pay/{id}
[GET] - 200PayDetails
Search
-
/api/search?q={query}
[GET] - 200 -Pageable<Product>
Users
-
/api/users
[ 403 -!hasAccess('ADMIN', 'SUPER_ADMIN')
]- GET - 200 -
Pageable<User>
- POST (
UserCreate
) - 201 -User
- GET - 200 -
-
/api/users/{id}
- GET - 200
User
- PATCH (
UserUpdate
) - 200User
- DELETE - 204
void
- GET - 200
Categories
-
/api/categories
- GET - 200 -
Collection<Category>
- POST (
CategoryCreate
) - 201 -Category
[ 403 -!hasAccess('ADMIN', 'SUPER_ADMIN')
]
- GET - 200 -
-
/api/categories/{id}
- GET - 200
Category
- PATCH (
CategoryUpdate
) - 200Category
[ 403 -!hasAccess('ADMIN', 'SUPER_ADMIN')
] - DELETE - 204
void
[ 403 -!hasAccess('ADMIN', 'SUPER_ADMIN')
]
- GET - 200
-
/api/categories/{id}/products
[GET] - 200 -Pageable<Product>
Products
-
/api/products
- GET - 200 -
Pageable<Product>
- POST (
ProductCreate
) - 201 -Product
- GET - 200 -
-
/api/products/{id}
- GET - 200
Product
- PATCH (
ProductUpdate
) - 200Product
[ 403 -!hasAccess('ADMIN', 'SUPER_ADMIN') or !isSeller
] - DELETE - 204
void
[ 403 -!hasAccess('ADMIN', 'SUPER_ADMIN') or !isSeller
]
- GET - 200
-
/api/products/{id}/comments
- GET - 200 -
Pageable<Comment>
- POST (
CommentCreate
) - 201 -Comment
- GET - 200 -
-
/api/products/{id}/comments/{id}
- [ 400InvalidCommentException
]- GET - 200 -
Comment
- PATCH (
CommentUpdate
) - 201 -Comment
[ 403 -!hasAccess('ADMIN', 'SUPER_ADMIN') or !isCreator
] - DELETE - 204 -
void
[ 403 -!hasAccess('ADMIN', 'SUPER_ADMIN') or !isCreator
]
- GET - 200 -
Entities
-
User
id: long
username: String
password: String
created_at: Instant
updated_at: Instant
permission: UserPermission
email: String
active: boolean
-
RegisterToken
token: UUID
user: User
expired_at: Instant
-
SessionToken
token: UUID
user: User
expired_at: Instant
user_agent: String
ip_address: String
-
Cart
id: String
- pulling fromJSESSIONID
cookieuser: User
[nullable ifanonymous
]items: Collection<CartItem>
-
CartItem
product: Product
quantity: int
-
PayDetails
id: UUID
status: PayStatus
processor: String
orders: Collection<Order>
reason: String
[nullable - ifPayStatus != ERROR
]
-
Product
id: long
name: String
description: String
images: Collection<URI>
seller: User
category: Category
unit_price: double
units: int
created_at: Instant
updated_at: Instant
-
Category
id: long
name: String
description: String
parent: Category
[nullable]
-
Comment
- one ofscore
/body
must be filledid: long
product: Product
author: User
body: String
[nullable]score: Integer
[nullable]
-
Order
id: UUID
details: OrderDetails
address: Address
user: User
[nullable]created_at: Instant
-
OrderDetails
id: UUID
product: Product
price: double
quantity: int
Responses
User
{
"id": 0,
"username": "String",
"email": "String",
"created_at": "date-time",
"updated_at": "date-time",
"active": false,
"permission": "ENUM"
}
SessionToken
{
"token": "UUID",
"expired_at": "date-time",
"user": {
"id": 0,
"username": "String",
"created_at": "date-time",
"updated_at": "date-time",
"permission": "ENUM",
"email": "String"
}
}
Pageable<T
>
{
"data": [T],
"items": 0
}
[CartItemDetail]
[
{
"quantity": 10,
"product": {
"id": 54510,
"name": "String",
"description": "String",
"images": ["URI"],
"unit_price": 0.01,
"created_at": "date-time",
"updated_at": "date-time",
"seller": {
"id": 0,
"username": "String",
"created_at": "date-time",
"updated_at": "date-time",
"active": false,
"permission": "ENUM"
}
}
}
]
Product
{
"id": 54510,
"name": "String",
"description": "String",
"images": [
"URI"
],
"category": {
"id": 110,
"name": "String",
"description": "String"
},
"units": 600,
"unit_price": 0.01,
"rating": 4.6821678,
"created_at": "date-time",
"updated_at": "date-time",
"seller": {
"id": 0,
"username": "String",
"created_at": "date-time",
"updated_at": "date-time",
"active": false,
"permission": "ENUM"
}
}
Comment
{
"id": 45204567,
"author": {
"id": 0,
"username": "String",
"created_at": "date-time",
"updated_at": "date-time",
"active": false,
"permission": "ENUM"
},
"body": "String",
"rate": 5
}
Category
{
"id": 110,
"name": "String",
"description": "String",
"parent": {
"id": 12,
"name": "String",
"description": "String"
}
}
PayDetails
{
"id": "UUID",
"status": "FAILED",
"processor": "PayPal",
"orders": [
{
"quantity": 10,
"product": {
"id": 54510,
"name": "String",
"description": "String",
"images": ["URI"],
"unit_price": 0.01,
"created_at": "date-time",
"updated_at": "date-time",
"seller": {
"id": 0,
"username": "String",
"created_at": "date-time",
"updated_at": "date-time",
"active": false,
"permission": "ENUM"
}
}
}
],
"reason": "Invalid Transaction ID"
}
Requests
RegisterUser
{
"username": "String",
"password": "String",
"email": "String"
}
CartItem
{
"product": 54965106,
"quantity": 6
}
UserCreate / UserUpdate
{
"username": "String",
"password": "String",
"email": "String",
"permission": "ADMIN",
"active": false
}
CategoryCreate / CategoryUpdate
{
"name": "String",
"description": "String",
"parent": 65206956,
}
ProductCreate / ProductUpdate
{
"name": "String",
"description": "String",
"images": ["URI"],
"category": 54198516,
"unit_price": 6.19,
"units": 400
}
CommentCreate / CommentUpdate
{
"body": "String",
"rate": 5
}
CheckoutData
{
"address": "String",
"rate": 5
}
Frontend
Framework: Vue Angular
Non-responsive (Desktop First)
- Index Page
/
- Login Page
/login
- Register Page
/register
- Search Product
/search?q={query}
- Category Page View
/category/{id}
- Product Page
/product/{id}
- Cart Page View
/cart
- Checkout Page View
/checkout
- Payment Page View
/pay/{id}
- Account
/account
- Settings
/account/settings
- Address
/account/settings/address
- Close
/account/settings
[modal] -> redirect with popup success - Orders
/account/orders
- Payments
/account/payments
- Products
/account/products
- Create
/account/products/new
- Update
/account/products/{id}
- View
/account/products/{id}
- Create
- Comments
/account/products/{id}/comments
- Settings
- Admin Dashboard
/admin
- Analytics (TODO in discuss)
/admin/dashboard
- Salary [tile diagram]
- Activities [tile diagram]
- Users
/admin/users
- Update [modal]
- Delete [modal]
- Categories
/admin/categories
- Create [modal]
- Update [modal]
- Delete [modal]
- Settings
/admin/settings
- Products
/admin/products
- Update [modal]
- Delete [modal]
- Comments
/admin/products/{id}/comments
- Update [modal]
- Delete [modal]
- Analytics (TODO in discuss)
ProductRepository
-
#findAll()
->Collection<Product>
-
#findById(Long productId)
->Optional<Product>
- -
#findByCategory(String category)
->List<Product>
-
#save(Product product)
->Product
-
#deleteById(Long productId)
-> throws someException
UserService
- Validation using annotations
- Password Encoding -
BCrypt
default - Methods
-
#register(@Validate CreateUserDTO dto)
->User
throwsValidationException
-
#update(@Validate UpdateUserDTO dto)
->User
throwsValidationException
-
#delete(long id)
throws someException
-
#get(long id)
->Optional<User>
-
#login(String user, String password)
->SessionToken
throws someException
-
#checkSession(String token)
->SessionToken
throws someException
-
#changePassword(long id, String old, String new)
(Low Prio)
-
- injecting
UserRepository
(via@Autowiered
/ constructor) - #1
ProductService
-
#getProducts(Pageable pageable)
->Collection<Product>
-
#getProductById(long id)
->Optional<Product>
-
#getProductsByCategory(String category)
->productRepository.findByCategory(category)
-
#create(@Validate ProductAddDTO dto)
->Product
-
#update(long id, ProductUpdateDTO dto)
->Product
-
#deleteProduct(long productId)
->void
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.