Skip to content

Commit

Permalink
[refactor] #147 merge conflict resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
khyojun committed Jan 20, 2025
2 parents c9f3ade + f79e1be commit e28e3be
Show file tree
Hide file tree
Showing 84 changed files with 244 additions and 406 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import com.ggang.be.api.comment.dto.ReadCommentResponse;
import com.ggang.be.api.comment.dto.WriteCommentRequest;
import com.ggang.be.api.comment.dto.WriteCommentResponse;
import com.ggang.be.api.comment.facade.CommentFacade;
import com.ggang.be.api.common.ApiResponse;
import com.ggang.be.api.common.ResponseBuilder;
import com.ggang.be.api.comment.facade.CommentFacade;
import com.ggang.be.global.jwt.JwtService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/com/ggang/be/api/comment/facade/CommentFacade.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.ggang.be.api.comment.facade;

import com.ggang.be.api.comment.dto.ReadCommentRequest;
import com.ggang.be.api.comment.dto.ReadCommentResponse;
import com.ggang.be.api.comment.dto.WriteCommentEntityDto;
import com.ggang.be.api.comment.dto.WriteCommentRequest;
import com.ggang.be.api.comment.dto.WriteCommentResponse;
import com.ggang.be.api.comment.service.CommentService;
import com.ggang.be.api.comment.dto.*;
import com.ggang.be.api.comment.registry.CommentStrategy;
import com.ggang.be.api.comment.registry.CommentStrategyRegistry;
import com.ggang.be.api.comment.service.CommentService;
import com.ggang.be.api.user.service.UserService;
import com.ggang.be.domain.comment.CommentEntity;
import com.ggang.be.domain.user.UserEntity;
Expand Down Expand Up @@ -35,15 +31,12 @@ public WriteCommentResponse writeComment(final long userId, WriteCommentRequest

}

