Skip to content

Commit

Permalink
Merge pull request #26 from ghojeong/feature/be/set-directory-structure
Browse files Browse the repository at this point in the history
수고하셨습니다.~~
  • Loading branch information
kjk402 committed Apr 21, 2021
2 parents 75abe5e + 3e2de1f commit 08e026c
Show file tree
Hide file tree
Showing 12 changed files with 453 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.codesquad.sidedish.SideDish.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

@Override
public void addCorsMappings(final CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("*");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.codesquad.sidedish.SideDish.controller;

import com.codesquad.sidedish.SideDish.dto.*;
import com.codesquad.sidedish.SideDish.service.CategoryService;
import com.codesquad.sidedish.SideDish.service.DishService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class DishController {
private final CategoryService categoryService;
private final DishService dishService;

DishController(CategoryService categoryService, DishService dishService) {
this.categoryService = categoryService;
this.dishService = dishService;
}

@GetMapping
@RequestMapping("/categories")
public ResponseEntity<List<CategoryDto>> getCategories() {
List<CategoryDto> categories = categoryService.getList();
return ResponseEntity.ok().body(categories);
}

@GetMapping("/detail/{hash}")
public ResponseEntity<DishDetailDto> getDetail(@PathVariable("hash") String hash) {
DishDetailDto dishDetailDto = dishService.getDetail(hash);
return ResponseEntity.ok().body(dishDetailDto);
}

@GetMapping("/detail/{hash}/refreshable")
public ResponseEntity<RefreshDto> getDetailRefreshable(@PathVariable("hash") String hash, @RequestParam("lastUpdated") int lastUpdated) {
RefreshDto refreshDto = dishService.getDetailRefreshable(hash, lastUpdated);
return ResponseEntity.ok().body(refreshDto);
}

@GetMapping("/detail/{hash}/quantity")
public ResponseEntity<QuantityDto> getDetailQuantity(@PathVariable("hash") String hash) {
QuantityDto quantityDto = dishService.getDetailQuantity(hash);
return ResponseEntity.ok().body(quantityDto);
}

@GetMapping("/main")
public ResponseEntity<List<DishDto>> getMainList() {
List<DishDto> dishes = dishService.getList(1);
return ResponseEntity.ok().body(dishes);
}

@GetMapping("/side")
public ResponseEntity<List<DishDto>> getSideList() {
List<DishDto> dishes = dishService.getList(1);
return ResponseEntity.ok().body(dishes);
}

@GetMapping("/soup")
public ResponseEntity<List<DishDto>> getSoupList() {
List<DishDto> dishes = dishService.getList(1);
return ResponseEntity.ok().body(dishes);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.codesquad.sidedish.SideDish.domain;

// TODO:
public class Dish {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.codesquad.sidedish.SideDish.domain;

// TODO:
public class DishRepository {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.codesquad.sidedish.SideDish.dto;

public class CategoryDto {
private long id;
private String categoryName;
private String endPoint;

public CategoryDto(long id, String categoryName, String endPoint) {
this.id = id;
this.categoryName = categoryName;
this.endPoint = endPoint;
}

public long getId() {
return id;
}

public String getCategoryName() {
return categoryName;
}

public String getEndPoint() {
return endPoint;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package com.codesquad.sidedish.SideDish.dto;

import java.util.List;

public class DishDetailDataDto {
private final String topImage;
private final List<String> thumbImages;
private final String productDescription;
private final int point;
private final String deliveryInfo;
private final String deliveryFee;
private final List<String> prices;
private final List<String> detailSection;

private DishDetailDataDto(Builder builder) {
this.topImage = builder.topImage;
this.thumbImages = builder.thumbImages;
this.productDescription = builder.productDescription;
this.point = builder.point;
this.deliveryInfo = builder.deliveryInfo;
this.deliveryFee = builder.deliveryFee;
this.prices = builder.prices;
this.detailSection = builder.detailSection;
}

public static class Builder {
private String topImage;
private List<String> thumbImages;
private String productDescription;
private int point;
private String deliveryInfo;
private String deliveryFee;
private List<String> prices;
private List<String> detailSection;

public DishDetailDataDto build() {
return new DishDetailDataDto(this);
}

public Builder topImage(String topImage) {
this.topImage = topImage;
return this;
}

public Builder thumbImages(List<String> thumbImages) {
this.thumbImages = thumbImages;
return this;
}

public Builder productDescription(String productDescription) {
this.productDescription = productDescription;
return this;
}

public Builder point(int point) {
this.point = point;
return this;
}

public Builder deliveryInfo(String deliveryInfo) {
this.deliveryInfo = deliveryInfo;
return this;
}

public Builder deliveryFee(String deliveryFee) {
this.deliveryFee = deliveryFee;
return this;
}

public Builder prices(List<String> prices) {
this.prices = prices;
return this;
}

public Builder detailSection(List<String> detailSection) {
this.detailSection = detailSection;
return this;
}
}

public String getTopImage() {
return topImage;
}

public List<String> getThumbImages() {
return thumbImages;
}

public String getProductDescription() {
return productDescription;
}

public int getPoint() {
return point;
}

public String getDeliveryInfo() {
return deliveryInfo;
}

public String getDeliveryFee() {
return deliveryFee;
}

public List<String> getPrices() {
return prices;
}

public List<String> getDetailSection() {
return detailSection;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.codesquad.sidedish.SideDish.dto;

public class DishDetailDto {
private final String hash;
private final DishDetailDataDto data;

public DishDetailDto(String hash, DishDetailDataDto data) {
this.hash = hash;
this.data = data;
}

public String getHash() {
return hash;
}

public DishDetailDataDto getData() {
return data;
}
}
113 changes: 113 additions & 0 deletions backend/src/main/java/com/codesquad/sidedish/SideDish/dto/DishDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
package com.codesquad.sidedish.SideDish.dto;

import java.util.List;

public class DishDto {
private final String detailHash;
private final String image;
private final List<String> deliveryType;
private final String title;
private final String description;
private final int nPrice;
private final String sPrice;
private final List<String> badge;

private DishDto(Builder builder) {
this.detailHash = builder.detailHash;
this.image = builder.image;
this.deliveryType = builder.deliveryType;
this.title = builder.title;
this.description = builder.description;
this.nPrice = builder.nPrice;
this.sPrice = builder.sPrice;
this.badge = builder.badge;
}

public static class Builder {
private String detailHash;
private String image;
private List<String> deliveryType;
private String title;
private String description;
private int nPrice;
private String sPrice;
private List<String> badge;

public DishDto build() {
return new DishDto(this);
}


public Builder detailHash(String detailHash) {
this.detailHash = detailHash;
return this;
}

public Builder image(String image) {
this.image = image;
return this;
}

public Builder deliveryType(List<String> deliveryType) {
this.deliveryType = deliveryType;
return this;
}

public Builder title(String title) {
this.title = title;
return this;
}

public Builder description(String description) {
this.description = description;
return this;
}

public Builder nPrice(int nPrice) {
this.nPrice = nPrice;
return this;
}

public Builder sPrice(String sPrice) {
this.sPrice = sPrice;
return this;
}

public Builder badge(List<String> badge) {
this.badge = badge;
return this;
}
}

public String getDetailHash() {
return detailHash;
}

public String getImage() {
return image;
}

public List<String> getDeliveryType() {
return deliveryType;
}

public String getTitle() {
return title;
}

public String getDescription() {
return description;
}

public int getnPrice() {
return nPrice;
}

public String getsPrice() {
return sPrice;
}

public List<String> getBadge() {
return badge;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.codesquad.sidedish.SideDish.dto;

public class QuantityDto {
private final int quantity;

public QuantityDto(int quantity) {
this.quantity = quantity;
}

public int getQuantity() {
return quantity;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.codesquad.sidedish.SideDish.dto;

public class RefreshDto {
private final boolean refreshable;

public RefreshDto(boolean refreshable) {
this.refreshable = refreshable;
}

public boolean isRefreshable() {
return refreshable;
}
}
Loading

0 comments on commit 08e026c

Please sign in to comment.