Skip to content

Commit

Permalink
feat: Add MyPage response dto (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahyun0326 committed Mar 21, 2024
1 parent 19b0b5a commit 528ed49
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.beotkkot.qtudy.dto.response.mypage;

import com.beotkkot.qtudy.common.ResponseCode;
import com.beotkkot.qtudy.common.ResponseMessage;
import com.beotkkot.qtudy.dto.response.ResponseDto;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.util.List;

@Getter
public class GetMyInterestResponseDto extends ResponseDto {

private List<Long> interests;

public GetMyInterestResponseDto(List<Long> interests) {
super(ResponseCode.SUCCESS, ResponseMessage.SUCCESS);
this.interests = interests;
}

public static ResponseEntity<GetMyInterestResponseDto> success(List<Long> interestIds) {
GetMyInterestResponseDto result = new GetMyInterestResponseDto(interestIds);
return ResponseEntity.status(HttpStatus.OK).body(result);
}

public static ResponseEntity<ResponseDto> noAuthentication() {
ResponseDto result = new ResponseDto(ResponseCode.AUTHORIZATION_FAIL, ResponseMessage.AUTHORIZATION_FAIL);
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(result);
}

public static ResponseEntity<ResponseDto> notExistedUser() {
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_USER, ResponseMessage.NOT_EXISTED_USER);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.beotkkot.qtudy.dto.response.mypage;

import com.beotkkot.qtudy.common.ResponseCode;
import com.beotkkot.qtudy.common.ResponseMessage;
import com.beotkkot.qtudy.dto.object.PostListItem;
import com.beotkkot.qtudy.dto.response.ResponseDto;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.util.List;


@Getter
public class GetMyPageAllResponseDto extends ResponseDto {
private int page;
private int totalPages;
private List<PostListItem> postList;

public GetMyPageAllResponseDto(List<PostListItem> postListItem, int page, int totalPages) {
super(ResponseCode.SUCCESS, ResponseMessage.SUCCESS);
this.page = page;
this.totalPages = totalPages;
this.postList = postListItem;
}

public static ResponseEntity<GetMyPageAllResponseDto> success(List<PostListItem> postListItem, int page, int totalPages) {
GetMyPageAllResponseDto result = new GetMyPageAllResponseDto(postListItem, page, totalPages);
return ResponseEntity.status(HttpStatus.OK).body(result);
}

public static ResponseEntity<ResponseDto> notExistedPost(){
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_POST, ResponseMessage.NOT_EXISTED_POST);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
}

public static ResponseEntity<ResponseDto> notExistedUser() {
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_USER, ResponseMessage.NOT_EXISTED_USER);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
}

public static ResponseEntity<ResponseDto> noAuthentication() {
ResponseDto result = new ResponseDto(ResponseCode.AUTHORIZATION_FAIL, ResponseMessage.AUTHORIZATION_FAIL);
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(result);
}
}



Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.beotkkot.qtudy.dto.response.mypage;

import com.beotkkot.qtudy.common.ResponseCode;
import com.beotkkot.qtudy.common.ResponseMessage;
import com.beotkkot.qtudy.domain.user.Users;
import com.beotkkot.qtudy.dto.response.ResponseDto;
import lombok.Builder;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

@Getter
public class GetMyPageInfoResponseDto extends ResponseDto {

private String name;
private String profileImageUrl;
private String email;

@Builder
private GetMyPageInfoResponseDto(Users user, String email) {
super(ResponseCode.SUCCESS, ResponseMessage.SUCCESS);
this.name = user.getName();
this.email = email;
this.profileImageUrl = null;
}

public static ResponseEntity<GetMyPageInfoResponseDto> success(Users user, String email) {
GetMyPageInfoResponseDto result = new GetMyPageInfoResponseDto(user, email);
return ResponseEntity.status(HttpStatus.OK).body(result);
}

public static ResponseEntity<ResponseDto> noAuthentication() {
ResponseDto result = new ResponseDto(ResponseCode.AUTHORIZATION_FAIL, ResponseMessage.AUTHORIZATION_FAIL);
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(result);
}

public static ResponseEntity<ResponseDto> notExistedUser() {
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_USER, ResponseMessage.NOT_EXISTED_USER);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.beotkkot.qtudy.dto.response.mypage;

import com.beotkkot.qtudy.common.ResponseCode;
import com.beotkkot.qtudy.common.ResponseMessage;
import com.beotkkot.qtudy.dto.response.ResponseDto;
import lombok.Getter;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

@Getter
public class MyInterestResponseDto extends ResponseDto {

public MyInterestResponseDto() {
super(ResponseCode.SUCCESS, ResponseMessage.SUCCESS);

}

public static ResponseEntity<MyInterestResponseDto> success() {
MyInterestResponseDto result = new MyInterestResponseDto();
return ResponseEntity.status(HttpStatus.OK).body(result);
}

public static ResponseEntity<ResponseDto> notExistedUser() {
ResponseDto result = new ResponseDto(ResponseCode.NOT_EXISTED_USER, ResponseMessage.NOT_EXISTED_USER);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
}

public static ResponseEntity<ResponseDto> noAuthentication() {
ResponseDto result = new ResponseDto(ResponseCode.AUTHORIZATION_FAIL, ResponseMessage.AUTHORIZATION_FAIL);
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(result);
}

public static ResponseEntity<ResponseDto> inputFailed() {
ResponseDto result = new ResponseDto(ResponseCode.INVALID_FORMAT, ResponseMessage.INVALID_FORMAT);
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(result);
}


}

0 comments on commit 528ed49

Please sign in to comment.