public ReadCommentResponse readComment(Long userId, final boolean isPublic,
ReadCommentRequest dto) {
public ReadCommentResponse readComment(Long userId, final boolean isPublic, ReadCommentRequest dto) {

CommentStrategy commentStrategy = commentStrategyRegistry.getCommentGroupStrategy(dto.groupType());


UserEntity findUserEntity = userService.getUserById(userId);


return commentStrategy.readComment(findUserEntity, isPublic, dto);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
package com.ggang.be.api.comment.registry;

import com.ggang.be.api.comment.dto.ReadCommentRequest;
import com.ggang.be.api.comment.dto.ReadCommentResponse;
import com.ggang.be.api.comment.dto.WriteCommentEntityDto;
import com.ggang.be.api.comment.dto.WriteCommentRequest;
import com.ggang.be.api.comment.dto.WriteCommentResponse;
import com.ggang.be.api.comment.dto.*;
import com.ggang.be.domain.constant.GroupType;
import com.ggang.be.domain.user.UserEntity;

public interface CommentStrategy {

ReadCommentResponse readComment(UserEntity findUserEntity, boolean isPublic,
ReadCommentRequest dto);
ReadCommentResponse readComment(UserEntity findUserEntity, boolean isPublic, ReadCommentRequest dto);

boolean supports(GroupType groupType);

WriteCommentResponse writeComment(final long userId, WriteCommentRequest dto,
WriteCommentEntityDto from);


WriteCommentResponse writeComment(final long userId, WriteCommentRequest dto, WriteCommentEntityDto from);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import com.ggang.be.api.exception.GongBaekException;
import com.ggang.be.domain.constant.GroupType;
import com.ggang.be.global.annotation.Registry;
import java.util.List;
import lombok.RequiredArgsConstructor;

import java.util.List;

@Registry
@RequiredArgsConstructor
public class CommentStrategyRegistry {
Expand All @@ -19,6 +20,4 @@ public CommentStrategy getCommentGroupStrategy(GroupType groupType) {
.findFirst()
.orElseThrow(() -> new GongBaekException(ResponseError.BAD_REQUEST));
}


}
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.ggang.be.api.comment.strategy;

import com.ggang.be.api.comment.dto.ReadCommentRequest;
import com.ggang.be.api.comment.dto.ReadCommentResponse;
import com.ggang.be.api.comment.dto.WriteCommentEntityDto;
import com.ggang.be.api.comment.dto.WriteCommentRequest;
import com.ggang.be.api.comment.dto.WriteCommentResponse;
import com.ggang.be.api.comment.dto.*;
import com.ggang.be.api.comment.registry.CommentStrategy;
import com.ggang.be.api.group.everyGroup.service.EveryGroupService;
import com.ggang.be.api.userEveryGroup.service.UserEveryGroupService;
Expand All @@ -25,29 +21,25 @@ public class EveryGroupCommentStrategy implements CommentStrategy {
private final UserEveryGroupService userEveryGroupService;

@Override
public WriteCommentResponse writeComment(long userId, WriteCommentRequest dto,
WriteCommentEntityDto from) {

public WriteCommentResponse writeComment(long userId, WriteCommentRequest dto, WriteCommentEntityDto from) {
CommentEntity commentEntity = from.commentEntity();
UserEntity findUserEntity = from.userEntity();

EveryGroupEntity everyGroupEntity = everyGroupService.findEveryGroupEntityByGroupId(
dto.groupId());
EveryGroupEntity everyGroupEntity = everyGroupService.findEveryGroupEntityByGroupId(dto.groupId());

sameSchoolValidator.isUserReadMySchoolEveryGroup(findUserEntity,
everyGroupEntity);
sameSchoolValidator.isUserReadMySchoolEveryGroup(findUserEntity, everyGroupEntity);
isUserAccessEveryGroupComment(findUserEntity, dto.isPublic(), dto.groupId());
everyGroupService.writeCommentInGroup(commentEntity, dto.groupId());

return WriteCommentResponse.of(commentEntity.getId());
}

@Override
public ReadCommentResponse readComment(UserEntity findUserEntity, boolean isPublic,
ReadCommentRequest dto) {
EveryGroupEntity everyGroupEntity = everyGroupService.findEveryGroupEntityByGroupId(
dto.groupId());
public ReadCommentResponse readComment(UserEntity findUserEntity, boolean isPublic, ReadCommentRequest dto) {
EveryGroupEntity everyGroupEntity = everyGroupService.findEveryGroupEntityByGroupId(dto.groupId());
sameSchoolValidator.isUserReadMySchoolEveryGroup(findUserEntity, everyGroupEntity);
isUserAccessEveryGroupComment(findUserEntity, isPublic, dto.groupId());

return ReadCommentResponse.of(everyGroupService.readCommentInGroup(findUserEntity, isPublic, dto.groupId()));
}

Expand All @@ -56,9 +48,7 @@ public boolean supports(GroupType groupType) {
return groupType.equals(GroupType.WEEKLY);
}

private void isUserAccessEveryGroupComment(UserEntity userEntity, boolean isPublic,
long groupId) {
if (!isPublic)
userEveryGroupService.isValidCommentAccess(userEntity, groupId);
private void isUserAccessEveryGroupComment(UserEntity userEntity, boolean isPublic, long groupId) {
if (!isPublic) userEveryGroupService.isValidCommentAccess(userEntity, groupId);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.ggang.be.api.comment.strategy;

import com.ggang.be.api.comment.dto.ReadCommentRequest;
import com.ggang.be.api.comment.dto.ReadCommentResponse;
import com.ggang.be.api.comment.dto.WriteCommentEntityDto;
import com.ggang.be.api.comment.dto.WriteCommentRequest;
import com.ggang.be.api.comment.dto.WriteCommentResponse;
import com.ggang.be.api.comment.dto.*;
import com.ggang.be.api.comment.registry.CommentStrategy;
import com.ggang.be.api.group.onceGroup.service.OnceGroupService;
import com.ggang.be.api.userOnceGroup.service.UserOnceGroupService;
Expand All @@ -24,44 +20,39 @@ public class OnceGroupCommentStrategy implements CommentStrategy {
private final SameSchoolValidator sameSchoolValidator;
private final UserOnceGroupService userOnceGroupService;


@Override
public boolean supports(GroupType groupType) {
return groupType.equals(GroupType.ONCE);
}

@Override
public WriteCommentResponse writeComment(long userId, WriteCommentRequest dto,
WriteCommentEntityDto entityDto) {
public WriteCommentResponse writeComment(
long userId, WriteCommentRequest dto, WriteCommentEntityDto entityDto
) {

UserEntity findUserEntity = entityDto.userEntity();
CommentEntity commentEntity = entityDto.commentEntity();
OnceGroupEntity onceGroupEntity = onceGroupService.findOnceGroupEntityByGroupId(
dto.groupId());
OnceGroupEntity onceGroupEntity = onceGroupService.findOnceGroupEntityByGroupId(dto.groupId());

sameSchoolValidator.isUserReadMySchoolOnceGroup(commentEntity.getUserEntity(),
onceGroupEntity);
sameSchoolValidator.isUserReadMySchoolOnceGroup(commentEntity.getUserEntity(), onceGroupEntity);
isUserAccessOnceGroupComment(findUserEntity, dto.isPublic(), dto.groupId());
onceGroupService.writeCommentInGroup(commentEntity, dto.groupId());

return WriteCommentResponse.of(commentEntity.getId());
}

@Override
public ReadCommentResponse readComment(UserEntity findUserEntity, boolean isPublic,
ReadCommentRequest dto) {
OnceGroupEntity onceGroupEntity = onceGroupService.findOnceGroupEntityByGroupId(
dto.groupId());
public ReadCommentResponse readComment(
UserEntity findUserEntity, boolean isPublic, ReadCommentRequest dto
) {
OnceGroupEntity onceGroupEntity = onceGroupService.findOnceGroupEntityByGroupId(dto.groupId());
sameSchoolValidator.isUserReadMySchoolOnceGroup(findUserEntity, onceGroupEntity);
isUserAccessOnceGroupComment(findUserEntity, isPublic, dto.groupId());

return ReadCommentResponse.of(onceGroupService.readCommentInGroup(findUserEntity, isPublic, dto.groupId()));
}

private void isUserAccessOnceGroupComment(UserEntity userEntity, boolean isPublic,
long groupId) {
if (!isPublic) {
userOnceGroupService.isValidCommentAccess(userEntity, groupId);
}
private void isUserAccessOnceGroupComment(UserEntity userEntity, boolean isPublic, long groupId) {
if (!isPublic) userOnceGroupService.isValidCommentAccess(userEntity, groupId);
}

}
4 changes: 0 additions & 4 deletions src/main/java/com/ggang/be/api/common/ApiResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ public static <T> ApiResponse<T> success(ResponseSuccess responseSuccess, T data
return new ApiResponse<>(true, responseSuccess.getCode(), responseSuccess.getMessage(), data);
}

public static <T> ApiResponse<T> success(ResponseSuccess responseSuccess) {
return new ApiResponse<>(true, responseSuccess.getCode(), responseSuccess.getMessage(), null);
}

public static <T> ApiResponse<T> error(ResponseError responseError) {
return new ApiResponse<>(false, responseError.getCode(), responseError.getMessage(), null);
}
Expand Down
26 changes: 0 additions & 26 deletions src/main/java/com/ggang/be/api/common/PracticeController.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
@Facade
@RequiredArgsConstructor
@Slf4j
public class GongbaekRequestFacade {
public class GroupRequestFacade {
private final LectureTimeSlotService lectureTimeSlotService;
private final UserService userService;
private final LocationValidator locationValidator;
private final TitleValidator titleValidator;
private final IntroductionValidator introductionValidator;



public void validateRegisterRequest(Long userId, RegisterGongbaekRequest dto) {
TimeValidator.isTimeValid(dto.startTime(), dto.endTime());
isDateValid(dto);
Expand All @@ -38,9 +36,7 @@ public void validateRegisterRequest(Long userId, RegisterGongbaekRequest dto) {
isValidCoverImg(dto);
isValidMaxPeople(dto);


UserEntity findUserEntity = userService.getUserById(userId);

checkLectureTimeSlot(dto, findUserEntity);
}

Expand All @@ -51,15 +47,13 @@ private void isValidMaxPeople(RegisterGongbaekRequest dto) {
}
}


private void isValidCoverImg(RegisterGongbaekRequest dto) {
if(dto.coverImg()<1 || dto.coverImg()>6) {
log.error("그룹 coverImg 검증에 실패하였습니다.");
throw new GongBaekException(ResponseError.BAD_REQUEST);
}
}


private void isDateValid(RegisterGongbaekRequest dto) {
if(dto.groupType() == GroupType.ONCE) {
TimeValidator.isDateBeforeNow(dto.weekDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import com.ggang.be.api.schoolMajor.service.SchoolMajorService;
import com.ggang.be.domain.school.application.School;
import com.ggang.be.global.annotation.Facade;
import java.util.List;
import lombok.RequiredArgsConstructor;

import java.util.List;

@Facade
@RequiredArgsConstructor
public class SearchSchoolMajorFacade {
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/ggang/be/api/facade/SignupFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,9 @@ public SignupResponse signup(SignupRequest request) {

duplicateUserCheck(request);

SchoolEntity schoolEntityByName = schoolService.findSchoolEntityByName(
request.schoolName());
SchoolEntity schoolEntityByName = schoolService.findSchoolEntityByName(request.schoolName());

SaveUserSignUp saveUserSignUp = SignupRequest.toSaveUserSignUp(request,
schoolEntityByName);
SaveUserSignUp saveUserSignUp = SignupRequest.toSaveUserSignUp(request, schoolEntityByName);

UserEntity userEntity = userService.saveUserBySignup(saveUserSignUp);

Expand All @@ -57,7 +55,7 @@ public SignupResponse signup(SignupRequest request) {
private void duplicateUserCheck(SignupRequest request) {
try{
duplicateCheckNickname(request.nickname());
}catch (GongBaekException e){
} catch (GongBaekException e) {
throw new GongBaekException(ResponseError.USERNAME_ALREADY_EXISTS);
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/com/ggang/be/api/facade/TimeTableFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ public class TimeTableFacade {

public ReadInvalidTimeResponse readMyInvalidTime(final long userId) {
UserEntity findUserEntity = userService.getUserById(userId);
List<LectureTimeSlotEntity> lectureTimeSlotEntities = lectureTimeSlotService.readUserTime(
findUserEntity);
return ReadInvalidTimeResponse.fromVo(
voMaker.convertToCommonResponse(lectureTimeSlotEntities));
List<LectureTimeSlotEntity> lectureTimeSlotEntities = lectureTimeSlotService.readUserTime(findUserEntity);

return ReadInvalidTimeResponse.fromVo(voMaker.convertToCommonResponse(lectureTimeSlotEntities));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
import com.ggang.be.domain.group.onceGroup.dto.OnceGroupVo;
import com.ggang.be.domain.user.UserEntity;
import com.ggang.be.global.annotation.Facade;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class ActivceCombinedGroupVoPreparer {
public class ActiveCombinedGroupVoPreparer {

private final EveryGroupService everyGroupService;
private final OnceGroupService onceGroupService;
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/com/ggang/be/api/group/GroupStatusUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
import com.ggang.be.domain.group.everyGroup.EveryGroupEntity;
import com.ggang.be.domain.group.onceGroup.OnceGroupEntity;
import com.ggang.be.global.util.TimeConverter;
import java.time.LocalDateTime;
import java.time.LocalTime;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.time.LocalTime;

@Component
public class GroupStatusUpdater {


@Transactional
public void updateOnceGroup(OnceGroupEntity entity){
double startTime = entity.getGongbaekTimeSlotEntity().getStartTime();
Expand All @@ -22,7 +21,6 @@ public void updateOnceGroup(OnceGroupEntity entity){
entity.updateStatus(Status.CLOSED);
}


@Transactional
public void updateEveryGroup(EveryGroupEntity entity){
LocalTime midNight = LocalTime.of(0, 0);
Expand Down
Loading

0 comments on commit e28e3be

Please sign in to comment.