Giter Site home page Giter Site logo

zdjava137-project's Introduction

zdjava137-project's People

Contributors

waldisurfer avatar stachu540 avatar mates124 avatar

Watchers

 avatar Mikołaj Kłosowski avatar

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 some Exception
  • 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 ]
  • /api/account/login
    • GET (token: String) - 200 - SessionToken [ 403 - InvalidTokenException ]
    • POST (username: String, password: String) - 201 - SessionToken [ 401 - InvalidAuthorizationException ]
  • /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
  • /api/checkout (CheckoutData) [POST] - 201 "redirect:/pay/{id}"
  • /api/pay/{id} [GET] - 200 PayDetails

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
  • /api/users/{id}
    • GET - 200 User
    • PATCH (UserUpdate) - 200 User
    • DELETE - 204 void

Categories

  • /api/categories
    • GET - 200 - Collection<Category>
    • POST (CategoryCreate) - 201 - Category [ 403 - !hasAccess('ADMIN', 'SUPER_ADMIN') ]
  • /api/categories/{id}
    • GET - 200 Category
    • PATCH (CategoryUpdate) - 200 Category [ 403 - !hasAccess('ADMIN', 'SUPER_ADMIN') ]
    • DELETE - 204 void [ 403 - !hasAccess('ADMIN', 'SUPER_ADMIN') ]
  • /api/categories/{id}/products [GET] - 200 - Pageable<Product>

Products

  • /api/products
    • GET - 200 - Pageable<Product>
    • POST (ProductCreate) - 201 - Product
  • /api/products/{id}
    • GET - 200 Product
    • PATCH (ProductUpdate) - 200 Product [ 403 - !hasAccess('ADMIN', 'SUPER_ADMIN') or !isSeller ]
    • DELETE - 204 void [ 403 - !hasAccess('ADMIN', 'SUPER_ADMIN') or !isSeller ]
  • /api/products/{id}/comments
    • GET - 200 - Pageable<Comment>
    • POST (CommentCreate) - 201 - Comment
  • /api/products/{id}/comments/{id} - [ 400 InvalidCommentException ]
    • GET - 200 - Comment
    • PATCH (CommentUpdate) - 201 - Comment [ 403 - !hasAccess('ADMIN', 'SUPER_ADMIN') or !isCreator ]
    • DELETE - 204 - void [ 403 - !hasAccess('ADMIN', 'SUPER_ADMIN') or !isCreator ]

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 from JSESSIONID cookie
    • user: User [nullable if anonymous]
    • items: Collection<CartItem>
  • CartItem
    • product: Product
    • quantity: int
  • PayDetails
    • id: UUID
    • status: PayStatus
    • processor: String
    • orders: Collection<Order>
    • reason: String [nullable - if PayStatus != 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 of score / body must be filled
    • id: 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}
    • Comments/account/products/{id}/comments
  • 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]

ProductRepository

  • #findAll() -> Collection<Product>
  • #findById(Long productId) -> Optional<Product>
  • -#findByCategory(String category) -> List<Product>
  • #save(Product product) -> Product
  • #deleteById(Long productId) -> throws some Exception

UserService

  • Validation using annotations
  • Password Encoding - BCrypt default
  • Methods
    • #register(@Validate CreateUserDTO dto) -> User throws ValidationException
    • #update(@Validate UpdateUserDTO dto) -> User throws ValidationException
    • #delete(long id) throws some Exception
    • #get(long id) -> Optional<User>
    • #login(String user, String password) -> SessionToken throws some Exception
    • #checkSession(String token) -> SessionToken throws some Exception
    • #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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.