Skip to content
 
 

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eCommerce

데이터 베이스 초기화

img.png

img_1.png

img_2.png

설정파일

dao-context.xml

<context:component-scan base-package="kr.ac.hansung.cse.dao" />

service-context.xml

<context:component-scan base-package="kr.ac.hansung.cse.service" />

servlert-context.xml

<context:component-scan base-package="kr.ac.hansung.cse.controller" />

컨트롤러 파일

ProductController.java

@PutMapping("/{id}")
public ResponseEntity<Product> updateProduct(@PathVariable Long id, @Valid @RequestBody ProductDto request) {
    Product product = productService.getProductById(id);
    if (product == null) {
        throw new NotFoundException(id);
    }

    product.setName(request.getName());
    product.setPrice(request.getPrice());

    productService.updateProduct(product);
    return ResponseEntity.ok(product);
}

CategoryController.java

@GetMapping("/{id}")
public ResponseEntity<Category> retrieveCategory(@PathVariable Long id) {
    Category category = categoryService.getCategoryById(id);
    if (category == null) {
        return ResponseEntity.notFound().build();
    }
    return ResponseEntity.ok(category);
}

CategoryProductsController.java

@DeleteMapping("/{productId}")
public ResponseEntity<Void> removeProduct(@PathVariable Long categoryId, @PathVariable Long productId) {
    Category category = categoryService.getCategoryById(categoryId);
    if (category == null) {
        throw new NotFoundException(categoryId);
    }

    Product product = productService.getProductById(productId);
    if (product == null) {
        throw new NotFoundException(productId);
    }

    if (!productService.hasCategory(product, category)) {
        throw new IllegalArgumentException("Product " + productId + " doesn't contains category " + categoryId);
    }

    productService.removeCategory(product, category);
    return ResponseEntity.noContent().build();
}

Rest API

Products:

img_3.png

img_4.png

img_5.png

img_6.png

img_7.png

Category:

img_8.png

img_9.png

img_10.png

img_11.png

img_12.png

img_13.png

img_14.png img_15.png

img_16.png

img_17.png

img_18.png

img_19.png img_20.png

img_21.png

img_22.png

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages