Skip to content

Commit

Permalink
Merge pull request #13 from BbeumbungE/feat/BACK-68
Browse files Browse the repository at this point in the history
Feat/back 68
  • Loading branch information
ah9mon authored Sep 5, 2023
2 parents 06cef99 + 73b4778 commit 8034171
Show file tree
Hide file tree
Showing 14 changed files with 288 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import com.siliconvalley.domain.item.avatar.application.AvatarCreateService;
import com.siliconvalley.domain.item.avatar.dao.AvatarItemFindDao;
import com.siliconvalley.domain.item.avatar.dto.AvatarItemCreateRequest;
import com.siliconvalley.domain.item.item.code.ItemCode;
import com.siliconvalley.domain.item.myitem.application.MyItemCreateService;
import com.siliconvalley.global.common.code.CommonCode;
import com.siliconvalley.global.common.dto.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
Expand All @@ -23,17 +26,20 @@ public class AvatarItemApi {

// 새 avatar 아이템 생성 // admin 가능하게 권한 설정 필요
@PostMapping
public Response createAvatarItem(@RequestBody @Valid AvatarItemCreateRequest dto) {
return Response.of(CommonCode.SUCCESS_CREATE, avatarCreateService.createAvatarItem(dto));
public ResponseEntity createAvatarItem(@RequestBody @Valid AvatarItemCreateRequest dto) {
Response response = Response.of(ItemCode.CREATE_SUCCESS, avatarCreateService.createAvatarItem(dto));
return new ResponseEntity(response, HttpStatus.CREATED);
}

@GetMapping
public Response getAllAvatarItems(Pageable pageable) {
return Response.of(CommonCode.GOOD_REQUEST, avatarItemFindDao.getAvatarItemListByPage(pageable));
public ResponseEntity getAllAvatarItems(Pageable pageable) {
Response response = Response.of(CommonCode.GOOD_REQUEST, avatarItemFindDao.getAvatarItemListByPage(pageable));
return new ResponseEntity(response, HttpStatus.OK);
}

@GetMapping("/{itemId}")
public Response getAvatarItem(@PathVariable("itemId") Long itemId) {
return Response.of(CommonCode.GOOD_REQUEST, avatarItemFindDao.getAvatarItemById(itemId));
public ResponseEntity getAvatarItem(@PathVariable("itemId") Long itemId) {
Response response = Response.of(CommonCode.GOOD_REQUEST, avatarItemFindDao.getAvatarItemById(itemId));
return new ResponseEntity(response, HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.siliconvalley.domain.item.item.code;

import com.siliconvalley.global.common.code.ResponseCode;
import org.springframework.http.HttpStatus;

public enum ItemCode implements ResponseCode {

CREATE_SUCCESS(201, "아이템 생성에 성공했습니다.", HttpStatus.CREATED);

private final int code;
private final String message;
private final HttpStatus httpStatus;

ItemCode(int code, String message, HttpStatus httpStatus) {
this.code = code;
this.message = message;
this.httpStatus = httpStatus;
}

@Override
public int getCode() {
return 0;
}

@Override
public String getMessage() {
return null;
}

@Override
public HttpStatus getHttpStatus() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.siliconvalley.domain.item.myitem.code;

import com.siliconvalley.global.common.code.ResponseCode;
import org.springframework.http.HttpStatus;

public enum MyItemCode implements ResponseCode {

CREATE_SUCCESS(201, "보유 아이템 생성에 성공했습니다.", HttpStatus.CREATED);

private final int code;
private final String message;
private final HttpStatus httpStatus;

MyItemCode(int code, String message, HttpStatus httpStatus) {
this.code = code;
this.message = message;
this.httpStatus = httpStatus;
}

@Override
public int getCode() {
return this.code;
}

@Override
public String getMessage() {
return this.message;
}

@Override
public HttpStatus getHttpStatus() {
return this.httpStatus;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.siliconvalley.domain.item.subject.api;

import com.siliconvalley.domain.item.item.code.ItemCode;
import com.siliconvalley.domain.item.myitem.application.MyItemCreateService;
import com.siliconvalley.domain.item.subject.application.SketchCreateService;
import com.siliconvalley.domain.item.subject.application.SubjectCreateService;
import com.siliconvalley.domain.item.subject.code.SketchCode;
import com.siliconvalley.domain.item.subject.dao.SketchFindDao;
import com.siliconvalley.domain.item.subject.dao.SubjectItemFindDao;
import com.siliconvalley.domain.item.subject.dto.SketchCreateRequest;
Expand All @@ -11,6 +13,8 @@
import com.siliconvalley.global.common.dto.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
Expand All @@ -28,29 +32,34 @@ public class SubjectItemApi {

// 새 subject 아이템 생성 // admin 가능하게 권한 설정 필요
@PostMapping
public Response createSubjectItem(@RequestBody @Valid SubjectItemCreateRequest dto) {
return Response.of(CommonCode.SUCCESS_CREATE, subjectCreateService.createSubjectItem(dto));
public ResponseEntity createSubjectItem(@RequestBody @Valid SubjectItemCreateRequest dto) {
Response response = Response.of(ItemCode.CREATE_SUCCESS, subjectCreateService.createSubjectItem(dto));
return new ResponseEntity(response, HttpStatus.CREATED);
}

@GetMapping
public Response getAllSubjectItems(Pageable pageable) {
return Response.of(CommonCode.GOOD_REQUEST, subjectItemFindDao.getSubjectItemListByPage(pageable));
public ResponseEntity getAllSubjectItems(Pageable pageable) {
Response response = Response.of(CommonCode.GOOD_REQUEST, subjectItemFindDao.getSubjectItemListByPage(pageable));
return new ResponseEntity(response, HttpStatus.OK);
}

@GetMapping("/{itemId}")
public Response getSubjectItem(@PathVariable("itemId") Long itemId) {
return Response.of(CommonCode.GOOD_REQUEST, subjectItemFindDao.getSubjectItemById(itemId));
public ResponseEntity getSubjectItem(@PathVariable("itemId") Long itemId) {
Response response = Response.of(CommonCode.GOOD_REQUEST, subjectItemFindDao.getSubjectItemById(itemId));
return new ResponseEntity(response, HttpStatus.OK);
}

@PostMapping("/{subjectId}/sketches")
public Response addSketch(
public ResponseEntity addSketch(
@PathVariable(name = "subjectId") Long subjectId,
@RequestBody @Valid SketchCreateRequest dto) {
return Response.of(CommonCode.SUCCESS_CREATE, sketchCreateService.createSketch(subjectId, dto));
Response response = Response.of(SketchCode.CREATE_SUCCESS, sketchCreateService.createSketch(subjectId, dto));
return new ResponseEntity(response, HttpStatus.CREATED);
}

@GetMapping("/{subjectId}/sketches")
public Response getAllSketches(@PathVariable(name = "subjectId") Long subjectId) {
return Response.of(CommonCode.GOOD_REQUEST, sketchFindDao.getAllsketches(subjectId));
public ResponseEntity getAllSketches(@PathVariable(name = "subjectId") Long subjectId) {
Response response = Response.of(CommonCode.GOOD_REQUEST, sketchFindDao.getAllsketches(subjectId));
return new ResponseEntity(response, HttpStatus.OK);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.siliconvalley.domain.item.subject.code;

import com.siliconvalley.global.common.code.ResponseCode;
import org.springframework.http.HttpStatus;

public enum SketchCode implements ResponseCode {
CREATE_SUCCESS(201, "스케치 생성에 성공했습니다.", HttpStatus.CREATED);

private final int code;
private final String message;
private final HttpStatus httpStatus;

SketchCode(int code, String message, HttpStatus httpStatus) {
this.code = code;
this.message = message;
this.httpStatus = httpStatus;
}

@Override
public int getCode() {
return 0;
}

@Override
public String getMessage() {
return null;
}

@Override
public HttpStatus getHttpStatus() {
return null;
}
}
17 changes: 11 additions & 6 deletions src/main/java/com/siliconvalley/domain/member/api/MemberApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import com.siliconvalley.global.common.code.CommonCode;
import com.siliconvalley.global.common.dto.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.web.bind.annotation.*;
Expand All @@ -20,20 +22,23 @@ public class MemberApi {
private final ProfileFindDao profileFindDao;

@GetMapping
public Response getMember(@AuthenticationPrincipal OAuth2User oAuth2User) {
public ResponseEntity getMember(@AuthenticationPrincipal OAuth2User oAuth2User) {
String id = (String) oAuth2User.getAttributes().get("id");
return Response.of(CommonCode.GOOD_REQUEST, memberFindDao.getMemberById(id));
Response response = Response.of(CommonCode.GOOD_REQUEST, memberFindDao.getMemberById(id));
return new ResponseEntity(response, HttpStatus.OK);
}

@DeleteMapping
public Response deleteMember(@AuthenticationPrincipal OAuth2User oAuth2User) {
public ResponseEntity deleteMember(@AuthenticationPrincipal OAuth2User oAuth2User) {
String id = (String) oAuth2User.getAttributes().get("id");
return Response.of(CommonCode.GOOD_REQUEST, memberDeleteService.deleteMember(id));
Response response = Response.of(CommonCode.GOOD_REQUEST, memberDeleteService.deleteMember(id));
return new ResponseEntity(response, HttpStatus.NO_CONTENT);
}

@GetMapping("/profiles")
public Response getProfilesOfMember(@AuthenticationPrincipal OAuth2User oAuth2User) {
public ResponseEntity getProfilesOfMember(@AuthenticationPrincipal OAuth2User oAuth2User) {
String id = (String) oAuth2User.getAttributes().get("id");
return Response.of(CommonCode.GOOD_REQUEST, profileFindDao.getProfilesByMemberId(id));
Response response = Response.of(CommonCode.GOOD_REQUEST, profileFindDao.getProfilesByMemberId(id));
return new ResponseEntity(response, HttpStatus.OK);
}
}
34 changes: 34 additions & 0 deletions src/main/java/com/siliconvalley/domain/point/code/PointCode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.siliconvalley.domain.point.code;

import com.siliconvalley.global.common.code.ResponseCode;
import org.springframework.http.HttpStatus;

public enum PointCode implements ResponseCode {

UPDATE_SUCCESS(204, "포인트 수정에 성공했습니다.", HttpStatus.NO_CONTENT);

private final int code;
private final String message;
private final HttpStatus httpStatus;

PointCode(int code, String message, HttpStatus httpStatus) {
this.code = code;
this.message = message;
this.httpStatus = httpStatus;
}

@Override
public int getCode() {
return this.code;
}

@Override
public String getMessage() {
return this.message;
}

@Override
public HttpStatus getHttpStatus() {
return this.httpStatus;
}
}
Loading

0 comments on commit 8034171

Please sign in to comment.