-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from Tea-Bliss/dev
완성차 대공사및 장바구니,전체리뷰 추가
- Loading branch information
Showing
24 changed files
with
964 additions
and
48 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
src/main/java/store/teabliss/basket/controller/BasketController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package store.teabliss.basket.controller; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import store.teabliss.basket.dto.BasketDto; | ||
import store.teabliss.basket.dto.DeleteBasketDto; | ||
import store.teabliss.basket.entity.Basket; | ||
import store.teabliss.basket.service.BasketService; | ||
import store.teabliss.ingredient.dto.IngredientResponse; | ||
import store.teabliss.ingredient.dto.IngredientResponseDto; | ||
import store.teabliss.ingredient.service.IngredientService; | ||
import store.teabliss.tea.dto.TeaDto; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@Tag(name = "장바구니 API") | ||
@RequestMapping("/api/basket") | ||
public class BasketController { | ||
|
||
private final BasketService basketService; | ||
|
||
@GetMapping("/") | ||
@Operation(summary = "장바구니 검색", description = "") | ||
public ResponseEntity<?> basket() { | ||
|
||
List<Basket> list = basketService.getbasket(); | ||
|
||
if (list.size()>0){ | ||
return ResponseEntity.ok(list); | ||
} | ||
else{ | ||
return ResponseEntity.status(400).body("조회 실패"); | ||
} | ||
} | ||
|
||
@PostMapping("/") | ||
@Operation(summary = "장바구니 저장",description = "") | ||
public ResponseEntity<?> postbasket(@RequestBody BasketDto basketDto){ | ||
|
||
|
||
boolean baskets=basketService.postBaskets(basketDto); | ||
|
||
if (baskets){ | ||
return ResponseEntity.ok("장바구니 등록 완료!"); | ||
} | ||
else{ | ||
return ResponseEntity.status(400).body("등록에 실패했네요!"); | ||
} | ||
|
||
} | ||
|
||
|
||
@PatchMapping("/") | ||
@Operation(summary = "장바구니 수정",description = "") | ||
public ResponseEntity<?> patchbasket(@RequestBody BasketDto basketDto){ | ||
|
||
boolean baskets=basketService.patchBaskets(basketDto); | ||
|
||
if (baskets){ | ||
return ResponseEntity.ok("장바구니 수정 완료!"); | ||
}else{ | ||
return ResponseEntity.status(400).body("수정 실패!"); | ||
} | ||
} | ||
|
||
@DeleteMapping("/{productid}") | ||
@Operation(summary = "장바구니 하나만 삭제",description = "") | ||
public ResponseEntity<?> deletebasket(@PathVariable Long productid){ | ||
|
||
boolean baskets=basketService.deleteBaskets(productid); | ||
|
||
if (baskets){ | ||
return ResponseEntity.ok("장바구니 삭제 완료!"); | ||
}else{ | ||
return ResponseEntity.status(400).body("삭제 실패!"); | ||
} | ||
} | ||
|
||
|
||
@DeleteMapping("/selecteddelete") | ||
@Operation(summary = "장바구니 선택 삭제",description = "") | ||
public ResponseEntity<?> deletebasket(@RequestBody ArrayList<DeleteBasketDto> deleteBasketDto){ | ||
|
||
|
||
for (DeleteBasketDto dto :deleteBasketDto) { | ||
boolean baskets = basketService.deleteselectBaskets(dto); | ||
} | ||
|
||
return ResponseEntity.ok("Successfully deleted items from basket"); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package store.teabliss.basket.dto; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
|
||
|
||
public class BasketDto { | ||
private Long id; | ||
|
||
private Long productid; | ||
|
||
private String quality; | ||
|
||
private String type; | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/store/teabliss/basket/dto/DeleteBasketDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package store.teabliss.basket.dto; | ||
|
||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
import java.util.ArrayList; | ||
|
||
@Getter | ||
@Setter | ||
public class DeleteBasketDto { | ||
|
||
private Long productid; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package store.teabliss.basket.entity; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Basket { | ||
|
||
private Long id; | ||
|
||
private String img; | ||
|
||
private Long productId; | ||
|
||
private String name; | ||
|
||
private String nameEng; | ||
|
||
private Long price; | ||
|
||
private String quality; | ||
|
||
private String type; | ||
|
||
|
||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/store/teabliss/basket/mapper/BasketMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package store.teabliss.basket.mapper; | ||
|
||
import org.apache.ibatis.annotations.Mapper; | ||
import store.teabliss.basket.entity.Basket; | ||
import store.teabliss.tea.entity.Tea; | ||
|
||
import java.util.List; | ||
|
||
|
||
@Mapper | ||
public interface BasketMapper { | ||
|
||
List<Basket> getbasket(); | ||
|
||
void update(Long productId,String quality,String type); | ||
|
||
boolean delete(Long productid); | ||
|
||
void save(Basket basket); | ||
} |
79 changes: 79 additions & 0 deletions
79
src/main/java/store/teabliss/basket/service/BasketService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package store.teabliss.basket.service; | ||
|
||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import store.teabliss.basket.dto.BasketDto; | ||
import store.teabliss.basket.dto.DeleteBasketDto; | ||
import store.teabliss.basket.entity.Basket; | ||
import store.teabliss.basket.mapper.BasketMapper; | ||
import store.teabliss.tea.entity.Tea; | ||
import store.teabliss.tea.mapper.TeaMapper; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class BasketService { | ||
|
||
|
||
private final TeaMapper teaMapper; | ||
private final BasketMapper basketMapper; | ||
|
||
|
||
public List<Basket> getbasket(){ | ||
|
||
List<Basket> list=basketMapper.getbasket(); | ||
|
||
return list; | ||
|
||
|
||
} | ||
|
||
|
||
public boolean postBaskets(BasketDto basketDto){ | ||
|
||
Basket basket=new Basket(); | ||
|
||
|
||
Tea tea = teaMapper.search(basketDto.getProductid()); | ||
|
||
basket.setImg(tea.getImg()); | ||
basket.setName(tea.getName()); | ||
basket.setNameEng(tea.getNameEng()); | ||
basket.setPrice(tea.getPrice()); | ||
basket.setProductId(basketDto.getProductid()); | ||
basket.setQuality(basketDto.getQuality()); | ||
basket.setType(basketDto.getType()); | ||
basketMapper.save(basket); | ||
return true; | ||
|
||
} | ||
|
||
public boolean patchBaskets(BasketDto basketDto){ | ||
|
||
Long productId =basketDto.getProductid(); | ||
String quality=basketDto.getQuality(); | ||
String type=basketDto.getType(); | ||
|
||
basketMapper.update(productId,quality,type); | ||
|
||
|
||
return true; | ||
} | ||
|
||
public boolean deleteBaskets(Long productid){ | ||
|
||
boolean result =basketMapper.delete(productid); | ||
|
||
return result; | ||
} | ||
|
||
public boolean deleteselectBaskets(DeleteBasketDto deleteBasketDto){ | ||
|
||
boolean result=basketMapper.delete(deleteBasketDto.getProductid()); | ||
|
||
return result; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/store/teabliss/review/controller/ReviewController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package store.teabliss.review.controller; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import store.teabliss.review.entity.Review; | ||
import store.teabliss.review.service.ReviewService; | ||
import store.teabliss.tea.dto.TeaDto; | ||
import store.teabliss.tea.service.TeaService; | ||
|
||
import java.util.List; | ||
|
||
@Slf4j | ||
@RestController | ||
@RequiredArgsConstructor | ||
@Tag(name = "리뷰 API") | ||
@RequestMapping("/api/review") | ||
public class ReviewController { | ||
|
||
|
||
private final ReviewService reviewservice; | ||
|
||
|
||
@Operation(summary = "전체 top 리뷰 ", description = "퀴리 파라미터는 limit 한개 만 보내주세요!") | ||
@GetMapping("/review-list/order") | ||
public ResponseEntity<?> summit(@RequestParam int limit){ | ||
|
||
List<Review> reviews=reviewservice.topreview(limit); | ||
|
||
return ResponseEntity.ok(reviews); | ||
} | ||
|
||
@Operation(summary = "모든 리뷰 조회", description = "페이지네이션 가능!") | ||
@GetMapping("/review-list") | ||
public ResponseEntity<?> summit(@RequestParam int page,@RequestParam int limit){ | ||
|
||
List<Review> reviews=reviewservice.reviews(page,limit); | ||
|
||
return ResponseEntity.ok(reviews); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package store.teabliss.review.dto; | ||
|
||
public class ReviewDto { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package store.teabliss.review.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.sql.Timestamp; | ||
import java.util.Date; | ||
|
||
|
||
|
||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class Review { | ||
|
||
|
||
private Long id; | ||
|
||
private String title; | ||
|
||
private Long like; | ||
|
||
private String contents; | ||
|
||
private Timestamp createat =new Timestamp(new Date().getTime()); | ||
|
||
private boolean IsLastPage = false; | ||
|
||
|
||
|
||
} |
Oops, something went wrong.