From 25557adc97f544fbfa1667d2bdc7fcf0df58b2b7 Mon Sep 17 00:00:00 2001 From: xhaktmchl Date: Mon, 10 Oct 2022 14:38:23 +0900 Subject: [PATCH] =?UTF-8?q?#9=20feat:=EB=AA=A8=EB=93=A0=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20BaseEntity=20=EC=83=81=EC=86=8D=20/=20fix:?= =?UTF-8?q?=20User.status->=20userStatus=EB=A1=9C=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=EB=AA=85=20=EC=88=98=EC=A0=95/=20feat:=20Board=EC=88=98?= =?UTF-8?q?=EC=A0=95=20api=20=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=ED=98=B8?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=ED=8C=90=EB=B3=84=20validation=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../board/controller/BoardController.java | 25 +++++-- .../board/dto/request/PatchBoardReq.java | 75 +++++++++++++++++++ .../com/yogit/server/board/entity/Board.java | 21 +++++- .../yogit/server/board/entity/BoardImage.java | 3 +- .../yogit/server/board/entity/BoardUser.java | 3 +- .../yogit/server/board/entity/BookMark.java | 3 +- .../yogit/server/board/entity/Category.java | 3 +- .../yogit/server/board/entity/ClipBoard.java | 3 +- .../yogit/server/board/entity/Comment.java | 3 +- .../board/exception/BoardExceptionList.java | 3 +- .../exception/NotHostOfBoardExcepion.java | 8 ++ .../board/repository/BoardRepository.java | 7 ++ .../server/board/service/BoardService.java | 3 + .../board/service/BoardServiceImpl.java | 39 +++++++++- .../com/yogit/server/user/entity/City.java | 3 +- .../yogit/server/user/entity/CountryCode.java | 3 +- .../yogit/server/user/entity/Interest.java | 3 +- .../yogit/server/user/entity/Language.java | 3 +- .../com/yogit/server/user/entity/User.java | 9 ++- .../yogit/server/user/entity/UserImage.java | 3 +- .../server/user/entity/UserInterest.java | 3 +- 21 files changed, 197 insertions(+), 29 deletions(-) create mode 100644 server/src/main/java/com/yogit/server/board/dto/request/PatchBoardReq.java create mode 100644 server/src/main/java/com/yogit/server/board/exception/NotHostOfBoardExcepion.java diff --git a/server/src/main/java/com/yogit/server/board/controller/BoardController.java b/server/src/main/java/com/yogit/server/board/controller/BoardController.java index f32baa1..cd3fc38 100644 --- a/server/src/main/java/com/yogit/server/board/controller/BoardController.java +++ b/server/src/main/java/com/yogit/server/board/controller/BoardController.java @@ -2,8 +2,9 @@ import com.yogit.server.board.dto.request.CreateBoardReq; +import com.yogit.server.board.dto.request.PatchBoardReq; import com.yogit.server.board.dto.response.BoardRes; -import com.yogit.server.board.service.BoardServiceImpl; +import com.yogit.server.board.service.BoardService; import com.yogit.server.global.dto.ApplicationResponse; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiResponse; @@ -12,10 +13,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; @Slf4j @RestController @@ -23,7 +21,7 @@ @RequestMapping("/boards") public class BoardController { - private final BoardServiceImpl boardServiceImpl; + private final BoardService boardService; /** * 게시글 등록 @@ -36,7 +34,20 @@ public class BoardController { }) @PostMapping("") public ApplicationResponse registerBoard(@RequestBody @Validated CreateBoardReq createBoardReq){ - return boardServiceImpl.createBoard(createBoardReq); + return boardService.createBoard(createBoardReq); } + /** + * 게시글 수정 + * @author 토마스 + */ + @ApiOperation(value = "게시글 수정", notes = "그룹 게시글에 필요한 정보를 입력받아 게시글 수정.") + @ApiResponses({ + @ApiResponse(code= 201, message = "요청에 성공하였습니다."), + @ApiResponse(code = 4000 , message = "서버 오류입니다.") + }) + @PatchMapping("") + public ApplicationResponse updateBoard(@RequestBody @Validated PatchBoardReq patchBoardReq){ + return boardService.updateBoard(patchBoardReq); + } } diff --git a/server/src/main/java/com/yogit/server/board/dto/request/PatchBoardReq.java b/server/src/main/java/com/yogit/server/board/dto/request/PatchBoardReq.java new file mode 100644 index 0000000..ea4c5d5 --- /dev/null +++ b/server/src/main/java/com/yogit/server/board/dto/request/PatchBoardReq.java @@ -0,0 +1,75 @@ +package com.yogit.server.board.dto.request; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.annotations.ApiParam; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.time.LocalDateTime; + +@Data +@NoArgsConstructor +public class PatchBoardReq { + + @ApiModelProperty(example = "1") + @ApiParam(value = "Board ID", required = true) + private Long boardId; + + @ApiModelProperty(example = "1") + @ApiParam(value = "도시 ID", required = true) + private Long cityId; + + @ApiModelProperty(example = "1") + @ApiParam(value = "호스트 ID", required = true) + private Long hostId; + + @ApiModelProperty(example = "경복궁 탐사입니다.") + @ApiParam(value = "게시글 제목", required = true) + @Size(min = 1, max=51) + @NotBlank + private String title; + + @ApiModelProperty(example = "서울특별시 종로구 사직로 130") + @ApiParam(value = "모임 주소", required = true) + @NotBlank + private String address; + + @ApiModelProperty(example = "37.1") + @ApiParam(value = "위도", required = true) + private float longitute; + + @ApiModelProperty(example = "37") + @ApiParam(value = "경도", required = true) + private float latitude; + + @ApiModelProperty(example = "2022-07-13 16:29:30") + @ApiParam(value = "사용자 ID", required = true) + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Seoul") + private LocalDateTime date; // 모임 시각 + + @ApiModelProperty(example = "시간에 맞춰오시기 바랍니다.") + @ApiParam(value = "모임 공지사항", required = false) + @Size(max = 1000) + private String notice; + + @ApiModelProperty(example = "3시에 모여서 경복궁역에서 경복궁으로 출발합니다.") + @ApiParam(value = "모임 상세설명", required = false) + @Size(max = 1000) + private String introduction; // 게시글 내용 상세설명 + + @ApiModelProperty(example = "활발한 사람이 오면 좋습니다.") + @ApiParam(value = "원하는 사람 설명", required = false) + @Size(max = 1000) + private String kindOfPerson; // 이런 사람을 원합니다 설명 글. + + @ApiModelProperty(example = "5") + @ApiParam(value = "총 인원수", required = true) + private int totalMember; + + @ApiModelProperty(example = "1") + @ApiParam(value = "그룹 카테고리 ID", required = false) + private Long categoryId; +} diff --git a/server/src/main/java/com/yogit/server/board/entity/Board.java b/server/src/main/java/com/yogit/server/board/entity/Board.java index df5385a..6fdd43c 100644 --- a/server/src/main/java/com/yogit/server/board/entity/Board.java +++ b/server/src/main/java/com/yogit/server/board/entity/Board.java @@ -1,6 +1,8 @@ package com.yogit.server.board.entity; import com.yogit.server.board.dto.request.CreateBoardReq; +import com.yogit.server.board.dto.request.PatchBoardReq; +import com.yogit.server.config.domain.BaseEntity; import com.yogit.server.user.entity.City; import com.yogit.server.user.entity.User; import lombok.AccessLevel; @@ -16,7 +18,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Board { +public class Board extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "board_id") @@ -54,7 +56,7 @@ public class Board { private List boardUsers = new ArrayList<>(); @OneToMany(mappedBy = "board") - private List boardImages; + private List boardImages = new ArrayList<>(); @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "category_id") @@ -123,4 +125,19 @@ public void changeBoardCurrentMember(int currentMember){ public void addBoardUser(BoardUser boardUser){ this.boardUsers.add(boardUser); } + + public void updateBoard(PatchBoardReq dto, City city, Category category){ + this.city = city; + this.title = dto.getTitle(); + this.address = dto.getAddress(); + this.longitute = dto.getLongitute(); + this.latitude = dto.getLatitude(); + this.date = dto.getDate(); + this.notice = dto.getNotice(); + this.introduction = dto.getIntroduction(); + this.kindOfPerson = dto.getKindOfPerson(); + this.totalMember = dto.getTotalMember(); +// this.boardImages = boardImages; + this.category = category; + } } diff --git a/server/src/main/java/com/yogit/server/board/entity/BoardImage.java b/server/src/main/java/com/yogit/server/board/entity/BoardImage.java index 559c04a..c4ec342 100644 --- a/server/src/main/java/com/yogit/server/board/entity/BoardImage.java +++ b/server/src/main/java/com/yogit/server/board/entity/BoardImage.java @@ -1,5 +1,6 @@ package com.yogit.server.board.entity; +import com.yogit.server.config.domain.BaseEntity; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,7 +10,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class BoardImage { +public class BoardImage extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "board_image_id") diff --git a/server/src/main/java/com/yogit/server/board/entity/BoardUser.java b/server/src/main/java/com/yogit/server/board/entity/BoardUser.java index 6d00bfa..239dc00 100644 --- a/server/src/main/java/com/yogit/server/board/entity/BoardUser.java +++ b/server/src/main/java/com/yogit/server/board/entity/BoardUser.java @@ -1,5 +1,6 @@ package com.yogit.server.board.entity; +import com.yogit.server.config.domain.BaseEntity; import com.yogit.server.user.entity.User; import lombok.AccessLevel; import lombok.Getter; @@ -10,7 +11,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class BoardUser { +public class BoardUser extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "board_user_id") diff --git a/server/src/main/java/com/yogit/server/board/entity/BookMark.java b/server/src/main/java/com/yogit/server/board/entity/BookMark.java index 1f668fb..d14f71d 100644 --- a/server/src/main/java/com/yogit/server/board/entity/BookMark.java +++ b/server/src/main/java/com/yogit/server/board/entity/BookMark.java @@ -1,5 +1,6 @@ package com.yogit.server.board.entity; +import com.yogit.server.config.domain.BaseEntity; import com.yogit.server.user.entity.User; import lombok.AccessLevel; import lombok.Getter; @@ -10,7 +11,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class BookMark { +public class BookMark extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "book_mark_id") diff --git a/server/src/main/java/com/yogit/server/board/entity/Category.java b/server/src/main/java/com/yogit/server/board/entity/Category.java index 6ae09b7..850bee7 100644 --- a/server/src/main/java/com/yogit/server/board/entity/Category.java +++ b/server/src/main/java/com/yogit/server/board/entity/Category.java @@ -1,5 +1,6 @@ package com.yogit.server.board.entity; +import com.yogit.server.config.domain.BaseEntity; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,7 +10,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Category { +public class Category extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "category_id") diff --git a/server/src/main/java/com/yogit/server/board/entity/ClipBoard.java b/server/src/main/java/com/yogit/server/board/entity/ClipBoard.java index 7a5804c..9bc46b8 100644 --- a/server/src/main/java/com/yogit/server/board/entity/ClipBoard.java +++ b/server/src/main/java/com/yogit/server/board/entity/ClipBoard.java @@ -1,5 +1,6 @@ package com.yogit.server.board.entity; +import com.yogit.server.config.domain.BaseEntity; import com.yogit.server.user.entity.User; import lombok.AccessLevel; import lombok.Getter; @@ -11,7 +12,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class ClipBoard { +public class ClipBoard extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "clip_board_id") diff --git a/server/src/main/java/com/yogit/server/board/entity/Comment.java b/server/src/main/java/com/yogit/server/board/entity/Comment.java index 9d21fd0..8697e55 100644 --- a/server/src/main/java/com/yogit/server/board/entity/Comment.java +++ b/server/src/main/java/com/yogit/server/board/entity/Comment.java @@ -1,5 +1,6 @@ package com.yogit.server.board.entity; +import com.yogit.server.config.domain.BaseEntity; import com.yogit.server.user.entity.User; import lombok.AccessLevel; import lombok.Getter; @@ -10,7 +11,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Comment { +public class Comment extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "comment_id") diff --git a/server/src/main/java/com/yogit/server/board/exception/BoardExceptionList.java b/server/src/main/java/com/yogit/server/board/exception/BoardExceptionList.java index 6cb8aef..c530a2d 100644 --- a/server/src/main/java/com/yogit/server/board/exception/BoardExceptionList.java +++ b/server/src/main/java/com/yogit/server/board/exception/BoardExceptionList.java @@ -10,7 +10,8 @@ @RequiredArgsConstructor public enum BoardExceptionList { - NOT_FOUND_BOARD("B0001", NOT_FOUND,"존재하지 않는 Board아이디입니다."); + NOT_FOUND_BOARD("B0001", NOT_FOUND,"존재하지 않는 Board아이디입니다."), + NOT_HOST_OF_BOARD("B0002",HttpStatus.BAD_REQUEST, "요청한 유저가 호스트가 아닙니다."); private final String CODE; private final HttpStatus HTTPSTATUS; diff --git a/server/src/main/java/com/yogit/server/board/exception/NotHostOfBoardExcepion.java b/server/src/main/java/com/yogit/server/board/exception/NotHostOfBoardExcepion.java new file mode 100644 index 0000000..2cb14a1 --- /dev/null +++ b/server/src/main/java/com/yogit/server/board/exception/NotHostOfBoardExcepion.java @@ -0,0 +1,8 @@ +package com.yogit.server.board.exception; + +public class NotHostOfBoardExcepion extends BoardException{ + + public NotHostOfBoardExcepion(){ + super(BoardExceptionList.NOT_HOST_OF_BOARD.getCODE(), BoardExceptionList.NOT_HOST_OF_BOARD.getHTTPSTATUS(), BoardExceptionList.NOT_HOST_OF_BOARD.getMESSAGE()); + } +} diff --git a/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java b/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java index beb863a..3fecb72 100644 --- a/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java +++ b/server/src/main/java/com/yogit/server/board/repository/BoardRepository.java @@ -2,6 +2,13 @@ import com.yogit.server.board.entity.Board; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import java.util.Optional; public interface BoardRepository extends JpaRepository { + + @Query("select b from Board b where b.id = :boardId and b.status = 'ACTIVE'") + Optional findBoardById(@Param("boardId") Long boardId); } diff --git a/server/src/main/java/com/yogit/server/board/service/BoardService.java b/server/src/main/java/com/yogit/server/board/service/BoardService.java index 0e62a9d..8de9199 100644 --- a/server/src/main/java/com/yogit/server/board/service/BoardService.java +++ b/server/src/main/java/com/yogit/server/board/service/BoardService.java @@ -1,10 +1,13 @@ package com.yogit.server.board.service; import com.yogit.server.board.dto.request.CreateBoardReq; +import com.yogit.server.board.dto.request.PatchBoardReq; import com.yogit.server.board.dto.response.BoardRes; import com.yogit.server.global.dto.ApplicationResponse; public interface BoardService { ApplicationResponse createBoard(CreateBoardReq createBoardReq); + + ApplicationResponse updateBoard(PatchBoardReq patchBoardReq); } diff --git a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java index 7f86229..8711b81 100644 --- a/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java +++ b/server/src/main/java/com/yogit/server/board/service/BoardServiceImpl.java @@ -1,10 +1,13 @@ package com.yogit.server.board.service; import com.yogit.server.board.dto.request.CreateBoardReq; +import com.yogit.server.board.dto.request.PatchBoardReq; import com.yogit.server.board.dto.response.BoardRes; import com.yogit.server.board.entity.Board; import com.yogit.server.board.entity.BoardUser; import com.yogit.server.board.entity.Category; +import com.yogit.server.board.exception.NotFoundBoardException; +import com.yogit.server.board.exception.NotHostOfBoardExcepion; import com.yogit.server.board.exception.boardCategory.NotFoundCategoryException; import com.yogit.server.board.repository.CategoryRepository; import com.yogit.server.board.repository.BoardRepository; @@ -18,6 +21,9 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.sound.midi.Patch; @Service @Transactional(readOnly = true) @@ -50,12 +56,39 @@ public ApplicationResponse createBoard(CreateBoardReq dto){ // 호스트 boardUser 생성 및 board에 추가 board.addBoardUser(new BoardUser(host, board)); + //TODO: BoardImages aws s3에 저장 , url board엔티티에 추가 + // board 저장 Board savedBoard = boardRepository.save(board); - // resDto 벼환 - BoardRes boardRes = BoardRes.toDto(savedBoard); - // 반환 + BoardRes boardRes = BoardRes.toDto(savedBoard); // resDto 벼환 return ApplicationResponse.create("요청에 성공하였습니다.", boardRes); } + + @Transactional(readOnly = false) + @Override + public ApplicationResponse updateBoard(PatchBoardReq dto){ + + User host = userRepository.findById(dto.getHostId()) + .orElseThrow(() -> new NotFoundUserException()); + + City city = cityRepository.findById(dto.getCityId()) + .orElseThrow(() -> new NotFoundCityException()); + + Category category = categoryRepository.findById(dto.getCategoryId()) + .orElseThrow(() -> new NotFoundCategoryException()); + + //validation: board 존재 여부 + Board board = boardRepository.findBoardById(dto.getBoardId()) + .orElseThrow(() -> new NotFoundBoardException()); + //validation: 요청자와 host 비교 + if(!board.getHost().getId().equals(dto.getHostId())){ + throw new NotHostOfBoardExcepion(); + } + + board.updateBoard(dto, city, category); + BoardRes boardRes = BoardRes.toDto(board); + return ApplicationResponse.ok(boardRes); + } + } diff --git a/server/src/main/java/com/yogit/server/user/entity/City.java b/server/src/main/java/com/yogit/server/user/entity/City.java index 9bd1392..7ff5360 100644 --- a/server/src/main/java/com/yogit/server/user/entity/City.java +++ b/server/src/main/java/com/yogit/server/user/entity/City.java @@ -1,6 +1,7 @@ package com.yogit.server.user.entity; import com.yogit.server.board.entity.Board; +import com.yogit.server.config.domain.BaseEntity; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -13,7 +14,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class City { +public class City extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "city_id") diff --git a/server/src/main/java/com/yogit/server/user/entity/CountryCode.java b/server/src/main/java/com/yogit/server/user/entity/CountryCode.java index 8bcc6e5..18dbe9d 100644 --- a/server/src/main/java/com/yogit/server/user/entity/CountryCode.java +++ b/server/src/main/java/com/yogit/server/user/entity/CountryCode.java @@ -1,5 +1,6 @@ package com.yogit.server.user.entity; +import com.yogit.server.config.domain.BaseEntity; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,7 +10,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class CountryCode { +public class CountryCode extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "country_code_id") diff --git a/server/src/main/java/com/yogit/server/user/entity/Interest.java b/server/src/main/java/com/yogit/server/user/entity/Interest.java index d26de6f..ce5cd91 100644 --- a/server/src/main/java/com/yogit/server/user/entity/Interest.java +++ b/server/src/main/java/com/yogit/server/user/entity/Interest.java @@ -1,5 +1,6 @@ package com.yogit.server.user.entity; +import com.yogit.server.config.domain.BaseEntity; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -11,7 +12,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Interest { +public class Interest extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "interest_id") diff --git a/server/src/main/java/com/yogit/server/user/entity/Language.java b/server/src/main/java/com/yogit/server/user/entity/Language.java index 76a0b43..3f9fec0 100644 --- a/server/src/main/java/com/yogit/server/user/entity/Language.java +++ b/server/src/main/java/com/yogit/server/user/entity/Language.java @@ -1,5 +1,6 @@ package com.yogit.server.user.entity; +import com.yogit.server.config.domain.BaseEntity; import lombok.*; import javax.persistence.*; @@ -7,7 +8,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class Language { +public class Language extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "language_id") diff --git a/server/src/main/java/com/yogit/server/user/entity/User.java b/server/src/main/java/com/yogit/server/user/entity/User.java index 75308bd..8aea8f5 100644 --- a/server/src/main/java/com/yogit/server/user/entity/User.java +++ b/server/src/main/java/com/yogit/server/user/entity/User.java @@ -1,6 +1,7 @@ package com.yogit.server.user.entity; import com.yogit.server.board.entity.*; +import com.yogit.server.config.domain.BaseEntity; import com.yogit.server.user.dto.request.editUserEssentialProfileReq; import lombok.*; @@ -12,7 +13,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class User { +public class User extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @@ -45,7 +46,7 @@ public class User { private float memberTemp; @Enumerated(EnumType.STRING) - private UserStatus status; + private UserStatus userStatus; @Enumerated(EnumType.STRING) private Gender gender; @@ -72,7 +73,7 @@ public User (String name, int age, Gender gender, Nationality nationality){ this.memberTemp = 0; this.gender = gender; this.nationality = nationality; - this.status = UserStatus.ACTIVE; + this.userStatus = UserStatus.ACTIVE; } public void addLanguage(Language language){ @@ -89,6 +90,6 @@ public void changeUserInfo(editUserEssentialProfileReq editUserEssentialProfileR public void delUser(){ this.name = null; this.profileImg = null; - this.status = UserStatus.DELETE; + this.userStatus = UserStatus.DELETE; } } diff --git a/server/src/main/java/com/yogit/server/user/entity/UserImage.java b/server/src/main/java/com/yogit/server/user/entity/UserImage.java index a3a43f9..b4c47bb 100644 --- a/server/src/main/java/com/yogit/server/user/entity/UserImage.java +++ b/server/src/main/java/com/yogit/server/user/entity/UserImage.java @@ -1,5 +1,6 @@ package com.yogit.server.user.entity; +import com.yogit.server.config.domain.BaseEntity; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,7 +10,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class UserImage { +public class UserImage extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "user_image_id") diff --git a/server/src/main/java/com/yogit/server/user/entity/UserInterest.java b/server/src/main/java/com/yogit/server/user/entity/UserInterest.java index 0ca5cdb..5fcea83 100644 --- a/server/src/main/java/com/yogit/server/user/entity/UserInterest.java +++ b/server/src/main/java/com/yogit/server/user/entity/UserInterest.java @@ -1,5 +1,6 @@ package com.yogit.server.user.entity; +import com.yogit.server.config.domain.BaseEntity; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -9,7 +10,7 @@ @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) -public class UserInterest { +public class UserInterest extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "user_interest_id")