Skip to content

Commit

Permalink
Merge pull request #144 from Team-GAJI/develop
Browse files Browse the repository at this point in the history
배포 서버 머지
  • Loading branch information
ShimFFF authored Aug 21, 2024
2 parents 893eeee + ab5e3e1 commit e93e68d
Show file tree
Hide file tree
Showing 50 changed files with 561 additions and 108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ public SelectCategory(Category category, Long entityId, PostTypeEnum type) {
this.entityId = entityId;
this.type = type;
}

public void updateCategory(Category category) {
this.category = category;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@
public interface SelectCategoryRepository extends JpaRepository<SelectCategory, Long>, SelectCategoryQueryDslRepository {

SelectCategory findByEntityIdAndType(Long entityId, PostTypeEnum type);

void deleteByEntityIdAndType(Long entityId, PostTypeEnum type);

boolean existsByEntityIdAndType(Long entityId, PostTypeEnum type);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ public interface CategoryService {

SelectCategory findByEntityIdAndType(Long entityId, PostTypeEnum type);

void deleteByEntityIdAndType(Long entityId, PostTypeEnum type);

List<Category> findAllByCategory(CategoryEnum category);

boolean existsByEntityIdAndType(Long entityId, PostTypeEnum type);
}

Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public List<Category> findAllByCategory(CategoryEnum category) {
return categoryRepository.findAllByCategory(category);
}

@Override
public boolean existsByEntityIdAndType(Long entityId, PostTypeEnum type) {
return selectCategoryRepository.existsByEntityIdAndType(entityId, type);
}

@Override
public Category findByCategoryId(Long categoryId) {
return categoryRepository.findById(categoryId)
Expand Down Expand Up @@ -87,4 +92,9 @@ public void saveAllSelectCategory(List<SelectCategory> selectCategoryList) {
public SelectCategory findByEntityIdAndType(Long entityId, PostTypeEnum type) {
return selectCategoryRepository.findByEntityIdAndType(entityId, type);
}

@Override
public void deleteByEntityIdAndType(Long entityId, PostTypeEnum type) {
selectCategoryRepository.deleteByEntityIdAndType(entityId, type);
}
}
2 changes: 0 additions & 2 deletions src/main/java/gaji/service/domain/enums/CategoryEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import gaji.service.global.exception.RestApiException;
import gaji.service.global.exception.code.status.GlobalErrorStatus;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package gaji.service.domain.post.converter;

import gaji.service.domain.common.converter.HashtagConverter;
import gaji.service.domain.common.entity.Category;
import gaji.service.domain.common.entity.SelectCategory;
import gaji.service.domain.common.entity.SelectHashtag;
import gaji.service.domain.common.service.CategoryService;
import gaji.service.domain.common.service.HashtagService;
import gaji.service.domain.common.web.dto.HashtagResponseDTO;
import gaji.service.domain.enums.CategoryEnum;
import gaji.service.domain.enums.PostStatusEnum;
import gaji.service.domain.enums.PostTypeEnum;
import gaji.service.domain.post.entity.CommnuityPost;
Expand All @@ -17,16 +15,15 @@
import gaji.service.domain.post.service.CommunityPostBookMarkService;
import gaji.service.domain.post.service.CommunityPostLikesService;
import gaji.service.domain.post.service.CommunityPostQueryService;
import gaji.service.domain.post.web.dto.CommunityPostResponseDTO;
import gaji.service.domain.post.web.dto.CommunityPostRequestDTO;
import gaji.service.domain.post.web.dto.CommunityPostResponseDTO;
import gaji.service.domain.user.entity.User;
import gaji.service.global.converter.DateConverter;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package gaji.service.domain.post.converter;

import gaji.service.domain.enums.PostStatusEnum;
import gaji.service.domain.post.code.CommunityPostErrorStatus;
import gaji.service.global.exception.RestApiException;
import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

public class PostStatusConverter implements Converter<String, PostStatusEnum> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package gaji.service.domain.post.converter;

import gaji.service.domain.enums.PostTypeEnum;
import gaji.service.domain.post.code.CommunityPostErrorStatus;
import gaji.service.global.exception.RestApiException;
import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

public class PostTypeConverter implements Converter<String, PostTypeEnum> {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package gaji.service.domain.post.converter;

import gaji.service.domain.enums.SortType;
import gaji.service.global.exception.RestApiException;
import gaji.service.global.exception.code.status.GlobalErrorStatus;
import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

public class SortTypeConverter implements Converter<String, SortType> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ private <T> Slice<T> checkLastPage(Pageable pageable, List<T> postList) {
private OrderSpecifier orderBySortType(SortType sortTypeCond) {
return switch (sortTypeCond) {
case HOT -> commnuityPost.popularityScore.desc(); // HOT: 인기점수 내림차순
case LIKE -> commnuityPost.createdAt.desc(); // LIKE: 좋아요 내림차순
case LIKE -> commnuityPost.likeCnt.desc(); // LIKE: 좋아요 내림차순
case HIT -> commnuityPost.hit.desc(); // HIT: 조회수 내림차순
default -> commnuityPost.createdAt.desc(); // null or RECENT: 최신순(생성일자 내림차순)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import gaji.service.domain.post.service.CommunityPostCommandService;
import gaji.service.domain.post.service.CommunityPostQueryService;
import gaji.service.domain.post.web.dto.CommunityPostCommentResponseDTO;
import gaji.service.domain.post.web.dto.CommunityPostResponseDTO;
import gaji.service.domain.post.web.dto.CommunityPostRequestDTO;
import gaji.service.domain.post.web.dto.CommunityPostResponseDTO;
import gaji.service.global.base.BaseResponse;
import gaji.service.jwt.service.TokenProviderService;
import io.swagger.v3.oas.annotations.Operation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gaji.service.domain.post.web.dto;

import gaji.service.domain.common.web.dto.HashtagResponseDTO;
import gaji.service.domain.enums.CategoryEnum;
import gaji.service.domain.enums.PostStatusEnum;
import gaji.service.domain.enums.PostTypeEnum;
import lombok.AllArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@AllArgsConstructor
public enum RecruitErrorStatus implements BaseErrorCodeInterface {
_RECRUIT_POST_NOT_FOUND(HttpStatus.BAD_REQUEST, "RECRUIT_4001", "모집 게시글을 찾을 수 없습니다."),
_RECRUIT_POST_ALREADY_COMPLETE(HttpStatus.BAD_REQUEST, "RECRUIT4002", "이미 모집 완료된 게시글 입니다."),

_COMMENT_NOT_FOUND(HttpStatus.BAD_REQUEST, "COMMENT_4001", "존재하지 않는 댓글입니다."),
_COMMENT_ALREADY_DELETE(HttpStatus.BAD_REQUEST, "COMMENT_4002", "이미 삭제된 댓글입니다."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import gaji.service.domain.enums.Role;
import gaji.service.domain.recruit.entity.RecruitPostBookmark;
import gaji.service.domain.recruit.entity.RecruitPostLikes;
import gaji.service.domain.studyMate.entity.StudyApplicant;
import gaji.service.domain.user.entity.User;
import gaji.service.domain.recruit.entity.StudyComment;
import gaji.service.domain.recruit.web.dto.RecruitRequestDTO;
import gaji.service.domain.recruit.web.dto.RecruitResponseDTO;
import gaji.service.domain.room.entity.Material;
import gaji.service.domain.room.entity.Room;
import gaji.service.domain.studyMate.entity.StudyMate;
import gaji.service.domain.user.entity.User;
import gaji.service.global.converter.DateConverter;
import org.springframework.data.domain.Slice;
import org.springframework.stereotype.Component;
Expand All @@ -25,7 +24,7 @@
@Component
public class RecruitConverter {

public static Room toRoom(RecruitRequestDTO.CreateRoomDTO request, User user, String thumbnailUrl, String inviteCode, int peopleMaximum) {
public static Room toRoom(RecruitRequestDTO.RoomContentDTO request, User user, String thumbnailUrl, String inviteCode, int peopleMaximum) {
return Room.builder()
.user(user)
.name(request.getName())
Expand All @@ -42,12 +41,18 @@ public static Room toRoom(RecruitRequestDTO.CreateRoomDTO request, User user, St
.build();
}

public static RecruitResponseDTO.CreateRoomResponseDTO toResponseDTO(Room room) {
public static RecruitResponseDTO.CreateRoomResponseDTO toCreateRoomResponseDTO(Room room) {
return RecruitResponseDTO.CreateRoomResponseDTO.builder()
.roomId(room.getId())
.build();
}

public static RecruitResponseDTO.UpdateRoomResponseDTO toUpdateRoomResponseDTO(Room room) {
return RecruitResponseDTO.UpdateRoomResponseDTO.builder()
.roomId(room.getId())
.build();
}

public static CategoryEnum toCategory(SelectCategory selectCategory) {
return selectCategory.getCategory().getCategory();
}
Expand Down Expand Up @@ -116,7 +121,7 @@ public static RecruitResponseDTO.CommentListResponseDTO toCommentListDTO(int com
.build();
}

public static StudyComment toComment(RecruitRequestDTO.WriteCommentDTO request, User user, Room room, StudyComment parentComment) {
public static StudyComment toComment(RecruitRequestDTO.CommentContentDTO request, User user, Room room, StudyComment parentComment) {
return StudyComment.builder()
.user(user)
.room(room)
Expand All @@ -131,6 +136,12 @@ public static RecruitResponseDTO.WriteCommentResponseDTO toWriteCommentDTO(Study
.build();
}

public static RecruitResponseDTO.UpdateCommentResponseDTO toUpdateCommentDTO(StudyComment comment) {
return RecruitResponseDTO.UpdateCommentResponseDTO.builder()
.commentId(comment.getId())
.build();
}

public static RecruitPostLikes toRecruitPostLikes(User user, Room room) {
return RecruitPostLikes.builder()
.user(user)
Expand Down Expand Up @@ -180,4 +191,10 @@ public static RecruitResponseDTO.JoinStudyResponseDTO toJoinStudyResponseDTO(Lon
.roomId(roomId)
.build();
}

public static RecruitResponseDTO.RecruitCompleteResponseDTO toRecruitCompleteResponseDTO(Long roomId) {
return RecruitResponseDTO.RecruitCompleteResponseDTO.builder()
.roomId(roomId)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,9 @@ public StudyComment(User user, Room room, StudyComment parentComment, String bod
this.commentOrder = parent.getCommentOrder();
}
}

public void update(String body) {
this.body = body;
this.status = CommentStatus.UPDATED;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,9 @@ public RecruitResponseDTO.PreviewListResponseDTO findByCategoryOrderBySortType(
CategoryEnum category, PreviewFilter filter, SortType sortType, String query, Long value, Pageable pageable) {
List<Room> results = queryFactory
.selectFrom(room)
.join(selectCategory).on(selectCategory.entityId.eq(room.id)
.and(selectCategory.type.eq(PostTypeEnum.ROOM))
.and(categoryEq(category)))
.where(lastStudyValue(sortType, value), checkFilter(filter), searchPost(query))
.leftJoin(selectCategory).on(selectCategory.entityId.eq(room.id)
.and(selectCategory.type.eq(PostTypeEnum.ROOM)))
.where(categoryEq(category), lastStudyValue(sortType, value), checkFilter(filter), searchPost(query))
.orderBy(getOrderSpecifier(sortType))
.limit(pageable.getPageSize() + 1)
.fetch();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
public interface StudyCommentRepository extends JpaRepository<StudyComment, Long>, StudyCommentCustomRepository {

int countByRoom(Room room);

void deleteAllByRoom(Room room);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@

public interface RecruitCommandService {

RecruitResponseDTO.CreateRoomResponseDTO createRoom(RecruitRequestDTO.CreateRoomDTO request, Long userId);
RecruitResponseDTO.CreateRoomResponseDTO createRoom(RecruitRequestDTO.RoomContentDTO request, Long userId);

RecruitResponseDTO.UpdateRoomResponseDTO updateRoom(RecruitRequestDTO.RoomContentDTO request, Long userId, Long roomId);

void deleteStudy(Long userId, Long roomId);

RecruitResponseDTO.StudyLikesIdResponseDTO likeStudy(Long userId, Long roomId);

Expand All @@ -23,6 +27,7 @@ public interface RecruitCommandService {

void kickStudy(Long userId, Long roomId, Long targetId);

RecruitResponseDTO.RecruitCompleteResponseDTO recruitComplete(Long userId, Long roomId);
boolean userLikeStatus(Room room, User user);
boolean userBookmarkStatus(Room room, User user);
}
Loading

0 comments on commit e93e68d

Please sign in to comment.