Skip to content

Commit

Permalink
Merge pull request #78 from U2DJ2/backend-main
Browse files Browse the repository at this point in the history
[BE] main branch 병합
  • Loading branch information
320Hwany authored May 1, 2024
2 parents 7cd731f + c3dc318 commit b972d2b
Show file tree
Hide file tree
Showing 98 changed files with 4,144 additions and 245 deletions.
3 changes: 3 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ build/
### Generated ###
**/src/main/generated/

### initDB ###
**/src/main/java/moim_today/global/init/**

### Properties ###
application.yml
application-dev.yml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public interface AuthService {

void login(final MemberLoginRequest memberLoginRequest, final HttpServletRequest request);

void register(final MemberRegisterRequest memberRegisterRequest, final HttpServletRequest request);
void signUp(final MemberRegisterRequest memberRegisterRequest, final HttpServletRequest request);

void logout(final HttpServletRequest request);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public void logout(final HttpServletRequest request) {
}

@Override
public void register(final MemberRegisterRequest memberRegisterRequest,
final HttpServletRequest request) {
public void signUp(final MemberRegisterRequest memberRegisterRequest,
final HttpServletRequest request) {
universityFinder.checkUniversityIdIsPresent(memberRegisterRequest.universityId());
departmentFinder.isDepartmentAssociatedWithUniversity(memberRegisterRequest.universityId(), memberRegisterRequest.departmentId());
memberFinder.validateEmailNotExists(memberRegisterRequest.email());
authManager.register(memberRegisterRequest, request);
authManager.signUp(memberRegisterRequest, request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

public interface DepartmentService {

void putAllDepartment();
void patchAllDepartment();

List<DepartmentInfoResponse> getAllDepartment(final long universityId, String universityName);
List<DepartmentInfoResponse> getAllDepartmentByUniversityName(final String universityName);

List<DepartmentInfoResponse> getAllDepartmentById(final long universityId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.List;

@Service
public class DepartmentServiceImpl implements DepartmentService{
public class DepartmentServiceImpl implements DepartmentService {

private final DepartmentAppender departmentAppender;
private final DepartmentFinder departmentFinder;
Expand All @@ -19,12 +19,17 @@ public DepartmentServiceImpl(final DepartmentAppender departmentAppender, final
}

@Override
public void putAllDepartment() {
public void patchAllDepartment() {
departmentAppender.putAllDepartment();
}

@Override
public List<DepartmentInfoResponse> getAllDepartment(final long universityId, final String universityName) {
return departmentFinder.getAllDepartment(universityId, universityName);
public List<DepartmentInfoResponse> getAllDepartmentByUniversityName(final String universityName) {
return departmentFinder.getAllDepartmentByUniversityName(universityName);
}

@Override
public List<DepartmentInfoResponse> getAllDepartmentById(final long universityId) {
return departmentFinder.getAllDepartmentById(universityId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;

@Service
public class AmazonS3Service implements FileService{

Expand All @@ -21,7 +23,8 @@ public AmazonS3Service(final FileUploader fileUploader, final FileRemover fileRe
}

public FileInfoResponse uploadFile(final String fileType, final MultipartFile multipartFile){
return fileUploader.uploadFile(fileType, multipartFile);
String imageUrl = fileUploader.uploadFile(fileType, multipartFile);
return new FileInfoResponse(imageUrl);
}

public void deleteFile(final MemberSession memberSession, final FileDeleteRequest fileDeleteRequest){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void updateProfile(final long memberId,

@Override
public void updateProfileImage(final long memberId, final MultipartFile file) {
FileInfoResponse fileInfoResponse = fileUploader.uploadFile(PROFILE_IMAGE.value(), file);
memberUpdater.updateProfileImageUrl(memberId, fileInfoResponse.uploadFileUrl());
String imageUrl = fileUploader.uploadFile(PROFILE_IMAGE.value(), file);
memberUpdater.updateProfileImageUrl(memberId, imageUrl);
}
}
19 changes: 19 additions & 0 deletions backend/src/main/java/moim_today/application/moim/MoimService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package moim_today.application.moim;

import moim_today.dto.moim.*;
import org.springframework.web.multipart.MultipartFile;

public interface MoimService {

void createPublicMoim(final long memberId, final long universityId,
final PublicMoimAppendRequest publicMoimAppendRequest);

void createPrivateMoim(final long memberId, final long universityId,
final PrivateMoimAppendRequest privateMoimAppendRequest);

UploadMoimImageResponse uploadMoimImage(final MultipartFile file);

MoimDetailResponse getMoimDetail(final long moimId);

void updateMoim(final long memberId, final MoimUpdateRequest moimUpdateRequest);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package moim_today.application.moim;

import moim_today.dto.moim.*;
import moim_today.implement.file.FileUploader;
import moim_today.implement.moim.MoimAppender;
import moim_today.implement.moim.MoimFinder;
import moim_today.implement.moim.MoimUpdater;
import moim_today.persistence.entity.moim.moim.MoimJpaEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import static moim_today.global.constant.FileTypeConstant.MOIM_IMAGE;

@Service
public class MoimServiceImpl implements MoimService{

private final MoimAppender moimAppender;
private final FileUploader fileUploader;
private final MoimFinder moimFinder;
private final MoimUpdater moimUpdater;

public MoimServiceImpl(final MoimAppender moimAppender,
final FileUploader fileUploader,
final MoimFinder moimFinder,
final MoimUpdater moimUpdater) {
this.moimAppender = moimAppender;
this.fileUploader = fileUploader;
this.moimFinder = moimFinder;
this.moimUpdater = moimUpdater;
}

@Override
public void createPublicMoim(final long memberId, final long universityId,
final PublicMoimAppendRequest publicMoimAppendRequest) {
moimAppender.createPublicMoim(memberId, universityId, publicMoimAppendRequest);
}

@Override
public void createPrivateMoim(final long memberId, final long universityId,
final PrivateMoimAppendRequest privateMoimAppendRequest) {
moimAppender.createPrivateMoim(memberId, universityId, privateMoimAppendRequest);
}

@Override
public UploadMoimImageResponse uploadMoimImage(final MultipartFile file) {
String imageUrl = fileUploader.uploadFile(MOIM_IMAGE.value(), file);
return UploadMoimImageResponse.from(imageUrl);
}

@Override
public MoimDetailResponse getMoimDetail(final long moimId) {
MoimJpaEntity moimJpaEntity = moimFinder.getById(moimId);
return MoimDetailResponse.from(moimJpaEntity);
}

@Override
public void updateMoim(final long memberId, final MoimUpdateRequest moimUpdateRequest) {
moimUpdater.updateMoim(memberId, moimUpdateRequest);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
package moim_today.application.schedule;

import moim_today.dto.schedule.ScheduleCreateRequest;
import moim_today.dto.schedule.ScheduleResponse;
import moim_today.dto.schedule.ScheduleUpdateRequest;
import moim_today.dto.schedule.TimeTableRequest;

import java.time.LocalDate;
import java.time.YearMonth;
import java.util.List;


public interface ScheduleService {

List<ScheduleResponse> findAllByWeekly(final long memberId, final LocalDate startDate);

List<ScheduleResponse> findAllByMonthly(final long memberId, final YearMonth yearMonth);

void fetchTimeTable(final long memberId, final TimeTableRequest timeTableRequest);

void createSchedule(final long memberId, final ScheduleCreateRequest scheduleCreateRequest);

void updateSchedule(final long memberId, final ScheduleUpdateRequest scheduleUpdateRequest);

void deleteSchedule(final long memberId, final long scheduleId);
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
package moim_today.application.schedule;

import moim_today.domain.schedule.Schedule;
import moim_today.dto.schedule.ScheduleCreateRequest;
import moim_today.dto.schedule.ScheduleResponse;
import moim_today.dto.schedule.ScheduleUpdateRequest;
import moim_today.dto.schedule.TimeTableRequest;
import moim_today.implement.schedule.ScheduleAppender;
import moim_today.implement.schedule.ScheduleManager;
import moim_today.implement.schedule.*;
import moim_today.persistence.entity.schedule.ScheduleJpaEntity;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.YearMonth;
import java.util.List;

@Service
public class ScheduleServiceImpl implements ScheduleService {

private final ScheduleManager scheduleManager;
private final ScheduleFinder scheduleFinder;
private final ScheduleAppender scheduleAppender;
private final ScheduleUpdater scheduleUpdater;
private final ScheduleDeleter scheduleDeleter;

public ScheduleServiceImpl(final ScheduleManager scheduleManager, final ScheduleAppender scheduleAppender) {
public ScheduleServiceImpl(final ScheduleManager scheduleManager, final ScheduleFinder scheduleFinder,
final ScheduleAppender scheduleAppender, final ScheduleUpdater scheduleUpdater,
final ScheduleDeleter scheduleDeleter) {
this.scheduleManager = scheduleManager;
this.scheduleFinder = scheduleFinder;
this.scheduleAppender = scheduleAppender;
this.scheduleUpdater = scheduleUpdater;
this.scheduleDeleter = scheduleDeleter;
}

@Override
public List<ScheduleResponse> findAllByWeekly(final long memberId, final LocalDate startDate) {
return scheduleFinder.findAllByWeekly(memberId, startDate);
}

@Override
public List<ScheduleResponse> findAllByMonthly(final long memberId, final YearMonth yearMonth) {
return scheduleFinder.findAllByMonthly(memberId, yearMonth);
}

@Override
Expand All @@ -25,4 +48,20 @@ public void fetchTimeTable(final long memberId, final TimeTableRequest timeTable
List<Schedule> schedules = scheduleManager.processTimetable(timeTableXML, timeTableRequest);
scheduleAppender.batchUpdateSchedules(schedules, memberId);
}

@Override
public void createSchedule(final long memberId, final ScheduleCreateRequest scheduleCreateRequest) {
ScheduleJpaEntity scheduleJpaEntity = scheduleCreateRequest.toEntity(memberId);
scheduleAppender.createSchedule(scheduleJpaEntity);
}

@Override
public void updateSchedule(final long memberId, final ScheduleUpdateRequest scheduleUpdateRequest) {
scheduleUpdater.updateSchedule(memberId, scheduleUpdateRequest);
}

@Override
public void deleteSchedule(final long memberId, final long scheduleId) {
scheduleDeleter.deleteSchedule(memberId, scheduleId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public interface UniversityService {

void putAllUniversity();
void fetchAllUniversity();

List<UniversityInfoResponse> getUniversities();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package moim_today.application.university;

import moim_today.dto.university.UniversityInfoResponse;
import moim_today.implement.university.UniversityAppender;
import moim_today.implement.university.UniversityUpdater;
import moim_today.implement.university.UniversityFinder;
import org.springframework.stereotype.Service;

Expand All @@ -10,17 +10,17 @@
@Service
public class UniversityServiceImpl implements UniversityService{

private final UniversityAppender universityAppender;
private final UniversityUpdater universityUpdater;
private final UniversityFinder universityFinder;

public UniversityServiceImpl(final UniversityAppender universityAppender, final UniversityFinder universityFinder) {
this.universityAppender = universityAppender;
public UniversityServiceImpl(final UniversityUpdater universityUpdater, final UniversityFinder universityFinder) {
this.universityUpdater = universityUpdater;
this.universityFinder = universityFinder;
}

@Override
public void putAllUniversity() {
universityAppender.fetchAllUniversity();
public void fetchAllUniversity() {
universityUpdater.fetchAllUniversity();
}

@Override
Expand Down
41 changes: 41 additions & 0 deletions backend/src/main/java/moim_today/domain/department/Department.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package moim_today.domain.department;

import moim_today.persistence.entity.department.DepartmentJpaEntity;
import moim_today.persistence.entity.university.UniversityJpaEntity;

import java.util.*;

public record Department(
long universityId,
String departmentName
) {

public static List<DepartmentJpaEntity> toEntities(final Map<String, Set<String>> universityAndDepartments,
final List<UniversityJpaEntity> universityJpaEntities) {
Map<Long, Set<String>> existingUniversities = convertToUnivIdAndDepartments(universityAndDepartments, universityJpaEntities);
List<DepartmentJpaEntity> departmentJpaEntities = new ArrayList<>();

for (Map.Entry<Long, Set<String>> entrySet : existingUniversities.entrySet()) {
for (String departmentName : entrySet.getValue()) {
departmentJpaEntities.add(DepartmentJpaEntity.builder()
.universityId(entrySet.getKey())
.departmentName(departmentName)
.build());
}
}
return departmentJpaEntities;
}

private static Map<Long, Set<String>> convertToUnivIdAndDepartments(final Map<String, Set<String>> universityAndDepartments,
final List<UniversityJpaEntity> universityJpaEntities) {
Map<Long, Set<String>> existingUniversities = new HashMap<>();

universityJpaEntities.stream()
.forEach(universityJpaEntity -> {
existingUniversities.put(universityJpaEntity.getId(), universityAndDepartments.get(universityJpaEntity.getUniversityName()));
});

return existingUniversities;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package moim_today.domain.moim;

public enum DisplayStatus {

PUBLIC, PRIVATE
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

// todo 정기 모임 카테고리 세부사항 추가
public enum MoimCategory {

STUDY, TEAM_PROJECT
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public ScheduleJpaEntity toEntity(final long memberId, final long meetingId) {
.endDateTime(endDateTime)
.build();
}

public boolean exists(final ScheduleJpaEntity scheduleJpaEntity) {
return scheduleJpaEntity.getEndDateTime().isAfter(startDateTime) &&
scheduleJpaEntity.getStartDateTime().isBefore(endDateTime);
}
}
Loading

0 comments on commit b972d2b

Please sign in to comment.