-
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 #75 from JeongSeonggil/release/v0.0.2
Release/v0.0.2
- Loading branch information
Showing
69 changed files
with
2,506 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
ItemService/src/main/java/com/submarket/itemservice/controller/GroupController.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,39 @@ | ||
package com.submarket.itemservice.controller; | ||
|
||
import com.submarket.itemservice.dto.GroupDto; | ||
import com.submarket.itemservice.service.impl.GroupService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class GroupController { | ||
private final GroupService groupService; | ||
|
||
|
||
@GetMapping("/group/{groupSeq}") | ||
public ResponseEntity<GroupDto> findItemInfoByGroupSeq(@PathVariable int groupSeq) throws Exception { | ||
log.info(this.getClass().getName() + ".findItemInfoByGroupSeq Start!"); | ||
|
||
GroupDto pDto = new GroupDto(); | ||
pDto.setGroupSeq(groupSeq); | ||
|
||
GroupDto groupDto = groupService.findItemInfoByGroupSeq(pDto); | ||
|
||
if (groupDto.equals(null)) { | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null); | ||
} | ||
|
||
log.info(this.getClass().getName() + ".findItemInfoByGroupSeq End!"); | ||
|
||
|
||
return ResponseEntity.ok().body(groupDto); | ||
|
||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
ItemService/src/main/java/com/submarket/itemservice/controller/ItemController.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,77 @@ | ||
package com.submarket.itemservice.controller; | ||
|
||
import com.submarket.itemservice.dto.ItemDto; | ||
import com.submarket.itemservice.service.impl.ItemService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class ItemController { | ||
private final ItemService itemService; | ||
|
||
// TODO: 2022/05/16 로직 추가 | ||
@GetMapping("/items") | ||
public ResponseEntity<List<ItemDto>> findAllItem() throws Exception { | ||
log.info(this.getClass().getName() + ".findAllItem Start"); | ||
|
||
List<ItemDto> itemDtoList = itemService.findAllItem(); | ||
|
||
log.info(this.getClass().getName() + ".findAllItem End"); | ||
return ResponseEntity.ok().body(itemDtoList); | ||
} | ||
|
||
@GetMapping("/items/{itemSeq}") | ||
public ResponseEntity<Object> findOneItem(@PathVariable int itemSeq) throws Exception { | ||
log.info(this.getClass().getName() + ".findOneItem Start! (itemSeq : " + itemSeq + ")"); | ||
|
||
ItemDto pDto = new ItemDto(); | ||
pDto.setItemSeq(itemSeq); | ||
|
||
// 상품 정보 가져오기 | ||
ItemDto itemDto = itemService.findItemInfo(pDto); | ||
|
||
if (itemDto.equals(null)) { | ||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("상품 정보를 찾을 수 없습니다"); | ||
} | ||
|
||
|
||
log.info(this.getClass().getName() + ".findOneItem End!"); | ||
return ResponseEntity.ok().body(itemDto); | ||
} | ||
|
||
@DeleteMapping("/items/{itemSeq}") | ||
public ResponseEntity<String> offItem(@PathVariable int itemSeq) throws Exception { | ||
// TODO: 2022/05/16 비활성화, 사업자 인증 | ||
ItemDto itemDto = new ItemDto(); | ||
itemDto.setItemSeq(itemSeq); | ||
|
||
itemService.offItem(itemDto); | ||
return ResponseEntity.ok().body("비활성화 완료"); | ||
} | ||
|
||
@PatchMapping("/items/{itemSeq}") | ||
public ResponseEntity<String> onItem(@PathVariable int itemSeq) throws Exception { | ||
ItemDto itemDto = new ItemDto(); | ||
itemDto.setItemSeq(itemSeq); | ||
|
||
itemService.onItem(itemDto); | ||
return ResponseEntity.ok().body("활성화 완료"); | ||
} | ||
|
||
@PutMapping("/items") | ||
public ResponseEntity<String> modifyItem(@RequestBody ItemDto itemDto) throws Exception { | ||
// TODO: 2022-05-16 상품 이미지 로직 추가 | ||
log.info(this.getClass().getName()); | ||
|
||
itemService.modifyItem(itemDto); | ||
|
||
return ResponseEntity.ok().body("상품 수정 완료"); | ||
} | ||
} |
75 changes: 75 additions & 0 deletions
75
ItemService/src/main/java/com/submarket/itemservice/controller/ItemReviewController.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,75 @@ | ||
package com.submarket.itemservice.controller; | ||
|
||
import com.submarket.itemservice.dto.ItemReviewDto; | ||
import com.submarket.itemservice.service.impl.ItemReviewService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.List; | ||
|
||
@RestController | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class ItemReviewController { | ||
private final ItemReviewService itemReviewService; | ||
|
||
@PostMapping("/item/{itemSeq}/review") | ||
public ResponseEntity<String> saveReview(@RequestBody ItemReviewDto itemReviewDto, @PathVariable int itemSeq) throws Exception { | ||
log.info(this.getClass().getName() + ".saveReview Start!"); | ||
// TODO: 2022-05-16 사용자가 이미 작성한 리뷰가 있는지 확인 with UserSeq | ||
|
||
if (itemReviewDto.equals(null)) { | ||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("리뷰 정보를 입력해주세요"); | ||
} | ||
|
||
int res = itemReviewService.saveReview(itemReviewDto, itemSeq); | ||
|
||
|
||
log.info(this.getClass().getName() + ".saveReview End!"); | ||
|
||
return ResponseEntity.status(HttpStatus.CREATED).body("리뷰 작성 완료"); | ||
} | ||
|
||
@PatchMapping("/item/review/{reviewSeq}") | ||
public ResponseEntity<String> modifyItemReview(@RequestBody ItemReviewDto itemReviewDto, @PathVariable int reviewSeq) | ||
throws Exception { | ||
log.info(this.getClass().getName() + ".modifyItemReview Start!"); | ||
|
||
itemReviewDto.setReviewSeq(reviewSeq); | ||
int res = itemReviewService.modifyReview(itemReviewDto); | ||
|
||
|
||
log.info(this.getClass().getName() + ".modifyItemReview End!"); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).body("리뷰 변경 완료"); | ||
} | ||
|
||
@DeleteMapping("/item/review/{reviewSeq}") | ||
public ResponseEntity<String> deleteItemReview(@PathVariable int reviewSeq) throws Exception { | ||
log.info(this.getClass().getName() + ".deleteReview Start!"); | ||
|
||
ItemReviewDto itemReviewDto = new ItemReviewDto(); | ||
itemReviewDto.setReviewSeq(reviewSeq); | ||
|
||
itemReviewService.deleteReview(itemReviewDto); | ||
|
||
log.info(this.getClass().getName() + ".deleteReview End!"); | ||
|
||
return ResponseEntity.status(HttpStatus.OK).body("리뷰 삭제 완료"); | ||
} | ||
|
||
@GetMapping("/item/{itemSeq}/review") | ||
public ResponseEntity<List<ItemReviewDto>> findItemReviewInItem(@PathVariable int itemSeq) throws Exception { | ||
log.info(this.getClass().getName() + "findItemReviewInItem Start!"); | ||
|
||
List<ItemReviewDto> itemReviewDtoList = itemReviewService.findAllReviewInItem(itemSeq); | ||
|
||
log.info(this.getClass().getName() + "findItemReviewInItem End!"); | ||
|
||
return ResponseEntity.ok().body(itemReviewDtoList); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
ItemService/src/main/java/com/submarket/itemservice/controller/MainController.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,33 @@ | ||
package com.submarket.itemservice.controller; | ||
|
||
import com.submarket.itemservice.jpa.CategoryRepository; | ||
import com.submarket.itemservice.jpa.ItemRepository; | ||
import com.submarket.itemservice.jpa.ItemReviewRepository; | ||
import com.submarket.itemservice.service.impl.ItemService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@Slf4j | ||
@RequiredArgsConstructor | ||
public class MainController { | ||
|
||
private final Environment env; | ||
private final CategoryRepository categoryRepository; | ||
private final ItemService itemService; | ||
private final ItemRepository itemRepository; | ||
private final ItemReviewRepository itemReviewRepository; | ||
|
||
@GetMapping("/health") | ||
public String health() { | ||
log.info("ItemService On"); | ||
return env.getProperty("spring.application.name") | ||
+ ", port(local.server.port) : " + env.getProperty("local.server.port") | ||
+ ", port(server.port) : " + env.getProperty("server.port") | ||
+ ", token secret : " + env.getProperty("token.secret") | ||
+ ", token expiration time : " + env.getProperty("token.expiration_time"); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
ItemService/src/main/java/com/submarket/itemservice/dto/CategoryDto.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,18 @@ | ||
package com.submarket.itemservice.dto; | ||
|
||
import com.submarket.itemservice.jpa.entity.ItemEntity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class CategoryDto { | ||
private int categorySeq; // 1, 2 | ||
private String categoryName; // 식품, 음료 | ||
|
||
private List<ItemEntity> items; | ||
} |
Oops, something went wrong.