Skip to content

Commit

Permalink
Merge pull request #75 from JeongSeonggil/release/v0.0.2
Browse files Browse the repository at this point in the history
Release/v0.0.2
  • Loading branch information
seonggil-jeong authored May 22, 2022
2 parents f4fd717 + ce861ae commit c5512ae
Show file tree
Hide file tree
Showing 69 changed files with 2,506 additions and 1 deletion.
1 change: 1 addition & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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);

}
}
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("상품 수정 완료");
}
}
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);
}

}
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");
}
}
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;
}
Loading

0 comments on commit c5512ae

Please sign in to comment.