Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: controller를 만들어라 #18

Merged
merged 1 commit into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package codsquad.team17.sidedish.controller;

import codsquad.team17.sidedish.domain.Item;
import codsquad.team17.sidedish.repository.ItemRepository;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/best")
public class BestCategoryController {

private final ItemRepository itemRepository;

public BestCategoryController (ItemRepository itemRepository){
this.itemRepository = itemRepository;
}


@GetMapping
public ResponseEntity getBestCategoryList(){



return new ResponseEntity("", HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package codsquad.team17.sidedish.dto;

import java.util.List;

public class BestCategoryDto {
private Long bestCategoryId;
private String bestCategoryName;
private List<ItemDto> items;

private BestCategoryDto(){

}

public BestCategoryDto(Long bestCategoryId, String bestCategoryName, List<ItemDto> items) {
this.bestCategoryId = bestCategoryId;
this.bestCategoryName = bestCategoryName;
this.items = items;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package codsquad.team17.sidedish.dto;

import java.math.BigDecimal;
import java.util.List;

public class ItemDto {
private Long itemId;
private String title;
private String discription;

private BigDecimal n_price;
private BigDecimal s_price;

private List<String> badge;
private String image;

private Long dishCategory;

public ItemDto(){

}

public ItemDto(Long itemId, String title, String discription, BigDecimal n_price, BigDecimal s_price, List<String> badge, String image, Long dishCategory) {
this.itemId = itemId;
this.title = title;
this.discription = discription;
this.n_price = n_price;
this.s_price = s_price;
this.badge = badge;
this.image = image;
this.dishCategory = dishCategory;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
import org.springframework.data.repository.CrudRepository;

public interface ItemRepository extends CrudRepository<Item, Long> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package codsquad.team17.sidedish.service;

public class BestCategoryService {
}
40 changes: 40 additions & 0 deletions backend/sidedish/src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,43 @@ INSERT INTO best_category(best_category_name) VALUES ("해당없음");
INSERT INTO dish_category(dish_category_name) VALUES ("든든한 메인요리");
INSERT INTO dish_category(dish_category_name) VALUES ("뜨끈한 국물요리");
INSERT INTO dish_category(dish_category_name) VALUES ("정갈한 밑찬반");


--item
INSERT INTO item(title, description, n_price, s_price, dish_category_id, best_category_id, stock, badge)
VALUES ("[소중한식사] 경상도 한상차림", "오늘 저녁은 이상하게 안주빨을 세워보고 싶다!", 39000, 31200,1, 1, 20, "이벤트 특가");
INSERT INTO item(title, description, n_price, s_price, dish_category_id, best_category_id, stock, badge)
VALUES ("[집밥의완성]초여름보양세트", "무더위에 대비하는 6월 한상차림 초여름 보양세트", 26000, 18200, 2, 2, 20, "이벤트 특가");
INSERT INTO item(title, description, n_price, s_price, dish_category_id, best_category_id, stock, badge)
VALUES ("[아내의쉐프] 아쉐찜닭", "아내의쉐프가 자신 있게 만들어서 이름도 '아쉐찜닭'입니다", 11900, 10700, 2, 3, 20, "이벤트 특가");
INSERT INTO item(title, description, n_price, s_price, dish_category_id, best_category_id, stock, badge)
VALUES ("[애슐리투고] 로스트 콤보 450g", "립과 치킨이 만나 더욱 맛있게", 10900, 10900, 2, 4, 20, "이벤트 특가");
INSERT INTO item(title, description, n_price, s_price, dish_category_id, best_category_id, stock, badge)
VALUES ("title5", "discription5", 50000, 40000, 2, 5, 20, "이벤트 특가");


--image
--경상도 한상 차림
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/H9881/f2a7b4df359c850b1a9eb57e17ddf6fc.jpg',1);
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/H9881/fbf29077698ca16f8050e43476b47f38.jpg',1);
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/H9881/c96c6949efc3391148e9b280a2c5ed0b.jpg',1);
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/H9881/71411e15d2d961df496f87f08648b345.jpg',1);

-- 초여름 보양세트
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/H7F20/fc5f385335b5d840be70b0cf612d0740.jpg',2);
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/H7F20/fc5f385335b5d840be70b0cf612d0740.jpg',2);
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/H7F20/ad8d4ecbdc341c7ff2cf6042e64437fb.jpg',2);
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/H7F20/76b6f0595fbdbcf8424406cc65463a2d.jpg',2);

-- 아쉐찜닭
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/HA567/739d2ed2a9c963dc616db52580de695d.jpg',3);
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/HA567/739d2ed2a9c963dc616db52580de695d.jpg',3);
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/HA567/9d2d191ddbc0555ae96ed7e8ec4c95e3.jpg',3);
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/HA567/f14a921e2abc277c7f2033d34155f372.jpg',3);

-- 애슐리투고
INSERT INTO image(url,item_id) VALUES('https://cdn.bmf.kr/_data/product/H206E/de61f1b996cb6a0c5e797b55178307f5.jpg',4);