From 376157dafd393db82c834fc5237f94a428cf0d14 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sun, 26 Jun 2022 02:08:46 +0900 Subject: [PATCH 01/51] =?UTF-8?q?fixing:=20getTheMemberHouseWork=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairer/api/HouseWorkController.java | 70 +++++++++++-------- .../fairer/domain/member/Member.java | 7 ++ .../fairer/global/util/DateTimeUtils.java | 6 ++ .../housework/HouseWorkCustomRepository.java | 3 + .../HouseWorkCustomRepositoryImpl.java | 13 ++++ .../housework/HouseWorkRepository.java | 1 + .../member/MemberCustomRepository.java | 3 + .../member/MemberCustomRepositoryImpl.java | 20 ++++++ .../repository/member/MemberRepository.java | 2 + .../service/housework/HouseWorkService.java | 42 +++++++++++ .../fairer/service/member/MemberService.java | 14 ++-- .../fairer/service/team/TeamService.java | 7 ++ .../vo/houseWork/HouseWorkAndAssigneeVo.java | 42 +++++++++++ .../fairer/vo/houseWork/PooClass.java | 15 ++++ 14 files changed, 210 insertions(+), 35 deletions(-) create mode 100644 src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java create mode 100644 src/main/java/com/depromeet/fairer/vo/houseWork/PooClass.java diff --git a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java index 31641cc3..a94ec9b7 100644 --- a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java +++ b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java @@ -4,6 +4,7 @@ import com.depromeet.fairer.domain.member.Member; import com.depromeet.fairer.dto.member.MemberDto; import com.depromeet.fairer.global.resolver.RequestMemberId; +import com.depromeet.fairer.global.util.DateTimeUtils; import com.depromeet.fairer.service.housework.HouseWorkService; import com.depromeet.fairer.dto.housework.request.HouseWorksCreateRequestDto; import com.depromeet.fairer.dto.housework.request.HouseWorkUpdateRequestDto; @@ -12,6 +13,7 @@ import com.depromeet.fairer.service.member.MemberService; import com.depromeet.fairer.vo.houseWork.HouseWorkUpdateVo; +import com.depromeet.fairer.vo.houseWork.PooClass; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.v3.oas.annotations.tags.Tag; @@ -25,7 +27,6 @@ import javax.validation.Valid; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -49,7 +50,7 @@ public ResponseEntity createHouseWorks(@ApiIgnore @ } @Tag(name = "houseWorks") - @ApiOperation(value = "집안일 수정 API ") + @ApiOperation(value = "집안일 수정 API") @PutMapping("/{houseWorkId}") public ResponseEntity editHouseWork(@ApiIgnore @RequestMemberId Long memberId, @RequestBody @Valid HouseWorkUpdateRequestDto dto, @@ -72,34 +73,47 @@ public ResponseEntity deleteHouseWork( } @Tag(name = "houseWorks") - @ApiOperation(value = "날짜별 집안일 조회", notes = "본인 포함 팀원들의 집안일까지 모두 조회") - @GetMapping(value = "") - public ResponseEntity> getHouseWork(@RequestParam("scheduledDate") String scheduledDate, - @ApiIgnore @RequestMemberId Long memberId) { - LocalDate scheduledDateParse = LocalDate.parse(scheduledDate, DateTimeFormatter.ISO_DATE); - - List members = memberService.getMemberList(memberId); - - List houseWorkDateResponseDtos = new ArrayList<>(); - for (Member member : members) { - List houseWorks = houseWorkService.getHouseWorks(scheduledDateParse, member); - - List houseWorkResponseDtoList = houseWorks.stream().map(houseWork -> { - List memberDtoList = memberService.getMemberListByHouseWorkId(houseWork.getHouseWorkId()) - .stream().map(MemberDto::from).collect(Collectors.toList()); - - return HouseWorkResponseDto.from(houseWork, memberDtoList); - }).collect(Collectors.toList()); - - long countDone = houseWorkResponseDtoList.stream().filter(HouseWorkResponseDto::getSuccess).count(); - long countLeft = houseWorkResponseDtoList.stream().filter(houseWorkResponseDto -> !houseWorkResponseDto.getSuccess()).count(); - - houseWorkDateResponseDtos.add(HouseWorkDateResponseDto.from(member.getMemberId(), scheduledDateParse, countDone, countLeft, houseWorkResponseDtoList)); - } - - return ResponseEntity.ok(houseWorkDateResponseDtos); + @ApiOperation(value = "특정 멤버의 날짜별 집안일 조회", notes = "특정 멤버의 날짜별 집안일 조회") + @GetMapping("") + public ResponseEntity getTheMemberHouseWork(@RequestParam("reqDate") String reqDate, + @RequestParam("memberId") Long memberId, + @ApiIgnore @RequestMemberId Long reqMemberId) { + final LocalDate localDate = DateTimeUtils.stringToLocalDate(reqDate); + final PooClass theMemberHouseWorks = houseWorkService.getTheMemberHouseWorks(reqMemberId, memberId, localDate); + return ResponseEntity.ok(theMemberHouseWorks); } +// @Tag(name = "houseWorks") +// @ApiOperation(value = "날짜별 집안일 조회", notes = "본인 포함 팀원들의 집안일까지 모두 조회") +// @GetMapping(value = "") +// public ResponseEntity> getHouseWork(@RequestParam("reqDate") String reqDate, +// @ApiIgnore @RequestMemberId Long memberId) { +// final LocalDate reqDateParse = DateTimeUtils.stringToLocalDate(reqDate); +// +// houseWorkService.getMyTeamAllHouseWorksByDate(memberId, reqDate); +// +// List members = memberService.getMyTeamMembers(memberId); +// +// List houseWorkDateResponseDtos = new ArrayList<>(); +// for (Member member : members) { +// List houseWorks = houseWorkService.getHouseWorks(reqDateParse, member); +// +// List houseWorkResponseDtoList = houseWorks.stream().map(houseWork -> { +// List memberDtoList = memberService.getMemberListByHouseWorkId(houseWork.getHouseWorkId()) +// .stream().map(MemberDto::from).collect(Collectors.toList()); +// +// return HouseWorkResponseDto.from(houseWork, memberDtoList); +// }).collect(Collectors.toList()); +// +// long countDone = houseWorkResponseDtoList.stream().filter(HouseWorkResponseDto::getSuccess).count(); +// long countLeft = houseWorkResponseDtoList.stream().filter(houseWorkResponseDto -> !houseWorkResponseDto.getSuccess()).count(); +// +// houseWorkDateResponseDtos.add(HouseWorkDateResponseDto.from(member.getMemberId(), reqDateParse, countDone, countLeft, houseWorkResponseDtoList)); +// } +// +// return ResponseEntity.ok(houseWorkDateResponseDtos); +// } + @Tag(name = "houseWorks") @ApiOperation(value = "개별 집안일 조회", notes = "") @GetMapping(value = "{houseWorkId}/detail") diff --git a/src/main/java/com/depromeet/fairer/domain/member/Member.java b/src/main/java/com/depromeet/fairer/domain/member/Member.java index c448e5b3..0d74baf3 100644 --- a/src/main/java/com/depromeet/fairer/domain/member/Member.java +++ b/src/main/java/com/depromeet/fairer/domain/member/Member.java @@ -15,6 +15,13 @@ import java.util.ArrayList; import java.util.List; +@NamedEntityGraph(name = "Member.withMyTeamMembers", attributeNodes = { + @NamedAttributeNode(value = "team", subgraph = "team") + }, + subgraphs = @NamedSubgraph(name = "team", attributeNodes = { + @NamedAttributeNode("members") + }) +) @Entity @Table(name = "member") @Getter diff --git a/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java b/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java index c21b9806..aaa7ce66 100644 --- a/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java +++ b/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java @@ -1,7 +1,9 @@ package com.depromeet.fairer.global.util; +import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; +import java.time.format.DateTimeFormatter; import java.util.Date; public class DateTimeUtils { @@ -10,4 +12,8 @@ public static LocalDateTime convertToLocalDateTime(Date date) { .atZone(ZoneId.systemDefault()) .toLocalDateTime(); } + + public static LocalDate stringToLocalDate(String localDate) { + return LocalDate.parse(localDate, DateTimeFormatter.ISO_DATE); + } } diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java index 88057099..2e94f83e 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java @@ -8,5 +8,8 @@ public interface HouseWorkCustomRepository { Long getHouseWorkSuccessCount(Long memberId, LocalDate startDate, LocalDate endDate); + List getHouseWorkAndAssignee(Long memberId, LocalDate localDate); + + // List getHouseWorkList(LocalDate scheduledDate, Long memberId); } diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java index 0cee9742..3bec48d3 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java @@ -29,4 +29,17 @@ public Long getHouseWorkSuccessCount(Long memberId, LocalDate startDate, LocalDa .stream() .count(); } + + @Override + public List getHouseWorkAndAssignee(Long memberId, LocalDate localDate) { + return jpaQueryFactory.selectFrom(houseWork) + .innerJoin(assignment.member, member) + .innerJoin(houseWork.assignments, assignment) + .where(member.memberId.eq(memberId) + .and(houseWork.scheduledDate.eq(localDate))) + .fetch(); + + } + + } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java index 4c37cf6a..27fa0b00 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java @@ -6,6 +6,7 @@ import org.apache.tomcat.jni.Local; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import java.time.LocalDate; diff --git a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java index e238d10c..fbe6391a 100644 --- a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java @@ -1,10 +1,13 @@ package com.depromeet.fairer.repository.member; import com.depromeet.fairer.domain.member.Member; +import org.springframework.data.jpa.repository.EntityGraph; import java.util.List; +import java.util.Optional; public interface MemberCustomRepository { List getMemberDtoListByHouseWorkId(Long houseWorkId); + List getMyTeamMembers(Long memberId); } diff --git a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java index d0c0ef4f..8e14b114 100644 --- a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java +++ b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java @@ -1,14 +1,19 @@ package com.depromeet.fairer.repository.member; import com.depromeet.fairer.domain.member.Member; +import com.depromeet.fairer.domain.member.QMember; +import com.depromeet.fairer.domain.team.QTeam; +import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Optional; import static com.depromeet.fairer.domain.assignment.QAssignment.assignment; import static com.depromeet.fairer.domain.member.QMember.member; +import static com.depromeet.fairer.domain.team.QTeam.team; @Repository @RequiredArgsConstructor @@ -23,4 +28,19 @@ public List getMemberDtoListByHouseWorkId(Long houseWorkId){ .where(assignment.houseWork.houseWorkId.eq(houseWorkId)) .fetch(); } + + @Override + public List getMyTeamMembers(Long memberId) { + final QMember teamMember = new QMember("teamMember"); + final QTeam aTeam = new QTeam("ATeam"); +// return jpaQueryFactory.select(teamMember) +// .leftJoin(teamMember.team, ateam) +// .where(JPAExpressions +// .selectFrom(team) +// .leftJoin(member.team, team) +// .where(member.memberId.eq(memberId)) +// ), aTeam).fetch(); + return null; + } + } diff --git a/src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java b/src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java index 04b9557f..9f2dffdf 100644 --- a/src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java @@ -4,6 +4,7 @@ import com.depromeet.fairer.domain.team.Team; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import java.util.List; @@ -20,4 +21,5 @@ public interface MemberRepository extends JpaRepository, MemberCus @EntityGraph(attributePaths = {"team"}) Optional findWithTeamByMemberId(Long memberId); + } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java index 1e39f361..e508bbaf 100644 --- a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java +++ b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java @@ -13,9 +13,13 @@ import com.depromeet.fairer.repository.housework.HouseWorkRepository; import com.depromeet.fairer.repository.member.MemberRepository; import com.depromeet.fairer.service.member.MemberService; +import com.depromeet.fairer.service.team.TeamService; +import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeVo; import com.depromeet.fairer.vo.houseWork.HouseWorkUpdateVo; +import com.depromeet.fairer.vo.houseWork.PooClass; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -39,6 +43,7 @@ public class HouseWorkService { private final MemberRepository memberRepository; private final AssignmentRepository assignmentRepository; private final MemberService memberService; + private final TeamService teamService; public List createHouseWorks(Long memberId, List houseWorksDto) { @@ -185,4 +190,41 @@ public HouseWork getHouseWorkById(Long houseWorkId) { return houseWorkRepository.findById(houseWorkId) .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 집안일 입니다.")); } + + public PooClass getTheMemberHouseWorks(Long reqMemberId, Long memberId, LocalDate localDate) { + teamService.validateSameTeam(reqMemberId, memberId); + // 이 멤버 아이디로 집안일 조회 + // 집안일에 할당된 assignee 리스트 가져오기 + final List houseWorkAndAssignee = houseWorkRepository.getHouseWorkAndAssignee(memberId, localDate); + + final List response = houseWorkAndAssignee.stream().map(h -> { + final HouseWorkAndAssigneeVo houseWorkAndAssigneeVo = new HouseWorkAndAssigneeVo(); + houseWorkAndAssigneeVo.setHouseWorkId(h.getHouseWorkId()); + houseWorkAndAssigneeVo.setSpace(h.getSpace()); + houseWorkAndAssigneeVo.setScheduledTime(h.getScheduledTime()); + houseWorkAndAssigneeVo.setSuccessDateTime(h.getSuccessDateTime()); + houseWorkAndAssigneeVo.setSuccess(h.getSuccess()); + + final List memberVos = h.getAssignments().stream() + .map(Assignment::getMember) + .collect(Collectors.toList()) + .stream() + .map(this::makeMemberVo).collect(Collectors.toList()); + + houseWorkAndAssigneeVo.setAssignees(memberVos); + return houseWorkAndAssigneeVo; + }).collect(Collectors.toList()); + final long successCount = houseWorkAndAssignee.stream().filter(HouseWork::getSuccess).count(); + + return new PooClass(response, successCount, houseWorkAndAssignee.size() - successCount); + } + + @NotNull + private HouseWorkAndAssigneeVo.MemberVo makeMemberVo(Member member) { + final HouseWorkAndAssigneeVo.MemberVo memberVo = new HouseWorkAndAssigneeVo.MemberVo(); + memberVo.setMemberId(member.getMemberId()); + memberVo.setMemberName(member.getMemberName()); + memberVo.setProfilePath(member.getProfilePath()); + return memberVo; + } } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/service/member/MemberService.java b/src/main/java/com/depromeet/fairer/service/member/MemberService.java index 7183f17a..318718ca 100644 --- a/src/main/java/com/depromeet/fairer/service/member/MemberService.java +++ b/src/main/java/com/depromeet/fairer/service/member/MemberService.java @@ -1,6 +1,5 @@ package com.depromeet.fairer.service.member; -import com.depromeet.fairer.domain.team.Team; import com.depromeet.fairer.domain.member.Member; import com.depromeet.fairer.global.exception.NoSuchMemberException; @@ -11,6 +10,7 @@ import javax.transaction.Transactional; +import java.util.ArrayList; import java.util.List; @@ -29,11 +29,6 @@ public Member findWithTeam(Long memberId) { return memberRepository.findWithTeamByMemberId(memberId).orElseThrow(()->new NoSuchMemberException("해당하는 멤버를 찾을 수 없습니다.")); } - public List getMemberList(Long memberId){ - Team team = findWithTeam(memberId).getTeam(); - return memberRepository.findAllByTeam(team); - } - public List getMemberListByHouseWorkId(Long houseWorkId) { return memberRepository.getMemberDtoListByHouseWorkId(houseWorkId); } @@ -49,4 +44,9 @@ public Member updateMember(Long memberId, String memberName, String profilePath, member.setProfilePath(profilePath); member.setStatusMessage(statusMessage); return memberRepository.save(member); - }} + } + + public List getMyTeamMembers(Long memberId) { + return memberRepository.getMyTeamMembers(memberId); + } +} diff --git a/src/main/java/com/depromeet/fairer/service/team/TeamService.java b/src/main/java/com/depromeet/fairer/service/team/TeamService.java index ed2637d1..037e2dbf 100644 --- a/src/main/java/com/depromeet/fairer/service/team/TeamService.java +++ b/src/main/java/com/depromeet/fairer/service/team/TeamService.java @@ -6,6 +6,7 @@ import com.depromeet.fairer.global.exception.BadRequestException; import com.depromeet.fairer.global.exception.CannotJoinTeamException; import com.depromeet.fairer.global.exception.MemberTokenNotFoundException; +import com.depromeet.fairer.global.exception.PermissionDeniedException; import com.depromeet.fairer.repository.member.MemberRepository; import com.depromeet.fairer.repository.team.TeamRepository; import com.depromeet.fairer.service.member.MemberService; @@ -124,4 +125,10 @@ public Team getTeam(Long memberId) { .getTeam(); } + + public void validateSameTeam(Long reqMemberId, Long memberId) { + if (memberService.getMyTeamMembers(reqMemberId).stream().noneMatch(m -> m.getMemberId().equals(memberId))) { + throw new PermissionDeniedException("해당 멤버의 정보를 가져올 수 없습니다."); + } + } } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java new file mode 100644 index 00000000..8392e7be --- /dev/null +++ b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java @@ -0,0 +1,42 @@ +package com.depromeet.fairer.vo.houseWork; + +import com.depromeet.fairer.domain.preset.constant.Space; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; + +@Getter @Setter +public class HouseWorkAndAssigneeVo { + + private Long houseWorkId; + + private Space space; + + private String houseWorkName; + + private List assignees; + + private LocalTime scheduledTime; + + private LocalDateTime successDateTime; + + private Boolean success; + + @Getter @Setter + public static class MemberVo{ + private Long memberId; + private String memberName; + private String profilePath; + } +} diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/PooClass.java b/src/main/java/com/depromeet/fairer/vo/houseWork/PooClass.java new file mode 100644 index 00000000..53ee6cb6 --- /dev/null +++ b/src/main/java/com/depromeet/fairer/vo/houseWork/PooClass.java @@ -0,0 +1,15 @@ +package com.depromeet.fairer.vo.houseWork; + +import java.util.List; + +public class PooClass { + private List houseWorkAndAssigneeVos; + private int successCount; + private int leftCount; + + public PooClass(List houseWorkAndAssigneeVos, long successCount, long leftCount) { + this.houseWorkAndAssigneeVos = houseWorkAndAssigneeVos; + this.successCount = (int) successCount; + this.leftCount = (int) leftCount; + } +} From 739b88fc7df565245ceb56d98dc8aaf16cc34359 Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Sun, 26 Jun 2022 03:42:25 +0900 Subject: [PATCH 02/51] temp --- .../housework/HouseWorkCustomRepository.java | 3 ++ .../HouseWorkCustomRepositoryImpl.java | 30 +++++++++++++ .../service/housework/HouseWorkService.java | 45 ++++++++++++++----- .../vo/houseWork/HouseWorkAndAssigneeVo.java | 4 +- .../vo/houseWork/HouseWorkDetailVo.java | 30 +++++++++++++ 5 files changed, 99 insertions(+), 13 deletions(-) create mode 100644 src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java index 2e94f83e..f45e280f 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java @@ -1,6 +1,8 @@ package com.depromeet.fairer.repository.housework; import com.depromeet.fairer.domain.housework.HouseWork; +import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeVo; +import com.depromeet.fairer.vo.houseWork.HouseWorkDetailVo; import java.time.LocalDate; import java.util.List; @@ -9,6 +11,7 @@ public interface HouseWorkCustomRepository { Long getHouseWorkSuccessCount(Long memberId, LocalDate startDate, LocalDate endDate); List getHouseWorkAndAssignee(Long memberId, LocalDate localDate); + List getHouseWorkAndAssignees(Long memberId, LocalDate localDate); // List getHouseWorkList(LocalDate scheduledDate, Long memberId); diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java index 3bec48d3..c7e15681 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java @@ -1,6 +1,12 @@ package com.depromeet.fairer.repository.housework; +import com.depromeet.fairer.domain.assignment.QAssignment; import com.depromeet.fairer.domain.housework.HouseWork; +import com.depromeet.fairer.domain.housework.QHouseWork; +import com.depromeet.fairer.domain.member.QMember; +import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeVo; +import com.depromeet.fairer.vo.houseWork.HouseWorkDetailVo; +import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; @@ -41,5 +47,29 @@ public List getHouseWorkAndAssignee(Long memberId, LocalDate localDat } + @Override + public List getHouseWorkAndAssignees(Long memberId, LocalDate localDate) { + QAssignment assignment1 = QAssignment.assignment; + QMember member = QMember.member; + QAssignment assignment2 = QAssignment.assignment; + QHouseWork houseWork = QHouseWork.houseWork; + return jpaQueryFactory.select(Projections.bean(HouseWorkDetailVo.class, + houseWork.houseWorkId, + houseWork.space, + houseWork.houseWorkName, + houseWork.scheduledTime, + houseWork.successDateTime, + houseWork.success, + member.memberId, + member.memberName, + member.profilePath)) + .from(assignment1) + .innerJoin(houseWork).on(assignment1.houseWork.houseWorkId.eq(houseWork.houseWorkId)) + .innerJoin(assignment2).on(assignment2.houseWork.houseWorkId.eq(houseWork.houseWorkId)) + .innerJoin(member).on(assignment2.member.memberId.eq(member.memberId)) + .where(houseWork.scheduledDate.eq(localDate) + .and(assignment1.member.memberId.eq(memberId))) + .fetch(); + } } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java index e508bbaf..c56bace7 100644 --- a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java +++ b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java @@ -15,6 +15,7 @@ import com.depromeet.fairer.service.member.MemberService; import com.depromeet.fairer.service.team.TeamService; import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeVo; +import com.depromeet.fairer.vo.houseWork.HouseWorkDetailVo; import com.depromeet.fairer.vo.houseWork.HouseWorkUpdateVo; import com.depromeet.fairer.vo.houseWork.PooClass; import lombok.RequiredArgsConstructor; @@ -28,10 +29,7 @@ import java.time.DayOfWeek; import java.time.LocalDateTime; import java.time.temporal.TemporalAdjusters; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; -import java.util.Set; +import java.util.*; import java.util.stream.Collectors; @Slf4j @@ -193,8 +191,30 @@ public HouseWork getHouseWorkById(Long houseWorkId) { public PooClass getTheMemberHouseWorks(Long reqMemberId, Long memberId, LocalDate localDate) { teamService.validateSameTeam(reqMemberId, memberId); + final List houseWorkDetailVoList = houseWorkRepository.getHouseWorkAndAssignees(memberId, localDate); + + Map> houseWorkMap = houseWorkDetailVoList.stream() + .collect(Collectors.groupingBy( + HouseWorkDetailVo::getHouseWorkId, + Collectors.mapping(houseWorkDetailVo -> HouseWorkAndAssigneeVo.MemberVo.builder().memberId(houseWorkDetailVo.getMemberId()).memberName(houseWorkDetailVo.getMemberName()).profilePath(houseWorkDetailVo.getProfilePath()).build(), Collectors.toList()))); + + List response = houseWorkDetailVoList.stream().map(houseWorkDetailVo -> + HouseWorkAndAssigneeVo.builder() + .houseWorkId(houseWorkDetailVo.getHouseWorkId()) + .space(houseWorkDetailVo.getSpace()) + .houseWorkName(houseWorkDetailVo.getHouseWorkName()) + .scheduledTime(houseWorkDetailVo.getScheduledTime()) + .successDateTime(houseWorkDetailVo.getSuccessDateTime()) + .success(houseWorkDetailVo.getSuccess()) + .assignees(houseWorkMap.get(houseWorkDetailVo.getHouseWorkId())) + .build()) + .distinct().collect(Collectors.toList()); + final long successCount = response.stream().filter(HouseWorkAndAssigneeVo::getSuccess).count(); + return new PooClass(response, successCount, response.size() - successCount); + // 이 멤버 아이디로 집안일 조회 // 집안일에 할당된 assignee 리스트 가져오기 + /* final List houseWorkAndAssignee = houseWorkRepository.getHouseWorkAndAssignee(memberId, localDate); final List response = houseWorkAndAssignee.stream().map(h -> { @@ -217,14 +237,15 @@ public PooClass getTheMemberHouseWorks(Long reqMemberId, Long memberId, LocalDat final long successCount = houseWorkAndAssignee.stream().filter(HouseWork::getSuccess).count(); return new PooClass(response, successCount, houseWorkAndAssignee.size() - successCount); + */ } - @NotNull - private HouseWorkAndAssigneeVo.MemberVo makeMemberVo(Member member) { - final HouseWorkAndAssigneeVo.MemberVo memberVo = new HouseWorkAndAssigneeVo.MemberVo(); - memberVo.setMemberId(member.getMemberId()); - memberVo.setMemberName(member.getMemberName()); - memberVo.setProfilePath(member.getProfilePath()); - return memberVo; - } +// @NotNull +// private HouseWorkAndAssigneeVo.MemberVo makeMemberVo(Member member) { +// final HouseWorkAndAssigneeVo.MemberVo memberVo = new HouseWorkAndAssigneeVo.MemberVo(); +// memberVo.setMemberId(member.getMemberId()); +// memberVo.setMemberName(member.getMemberName()); +// memberVo.setProfilePath(member.getProfilePath()); +// return memberVo; +// } } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java index 8392e7be..6cb1fb6c 100644 --- a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java +++ b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java @@ -7,6 +7,7 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; import io.swagger.annotations.ApiModelProperty; +import lombok.Builder; import lombok.Getter; import lombok.Setter; import org.springframework.stereotype.Service; @@ -17,6 +18,7 @@ import java.util.List; @Getter @Setter +@Builder public class HouseWorkAndAssigneeVo { private Long houseWorkId; @@ -33,7 +35,7 @@ public class HouseWorkAndAssigneeVo { private Boolean success; - @Getter @Setter + @Getter @Setter @Builder public static class MemberVo{ private Long memberId; private String memberName; diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java new file mode 100644 index 00000000..a4840e50 --- /dev/null +++ b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java @@ -0,0 +1,30 @@ +package com.depromeet.fairer.vo.houseWork; + +import com.depromeet.fairer.domain.preset.constant.Space; +import lombok.Getter; +import lombok.Setter; + +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.List; + +@Getter +@Setter +public class HouseWorkDetailVo { + + private Long houseWorkId; + + private Space space; + + private String houseWorkName; + + private LocalTime scheduledTime; + + private LocalDateTime successDateTime; + + private Boolean success; + + private Long memberId; + private String memberName; + private String profilePath; +} From 9fe7f23bdd96398d57c3ca21ced5a0a6004be218 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Mon, 27 Jun 2022 02:03:16 +0900 Subject: [PATCH 03/51] =?UTF-8?q?refactor=20#96:=20=ED=8A=B9=EC=A0=95=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84,=20=EB=82=A0=EC=A7=9C=EB=A1=9C=20=EC=A7=91?= =?UTF-8?q?=EC=95=88=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EC=BF=BC?= =?UTF-8?q?=EB=A6=AC=20=EB=A7=8E=EC=9D=80=20=EB=AC=B8=EC=A0=9C=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairer/api/HouseWorkController.java | 15 ++---- .../member/MemberCustomRepositoryImpl.java | 18 +++---- .../service/housework/HouseWorkService.java | 51 ++++--------------- .../HouseWorkAndAssigneeResponseDto.java | 30 +++++++++++ .../fairer/vo/houseWork/PooClass.java | 15 ------ 5 files changed, 53 insertions(+), 76 deletions(-) create mode 100644 src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeResponseDto.java delete mode 100644 src/main/java/com/depromeet/fairer/vo/houseWork/PooClass.java diff --git a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java index a94ec9b7..3a47f6a0 100644 --- a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java +++ b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java @@ -1,8 +1,5 @@ package com.depromeet.fairer.api; -import com.depromeet.fairer.domain.housework.HouseWork; -import com.depromeet.fairer.domain.member.Member; -import com.depromeet.fairer.dto.member.MemberDto; import com.depromeet.fairer.global.resolver.RequestMemberId; import com.depromeet.fairer.global.util.DateTimeUtils; import com.depromeet.fairer.service.housework.HouseWorkService; @@ -13,7 +10,7 @@ import com.depromeet.fairer.service.member.MemberService; import com.depromeet.fairer.vo.houseWork.HouseWorkUpdateVo; -import com.depromeet.fairer.vo.houseWork.PooClass; +import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeResponseDto; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.v3.oas.annotations.tags.Tag; @@ -27,9 +24,7 @@ import javax.validation.Valid; import java.time.LocalDate; -import java.util.ArrayList; import java.util.List; -import java.util.stream.Collectors; @Slf4j @RestController @@ -75,11 +70,11 @@ public ResponseEntity deleteHouseWork( @Tag(name = "houseWorks") @ApiOperation(value = "특정 멤버의 날짜별 집안일 조회", notes = "특정 멤버의 날짜별 집안일 조회") @GetMapping("") - public ResponseEntity getTheMemberHouseWork(@RequestParam("reqDate") String reqDate, - @RequestParam("memberId") Long memberId, - @ApiIgnore @RequestMemberId Long reqMemberId) { + public ResponseEntity getTheMemberHouseWork(@RequestParam("reqDate") String reqDate, + @RequestParam("memberId") Long memberId, + @ApiIgnore @RequestMemberId Long reqMemberId) { final LocalDate localDate = DateTimeUtils.stringToLocalDate(reqDate); - final PooClass theMemberHouseWorks = houseWorkService.getTheMemberHouseWorks(reqMemberId, memberId, localDate); + final HouseWorkAndAssigneeResponseDto theMemberHouseWorks = houseWorkService.getTheMemberHouseWorks(reqMemberId, memberId, localDate); return ResponseEntity.ok(theMemberHouseWorks); } diff --git a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java index 8e14b114..917bd02c 100644 --- a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java +++ b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java @@ -31,16 +31,14 @@ public List getMemberDtoListByHouseWorkId(Long houseWorkId){ @Override public List getMyTeamMembers(Long memberId) { - final QMember teamMember = new QMember("teamMember"); - final QTeam aTeam = new QTeam("ATeam"); -// return jpaQueryFactory.select(teamMember) -// .leftJoin(teamMember.team, ateam) -// .where(JPAExpressions -// .selectFrom(team) -// .leftJoin(member.team, team) -// .where(member.memberId.eq(memberId)) -// ), aTeam).fetch(); - return null; + final QMember member1 = QMember.member; + final QMember member2 = QMember.member; + final QTeam team = QTeam.team; + return jpaQueryFactory.select(member1) + .from(team) + .innerJoin(member2).on(member2.team.eq(team)) + .where(member2.memberId.eq(memberId)) + .fetch(); } } diff --git a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java index c56bace7..30073a05 100644 --- a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java +++ b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java @@ -17,7 +17,7 @@ import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeVo; import com.depromeet.fairer.vo.houseWork.HouseWorkDetailVo; import com.depromeet.fairer.vo.houseWork.HouseWorkUpdateVo; -import com.depromeet.fairer.vo.houseWork.PooClass; +import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeResponseDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.jetbrains.annotations.NotNull; @@ -189,16 +189,23 @@ public HouseWork getHouseWorkById(Long houseWorkId) { .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 집안일 입니다.")); } - public PooClass getTheMemberHouseWorks(Long reqMemberId, Long memberId, LocalDate localDate) { + public HouseWorkAndAssigneeResponseDto getTheMemberHouseWorks(Long reqMemberId, Long memberId, LocalDate localDate) { teamService.validateSameTeam(reqMemberId, memberId); final List houseWorkDetailVoList = houseWorkRepository.getHouseWorkAndAssignees(memberId, localDate); + List houseWorkAndAssigneeVos = makeHouseWorkAndAssigneeVos(houseWorkDetailVoList); + final long successCount = houseWorkAndAssigneeVos.stream().filter(HouseWorkAndAssigneeVo::getSuccess).count(); + return new HouseWorkAndAssigneeResponseDto(houseWorkAndAssigneeVos, successCount, houseWorkAndAssigneeVos.size() - successCount); + } + + @NotNull + private List makeHouseWorkAndAssigneeVos(List houseWorkDetailVoList) { Map> houseWorkMap = houseWorkDetailVoList.stream() .collect(Collectors.groupingBy( HouseWorkDetailVo::getHouseWorkId, Collectors.mapping(houseWorkDetailVo -> HouseWorkAndAssigneeVo.MemberVo.builder().memberId(houseWorkDetailVo.getMemberId()).memberName(houseWorkDetailVo.getMemberName()).profilePath(houseWorkDetailVo.getProfilePath()).build(), Collectors.toList()))); - List response = houseWorkDetailVoList.stream().map(houseWorkDetailVo -> + return houseWorkDetailVoList.stream().map(houseWorkDetailVo -> HouseWorkAndAssigneeVo.builder() .houseWorkId(houseWorkDetailVo.getHouseWorkId()) .space(houseWorkDetailVo.getSpace()) @@ -209,43 +216,5 @@ public PooClass getTheMemberHouseWorks(Long reqMemberId, Long memberId, LocalDat .assignees(houseWorkMap.get(houseWorkDetailVo.getHouseWorkId())) .build()) .distinct().collect(Collectors.toList()); - final long successCount = response.stream().filter(HouseWorkAndAssigneeVo::getSuccess).count(); - return new PooClass(response, successCount, response.size() - successCount); - - // 이 멤버 아이디로 집안일 조회 - // 집안일에 할당된 assignee 리스트 가져오기 - /* - final List houseWorkAndAssignee = houseWorkRepository.getHouseWorkAndAssignee(memberId, localDate); - - final List response = houseWorkAndAssignee.stream().map(h -> { - final HouseWorkAndAssigneeVo houseWorkAndAssigneeVo = new HouseWorkAndAssigneeVo(); - houseWorkAndAssigneeVo.setHouseWorkId(h.getHouseWorkId()); - houseWorkAndAssigneeVo.setSpace(h.getSpace()); - houseWorkAndAssigneeVo.setScheduledTime(h.getScheduledTime()); - houseWorkAndAssigneeVo.setSuccessDateTime(h.getSuccessDateTime()); - houseWorkAndAssigneeVo.setSuccess(h.getSuccess()); - - final List memberVos = h.getAssignments().stream() - .map(Assignment::getMember) - .collect(Collectors.toList()) - .stream() - .map(this::makeMemberVo).collect(Collectors.toList()); - - houseWorkAndAssigneeVo.setAssignees(memberVos); - return houseWorkAndAssigneeVo; - }).collect(Collectors.toList()); - final long successCount = houseWorkAndAssignee.stream().filter(HouseWork::getSuccess).count(); - - return new PooClass(response, successCount, houseWorkAndAssignee.size() - successCount); - */ } - -// @NotNull -// private HouseWorkAndAssigneeVo.MemberVo makeMemberVo(Member member) { -// final HouseWorkAndAssigneeVo.MemberVo memberVo = new HouseWorkAndAssigneeVo.MemberVo(); -// memberVo.setMemberId(member.getMemberId()); -// memberVo.setMemberName(member.getMemberName()); -// memberVo.setProfilePath(member.getProfilePath()); -// return memberVo; -// } } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeResponseDto.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeResponseDto.java new file mode 100644 index 00000000..be1b175a --- /dev/null +++ b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeResponseDto.java @@ -0,0 +1,30 @@ +package com.depromeet.fairer.vo.houseWork; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@NoArgsConstructor @AllArgsConstructor +@ApiModel(value = "특정 멤버, 날짜에 할당된 집안일 모두 조회 반환 객체", description = "특정 멤버, 날짜에 할당된 집안일 모두 조회 반환 객체") +public class HouseWorkAndAssigneeResponseDto { + + @ApiModelProperty(value = "집안일, 담당자 객체 리스트") + private List houseWorkAndAssigneeVos; + + @ApiModelProperty(value = "완료한 집안일 갯수") + private int successCount; + + @ApiModelProperty(value = "남은 집안일 갯수") + private int leftCount; + + public HouseWorkAndAssigneeResponseDto(List houseWorkAndAssigneeVos, long successCount, long leftCount) { + this.houseWorkAndAssigneeVos = houseWorkAndAssigneeVos; + this.successCount = (int) successCount; + this.leftCount = (int) leftCount; + } +} diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/PooClass.java b/src/main/java/com/depromeet/fairer/vo/houseWork/PooClass.java deleted file mode 100644 index 53ee6cb6..00000000 --- a/src/main/java/com/depromeet/fairer/vo/houseWork/PooClass.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.depromeet.fairer.vo.houseWork; - -import java.util.List; - -public class PooClass { - private List houseWorkAndAssigneeVos; - private int successCount; - private int leftCount; - - public PooClass(List houseWorkAndAssigneeVos, long successCount, long leftCount) { - this.houseWorkAndAssigneeVos = houseWorkAndAssigneeVos; - this.successCount = (int) successCount; - this.leftCount = (int) leftCount; - } -} From 3e4d6f513554ca24fc628b55860b7d8bb537f523 Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Mon, 27 Jun 2022 16:21:41 +0900 Subject: [PATCH 04/51] fix:rule limit check logic --- .../depromeet/fairer/api/RuleController.java | 26 +++++++++++-------- .../dto/rule/request/RuleRequestDto.java | 4 ++- .../repository/rule/RuleRepository.java | 1 + .../fairer/service/rule/RuleService.java | 12 +++++---- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/api/RuleController.java b/src/main/java/com/depromeet/fairer/api/RuleController.java index 9546e2d0..48a160ca 100644 --- a/src/main/java/com/depromeet/fairer/api/RuleController.java +++ b/src/main/java/com/depromeet/fairer/api/RuleController.java @@ -1,13 +1,14 @@ package com.depromeet.fairer.api; import com.depromeet.fairer.domain.rule.Rule; +import com.depromeet.fairer.domain.team.Team; import com.depromeet.fairer.dto.common.CommonApiResult; import com.depromeet.fairer.dto.rule.request.RuleRequestDto; import com.depromeet.fairer.dto.rule.response.RuleResponseDto; import com.depromeet.fairer.dto.rule.response.RulesResponseDto; +import com.depromeet.fairer.global.exception.BadRequestException; import com.depromeet.fairer.global.resolver.RequestMemberId; import com.depromeet.fairer.service.member.MemberService; import com.depromeet.fairer.service.rule.RuleService; -import com.depromeet.fairer.service.team.TeamService; import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; @@ -20,6 +21,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import static org.springframework.http.ResponseEntity.ok; @@ -31,7 +33,6 @@ public class RuleController { private final RuleService ruleService; - private final TeamService teamService; private final MemberService memberService; @Tag(name = "rules") @@ -39,19 +40,22 @@ public class RuleController { @PostMapping(value = "") public ResponseEntity createTeamRules(@ApiIgnore @RequestMemberId Long memberId, @RequestBody @Valid RuleRequestDto req){ + Team team = memberService.findWithTeam(memberId).getTeam(); + + // 규칙 조회 + Long count = ruleService.countRules(team); + if(count >= 10) { + throw new BadRequestException("규칙은 최대 10개까지 생성할 수 있습니다."); + } + // 규칙 생성 - Rule rule = ruleService.createRules(memberId, req.getRuleName()); + ruleService.createRules(team, req.getRuleName()); // 반환 객체 생성 - List rules = ruleService.findAllByTeam(rule.getTeam()); - - List ruleResponseDtos = new ArrayList<>(); - for(Rule rulee : rules){ - ruleResponseDtos.add(RuleResponseDto.createRule(rulee)); - } + List rules = ruleService.findAllByTeam(team); - Long teamId = memberService.findWithTeam(memberId).getTeam().getTeamId(); - return ok(RulesResponseDto.createRules(teamId, ruleResponseDtos)); + List ruleResponseDtos = rules.stream().map(RuleResponseDto::createRule).collect(Collectors.toList()); + return ok(RulesResponseDto.createRules(team.getTeamId(), ruleResponseDtos)); } @Tag(name = "rules") diff --git a/src/main/java/com/depromeet/fairer/dto/rule/request/RuleRequestDto.java b/src/main/java/com/depromeet/fairer/dto/rule/request/RuleRequestDto.java index ce587f7a..002dc5ce 100644 --- a/src/main/java/com/depromeet/fairer/dto/rule/request/RuleRequestDto.java +++ b/src/main/java/com/depromeet/fairer/dto/rule/request/RuleRequestDto.java @@ -7,13 +7,15 @@ import lombok.Data; import lombok.NoArgsConstructor; +import javax.validation.constraints.NotBlank; + @Data @Builder @NoArgsConstructor @AllArgsConstructor @ApiModel(value = "팀 규칙 요청 객체", description = "팀 규칙 요청 객체") public class RuleRequestDto { - @ApiModelProperty(value = "규칙 이름") + @NotBlank private String ruleName; } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/repository/rule/RuleRepository.java b/src/main/java/com/depromeet/fairer/repository/rule/RuleRepository.java index c141dd82..8144f195 100644 --- a/src/main/java/com/depromeet/fairer/repository/rule/RuleRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/rule/RuleRepository.java @@ -11,4 +11,5 @@ public interface RuleRepository extends JpaRepository { List findAllByTeam(Team team); + long countByTeam(Team team); } diff --git a/src/main/java/com/depromeet/fairer/service/rule/RuleService.java b/src/main/java/com/depromeet/fairer/service/rule/RuleService.java index b1b2a185..2a6d3ca3 100644 --- a/src/main/java/com/depromeet/fairer/service/rule/RuleService.java +++ b/src/main/java/com/depromeet/fairer/service/rule/RuleService.java @@ -21,12 +21,9 @@ public class RuleService { private final MemberService memberService; @Transactional - public Rule createRules(Long memberId, String ruleName){ - Team team = memberService.findWithTeam(memberId).getTeam(); + public Rule createRules(Team team, String ruleName){ Rule rule = Rule.builder().team(team).ruleName(ruleName).build(); - ruleRepository.save(rule); - - return rule; + return ruleRepository.save(rule); } @Transactional @@ -43,4 +40,9 @@ public List deleteRules(Long memberId, Long ruleId){ public List findAllByTeam(Team team) { return ruleRepository.findAllByTeam(team); } + + public Long countRules(Team team) { + return ruleRepository.countByTeam(team); + } + } From 3c1e6a32ee0f1d2b69c133201e3ba818c05c00ee Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Mon, 27 Jun 2022 18:10:30 +0900 Subject: [PATCH 05/51] refactor:member logic --- .../java/com/depromeet/fairer/api/MemberController.java | 2 +- .../fairer/domain/member/constant/ProfileImage.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/api/MemberController.java b/src/main/java/com/depromeet/fairer/api/MemberController.java index a76978df..68639795 100644 --- a/src/main/java/com/depromeet/fairer/api/MemberController.java +++ b/src/main/java/com/depromeet/fairer/api/MemberController.java @@ -57,7 +57,7 @@ public ResponseEntity getDefaultProfileImageList( @ApiOperation(value = "멤버 업데이트", notes = "멤버 정보 업데이트

" + "멤버 이름
프로필 url") @PatchMapping(value = "") - public ResponseEntity updateTeam(@ApiIgnore @RequestMemberId Long memberId, @RequestBody MemberUpdateRequestDto requestDto) { + public ResponseEntity updateTeam(@ApiIgnore @RequestMemberId Long memberId, @Valid @RequestBody MemberUpdateRequestDto requestDto) { // TODO 이름, url 정규식 검증 memberService.updateMember(memberId, requestDto.getMemberName(), requestDto.getProfilePath(), requestDto.getStatusMessage()); return ResponseEntity.ok(CommonApiResult.createOk("멤버 정보가 업데이트 되었습니다.")); diff --git a/src/main/java/com/depromeet/fairer/domain/member/constant/ProfileImage.java b/src/main/java/com/depromeet/fairer/domain/member/constant/ProfileImage.java index 531ff6c2..a11f9d2c 100644 --- a/src/main/java/com/depromeet/fairer/domain/member/constant/ProfileImage.java +++ b/src/main/java/com/depromeet/fairer/domain/member/constant/ProfileImage.java @@ -31,6 +31,10 @@ public enum ProfileImage { final String bigImageName; public static List getBigImageFullPathList(String domain, String path) { - return Arrays.stream(values()).map(profileImage -> UriComponentsBuilder.fromHttpUrl(domain).path(path).path(profileImage.bigImageName).build().toString()).collect(Collectors.toList()); + return Arrays.stream(values()) + .map(profileImage -> UriComponentsBuilder.fromHttpUrl(domain) + .path(path).path(profileImage.bigImageName) + .build().toString()) + .collect(Collectors.toList()); } } From d81f3851dbc8612402d4e3bf31a50cb240e21d5e Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Wed, 29 Jun 2022 01:33:16 +0900 Subject: [PATCH 06/51] =?UTF-8?q?feat:=20=EA=B0=99=EC=9D=80=20=ED=8C=80?= =?UTF-8?q?=EC=9D=98=20=EB=AA=A8=EB=93=A0=20=ED=8A=B9=EC=A0=95=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EC=A7=91=EC=95=88=EC=9D=BC=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairer/api/HouseWorkController.java | 9 ++++++ .../housework/HouseWorkCustomRepository.java | 3 +- .../HouseWorkCustomRepositoryImpl.java | 28 ++++++++++++++++++- .../housework/HouseWorkRepository.java | 2 ++ .../service/housework/HouseWorkService.java | 7 +++++ 5 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java index 3a47f6a0..33014a15 100644 --- a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java +++ b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java @@ -78,6 +78,15 @@ public ResponseEntity getTheMemberHouseWork(@Re return ResponseEntity.ok(theMemberHouseWorks); } + @Tag(name = "houseWorks") + @ApiOperation(value = "특정 날짜별 집안일 조회", notes = "특정 날짜별 집안일 조회") + @GetMapping("/date") + public ResponseEntity getHouseWorkByDate(@RequestParam("reqDate") String reqDate, @ApiIgnore @RequestMemberId Long reqMemberId) { + final LocalDate localDate = DateTimeUtils.stringToLocalDate(reqDate); + final HouseWorkAndAssigneeResponseDto responseDto = houseWorkService.getHouseWorkByDate(reqMemberId, localDate); + return ResponseEntity.ok(responseDto); + } + // @Tag(name = "houseWorks") // @ApiOperation(value = "날짜별 집안일 조회", notes = "본인 포함 팀원들의 집안일까지 모두 조회") // @GetMapping(value = "") diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java index f45e280f..b6ffbcba 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java @@ -1,7 +1,6 @@ package com.depromeet.fairer.repository.housework; import com.depromeet.fairer.domain.housework.HouseWork; -import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeVo; import com.depromeet.fairer.vo.houseWork.HouseWorkDetailVo; import java.time.LocalDate; @@ -13,6 +12,8 @@ public interface HouseWorkCustomRepository { List getHouseWorkAndAssignee(Long memberId, LocalDate localDate); List getHouseWorkAndAssignees(Long memberId, LocalDate localDate); + List getHouseWorkAndAssigneesByDate(Long reqMemberId, LocalDate localDate); + // List getHouseWorkList(LocalDate scheduledDate, Long memberId); } diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java index c7e15681..aa1bd800 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java @@ -4,7 +4,7 @@ import com.depromeet.fairer.domain.housework.HouseWork; import com.depromeet.fairer.domain.housework.QHouseWork; import com.depromeet.fairer.domain.member.QMember; -import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeVo; +import com.depromeet.fairer.domain.team.QTeam; import com.depromeet.fairer.vo.houseWork.HouseWorkDetailVo; import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -72,4 +72,30 @@ public List getHouseWorkAndAssignees(Long memberId, LocalDate .and(assignment1.member.memberId.eq(memberId))) .fetch(); } + + @Override + public List getHouseWorkAndAssigneesByDate(Long reqMemberId, LocalDate localDate) { + QMember reqMember = QMember.member; + QHouseWork houseWork = QHouseWork.houseWork; + QTeam team = QTeam.team; + + return jpaQueryFactory.select(Projections.bean(HouseWorkDetailVo.class, + houseWork.houseWorkId, + houseWork.space, + houseWork.houseWorkName, + houseWork.scheduledTime, + houseWork.successDateTime, + houseWork.success, + member.memberId, + member.memberName, + member.profilePath)) + .from(team) + .innerJoin(reqMember).on(reqMember.team.teamId.eq(team.teamId)) + .innerJoin(member).on(member.team.teamId.eq(team.teamId)) + .innerJoin(assignment).on(assignment.member.memberId.eq(member.memberId)) + .innerJoin(houseWork).on(assignment.houseWork.houseWorkId.eq(houseWork.houseWorkId)) + .where(reqMember.memberId.eq(reqMemberId) + .and(houseWork.scheduledDate.eq(localDate))) + .fetch(); + } } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java index 27fa0b00..19e3a49b 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java @@ -3,6 +3,7 @@ import com.depromeet.fairer.domain.assignment.Assignment; import com.depromeet.fairer.domain.housework.HouseWork; import com.depromeet.fairer.domain.member.Member; +import com.depromeet.fairer.domain.team.Team; import org.apache.tomcat.jni.Local; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; @@ -18,6 +19,7 @@ public interface HouseWorkRepository extends JpaRepository, HouseWorkCustomRepository { List findAllByScheduledDateAndAssignmentsIn(LocalDate scheduledDate, List assignments); + // @EntityGraph(attributePaths = {"assignments"}) // List findHouseWorksByMember(Member member); } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java index 30073a05..c4804dd1 100644 --- a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java +++ b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java @@ -217,4 +217,11 @@ private List makeHouseWorkAndAssigneeVos(List houseWorkDetailVos = houseWorkRepository.getHouseWorkAndAssigneesByDate(reqMemberId, localDate); + final List houseWorkAndAssigneeVos = makeHouseWorkAndAssigneeVos(houseWorkDetailVos); + final long successCount = houseWorkAndAssigneeVos.stream().filter(HouseWorkAndAssigneeVo::getSuccess).count(); + return new HouseWorkAndAssigneeResponseDto(houseWorkAndAssigneeVos, successCount, houseWorkDetailVos.size() - successCount); + } } \ No newline at end of file From 068b6443f4a51808740c13113a9f85a01eb8b859 Mon Sep 17 00:00:00 2001 From: daeunkwak <77181984+daeunkwak@users.noreply.github.com> Date: Wed, 29 Jun 2022 15:13:57 +0900 Subject: [PATCH 07/51] Create README.md --- README.md | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..33a529bb --- /dev/null +++ b/README.md @@ -0,0 +1,89 @@ +# 🧹 fairer +

+ + + +

+ +
+집안일을 하는 모든 이들의 평화를 위한 집안일 관리, 분담 서비스 👨‍👧‍👧
+fairer의 백엔드 레포지토리 입니다. +> Play 스토어 : link + +
+ +## 🎬 Preview +    + +
+ +## 👨‍👩‍👧‍👧 BackEnd Developer + + + +| | | | | +| :-----------------------------------: | :-----------------: | :----------------: |:----------------: | +| [김승윤](https://github.com/dskym) | [신동빈](https://github.com/SDB016) | [김다슬](https://github.com/daseulll) | [곽다은](https://github.com/daeunkwak) | + +
+ +## **💻 Tech Stack** + +- Skills + + > Spring Boot, Data JPA(+Querydsl) + > +- Database + + > Mysql, RDS + > +- 개발 환경 + + > AWS EC2 + > +- 운영 환경 + + > Elastic Beanstalk + > +- CI/CD + + > [Github Actions](https://github.com/depromeet/fairer-be/actions) + > +- 문서화 + + > [Swagger](http://ec2-13-125-232-180.ap-northeast-2.compute.amazonaws.com:8080/swagger-ui/index.html) + > +- ETC + + > JWT, Oauth2(google) + + > Spring Batch + > + +
+ +## 📚 Architecture + + +
+ +## 📝ERD + + +## 📢 Commit message + + +`feat` : 새로운 기능에 대한 커밋 + +`fix` : 버그 수정에 대한 커밋 + +`refactor` : 새로운 기능 추가나 수정 없이 기존 코드 리팩토링 + +`docs` : 문서화에 대한 커밋 + + +
+ +## 📞 Contact +[![Facebook](https://img.shields.io/badge/facebook-1877f2?style=flat-square&logo=facebook&logoColor=white&link=https://www.facebook.com/fairer.official/)](https://www.facebook.com/fairer.official) +[![instagram](https://img.shields.io/badge/instagram-E4405F?style=flat-square&logo=Instagram&logoColor=white&link=https://www.instagram.com/fairer.official/)](https://www.instagram.com/fairer.official/) From 9a91db1ded5e6b306901e74b2c87a8d31710de77 Mon Sep 17 00:00:00 2001 From: daeunkwak <77181984+daeunkwak@users.noreply.github.com> Date: Thu, 30 Jun 2022 21:50:24 +0900 Subject: [PATCH 08/51] Update README.md --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 33a529bb..51979a4b 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,27 @@ fairer의 백엔드 레포지토리 입니다.
+## 🗂 Directory +``` +📂 fairer + 📂 api + 📂 domain + 📂 dto + 📂 global + ├── 📂 config + ├── 📂 exception + | ├── 📂 dto + | └── 📂 handler + ├── 📂 resolver + └── 📂 util + 📂 repository + 📂 service + 📂 vo + - Application.java +``` + +
+ ## 📝ERD From 1c83bb841a0e3e42e4ca1a3b1f0e2f95d34c1ea8 Mon Sep 17 00:00:00 2001 From: daeunkwak <77181984+daeunkwak@users.noreply.github.com> Date: Thu, 7 Jul 2022 21:15:33 +0900 Subject: [PATCH 09/51] Update README.md --- README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 51979a4b..125b3b9c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@
집안일을 하는 모든 이들의 평화를 위한 집안일 관리, 분담 서비스 👨‍👧‍👧
fairer의 백엔드 레포지토리 입니다. -> Play 스토어 : link +> Play 스토어 : https://play.google.com/store/apps/details?id=com.depromeet.housekeeper
@@ -91,6 +91,22 @@ fairer의 백엔드 레포지토리 입니다. ## 📝ERD +
+ +## 💻 Build & Run +1. 빌드 +``` +$ ./gradlew build +``` +2. 빌드된 파일 (*.jar) 실행 +``` +$ fairer-0.0.1-SNAPSHOT.jar +$ java -jar fairer-0.0.1-SNAPSHOT.jar +``` + +
+ + ## 📢 Commit message From 69c10e995a4c8f73ea19b291b2c624543adaa8f3 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sat, 23 Jul 2022 20:13:59 +0900 Subject: [PATCH 10/51] Create dev-fairer-jib --- .github/workflows/dev-fairer-jib | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/dev-fairer-jib diff --git a/.github/workflows/dev-fairer-jib b/.github/workflows/dev-fairer-jib new file mode 100644 index 00000000..1e7fee42 --- /dev/null +++ b/.github/workflows/dev-fairer-jib @@ -0,0 +1,53 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle + +name: dev-fairer + +on: + workflow_dispatch: + push: + branches: [ develop ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew # gradle wrapper를 실행할 수 있도록 권한 부여 + shell: bash + + - name: JIB Build with Gradle + run: ./gradlew clean jib # 프로젝트 빌드 + shell: bash + + - name: Get current time + uses: 1466587594/get-current-time@v2 # 빌드 완료 시간 가져오기 + id: current-time + with: + format: YYYY-MM-DD-HH-mm-ss + utcOffset: "+09:00" + + - name: Show Current Time + run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" # 빌드 완료 시간 출력하기 + shell: bash + From 8c30dc75446cb56cf9f7ebf3a47085e275686615 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sat, 23 Jul 2022 20:17:17 +0900 Subject: [PATCH 11/51] =?UTF-8?q?feat:=20build.gradle=EC=97=90=20jib=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 --- build.gradle | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/build.gradle b/build.gradle index ae293601..b673419e 100644 --- a/build.gradle +++ b/build.gradle @@ -3,9 +3,24 @@ plugins { id 'io.spring.dependency-management' version '1.0.11.RELEASE' // querydsl 추가 id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" + // jib + id 'com.google.cloud.tools.jib' version '3.2.1' id 'java' } +jib { + from { + image = "adoptopenjdk/openjdk16:x86_64-alpine-jdk-16.0.1_9" + } + to { + image = "ehdqls4013/fairer-dev-repo" + tags = ["latest"] + } + container { + jvmFlags = ["-Xms128m", "-Xmx128m"] + } +} + group = 'com.depromeet' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' From dffd2c806df3d165bcbd579677aca6aa3a36a07e Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sat, 23 Jul 2022 20:18:41 +0900 Subject: [PATCH 12/51] Rename dev-fairer-jib to dev-fairer-jib.yml --- .github/workflows/{dev-fairer-jib => dev-fairer-jib.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{dev-fairer-jib => dev-fairer-jib.yml} (100%) diff --git a/.github/workflows/dev-fairer-jib b/.github/workflows/dev-fairer-jib.yml similarity index 100% rename from .github/workflows/dev-fairer-jib rename to .github/workflows/dev-fairer-jib.yml From 40a945bb0c8fe78c8ea306b752e9ccb5c02866ca Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sat, 23 Jul 2022 20:20:55 +0900 Subject: [PATCH 13/51] Update dev-fairer-jib.yml --- .github/workflows/dev-fairer-jib.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev-fairer-jib.yml b/.github/workflows/dev-fairer-jib.yml index 1e7fee42..2d9c2cc4 100644 --- a/.github/workflows/dev-fairer-jib.yml +++ b/.github/workflows/dev-fairer-jib.yml @@ -37,7 +37,7 @@ jobs: shell: bash - name: JIB Build with Gradle - run: ./gradlew clean jib # 프로젝트 빌드 + run: ./gradlew jib # 프로젝트 빌드 shell: bash - name: Get current time From a5fe12dd01e0dcb5080294b11c227dd962676848 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sat, 23 Jul 2022 21:58:14 +0900 Subject: [PATCH 14/51] =?UTF-8?q?feat:=20=ED=83=9C=EA=B7=B8=20=EB=B0=8F=20?= =?UTF-8?q?=EB=8F=84=EC=BB=A4=20=ED=97=88=EB=B8=8C=20url,=20jvm=20?= =?UTF-8?q?=EC=98=B5=EC=85=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index b673419e..5d06d33f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import java.text.SimpleDateFormat + plugins { id 'org.springframework.boot' version '2.6.5' id 'io.spring.dependency-management' version '1.0.11.RELEASE' @@ -13,11 +15,12 @@ jib { image = "adoptopenjdk/openjdk16:x86_64-alpine-jdk-16.0.1_9" } to { - image = "ehdqls4013/fairer-dev-repo" - tags = ["latest"] + image = "registry.hub.docker.com/ehdqls4013/fairer-dev-repo" + tags = ['latest', new SimpleDateFormat('yyyyMMddHHmmss').format(System.currentTimeMillis())] // 2개의 태그에 모두 push } container { - jvmFlags = ["-Xms128m", "-Xmx128m"] + creationTime = "USE_CURRENT_TIMESTAMP" + jvmFlags = ['-Dspring.profiles.active=dev', '-XX:+UseContainerSupport', '-Dfile.encoding=UTF-8'] } } From 0ce90ca4c953bcd942fd8fd8e5935750cd63556c Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sat, 23 Jul 2022 22:05:56 +0900 Subject: [PATCH 15/51] Update dev-fairer-jib.yml --- .github/workflows/dev-fairer-jib.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/dev-fairer-jib.yml b/.github/workflows/dev-fairer-jib.yml index 2d9c2cc4..6a915ad9 100644 --- a/.github/workflows/dev-fairer-jib.yml +++ b/.github/workflows/dev-fairer-jib.yml @@ -35,6 +35,10 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x ./gradlew # gradle wrapper를 실행할 수 있도록 권한 부여 shell: bash + + - name: Set timezone to Seoul + run: sudo timedatectl set-timezone Asia/Seoul + shell: bash - name: JIB Build with Gradle run: ./gradlew jib # 프로젝트 빌드 From ee52188b0975639f064f5fde7c1256675501e405 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sat, 23 Jul 2022 23:49:04 +0900 Subject: [PATCH 16/51] Update dev-fairer-jib.yml --- .github/workflows/dev-fairer-jib.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/dev-fairer-jib.yml b/.github/workflows/dev-fairer-jib.yml index 6a915ad9..e76f23e2 100644 --- a/.github/workflows/dev-fairer-jib.yml +++ b/.github/workflows/dev-fairer-jib.yml @@ -54,4 +54,14 @@ jobs: - name: Show Current Time run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" # 빌드 완료 시간 출력하기 shell: bash + + deploy: + needs: build + name: Deploy + runs-on: [ self-hosted ] + steps: + - name: Docker run + run: | + sudo docker ps -q --filter "name=fairer-dev" | grep -q . && sudo docker stop "fairer-dev" && sudo docker rmi "ehdqls4013/fairer:lastest" + sudo docker run -d --name fairer-dev --rm -p 8080:8080 ehdqls4013/fairer:lastest From bd6aff35f0de9b584add189fdbd6872041d5c091 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sat, 23 Jul 2022 23:53:43 +0900 Subject: [PATCH 17/51] Update dev-fairer-jib.yml --- .github/workflows/dev-fairer-jib.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev-fairer-jib.yml b/.github/workflows/dev-fairer-jib.yml index e76f23e2..75779048 100644 --- a/.github/workflows/dev-fairer-jib.yml +++ b/.github/workflows/dev-fairer-jib.yml @@ -58,7 +58,7 @@ jobs: deploy: needs: build name: Deploy - runs-on: [ self-hosted ] + runs-on: self-hosted steps: - name: Docker run run: | From 901d8f394ebc2b23b27619f154dc058c932ee201 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sat, 23 Jul 2022 23:56:12 +0900 Subject: [PATCH 18/51] Update dev-fairer-jib.yml --- .github/workflows/dev-fairer-jib.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dev-fairer-jib.yml b/.github/workflows/dev-fairer-jib.yml index 75779048..a10016ae 100644 --- a/.github/workflows/dev-fairer-jib.yml +++ b/.github/workflows/dev-fairer-jib.yml @@ -58,7 +58,7 @@ jobs: deploy: needs: build name: Deploy - runs-on: self-hosted + runs-on: [ self-hosted, label-development ] steps: - name: Docker run run: | From daab47e1fb9760dc968110a7c37f1a1871406127 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Sun, 24 Jul 2022 00:00:55 +0900 Subject: [PATCH 19/51] Update dev-fairer-jib.yml --- .github/workflows/dev-fairer-jib.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-fairer-jib.yml b/.github/workflows/dev-fairer-jib.yml index a10016ae..eee750d3 100644 --- a/.github/workflows/dev-fairer-jib.yml +++ b/.github/workflows/dev-fairer-jib.yml @@ -62,6 +62,6 @@ jobs: steps: - name: Docker run run: | - sudo docker ps -q --filter "name=fairer-dev" | grep -q . && sudo docker stop "fairer-dev" && sudo docker rmi "ehdqls4013/fairer:lastest" - sudo docker run -d --name fairer-dev --rm -p 8080:8080 ehdqls4013/fairer:lastest + sudo docker ps -q --filter "name=fairer-dev" | grep -q . && sudo docker stop "fairer-dev" && sudo docker rmi "ehdqls4013/fairer-dev-repo:latest" + sudo docker run -d --name fairer-dev --rm -p 8080:8080 ehdqls4013/fairer-dev-repo:latest From ae4fc2fd8c924fc146131252d5b2b90e3a4f3ab9 Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Sun, 24 Jul 2022 00:32:46 +0900 Subject: [PATCH 20/51] rollback deprecated housework api --- .../fairer/api/HouseWorkController.java | 40 ++++++++++++++++++- .../fairer/service/member/MemberService.java | 6 +++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java index 33014a15..7dd85611 100644 --- a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java +++ b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java @@ -1,5 +1,8 @@ package com.depromeet.fairer.api; +import com.depromeet.fairer.domain.housework.HouseWork; +import com.depromeet.fairer.domain.member.Member; +import com.depromeet.fairer.dto.member.MemberDto; import com.depromeet.fairer.global.resolver.RequestMemberId; import com.depromeet.fairer.global.util.DateTimeUtils; import com.depromeet.fairer.service.housework.HouseWorkService; @@ -24,7 +27,10 @@ import javax.validation.Valid; import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Slf4j @RestController @@ -67,11 +73,41 @@ public ResponseEntity deleteHouseWork( return new ResponseEntity<>(HttpStatus.OK); } + @Tag(name = "houseWorks") + @ApiOperation(value = "날짜별 집안일 조회", notes = "본인 포함 팀원들의 집안일까지 모두 조회") + @GetMapping(value = "") + @Deprecated + public ResponseEntity> getHouseWork(@RequestParam("scheduledDate") String scheduledDate, + @ApiIgnore @RequestMemberId Long memberId) { + LocalDate scheduledDateParse = LocalDate.parse(scheduledDate, DateTimeFormatter.ISO_DATE); + + List members = memberService.getMemberList(memberId); + + List houseWorkDateResponseDtos = new ArrayList<>(); + for (Member member : members) { + List houseWorks = houseWorkService.getHouseWorks(scheduledDateParse, member); + + List houseWorkResponseDtoList = houseWorks.stream().map(houseWork -> { + List memberDtoList = memberService.getMemberListByHouseWorkId(houseWork.getHouseWorkId()) + .stream().map(MemberDto::from).collect(Collectors.toList()); + + return HouseWorkResponseDto.from(houseWork, memberDtoList); + }).collect(Collectors.toList()); + + long countDone = houseWorkResponseDtoList.stream().filter(HouseWorkResponseDto::getSuccess).count(); + long countLeft = houseWorkResponseDtoList.stream().filter(houseWorkResponseDto -> !houseWorkResponseDto.getSuccess()).count(); + + houseWorkDateResponseDtos.add(HouseWorkDateResponseDto.from(member.getMemberId(), scheduledDateParse, countDone, countLeft, houseWorkResponseDtoList)); + } + + return ResponseEntity.ok(houseWorkDateResponseDtos); + } + @Tag(name = "houseWorks") @ApiOperation(value = "특정 멤버의 날짜별 집안일 조회", notes = "특정 멤버의 날짜별 집안일 조회") - @GetMapping("") + @GetMapping("{memberId}") public ResponseEntity getTheMemberHouseWork(@RequestParam("reqDate") String reqDate, - @RequestParam("memberId") Long memberId, + @PathVariable("memberId") Long memberId, @ApiIgnore @RequestMemberId Long reqMemberId) { final LocalDate localDate = DateTimeUtils.stringToLocalDate(reqDate); final HouseWorkAndAssigneeResponseDto theMemberHouseWorks = houseWorkService.getTheMemberHouseWorks(reqMemberId, memberId, localDate); diff --git a/src/main/java/com/depromeet/fairer/service/member/MemberService.java b/src/main/java/com/depromeet/fairer/service/member/MemberService.java index bd32e193..f1a18da5 100644 --- a/src/main/java/com/depromeet/fairer/service/member/MemberService.java +++ b/src/main/java/com/depromeet/fairer/service/member/MemberService.java @@ -1,5 +1,6 @@ package com.depromeet.fairer.service.member; +import com.depromeet.fairer.domain.team.Team; import com.depromeet.fairer.domain.member.Member; import com.depromeet.fairer.global.exception.NoSuchMemberException; @@ -29,6 +30,11 @@ public Member findWithTeam(Long memberId) { return memberRepository.findWithTeamByMemberId(memberId).orElseThrow(()->new NoSuchMemberException("해당하는 멤버를 찾을 수 없습니다.")); } + public List getMemberList(Long memberId){ + Team team = findWithTeam(memberId).getTeam(); + return memberRepository.findAllByTeam(team); + } + public List getMemberListByHouseWorkId(Long houseWorkId) { return memberRepository.getMemberDtoListByHouseWorkId(houseWorkId); } From 1a3517c774cc5089cd344e8b0bc6649efabd2b61 Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Tue, 7 Jun 2022 00:31:12 +0900 Subject: [PATCH 21/51] feat:fcm push noti --- build.gradle | 3 + .../fairer/api/fcm/FCMController.java | 33 ++++++++ .../fairer/domain/member/Member.java | 6 ++ .../fairer/dto/fcm/FCMSendRequest.java | 14 ++++ .../dto/fcm/request/FCMMessageRequest.java | 16 ++++ .../dto/fcm/request/SaveTokenRequest.java | 11 +++ .../dto/fcm/response/FCMMessageResponse.java | 7 ++ .../dto/fcm/response/SaveTokenResponse.java | 7 ++ .../fairer/global/config/SecurityConfig.java | 2 +- .../global/factory/RestTemplateFactory.java | 11 +++ .../fairer/service/fcm/FCMService.java | 80 +++++++++++++++++++ ...59-firebase-adminsdk-uvxs2-2b35d6203d.json | 12 +++ 12 files changed, 201 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/depromeet/fairer/api/fcm/FCMController.java create mode 100644 src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java create mode 100644 src/main/java/com/depromeet/fairer/dto/fcm/request/FCMMessageRequest.java create mode 100644 src/main/java/com/depromeet/fairer/dto/fcm/request/SaveTokenRequest.java create mode 100644 src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java create mode 100644 src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java create mode 100644 src/main/java/com/depromeet/fairer/global/factory/RestTemplateFactory.java create mode 100644 src/main/java/com/depromeet/fairer/service/fcm/FCMService.java create mode 100644 src/main/resources/firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json diff --git a/build.gradle b/build.gradle index 5d06d33f..09a9ab38 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,9 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-validation' + //firebase sdk + implementation 'com.google.firebase:firebase-admin:6.8.1' + //mysql connector implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.28' diff --git a/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java b/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java new file mode 100644 index 00000000..23c88df3 --- /dev/null +++ b/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java @@ -0,0 +1,33 @@ +package com.depromeet.fairer.api.fcm; + +import com.depromeet.fairer.dto.fcm.request.FCMMessageRequest; +import com.depromeet.fairer.dto.fcm.request.SaveTokenRequest; +import com.depromeet.fairer.dto.fcm.response.FCMMessageResponse; +import com.depromeet.fairer.dto.fcm.response.SaveTokenResponse; +import com.depromeet.fairer.global.resolver.RequestMemberId; +import com.depromeet.fairer.service.fcm.FCMService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; +import springfox.documentation.annotations.ApiIgnore; + +import javax.validation.Valid; + +@Slf4j +@RestController(value = "/api/fcm") +@RequiredArgsConstructor +public class FCMController { + private final FCMService fcmService; + + @PostMapping("/token") + public ResponseEntity saveToken(@Valid SaveTokenRequest request, @ApiIgnore @RequestMemberId Long memberId) { + return ResponseEntity.ok(fcmService.saveToken(request, memberId)); + } + + @PostMapping("/message") + public ResponseEntity sendMessage(@Valid FCMMessageRequest request) { + return ResponseEntity.ok(fcmService.sendMessage(request)); + } +} diff --git a/src/main/java/com/depromeet/fairer/domain/member/Member.java b/src/main/java/com/depromeet/fairer/domain/member/Member.java index 5f9d8942..2fd807b4 100644 --- a/src/main/java/com/depromeet/fairer/domain/member/Member.java +++ b/src/main/java/com/depromeet/fairer/domain/member/Member.java @@ -64,6 +64,12 @@ public class Member extends BaseTimeEntity { @JoinColumn(name = "team_id") private Team team; + @Column(name = "fcm_token", columnDefinition = "VARCHAR(200)") + private String fcmToken; + + @Column(name = "fcm_token_date", columnDefinition = "DATETIME") + private LocalDateTime fcmTokenDate; + /** * TODO 닉네임 동의 안했을 때 처리 (입력한 닉네임으로 변경) * diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java b/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java new file mode 100644 index 00000000..e7caffee --- /dev/null +++ b/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java @@ -0,0 +1,14 @@ +package com.depromeet.fairer.dto.fcm; + +import com.google.firebase.messaging.Message; +import lombok.Data; + +/*** + * https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send + */ +@Data +public class FCMSendRequest { + private boolean validate_only; + private Message message; +} + diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/request/FCMMessageRequest.java b/src/main/java/com/depromeet/fairer/dto/fcm/request/FCMMessageRequest.java new file mode 100644 index 00000000..dae5bb8c --- /dev/null +++ b/src/main/java/com/depromeet/fairer/dto/fcm/request/FCMMessageRequest.java @@ -0,0 +1,16 @@ +package com.depromeet.fairer.dto.fcm.request; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +@Data +public class FCMMessageRequest { + @NotNull + private Long memberId; + @NotBlank + private String title; + @NotBlank + private String body; +} diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/request/SaveTokenRequest.java b/src/main/java/com/depromeet/fairer/dto/fcm/request/SaveTokenRequest.java new file mode 100644 index 00000000..8be0f886 --- /dev/null +++ b/src/main/java/com/depromeet/fairer/dto/fcm/request/SaveTokenRequest.java @@ -0,0 +1,11 @@ +package com.depromeet.fairer.dto.fcm.request; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; + +@Data +public class SaveTokenRequest { + @NotBlank + private String token; +} diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java b/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java new file mode 100644 index 00000000..bb1a0cbf --- /dev/null +++ b/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java @@ -0,0 +1,7 @@ +package com.depromeet.fairer.dto.fcm.response; + +import lombok.Data; + +@Data +public class FCMMessageResponse { +} diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java b/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java new file mode 100644 index 00000000..35399d50 --- /dev/null +++ b/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java @@ -0,0 +1,7 @@ +package com.depromeet.fairer.dto.fcm.response; + +import lombok.Data; + +@Data +public class SaveTokenResponse { +} diff --git a/src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java b/src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java index 170a3d04..a97ad292 100644 --- a/src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java +++ b/src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java @@ -20,7 +20,7 @@ protected void configure(HttpSecurity http) throws Exception { .csrf().disable().headers().frameOptions().disable() .and() .authorizeRequests() // url별 권한 관리를 설정하는 옵션의 시작점 - .antMatchers("/oauth/login").permitAll() + .antMatchers("/oauth/login", "/fcm/message").permitAll() .antMatchers("/", "/css/**", "**.html", "/images/**", "/js/**" , "/assets/**", "/swagger-ui.html").permitAll(); } diff --git a/src/main/java/com/depromeet/fairer/global/factory/RestTemplateFactory.java b/src/main/java/com/depromeet/fairer/global/factory/RestTemplateFactory.java new file mode 100644 index 00000000..74e0cacf --- /dev/null +++ b/src/main/java/com/depromeet/fairer/global/factory/RestTemplateFactory.java @@ -0,0 +1,11 @@ +package com.depromeet.fairer.global.factory; + +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.web.client.RestTemplate; + +public class RestTemplateFactory { + public static RestTemplate getRestTemplate() { + return new RestTemplateBuilder() + .build(); + } +} diff --git a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java new file mode 100644 index 00000000..8c626562 --- /dev/null +++ b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java @@ -0,0 +1,80 @@ +package com.depromeet.fairer.service.fcm; + +import com.depromeet.fairer.domain.member.Member; +import com.depromeet.fairer.dto.fcm.FCMSendRequest; +import com.depromeet.fairer.dto.fcm.request.FCMMessageRequest; +import com.depromeet.fairer.dto.fcm.request.SaveTokenRequest; +import com.depromeet.fairer.dto.fcm.response.FCMMessageResponse; +import com.depromeet.fairer.dto.fcm.response.SaveTokenResponse; +import com.depromeet.fairer.global.factory.RestTemplateFactory; +import com.depromeet.fairer.repository.member.MemberRepository; +import com.google.auth.oauth2.GoogleCredentials; +import com.google.firebase.messaging.Message; +import com.google.firebase.messaging.Notification; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.io.ClassPathResource; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.List; + +@Slf4j +@Service +@RequiredArgsConstructor +public class FCMService { + private static final String FCM_DOMAIN = "https://fcm.googleapis.com/v1/projects/fairer-def59/messages:send"; + private static final String FIREBASE_KEY_PATH = "firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json"; + private static final RestTemplate restTemplate = RestTemplateFactory.getRestTemplate(); + + private final MemberRepository memberRepository; + + public SaveTokenResponse saveToken(SaveTokenRequest request, Long memberId) { + Member member = memberRepository.findById(memberId) + .orElseThrow(() -> new IllegalArgumentException("memberId에 해당하는 회원을 찾지 못했습니다.")); + member.setFcmToken(request.getToken()); + member.setFcmTokenDate(LocalDateTime.now()); + return new SaveTokenResponse(); + } + + public FCMMessageResponse sendMessage(FCMMessageRequest fcmMessageRequest) { + Member member = memberRepository.findById(fcmMessageRequest.getMemberId()) + .orElseThrow(() -> new IllegalArgumentException("memberId에 해당하는 회원을 찾지 못했습니다.")); + + FCMSendRequest fcmSendRequest = createMessage(member.getFcmToken(), fcmMessageRequest.getTitle(), fcmMessageRequest.getBody()); + + HttpHeaders headers = new HttpHeaders(); + headers.add(HttpHeaders.AUTHORIZATION, "Bearer " + getAccessToken()); + headers.add(HttpHeaders.CONTENT_TYPE, "application/json; UTF-8"); + + HttpEntity request = new HttpEntity<>(fcmSendRequest, headers); + Message message = restTemplate.postForObject(FCM_DOMAIN, request, Message.class); + return new FCMMessageResponse(); + } + + private FCMSendRequest createMessage(String token, String title, String body) { + Message message = Message.builder() + .setToken(token) + .setNotification(new Notification(title, body)) + .build(); + + FCMSendRequest request = new FCMSendRequest(); + request.setValidate_only(false); + request.setMessage(message); + return request; + } + + private String getAccessToken() { + try { + GoogleCredentials googleCredentials = GoogleCredentials.fromStream(new ClassPathResource(FIREBASE_KEY_PATH).getInputStream()).createScoped(List.of("https://www.googleapis.com/auth/cloud-platform")); + googleCredentials.refreshIfExpired(); + return googleCredentials.getAccessToken().getTokenValue(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } +} diff --git a/src/main/resources/firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json b/src/main/resources/firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json new file mode 100644 index 00000000..7899de08 --- /dev/null +++ b/src/main/resources/firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json @@ -0,0 +1,12 @@ +{ + "type": "service_account", + "project_id": "fairer-def59", + "private_key_id": "2b35d6203d536ecd7f9a3d4515623d3c5ac9e8a5", + "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDRDOnG9/PEg6Sf\n4EuGNECa47lw22hJTIHhPSUxkliWxIcF+AevacOG2zxidhLXUMiufJIVDlbb+4Jc\n0PNvuZT4ZJhSw5N39otG4nd9AXKOnmcNh2wZZdGW1TCcLpers1Ga3WYRBQ+SqOV+\na0sBzFSdibHezjqXIo5J0ND6fH8Tz7NUYForvQcZHtcDPE5Lb6dDbTgnqfVJ5Xra\no9v45hIv4lq8ZqBn6U9Xb2qbepiPPQik24z6VUOV8IrxVqFOJwstJbaac3Pebd8k\n0ALKPyvbXRIa1DHTh/Rue8i1OfZQBr+iftKL6Z7W/rsNQmL9o2XyLFi5lRWaoG4H\n3PXwk8wvAgMBAAECggEALyHyM2IEG/JyU3mGjaOKTWG6la9iO+R8BAR9NkgAoT1+\nE+JwGSSHaQhU/P4SEWmtVWnQpd6txrtWEQcrW61D4R0NGtvti8aScFDvD8gbw/wC\n0BIQVUmXj6JRa2U13Qh5BamVMZEqia56z53xM16WVU6OQ+XLX/fyjMH/2/nlzNlH\nCuCBYtXqHVg4KsB3WLJoJIFrM6cY2h61NnjJGh2st/lpdSf91D/j2tPG9puzz2ys\nJKV7nyOtHzHxo+E8mK40Sb4NW4KGtUb+Ll1dqU5NgrvjsLBm1TkX4YikEcBhHwFZ\nDPa4dNJrkrO5c2eNXoqCDxITpVkQX24Dok+AypxWQQKBgQDp1JMqc/Q9q7kdYjp/\n7z0EwSTjEtcNUVZ1f9r/IFTa3OOAWaI/AmmqTkxtDCbyZIRonlPwxcIlwfj3XZ2e\nKkOyAGoDtcqTmGul98Nd1aV7mJPcxeSzr+O8+GTlbluuCYIU81oMxL3ILyfreWE+\n2fpkID0x2DUUCMrM9yf1vZa0awKBgQDk3uQe45hUHNQYqMIDJdXBkypCsqcrCKTu\niLJqljKSAupQo5u3z7VIQ1s7eWGbKb4bf4CJafL0wHCzflP2WwDsX0hlhozW/Y8f\ncQrF09JCVKQ6hPW897SfOsIarTgMIeJcio5uz/30OlrT47KOnppxgb/60IW+5JvH\nUGj+FWCYTQKBgQDgb6ExxkpQR1tO0NHFqiOvRJPbQGIZ7lBGR4o0BxxrVkknEOGi\nCPbS+IRyxo87aS+OGyoGmEpZY21MQRbgkUCYwb0AAqWGNW5dxwpGLqK/lxuVdHyn\n29ODtgdiECL/UTECWvG7/7sJQfnXEpI8eYzUPf1+sj+AE1BUm4ZHYMoeMQKBgCRE\nUZ+3bv79JnrV2xCGoU2wVUUGbEj8cK4/yQ3syQysG5c1pcpFxrMxwTY2cMoWnkJb\nPPIJcO9pwzIeNY3XM9lA7AbygETdHx3bWtqoSywpn3CKeyo7kkqdE/8ILdZ2VBlX\n92QF33cg/B2RekzxQwXzioljG555OVonGswQdSMNAoGAO9wGzytPSYgdp6l1GKFp\nGXtOD+XnxDDwiW4FAu/aWqpYr4MmSGQz910HatK6ndS1OHWqkl9OCOQJfPduDFTK\nadUZXQhpveOI+ap7dp+XcmZlWEFXQbXyghhrr7UekBXJp1yFOQnRZWEnoiO0Ho40\nSEofrS1onMwXruF9/2upTM4=\n-----END PRIVATE KEY-----\n", + "client_email": "firebase-adminsdk-uvxs2@fairer-def59.iam.gserviceaccount.com", + "client_id": "109541995676989814778", + "auth_uri": "https://accounts.google.com/o/oauth2/auth", + "token_uri": "https://oauth2.googleapis.com/token", + "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", + "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/firebase-adminsdk-uvxs2%40fairer-def59.iam.gserviceaccount.com" +} From a0b99fd4145c6ea4ddfa77e575c1bc7f0904d785 Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Sun, 24 Jul 2022 18:19:49 +0900 Subject: [PATCH 22/51] feat:fcm push noti --- .../java/com/depromeet/fairer/api/fcm/FCMController.java | 6 +++++- .../com/depromeet/fairer/global/config/SwaggerConfig.java | 2 +- .../java/com/depromeet/fairer/global/config/WebConfig.java | 2 +- src/main/resources/application.yml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java b/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java index 23c88df3..98100e82 100644 --- a/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java +++ b/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java @@ -6,18 +6,22 @@ import com.depromeet.fairer.dto.fcm.response.SaveTokenResponse; import com.depromeet.fairer.global.resolver.RequestMemberId; import com.depromeet.fairer.service.fcm.FCMService; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import springfox.documentation.annotations.ApiIgnore; import javax.validation.Valid; @Slf4j -@RestController(value = "/api/fcm") +@RestController @RequiredArgsConstructor +@Tag(name = "fcm", description = "FCM 관련 API") +@RequestMapping(value = "/api/fcm") public class FCMController { private final FCMService fcmService; diff --git a/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java b/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java index 2a1d7316..ce7e0651 100644 --- a/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java +++ b/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java @@ -42,7 +42,7 @@ public Docket swaggerApi() { .apiInfo(this.apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.depromeet.fairer.api")) - .paths(PathSelectors.ant("/api/**")) + .paths(PathSelectors.ant("/api/**/*")) .build(); } diff --git a/src/main/java/com/depromeet/fairer/global/config/WebConfig.java b/src/main/java/com/depromeet/fairer/global/config/WebConfig.java index 62ed73d6..42ddeeb6 100644 --- a/src/main/java/com/depromeet/fairer/global/config/WebConfig.java +++ b/src/main/java/com/depromeet/fairer/global/config/WebConfig.java @@ -24,7 +24,7 @@ public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(authInterceptor()) .order(1) .addPathPatterns("/api/**") - .excludePathPatterns("/api/oauth/login", "/api/member/profile-image"); + .excludePathPatterns("/api/oauth/login", "/api/member/profile-image", "/api/fcm/message"); } @Bean diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 7b870fe8..b443f8b0 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -27,7 +27,7 @@ spring: on-profile: ["dev"] swagger: - url: http://ec2-13-125-232-180.ap-northeast-2.compute.amazonaws.com:8080 + url: http://ec2-3-39-60-64.ap-northeast-2.compute.amazonaws.com:8080 desc: for dev usages oauth2: From 60b17c311b30bd3516ad3c5f50629e1f97e8da4e Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Sun, 24 Jul 2022 18:20:58 +0900 Subject: [PATCH 23/51] feat:fcm push noti --- .../java/com/depromeet/fairer/global/config/SwaggerConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java b/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java index ce7e0651..2a1d7316 100644 --- a/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java +++ b/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java @@ -42,7 +42,7 @@ public Docket swaggerApi() { .apiInfo(this.apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.depromeet.fairer.api")) - .paths(PathSelectors.ant("/api/**/*")) + .paths(PathSelectors.ant("/api/**")) .build(); } From 2bca76e2eb838ddf7bb048ec53686bc485dfcd0d Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Sun, 24 Jul 2022 18:34:19 +0900 Subject: [PATCH 24/51] feat:fcm push noti --- src/main/java/com/depromeet/fairer/api/fcm/FCMController.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java b/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java index 98100e82..c448c716 100644 --- a/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java +++ b/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java @@ -25,11 +25,13 @@ public class FCMController { private final FCMService fcmService; + @Tag(name = "fcm") @PostMapping("/token") public ResponseEntity saveToken(@Valid SaveTokenRequest request, @ApiIgnore @RequestMemberId Long memberId) { return ResponseEntity.ok(fcmService.saveToken(request, memberId)); } + @Tag(name = "fcm") @PostMapping("/message") public ResponseEntity sendMessage(@Valid FCMMessageRequest request) { return ResponseEntity.ok(fcmService.sendMessage(request)); From 43dab55a0142d13dbfb8db69ae31e2240a93c128 Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Sun, 24 Jul 2022 18:38:53 +0900 Subject: [PATCH 25/51] feat:fcm push noti --- .../java/com/depromeet/fairer/api/fcm/FCMController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java b/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java index c448c716..4cd11ee3 100644 --- a/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java +++ b/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java @@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.http.ResponseEntity; 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 springfox.documentation.annotations.ApiIgnore; @@ -27,13 +28,13 @@ public class FCMController { @Tag(name = "fcm") @PostMapping("/token") - public ResponseEntity saveToken(@Valid SaveTokenRequest request, @ApiIgnore @RequestMemberId Long memberId) { + public ResponseEntity saveToken(@Valid @RequestBody SaveTokenRequest request, @ApiIgnore @RequestMemberId Long memberId) { return ResponseEntity.ok(fcmService.saveToken(request, memberId)); } @Tag(name = "fcm") @PostMapping("/message") - public ResponseEntity sendMessage(@Valid FCMMessageRequest request) { + public ResponseEntity sendMessage(@Valid @RequestBody FCMMessageRequest request) { return ResponseEntity.ok(fcmService.sendMessage(request)); } } From 56221e1eb1bde7862ae7578e822d4acecf873ad8 Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Thu, 28 Jul 2022 20:11:16 +0900 Subject: [PATCH 26/51] feat: add response detail --- .../fairer/dto/fcm/response/FCMMessageResponse.java | 13 +++++++++++++ .../fairer/dto/fcm/response/SaveTokenResponse.java | 9 +++++++++ .../depromeet/fairer/service/fcm/FCMService.java | 6 ++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java b/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java index bb1a0cbf..3ab58573 100644 --- a/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java +++ b/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java @@ -1,7 +1,20 @@ package com.depromeet.fairer.dto.fcm.response; +import lombok.Builder; import lombok.Data; @Data +@Builder public class FCMMessageResponse { + private String title; + private String body; + private Long memberId; + + public static FCMMessageResponse of(String title, String body, Long memberId) { + return FCMMessageResponse.builder() + .title(title) + .body(body) + .memberId(memberId) + .build(); + } } diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java b/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java index 35399d50..8f045d0e 100644 --- a/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java +++ b/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java @@ -1,7 +1,16 @@ package com.depromeet.fairer.dto.fcm.response; +import lombok.Builder; import lombok.Data; @Data +@Builder public class SaveTokenResponse { + private String token; + + public static SaveTokenResponse of(String token) { + return SaveTokenResponse.builder() + .token(token) + .build(); + } } diff --git a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java index 8c626562..a6e5998f 100644 --- a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java +++ b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java @@ -38,7 +38,8 @@ public SaveTokenResponse saveToken(SaveTokenRequest request, Long memberId) { .orElseThrow(() -> new IllegalArgumentException("memberId에 해당하는 회원을 찾지 못했습니다.")); member.setFcmToken(request.getToken()); member.setFcmTokenDate(LocalDateTime.now()); - return new SaveTokenResponse(); + memberRepository.save(member); + return SaveTokenResponse.of(request.getToken()); } public FCMMessageResponse sendMessage(FCMMessageRequest fcmMessageRequest) { @@ -53,7 +54,8 @@ public FCMMessageResponse sendMessage(FCMMessageRequest fcmMessageRequest) { HttpEntity request = new HttpEntity<>(fcmSendRequest, headers); Message message = restTemplate.postForObject(FCM_DOMAIN, request, Message.class); - return new FCMMessageResponse(); + log.info("Send FCM Message : {}, request : {}", message, fcmMessageRequest); + return FCMMessageResponse.of(fcmMessageRequest.getTitle(), fcmMessageRequest.getBody(), fcmMessageRequest.getMemberId()); } private FCMSendRequest createMessage(String token, String title, String body) { From a3494b492c1231516266fa914ee149304e2d851e Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Thu, 28 Jul 2022 20:40:47 +0900 Subject: [PATCH 27/51] fix fcm request --- .../fairer/global/config/MapperConfig.java | 5 +++ .../exception/handler/FairerException.java | 7 ++++ .../fairer/service/fcm/FCMService.java | 34 +++++++++++-------- 3 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/depromeet/fairer/global/exception/handler/FairerException.java diff --git a/src/main/java/com/depromeet/fairer/global/config/MapperConfig.java b/src/main/java/com/depromeet/fairer/global/config/MapperConfig.java index 96b01582..a708c21b 100644 --- a/src/main/java/com/depromeet/fairer/global/config/MapperConfig.java +++ b/src/main/java/com/depromeet/fairer/global/config/MapperConfig.java @@ -1,5 +1,8 @@ package com.depromeet.fairer.global.config; +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.modelmapper.ModelMapper; @@ -18,6 +21,8 @@ public ModelMapper modelMapper() { public ObjectMapper objectMapper() { ObjectMapper objectMapper = new ObjectMapper(); objectMapper.registerModule(new JavaTimeModule()); + objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY); + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); return objectMapper; } } diff --git a/src/main/java/com/depromeet/fairer/global/exception/handler/FairerException.java b/src/main/java/com/depromeet/fairer/global/exception/handler/FairerException.java new file mode 100644 index 00000000..fdcdf31d --- /dev/null +++ b/src/main/java/com/depromeet/fairer/global/exception/handler/FairerException.java @@ -0,0 +1,7 @@ +package com.depromeet.fairer.global.exception.handler; + +public class FairerException extends RuntimeException { + public FairerException(Exception e) { + super(e); + } +} diff --git a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java index a6e5998f..9d0f42dc 100644 --- a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java +++ b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java @@ -6,8 +6,10 @@ import com.depromeet.fairer.dto.fcm.request.SaveTokenRequest; import com.depromeet.fairer.dto.fcm.response.FCMMessageResponse; import com.depromeet.fairer.dto.fcm.response.SaveTokenResponse; +import com.depromeet.fairer.global.exception.handler.FairerException; import com.depromeet.fairer.global.factory.RestTemplateFactory; import com.depromeet.fairer.repository.member.MemberRepository; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.auth.oauth2.GoogleCredentials; import com.google.firebase.messaging.Message; import com.google.firebase.messaging.Notification; @@ -30,6 +32,7 @@ public class FCMService { private static final String FCM_DOMAIN = "https://fcm.googleapis.com/v1/projects/fairer-def59/messages:send"; private static final String FIREBASE_KEY_PATH = "firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json"; private static final RestTemplate restTemplate = RestTemplateFactory.getRestTemplate(); + private final ObjectMapper objectMapper; private final MemberRepository memberRepository; @@ -48,14 +51,19 @@ public FCMMessageResponse sendMessage(FCMMessageRequest fcmMessageRequest) { FCMSendRequest fcmSendRequest = createMessage(member.getFcmToken(), fcmMessageRequest.getTitle(), fcmMessageRequest.getBody()); - HttpHeaders headers = new HttpHeaders(); - headers.add(HttpHeaders.AUTHORIZATION, "Bearer " + getAccessToken()); - headers.add(HttpHeaders.CONTENT_TYPE, "application/json; UTF-8"); + try { + HttpHeaders headers = new HttpHeaders(); + headers.add(HttpHeaders.AUTHORIZATION, "Bearer " + getAccessToken()); + headers.add(HttpHeaders.CONTENT_TYPE, "application/json; UTF-8"); - HttpEntity request = new HttpEntity<>(fcmSendRequest, headers); - Message message = restTemplate.postForObject(FCM_DOMAIN, request, Message.class); - log.info("Send FCM Message : {}, request : {}", message, fcmMessageRequest); - return FCMMessageResponse.of(fcmMessageRequest.getTitle(), fcmMessageRequest.getBody(), fcmMessageRequest.getMemberId()); + HttpEntity request = new HttpEntity<>(objectMapper.writeValueAsString(fcmSendRequest), headers); + Message message = restTemplate.postForObject(FCM_DOMAIN, request, Message.class); + log.info("Send FCM Message : {}, request : {}", message, fcmMessageRequest); + return FCMMessageResponse.of(fcmMessageRequest.getTitle(), fcmMessageRequest.getBody(), fcmMessageRequest.getMemberId()); + } catch (Exception e) { + log.error("Error to send message.", e); + throw new FairerException(e); + } } private FCMSendRequest createMessage(String token, String title, String body) { @@ -70,13 +78,9 @@ private FCMSendRequest createMessage(String token, String title, String body) { return request; } - private String getAccessToken() { - try { - GoogleCredentials googleCredentials = GoogleCredentials.fromStream(new ClassPathResource(FIREBASE_KEY_PATH).getInputStream()).createScoped(List.of("https://www.googleapis.com/auth/cloud-platform")); - googleCredentials.refreshIfExpired(); - return googleCredentials.getAccessToken().getTokenValue(); - } catch (IOException e) { - throw new RuntimeException(e); - } + private String getAccessToken() throws IOException { + GoogleCredentials googleCredentials = GoogleCredentials.fromStream(new ClassPathResource(FIREBASE_KEY_PATH).getInputStream()).createScoped(List.of("https://www.googleapis.com/auth/cloud-platform")); + googleCredentials.refreshIfExpired(); + return googleCredentials.getAccessToken().getTokenValue(); } } From 4f25736503d83c6645420ddbe1a42934918fe79a Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Thu, 28 Jul 2022 20:44:47 +0900 Subject: [PATCH 28/51] =?UTF-8?q?=EA=B8=B0=EC=A1=B4=20=EA=B0=9C=EB=B0=9C?= =?UTF-8?q?=20=EC=84=9C=EB=B2=84=20workflow=20=EB=B9=84=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev-fairer.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-fairer.yml b/.github/workflows/dev-fairer.yml index 0d2147c3..803ee964 100644 --- a/.github/workflows/dev-fairer.yml +++ b/.github/workflows/dev-fairer.yml @@ -9,8 +9,8 @@ name: dev-fairer on: workflow_dispatch: - push: - branches: [ develop ] +# push: +# branches: [ develop ] jobs: build: From 6832a3beae23eacccce3e796be3b15a59237ac6a Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Mon, 1 Aug 2022 18:13:06 +0900 Subject: [PATCH 29/51] =?UTF-8?q?Preset=20Enum=EC=9C=BC=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=20#114?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairer/api/PresetController.java | 22 +++-- .../fairer/domain/housework/HouseWork.java | 2 +- .../fairer/domain/preset/Preset.java | 82 ++++++++++++++----- .../domain/preset/{constant => }/Space.java | 2 +- .../request/HouseWorkUpdateRequestDto.java | 2 +- .../response/HouseWorkResponseDto.java | 2 +- .../dto/member/jwt/ResponseJwtTokenDto.java | 2 + .../HouseWorkPresetListResponseDto.java | 14 ---- .../global/exception/FairerException.java | 16 ++++ .../exception/handler/FairerException.java | 7 -- .../handler/GlobalExceptionHandler.java | 5 ++ .../repository/preset/PresetRepository.java | 12 --- .../fairer/service/PresetService.java | 49 ----------- .../fairer/service/fcm/FCMService.java | 2 +- .../vo/houseWork/HouseWorkAndAssigneeVo.java | 10 +-- .../vo/houseWork/HouseWorkDetailVo.java | 3 +- .../vo/houseWork/HouseWorkUpdateVo.java | 8 +- 17 files changed, 108 insertions(+), 132 deletions(-) rename src/main/java/com/depromeet/fairer/domain/preset/{constant => }/Space.java (80%) delete mode 100644 src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetListResponseDto.java create mode 100644 src/main/java/com/depromeet/fairer/global/exception/FairerException.java delete mode 100644 src/main/java/com/depromeet/fairer/global/exception/handler/FairerException.java delete mode 100644 src/main/java/com/depromeet/fairer/repository/preset/PresetRepository.java delete mode 100644 src/main/java/com/depromeet/fairer/service/PresetService.java diff --git a/src/main/java/com/depromeet/fairer/api/PresetController.java b/src/main/java/com/depromeet/fairer/api/PresetController.java index 35414258..768b9326 100644 --- a/src/main/java/com/depromeet/fairer/api/PresetController.java +++ b/src/main/java/com/depromeet/fairer/api/PresetController.java @@ -1,9 +1,8 @@ package com.depromeet.fairer.api; -import com.depromeet.fairer.domain.preset.constant.Space; -import com.depromeet.fairer.dto.preset.response.HouseWorkPresetListResponseDto; +import com.depromeet.fairer.domain.preset.Preset; +import com.depromeet.fairer.domain.preset.Space; import com.depromeet.fairer.dto.preset.response.HouseWorkPresetResponseDto; -import com.depromeet.fairer.service.PresetService; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -13,13 +12,15 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.ArrayList; +import java.util.List; + @Slf4j @RestController @RequiredArgsConstructor @Tag(name = "presets", description = "프리셋 API") @RequestMapping("/api/preset") public class PresetController { - private final PresetService presetService; /** * 공간 -> 집안일 프리셋 조회 @@ -29,12 +30,19 @@ public class PresetController { @Tag(name = "presets") @GetMapping(value = "{space}") public ResponseEntity getHouseWorkPreset(@PathVariable Space space){ - return ResponseEntity.ok(presetService.getHouseWorkPreset(space)); + return ResponseEntity.ok(new HouseWorkPresetResponseDto(space.name(), Preset.getHouseworkNameListBySpace(space))); } @Tag(name = "presets") @GetMapping(value = "") - public ResponseEntity getPreset(){ - return ResponseEntity.ok(presetService.getPreset()); + public ResponseEntity> getAllPreset(){ + List response = new ArrayList<>(); + for (Space space : Space.values()) { + if (space.equals(Space.ETC)) { + continue; + } + response.add(new HouseWorkPresetResponseDto(space.name(), Preset.getHouseworkNameListBySpace(space))); + } + return ResponseEntity.ok(response); } } diff --git a/src/main/java/com/depromeet/fairer/domain/housework/HouseWork.java b/src/main/java/com/depromeet/fairer/domain/housework/HouseWork.java index ec5e61d2..e01d393f 100644 --- a/src/main/java/com/depromeet/fairer/domain/housework/HouseWork.java +++ b/src/main/java/com/depromeet/fairer/domain/housework/HouseWork.java @@ -2,7 +2,7 @@ import com.depromeet.fairer.domain.assignment.Assignment; import com.depromeet.fairer.domain.base.BaseTimeEntity; -import com.depromeet.fairer.domain.preset.constant.Space; +import com.depromeet.fairer.domain.preset.Space; import com.depromeet.fairer.domain.team.Team; import lombok.*; diff --git a/src/main/java/com/depromeet/fairer/domain/preset/Preset.java b/src/main/java/com/depromeet/fairer/domain/preset/Preset.java index 8f79a6b8..ec380899 100644 --- a/src/main/java/com/depromeet/fairer/domain/preset/Preset.java +++ b/src/main/java/com/depromeet/fairer/domain/preset/Preset.java @@ -1,26 +1,68 @@ package com.depromeet.fairer.domain.preset; -import com.depromeet.fairer.domain.base.BaseTimeEntity; -import lombok.*; +import com.depromeet.fairer.global.exception.FairerException; +import lombok.AllArgsConstructor; +import lombok.EqualsAndHashCode; +import lombok.Getter; -import javax.persistence.*; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; - -@Entity -@Table(name = "preset") @Getter -@Setter -@Builder -@NoArgsConstructor @AllArgsConstructor -public class Preset extends BaseTimeEntity { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "preset_id", columnDefinition = "BIGINT", nullable = false, unique = true) - private Long presetId; - - @Column(name = "space_name", columnDefinition = "VARCHAR(50)", nullable = false) - private String presetSpaceName; - - @Column(name = "housework_name", columnDefinition = "VARCHAR(50)", nullable = false) - private String presetHouseWorkName; +@AllArgsConstructor +public enum Preset { + PRESET_1(1, Space.ENTRANCE,"신발 정리"), + PRESET_2(2, Space.ENTRANCE,"현관 청소"), + PRESET_3(3, Space.ENTRANCE,"분리수거하기"), + PRESET_4(4, Space.BATHROOM,"욕조 청소"), + PRESET_5(5, Space.BATHROOM,"변기 청소"), + PRESET_6(6, Space.BATHROOM,"화장실 청소"), + PRESET_7(7, Space.BATHROOM,"욕실 용품 정리"), + PRESET_8(8, Space.ROOM,"옷장 정리"), + PRESET_9(9, Space.ROOM,"화장대 정리"), + PRESET_10(10, Space.ROOM,"방청소"), + PRESET_11(11, Space.ROOM,"물건 정리정돈"), + PRESET_12(12, Space.ROOM,"이불 정리"), + PRESET_13(13, Space.KITCHEN,"설거지"), + PRESET_14(14, Space.KITCHEN,"가스렌지 닦기"), + PRESET_15(15, Space.KITCHEN,"냉장고 정리"), + PRESET_16(16, Space.KITCHEN,"부엌 정리정돈"), + PRESET_17(17, Space.KITCHEN,"음식물 쓰레기 버리기"), + PRESET_18(18, Space.KITCHEN,"식사 준비하기"), + PRESET_19(19, Space.KITCHEN,"간식 준비하기"), + PRESET_20(20, Space.OUTSIDE,"쓰레기 버리기"), + PRESET_21(21, Space.OUTSIDE,"장보기"), + PRESET_22(22, Space.OUTSIDE,"반려동물 산책"), + PRESET_23(23, Space.OUTSIDE,"마중 나가기"), + PRESET_24(24, Space.LIVINGROOM,"창 청소"), + PRESET_25(25, Space.LIVINGROOM,"거실 청소"), + PRESET_26(26, Space.LIVINGROOM,"물건 정리정돈"), + PRESET_27(27, Space.LIVINGROOM,"환기 시키기"), + PRESET_28(28, Space.LIVINGROOM,"빨래 돌리기"), + PRESET_29(29, Space.LIVINGROOM,"빨래 개기"), + PRESET_30(30, Space.LIVINGROOM,"세탁기 청소"), + ; + + public static Preset getPreset(Space space, String houseWorkName) { + return Arrays.stream(values()).filter(p -> p.houseworkName.equals(houseWorkName) && p.space.equals(space)) + .findFirst().orElseThrow(() -> new FairerException("Preset Not Found")); + } + + public static Preset getPreset(int presetId) { + return Arrays.stream(values()).filter(p -> p.presetId == presetId) + .findFirst().orElseThrow(() -> new FairerException("Preset Not Found")); + } + + public static List getPresetListBySpace(Space space) { + return Arrays.stream(values()).filter(p -> p.space.equals(space)).collect(Collectors.toList()); + } + + public static List getHouseworkNameListBySpace(Space space) { + return Arrays.stream(values()).filter(p -> p.space.equals(space)).map(Preset::getHouseworkName).collect(Collectors.toList()); + } + + private int presetId; + private Space space; + private String houseworkName; } diff --git a/src/main/java/com/depromeet/fairer/domain/preset/constant/Space.java b/src/main/java/com/depromeet/fairer/domain/preset/Space.java similarity index 80% rename from src/main/java/com/depromeet/fairer/domain/preset/constant/Space.java rename to src/main/java/com/depromeet/fairer/domain/preset/Space.java index fc40b483..0a32ba5a 100644 --- a/src/main/java/com/depromeet/fairer/domain/preset/constant/Space.java +++ b/src/main/java/com/depromeet/fairer/domain/preset/Space.java @@ -1,4 +1,4 @@ -package com.depromeet.fairer.domain.preset.constant; +package com.depromeet.fairer.domain.preset; import lombok.Getter; diff --git a/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkUpdateRequestDto.java b/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkUpdateRequestDto.java index 5fd278d0..e99e32f9 100644 --- a/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkUpdateRequestDto.java +++ b/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkUpdateRequestDto.java @@ -1,7 +1,7 @@ package com.depromeet.fairer.dto.housework.request; import com.depromeet.fairer.domain.housework.HouseWork; -import com.depromeet.fairer.domain.preset.constant.Space; +import com.depromeet.fairer.domain.preset.Space; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; diff --git a/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkResponseDto.java b/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkResponseDto.java index 136fa979..53509aa0 100644 --- a/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkResponseDto.java +++ b/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkResponseDto.java @@ -1,7 +1,7 @@ package com.depromeet.fairer.dto.housework.response; import com.depromeet.fairer.domain.housework.HouseWork; -import com.depromeet.fairer.domain.preset.constant.Space; +import com.depromeet.fairer.domain.preset.Space; import com.depromeet.fairer.dto.member.MemberDto; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; diff --git a/src/main/java/com/depromeet/fairer/dto/member/jwt/ResponseJwtTokenDto.java b/src/main/java/com/depromeet/fairer/dto/member/jwt/ResponseJwtTokenDto.java index b8c93387..b2dee2ec 100644 --- a/src/main/java/com/depromeet/fairer/dto/member/jwt/ResponseJwtTokenDto.java +++ b/src/main/java/com/depromeet/fairer/dto/member/jwt/ResponseJwtTokenDto.java @@ -27,9 +27,11 @@ public class ResponseJwtTokenDto { private Date refreshTokenExpireTime; @ApiModelProperty(value = "신규 회원 여부 - 이름이 저장되어 있는지 여부") + @Builder.Default private Boolean isNewMember = false; @ApiModelProperty(value = "팀 소속 여부") + @Builder.Default private Boolean hasTeam = false; @ApiModelProperty(value = "멤버 이름") diff --git a/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetListResponseDto.java b/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetListResponseDto.java deleted file mode 100644 index f52027a0..00000000 --- a/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetListResponseDto.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.depromeet.fairer.dto.preset.response; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.List; - -@NoArgsConstructor -@AllArgsConstructor -@Getter -public class HouseWorkPresetListResponseDto { - private List preset; -} diff --git a/src/main/java/com/depromeet/fairer/global/exception/FairerException.java b/src/main/java/com/depromeet/fairer/global/exception/FairerException.java new file mode 100644 index 00000000..a4e71d8c --- /dev/null +++ b/src/main/java/com/depromeet/fairer/global/exception/FairerException.java @@ -0,0 +1,16 @@ +package com.depromeet.fairer.global.exception; + + +public class FairerException extends RuntimeException { + public FairerException(Exception e) { + super(e); + } + + public FairerException() { + super(); + } + + public FairerException(String message) { + super(message); + } +} diff --git a/src/main/java/com/depromeet/fairer/global/exception/handler/FairerException.java b/src/main/java/com/depromeet/fairer/global/exception/handler/FairerException.java deleted file mode 100644 index fdcdf31d..00000000 --- a/src/main/java/com/depromeet/fairer/global/exception/handler/FairerException.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.depromeet.fairer.global.exception.handler; - -public class FairerException extends RuntimeException { - public FairerException(Exception e) { - super(e); - } -} diff --git a/src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java b/src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java index 682b3b1e..5ba4d9ef 100644 --- a/src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java +++ b/src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java @@ -117,6 +117,11 @@ protected ResponseEntity handleMemberTokenNotFoundException(Me return exceptionResponseEntity(e.getMessage(), HttpStatus.NOT_FOUND, request.getRequestURI()); } + @ExceptionHandler(FairerException.class) + protected ResponseEntity handleFairerException(FairerException e, HttpServletRequest request) { + log.error("FairerException", e); + return exceptionResponseEntity(e.getMessage(), HttpStatus.INTERNAL_SERVER_ERROR, request.getRequestURI()); + } /** diff --git a/src/main/java/com/depromeet/fairer/repository/preset/PresetRepository.java b/src/main/java/com/depromeet/fairer/repository/preset/PresetRepository.java deleted file mode 100644 index dc3ff5e0..00000000 --- a/src/main/java/com/depromeet/fairer/repository/preset/PresetRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.depromeet.fairer.repository.preset; - -import com.depromeet.fairer.domain.preset.Preset; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -import java.util.List; - -@Repository -public interface PresetRepository extends JpaRepository { - List findByPresetSpaceName(String presetSpaceName); -} diff --git a/src/main/java/com/depromeet/fairer/service/PresetService.java b/src/main/java/com/depromeet/fairer/service/PresetService.java deleted file mode 100644 index 38888360..00000000 --- a/src/main/java/com/depromeet/fairer/service/PresetService.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.depromeet.fairer.service; - -import com.depromeet.fairer.domain.preset.Preset; -import com.depromeet.fairer.domain.preset.constant.Space; -import com.depromeet.fairer.dto.preset.response.HouseWorkPresetListResponseDto; -import com.depromeet.fairer.dto.preset.response.HouseWorkPresetResponseDto; -import com.depromeet.fairer.repository.preset.PresetRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -@Service -@RequiredArgsConstructor -public class PresetService { - private final PresetRepository presetRepository; - - /** - * 공간 -> 집안일 프리셋 조회 - * @param space 공간 - * @return 집안일 이름 list - */ - @Transactional - public HouseWorkPresetResponseDto getHouseWorkPreset(Space space){ - List houseWorks = presetRepository.findByPresetSpaceName(space.name()) - .stream().map(Preset::getPresetHouseWorkName) - .collect(Collectors.toList()); - return new HouseWorkPresetResponseDto(space.name(), houseWorks); - } - - public HouseWorkPresetListResponseDto getPreset() { - List preset = new ArrayList<>(); - for (Space space : Space.values()) { - if (space.equals(Space.ETC)) { - continue; - } - - List houseWorks = presetRepository.findByPresetSpaceName(space.name()) - .stream().map(Preset::getPresetHouseWorkName) - .collect(Collectors.toList()); - - preset.add(new HouseWorkPresetResponseDto(space.name(), houseWorks)); - } - return new HouseWorkPresetListResponseDto(preset); - } -} diff --git a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java index 9d0f42dc..0177b353 100644 --- a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java +++ b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java @@ -6,7 +6,7 @@ import com.depromeet.fairer.dto.fcm.request.SaveTokenRequest; import com.depromeet.fairer.dto.fcm.response.FCMMessageResponse; import com.depromeet.fairer.dto.fcm.response.SaveTokenResponse; -import com.depromeet.fairer.global.exception.handler.FairerException; +import com.depromeet.fairer.global.exception.FairerException; import com.depromeet.fairer.global.factory.RestTemplateFactory; import com.depromeet.fairer.repository.member.MemberRepository; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java index 6cb1fb6c..ca3573dd 100644 --- a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java +++ b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java @@ -1,18 +1,10 @@ package com.depromeet.fairer.vo.houseWork; -import com.depromeet.fairer.domain.preset.constant.Space; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; -import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; -import io.swagger.annotations.ApiModelProperty; +import com.depromeet.fairer.domain.preset.Space; import lombok.Builder; import lombok.Getter; import lombok.Setter; -import org.springframework.stereotype.Service; -import java.time.LocalDate; import java.time.LocalDateTime; import java.time.LocalTime; import java.util.List; diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java index a4840e50..fa0bcbc7 100644 --- a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java +++ b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java @@ -1,12 +1,11 @@ package com.depromeet.fairer.vo.houseWork; -import com.depromeet.fairer.domain.preset.constant.Space; +import com.depromeet.fairer.domain.preset.Space; import lombok.Getter; import lombok.Setter; import java.time.LocalDateTime; import java.time.LocalTime; -import java.util.List; @Getter @Setter diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkUpdateVo.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkUpdateVo.java index 2e4760f2..b1825ea5 100644 --- a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkUpdateVo.java +++ b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkUpdateVo.java @@ -1,15 +1,9 @@ package com.depromeet.fairer.vo.houseWork; -import com.depromeet.fairer.domain.preset.constant.Space; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer; -import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer; -import io.swagger.annotations.ApiModelProperty; +import com.depromeet.fairer.domain.preset.Space; import lombok.Getter; import lombok.Setter; -import javax.validation.constraints.NotNull; import java.time.LocalDate; import java.time.LocalTime; import java.util.List; From a443c7c031ac81920ca10d6a4f6f5bb361cb948c Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Tue, 2 Aug 2022 01:21:36 +0900 Subject: [PATCH 30/51] =?UTF-8?q?=EB=B3=80=EC=88=98=EB=AA=85=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD=20=EB=B0=8F=20id=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairer/domain/preset/Preset.java | 66 +++++++++---------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/domain/preset/Preset.java b/src/main/java/com/depromeet/fairer/domain/preset/Preset.java index ec380899..841e22c8 100644 --- a/src/main/java/com/depromeet/fairer/domain/preset/Preset.java +++ b/src/main/java/com/depromeet/fairer/domain/preset/Preset.java @@ -12,36 +12,36 @@ @Getter @AllArgsConstructor public enum Preset { - PRESET_1(1, Space.ENTRANCE,"신발 정리"), - PRESET_2(2, Space.ENTRANCE,"현관 청소"), - PRESET_3(3, Space.ENTRANCE,"분리수거하기"), - PRESET_4(4, Space.BATHROOM,"욕조 청소"), - PRESET_5(5, Space.BATHROOM,"변기 청소"), - PRESET_6(6, Space.BATHROOM,"화장실 청소"), - PRESET_7(7, Space.BATHROOM,"욕실 용품 정리"), - PRESET_8(8, Space.ROOM,"옷장 정리"), - PRESET_9(9, Space.ROOM,"화장대 정리"), - PRESET_10(10, Space.ROOM,"방청소"), - PRESET_11(11, Space.ROOM,"물건 정리정돈"), - PRESET_12(12, Space.ROOM,"이불 정리"), - PRESET_13(13, Space.KITCHEN,"설거지"), - PRESET_14(14, Space.KITCHEN,"가스렌지 닦기"), - PRESET_15(15, Space.KITCHEN,"냉장고 정리"), - PRESET_16(16, Space.KITCHEN,"부엌 정리정돈"), - PRESET_17(17, Space.KITCHEN,"음식물 쓰레기 버리기"), - PRESET_18(18, Space.KITCHEN,"식사 준비하기"), - PRESET_19(19, Space.KITCHEN,"간식 준비하기"), - PRESET_20(20, Space.OUTSIDE,"쓰레기 버리기"), - PRESET_21(21, Space.OUTSIDE,"장보기"), - PRESET_22(22, Space.OUTSIDE,"반려동물 산책"), - PRESET_23(23, Space.OUTSIDE,"마중 나가기"), - PRESET_24(24, Space.LIVINGROOM,"창 청소"), - PRESET_25(25, Space.LIVINGROOM,"거실 청소"), - PRESET_26(26, Space.LIVINGROOM,"물건 정리정돈"), - PRESET_27(27, Space.LIVINGROOM,"환기 시키기"), - PRESET_28(28, Space.LIVINGROOM,"빨래 돌리기"), - PRESET_29(29, Space.LIVINGROOM,"빨래 개기"), - PRESET_30(30, Space.LIVINGROOM,"세탁기 청소"), + ORGANIZING_SHOES(Space.ENTRANCE,"신발 정리"), + CLEANING_ENTRANCE(Space.ENTRANCE,"현관 청소"), + SEPARATING_TRASH(Space.ENTRANCE,"분리수거하기"), + CLEANING_BATHTUB(Space.BATHROOM,"욕조 청소"), + CLEANING_TOILET_BOWL(Space.BATHROOM,"변기 청소"), + CLEANING_BATHROOM(Space.BATHROOM,"화장실 청소"), + ORGANIZING_BATHROOM_ITEMS(Space.BATHROOM,"욕실 용품 정리"), + ORGANIZING_CLOSET(Space.ROOM,"옷장 정리"), + ARRANGEMENT_DRESSING_TABLE(Space.ROOM,"화장대 정리"), + CLEANING_ROOM(Space.ROOM,"방 청소"), + ORGANIZING_ROOM_ITEMS(Space.ROOM,"물건 정리정돈"), + MAKING_BED(Space.ROOM,"이불 정리"), + WASHING_DISH(Space.KITCHEN,"설거지"), + CLEANING_STOVE(Space.KITCHEN,"가스렌지 닦기"), + CLEANING_UP_REFRIGERATOR(Space.KITCHEN,"냉장고 정리"), + CLEANING_UP_KITCHEN(Space.KITCHEN,"부엌 정리정돈"), + DISPOSAL_FOOD_WASTE(Space.KITCHEN,"음식물 쓰레기 버리기"), + PREPARING_MEAL(Space.KITCHEN,"식사 준비하기"), + PREPARING_SNACK(Space.KITCHEN,"간식 준비하기"), + DISPOSAL_GARBAGE(Space.OUTSIDE,"쓰레기 버리기"), + SHOPPING(Space.OUTSIDE,"장보기"), + PET_WALKING(Space.OUTSIDE,"반려동물 산책"), + MEETING(Space.OUTSIDE,"마중 나가기"), + CLEANING_WINDOW(Space.LIVINGROOM,"창 청소"), + CLEANING_LININGROOM(Space.LIVINGROOM,"거실 청소"), + ORGANIZING_LININGROOM_ITEMS(Space.LIVINGROOM,"물건 정리정돈"), + VENTILATION(Space.LIVINGROOM,"환기 시키기"), + WASHING_CLOTHES(Space.LIVINGROOM,"빨래 돌리기"), + FOLDING_LAUNDRY(Space.LIVINGROOM,"빨래 개기"), + CLEANING_WASHING_MACHINE(Space.LIVINGROOM,"세탁기 청소"), ; public static Preset getPreset(Space space, String houseWorkName) { @@ -49,11 +49,6 @@ public static Preset getPreset(Space space, String houseWorkName) { .findFirst().orElseThrow(() -> new FairerException("Preset Not Found")); } - public static Preset getPreset(int presetId) { - return Arrays.stream(values()).filter(p -> p.presetId == presetId) - .findFirst().orElseThrow(() -> new FairerException("Preset Not Found")); - } - public static List getPresetListBySpace(Space space) { return Arrays.stream(values()).filter(p -> p.space.equals(space)).collect(Collectors.toList()); } @@ -62,7 +57,6 @@ public static List getHouseworkNameListBySpace(Space space) { return Arrays.stream(values()).filter(p -> p.space.equals(space)).map(Preset::getHouseworkName).collect(Collectors.toList()); } - private int presetId; private Space space; private String houseworkName; } From f59815fcd3ab9e607406238cdbc21e08080f3d53 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Tue, 2 Aug 2022 14:39:39 +0900 Subject: [PATCH 31/51] =?UTF-8?q?dockerhub=20=EA=B3=84=EC=A0=95=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev-fairer-jib.yml | 4 ++-- build.gradle | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev-fairer-jib.yml b/.github/workflows/dev-fairer-jib.yml index eee750d3..33fb15b1 100644 --- a/.github/workflows/dev-fairer-jib.yml +++ b/.github/workflows/dev-fairer-jib.yml @@ -62,6 +62,6 @@ jobs: steps: - name: Docker run run: | - sudo docker ps -q --filter "name=fairer-dev" | grep -q . && sudo docker stop "fairer-dev" && sudo docker rmi "ehdqls4013/fairer-dev-repo:latest" - sudo docker run -d --name fairer-dev --rm -p 8080:8080 ehdqls4013/fairer-dev-repo:latest + sudo docker ps -q --filter "name=fairer-dev" | grep -q . && sudo docker stop "fairer-dev" && sudo docker rmi "fairerbe/fairer-dev-repo:latest" + sudo docker run -d --name fairer-dev --rm -p 8080:8080 fairerbe/fairer-dev-repo:latest diff --git a/build.gradle b/build.gradle index 09a9ab38..901f8297 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ jib { image = "adoptopenjdk/openjdk16:x86_64-alpine-jdk-16.0.1_9" } to { - image = "registry.hub.docker.com/ehdqls4013/fairer-dev-repo" + image = "registry.hub.docker.com/fairerbe/fairer-dev-repo" tags = ['latest', new SimpleDateFormat('yyyyMMddHHmmss').format(System.currentTimeMillis())] // 2개의 태그에 모두 push } container { From 75c6111a009c7c998276037d5d8b3c6c3428ac59 Mon Sep 17 00:00:00 2001 From: dongbin Shin <59786670+SDB016@users.noreply.github.com> Date: Wed, 3 Aug 2022 00:01:48 +0900 Subject: [PATCH 32/51] =?UTF-8?q?Member.password=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/depromeet/fairer/domain/member/Member.java | 5 ----- .../depromeet/fairer/dto/member/oauth/OAuthAttributes.java | 4 +--- .../service/member/oauth/google/GoogleFeignService.java | 2 -- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/domain/member/Member.java b/src/main/java/com/depromeet/fairer/domain/member/Member.java index 2fd807b4..20aa3ed9 100644 --- a/src/main/java/com/depromeet/fairer/domain/member/Member.java +++ b/src/main/java/com/depromeet/fairer/domain/member/Member.java @@ -50,10 +50,6 @@ public class Member extends BaseTimeEntity { @Column(name = "member_name", columnDefinition = "VARCHAR(50)", nullable = false) private String memberName; - @JsonIgnore - @Column(name = "password", columnDefinition = "VARCHAR(300)", nullable = false) - private String password; - @Column(name = "status_message", columnDefinition = "VARCHAR(40)") private String statusMessage; @@ -80,7 +76,6 @@ public static Member create(OAuthAttributes socialUserInfo) { return Member.builder() .email(socialUserInfo.getEmail()) .socialType(socialUserInfo.getSocialType()) - .password(socialUserInfo.getPassword()) .assignments(new ArrayList<>()) .memberName("") // 회원가입 할때는 빈값으로 세팅, 이후 멤버 업데이트 api 로 변경 .profilePath("") diff --git a/src/main/java/com/depromeet/fairer/dto/member/oauth/OAuthAttributes.java b/src/main/java/com/depromeet/fairer/dto/member/oauth/OAuthAttributes.java index 0ce2de3f..ce2ae25f 100644 --- a/src/main/java/com/depromeet/fairer/dto/member/oauth/OAuthAttributes.java +++ b/src/main/java/com/depromeet/fairer/dto/member/oauth/OAuthAttributes.java @@ -16,15 +16,13 @@ public class OAuthAttributes { private String name; private String email; private SocialType socialType; - private String password; @Builder - public OAuthAttributes(Map attributes, String nameAttributesKey, String name, String email, SocialType socialType, String password) { + public OAuthAttributes(Map attributes, String nameAttributesKey, String name, String email, SocialType socialType) { this.attributes = attributes; this.nameAttributesKey = nameAttributesKey; this.name = name; this.email = email; this.socialType = socialType; - this.password = password; } } diff --git a/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleFeignService.java b/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleFeignService.java index e1fc7a6b..dd5a078f 100644 --- a/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleFeignService.java +++ b/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleFeignService.java @@ -36,7 +36,6 @@ public class GoogleFeignService { @Value("${oauth2.clientSecret}") private String CLIENT_SECRET; - private final String PASSWORD = "autoPassword"; private final String GRANT_TYPE = "authorization_code"; private final String REQUEST_URI = "https://www.googleapis.com/oauth2/v4/token"; @@ -53,7 +52,6 @@ public OAuthAttributes getUserInfo(String accessToken) { .email(StringUtils.isBlank(googleUserInfo.getEmail()) ? googleUserInfo.getId() : googleUserInfo.getEmail()) // 이메일 동의 x 경우 .name(googleUserInfo.getName()) .socialType(SocialType.GOOGLE) - .password(passwordEncoder.encode(PASSWORD)) .build(); } From 5d7532cf1477f3a02cbe32ed952d13758736a7cd Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Wed, 3 Aug 2022 00:00:43 +0900 Subject: [PATCH 33/51] feat: add logging aspect --- build.gradle | 1 + .../global/aop/ControllerLoggingAspect.java | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java diff --git a/build.gradle b/build.gradle index 901f8297..7398e7a0 100644 --- a/build.gradle +++ b/build.gradle @@ -54,6 +54,7 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-aop' //firebase sdk implementation 'com.google.firebase:firebase-admin:6.8.1' diff --git a/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java b/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java new file mode 100644 index 00000000..0e89f3b5 --- /dev/null +++ b/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java @@ -0,0 +1,30 @@ +package com.depromeet.fairer.global.aop; + +import lombok.extern.slf4j.Slf4j; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.*; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Component; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +@Slf4j +@Aspect +@Component +public class ControllerLoggingAspect { + @Pointcut("execution(* com.depromeet.fairer.api.*.*(..))") + private void controllerPointCut(){} + + @Around(value = "controllerPointCut()") + public Object aroundControllerPointCut(ProceedingJoinPoint joinPoint) throws Throwable { + HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); + Object[] args = joinPoint.getArgs(); + log.info("[{}] request : {}", request.getRequestURI(), args); + Object response = joinPoint.proceed(); + ResponseEntity responseEntity = (ResponseEntity)response; + log.info("[{}|{}] response : {}", request.getRequestURI(), responseEntity.getStatusCode(), responseEntity.getBody()); + return response; + } +} From 62eecf53e3f27e1aed51c24309a2efa91c1d75ee Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Wed, 3 Aug 2022 00:27:03 +0900 Subject: [PATCH 34/51] feat: add logging aspect --- .../fairer/dto/preset/response/HouseWorkPresetResponseDto.java | 2 ++ .../depromeet/fairer/global/aop/ControllerLoggingAspect.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetResponseDto.java b/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetResponseDto.java index 950a8c2d..d4870097 100644 --- a/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetResponseDto.java +++ b/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetResponseDto.java @@ -3,12 +3,14 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.ToString; import java.util.List; @NoArgsConstructor @AllArgsConstructor @Getter +@ToString public class HouseWorkPresetResponseDto { private String space; private List houseWorks; diff --git a/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java b/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java index 0e89f3b5..449cb5e3 100644 --- a/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java +++ b/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java @@ -21,7 +21,7 @@ private void controllerPointCut(){} public Object aroundControllerPointCut(ProceedingJoinPoint joinPoint) throws Throwable { HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); Object[] args = joinPoint.getArgs(); - log.info("[{}] request : {}", request.getRequestURI(), args); + log.info("[{}|{}] request : {}", request.getRequestURI(), request.getMethod(), args); Object response = joinPoint.proceed(); ResponseEntity responseEntity = (ResponseEntity)response; log.info("[{}|{}] response : {}", request.getRequestURI(), responseEntity.getStatusCode(), responseEntity.getBody()); From 21fec0384f523af3eee16463839afe83185ba368 Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Wed, 3 Aug 2022 20:12:46 +0900 Subject: [PATCH 35/51] =?UTF-8?q?feat:=20=ED=8C=80=20=EC=B0=B8=EC=97=AC=20?= =?UTF-8?q?=EC=8B=9C=20=ED=8C=80=EC=9B=90=EC=97=90=EA=B2=8C=20=ED=91=B8?= =?UTF-8?q?=EC=8B=9C=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=A0=84=EC=86=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/depromeet/fairer/Application.java | 2 ++ .../fairer/dto/fcm/FCMSendRequest.java | 9 ++++++ .../global/config/TaskExecutorConfig.java | 18 +++++++++++ .../fairer/service/fcm/FCMService.java | 32 ++++++++++--------- .../fairer/service/team/TeamService.java | 27 +++++++++------- 5 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 src/main/java/com/depromeet/fairer/global/config/TaskExecutorConfig.java diff --git a/src/main/java/com/depromeet/fairer/Application.java b/src/main/java/com/depromeet/fairer/Application.java index 602efab0..f06f4949 100644 --- a/src/main/java/com/depromeet/fairer/Application.java +++ b/src/main/java/com/depromeet/fairer/Application.java @@ -3,8 +3,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +import org.springframework.scheduling.annotation.EnableAsync; @EnableJpaAuditing +@EnableAsync @SpringBootApplication public class Application { diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java b/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java index e7caffee..33eba930 100644 --- a/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java +++ b/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java @@ -1,14 +1,23 @@ package com.depromeet.fairer.dto.fcm; import com.google.firebase.messaging.Message; +import lombok.Builder; import lombok.Data; /*** * https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages/send */ @Data +@Builder public class FCMSendRequest { private boolean validate_only; private Message message; + + public static FCMSendRequest of(Message message, boolean validate_only) { + return FCMSendRequest.builder() + .message(message) + .validate_only(validate_only) + .build(); + } } diff --git a/src/main/java/com/depromeet/fairer/global/config/TaskExecutorConfig.java b/src/main/java/com/depromeet/fairer/global/config/TaskExecutorConfig.java new file mode 100644 index 00000000..31378409 --- /dev/null +++ b/src/main/java/com/depromeet/fairer/global/config/TaskExecutorConfig.java @@ -0,0 +1,18 @@ +package com.depromeet.fairer.global.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +@Configuration +public class TaskExecutorConfig { + @Bean(name = "fcmTaskExecutor") + public ThreadPoolTaskExecutor fcmTaskExecutor() { + ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor(); + taskExecutor.setCorePoolSize(20); + taskExecutor.setMaxPoolSize(100); + taskExecutor.setQueueCapacity(200); + taskExecutor.setThreadNamePrefix("fcm-"); + return taskExecutor; + } +} diff --git a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java index 0177b353..a22f253d 100644 --- a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java +++ b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java @@ -18,6 +18,7 @@ import org.springframework.core.io.ClassPathResource; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; +import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; @@ -50,7 +51,22 @@ public FCMMessageResponse sendMessage(FCMMessageRequest fcmMessageRequest) { .orElseThrow(() -> new IllegalArgumentException("memberId에 해당하는 회원을 찾지 못했습니다.")); FCMSendRequest fcmSendRequest = createMessage(member.getFcmToken(), fcmMessageRequest.getTitle(), fcmMessageRequest.getBody()); + this.sendFCMMessage(fcmSendRequest); + return FCMMessageResponse.of(fcmMessageRequest.getTitle(), fcmMessageRequest.getBody(), fcmMessageRequest.getMemberId()); + } + + private FCMSendRequest createMessage(String token, String title, String body) { + Message message = Message.builder() + .setToken(token) + .setNotification(new Notification(title, body)) + .build(); + + return FCMSendRequest.of(message, false); + } + + @Async(value = "fcmTaskExecutor") + private void sendFCMMessage(FCMSendRequest fcmSendRequest) { try { HttpHeaders headers = new HttpHeaders(); headers.add(HttpHeaders.AUTHORIZATION, "Bearer " + getAccessToken()); @@ -58,26 +74,12 @@ public FCMMessageResponse sendMessage(FCMMessageRequest fcmMessageRequest) { HttpEntity request = new HttpEntity<>(objectMapper.writeValueAsString(fcmSendRequest), headers); Message message = restTemplate.postForObject(FCM_DOMAIN, request, Message.class); - log.info("Send FCM Message : {}, request : {}", message, fcmMessageRequest); - return FCMMessageResponse.of(fcmMessageRequest.getTitle(), fcmMessageRequest.getBody(), fcmMessageRequest.getMemberId()); + log.info("Send FCM Message : {}, request : {}", message, fcmSendRequest); } catch (Exception e) { log.error("Error to send message.", e); - throw new FairerException(e); } } - private FCMSendRequest createMessage(String token, String title, String body) { - Message message = Message.builder() - .setToken(token) - .setNotification(new Notification(title, body)) - .build(); - - FCMSendRequest request = new FCMSendRequest(); - request.setValidate_only(false); - request.setMessage(message); - return request; - } - private String getAccessToken() throws IOException { GoogleCredentials googleCredentials = GoogleCredentials.fromStream(new ClassPathResource(FIREBASE_KEY_PATH).getInputStream()).createScoped(List.of("https://www.googleapis.com/auth/cloud-platform")); googleCredentials.refreshIfExpired(); diff --git a/src/main/java/com/depromeet/fairer/service/team/TeamService.java b/src/main/java/com/depromeet/fairer/service/team/TeamService.java index 3256a2e9..07694614 100644 --- a/src/main/java/com/depromeet/fairer/service/team/TeamService.java +++ b/src/main/java/com/depromeet/fairer/service/team/TeamService.java @@ -4,6 +4,7 @@ import com.depromeet.fairer.domain.assignment.Assignment; import com.depromeet.fairer.domain.member.Member; import com.depromeet.fairer.domain.team.Team; +import com.depromeet.fairer.dto.fcm.request.FCMMessageRequest; import com.depromeet.fairer.global.exception.BadRequestException; import com.depromeet.fairer.global.exception.CannotJoinTeamException; import com.depromeet.fairer.global.exception.MemberTokenNotFoundException; @@ -12,6 +13,7 @@ import com.depromeet.fairer.repository.housework.HouseWorkRepository; import com.depromeet.fairer.repository.member.MemberRepository; import com.depromeet.fairer.repository.team.TeamRepository; +import com.depromeet.fairer.service.fcm.FCMService; import com.depromeet.fairer.service.member.MemberService; import com.depromeet.fairer.vo.team.InviteCodeVo; @@ -23,7 +25,6 @@ import java.time.LocalDateTime; import java.util.List; import java.util.Set; -import java.util.stream.Collectors; @Slf4j @Service @@ -36,6 +37,7 @@ public class TeamService { private final MemberRepository memberRepository; private final AssignmentRepository assignmentRepository; private final HouseWorkRepository houseWorkRepository; + private final FCMService fcmService; public Team createTeam(Long memberId, String teamName) { final Member reqMember = memberService.findWithTeam(memberId); @@ -63,9 +65,22 @@ public Team joinTeam(Long memberId, String inviteCode) { validateInviteCode(team, inviteCode); Member member = reqMember.joinTeam(team); + + pushMessageToTeamMember(team.getMembers()); + return member.getTeam(); } + private void pushMessageToTeamMember(Set members) { + for(Member member : members) { + FCMMessageRequest request = new FCMMessageRequest(); + request.setMemberId(member.getMemberId()); + request.setTitle(String.format("%s님이 %s에 참여", member.getMemberName(), member.getTeam().getTeamName())); + request.setBody("앞으로 함께 평화롭게 집안일 해보아요✨"); + fcmService.sendMessage(request); + } + } + private void validateInviteCode(Team team, String reqInviteCode) { // 초대 코드 및 유효기간 검증 @@ -103,16 +118,6 @@ public Team updateTeam(Long memberId, String teamName) { return reqTeam; } - public Set getTeamMembers(Long memberId) { - Member member = memberService.findWithTeam(memberId); - - if (member.hasTeam()) { - return member.getTeam().getMembers(); - } - - throw new BadRequestException("소속된 팀이 없습니다."); - } - public void leaveTeam(Long memberId) { final Member member = memberService.findWithTeam(memberId); From 8bc096f984b4b8a634993ab47f592ffd8ca12c5d Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Thu, 4 Aug 2022 02:46:15 +0900 Subject: [PATCH 36/51] =?UTF-8?q?refactor:=20=EC=A7=91=EC=95=88=EC=9D=BC?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EB=82=A0=EC=A7=9C=20?= =?UTF-8?q?=EA=B5=AC=EA=B0=84=EC=9C=BC=EB=A1=9C=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairer/api/HouseWorkController.java | 109 ++++++++++-------- .../fairer/global/util/DateTimeUtils.java | 4 + .../housework/HouseWorkCustomRepository.java | 12 -- .../HouseWorkCustomRepositoryImpl.java | 71 ------------ .../housework/HouseWorkRepository.java | 11 +- .../member/MemberCustomRepository.java | 4 - .../member/MemberCustomRepositoryImpl.java | 18 --- .../service/housework/HouseWorkService.java | 80 ++----------- .../fairer/service/member/MemberService.java | 4 - .../fairer/service/team/TeamService.java | 8 +- .../HouseWorkAndAssigneeResponseDto.java | 30 ----- .../vo/houseWork/HouseWorkAndAssigneeVo.java | 36 ------ .../vo/houseWork/HouseWorkDetailVo.java | 29 ----- 13 files changed, 81 insertions(+), 335 deletions(-) delete mode 100644 src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeResponseDto.java delete mode 100644 src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java delete mode 100644 src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java diff --git a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java index 7dd85611..5451550c 100644 --- a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java +++ b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java @@ -12,8 +12,8 @@ import com.depromeet.fairer.dto.housework.response.*; import com.depromeet.fairer.service.member.MemberService; +import com.depromeet.fairer.service.team.TeamService; import com.depromeet.fairer.vo.houseWork.HouseWorkUpdateVo; -import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeResponseDto; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import io.swagger.v3.oas.annotations.tags.Tag; @@ -27,9 +27,10 @@ import javax.validation.Valid; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @Slf4j @@ -40,12 +41,14 @@ public class HouseWorkController { private final HouseWorkService houseWorkService; private final MemberService memberService; + private final TeamService teamService; private final ModelMapper modelMapper; @Tag(name = "houseWorks") @ApiOperation(value = "집안일 생성 API ") @PostMapping("") - public ResponseEntity createHouseWorks(@ApiIgnore @RequestMemberId Long memberId, @RequestBody @Valid HouseWorksCreateRequestDto dto) { + public ResponseEntity createHouseWorks(@ApiIgnore @RequestMemberId Long memberId, + @RequestBody @Valid HouseWorksCreateRequestDto dto) { List houseWorkList = houseWorkService.createHouseWorks(memberId, dto.getHouseWorks()); return new ResponseEntity<>(new HouseWorksCreateResponseDto(houseWorkList), HttpStatus.CREATED); } @@ -79,7 +82,7 @@ public ResponseEntity deleteHouseWork( @Deprecated public ResponseEntity> getHouseWork(@RequestParam("scheduledDate") String scheduledDate, @ApiIgnore @RequestMemberId Long memberId) { - LocalDate scheduledDateParse = LocalDate.parse(scheduledDate, DateTimeFormatter.ISO_DATE); + LocalDate scheduledDateParse = DateTimeUtils.stringToLocalDate(scheduledDate); List members = memberService.getMemberList(memberId); @@ -104,55 +107,61 @@ public ResponseEntity> getHouseWork(@RequestParam } @Tag(name = "houseWorks") - @ApiOperation(value = "특정 멤버의 날짜별 집안일 조회", notes = "특정 멤버의 날짜별 집안일 조회") - @GetMapping("{memberId}") - public ResponseEntity getTheMemberHouseWork(@RequestParam("reqDate") String reqDate, - @PathVariable("memberId") Long memberId, - @ApiIgnore @RequestMemberId Long reqMemberId) { - final LocalDate localDate = DateTimeUtils.stringToLocalDate(reqDate); - final HouseWorkAndAssigneeResponseDto theMemberHouseWorks = houseWorkService.getTheMemberHouseWorks(reqMemberId, memberId, localDate); - return ResponseEntity.ok(theMemberHouseWorks); + @ApiOperation(value = "팀원의 특정 기간 집안일 목록 조회", notes = "본인이 속한 팀의 팀원의 특정 기간 집안일 목록 조회") + @GetMapping("/list/member/{teamMemberId}") + public ResponseEntity> getHouseWorkListByTeamMemberAndDate(@RequestParam("fromDate") String fromDate, + @RequestParam("toDate") String toDate, + @PathVariable("teamMemberId") Long teamMemberId, + @ApiIgnore @RequestMemberId Long memberId) { + final LocalDate from = DateTimeUtils.stringToLocalDate(fromDate); + final LocalDate to = DateTimeUtils.stringToLocalDate(toDate); + + teamService.checkJoinSameTeam(teamMemberId, memberId); + + Member teamMember = memberService.find(teamMemberId); + + List houseWorkList = houseWorkService.getHouseWorkByDate(teamMember, from, to); + + Map> houseWorkListGroupByScheduledDate = getHouseWorkListGroupByScheduledDate(houseWorkList); + + return ResponseEntity.ok(makeHouseWorkListResponse(teamMemberId, houseWorkListGroupByScheduledDate)); } @Tag(name = "houseWorks") @ApiOperation(value = "특정 날짜별 집안일 조회", notes = "특정 날짜별 집안일 조회") - @GetMapping("/date") - public ResponseEntity getHouseWorkByDate(@RequestParam("reqDate") String reqDate, @ApiIgnore @RequestMemberId Long reqMemberId) { - final LocalDate localDate = DateTimeUtils.stringToLocalDate(reqDate); - final HouseWorkAndAssigneeResponseDto responseDto = houseWorkService.getHouseWorkByDate(reqMemberId, localDate); - return ResponseEntity.ok(responseDto); + @GetMapping("/list") + public ResponseEntity> getHouseWorkListByDate(@RequestParam("fromDate") String fromDate, + @RequestParam("toDate") String toDate, + @ApiIgnore @RequestMemberId Long memberId) { + final LocalDate from = DateTimeUtils.stringToLocalDate(fromDate); + final LocalDate to = DateTimeUtils.stringToLocalDate(toDate); + + Member member = memberService.find(memberId); + + List houseWorkList = houseWorkService.getHouseWorkByDateAndTeam(member.getTeam(), from, to); + + Map> houseWorkListGroupByScheduledDate = getHouseWorkListGroupByScheduledDate(houseWorkList); + + return ResponseEntity.ok(makeHouseWorkListResponse(memberId, houseWorkListGroupByScheduledDate)); + } + + private Map> getHouseWorkListGroupByScheduledDate(List houseWorkList) { + return houseWorkList.stream().map(houseWork -> { + List memberDtoList = memberService.getMemberListByHouseWorkId(houseWork.getHouseWorkId()) + .stream().map(MemberDto::from).collect(Collectors.toList()); + return HouseWorkResponseDto.from(houseWork, memberDtoList); + }).collect(Collectors.groupingBy(HouseWorkResponseDto::getScheduledDate, HashMap::new, Collectors.toCollection(ArrayList::new))); } -// @Tag(name = "houseWorks") -// @ApiOperation(value = "날짜별 집안일 조회", notes = "본인 포함 팀원들의 집안일까지 모두 조회") -// @GetMapping(value = "") -// public ResponseEntity> getHouseWork(@RequestParam("reqDate") String reqDate, -// @ApiIgnore @RequestMemberId Long memberId) { -// final LocalDate reqDateParse = DateTimeUtils.stringToLocalDate(reqDate); -// -// houseWorkService.getMyTeamAllHouseWorksByDate(memberId, reqDate); -// -// List members = memberService.getMyTeamMembers(memberId); -// -// List houseWorkDateResponseDtos = new ArrayList<>(); -// for (Member member : members) { -// List houseWorks = houseWorkService.getHouseWorks(reqDateParse, member); -// -// List houseWorkResponseDtoList = houseWorks.stream().map(houseWork -> { -// List memberDtoList = memberService.getMemberListByHouseWorkId(houseWork.getHouseWorkId()) -// .stream().map(MemberDto::from).collect(Collectors.toList()); -// -// return HouseWorkResponseDto.from(houseWork, memberDtoList); -// }).collect(Collectors.toList()); -// -// long countDone = houseWorkResponseDtoList.stream().filter(HouseWorkResponseDto::getSuccess).count(); -// long countLeft = houseWorkResponseDtoList.stream().filter(houseWorkResponseDto -> !houseWorkResponseDto.getSuccess()).count(); -// -// houseWorkDateResponseDtos.add(HouseWorkDateResponseDto.from(member.getMemberId(), reqDateParse, countDone, countLeft, houseWorkResponseDtoList)); -// } -// -// return ResponseEntity.ok(houseWorkDateResponseDtos); -// } + private Map makeHouseWorkListResponse(Long memberId, Map> houseWorkListGroupByScheduledDate) { + Map response = new HashMap<>(); + houseWorkListGroupByScheduledDate.forEach((scheduledDate, houseWorkResponseDtoList) -> { + long countDone = houseWorkResponseDtoList.stream().filter(HouseWorkResponseDto::getSuccess).count(); + long countLeft = houseWorkResponseDtoList.stream().filter(houseWorkResponseDto -> !houseWorkResponseDto.getSuccess()).count(); + response.put(DateTimeUtils.localDateToString(scheduledDate), HouseWorkDateResponseDto.from(memberId, scheduledDate, countDone, countLeft, houseWorkResponseDtoList)); + }); + return response; + } @Tag(name = "houseWorks") @ApiOperation(value = "개별 집안일 조회", notes = "") @@ -164,13 +173,15 @@ public ResponseEntity getHouseWorkDetail(@PathVariable("ho @Tag(name = "houseWorks") @ApiOperation(value = "집안일 완료여부 수정", notes = "toBeStatus=0이면 완료->미완료, toBeStatus=1이면 미완료->완료") @PatchMapping(value = "{houseWorkId}") - public ResponseEntity updateHouseWorkStatus(@PathVariable("houseWorkId") Long houseWorkId, @RequestBody @Valid HouseWorkStatusRequestDto req) { + public ResponseEntity updateHouseWorkStatus(@PathVariable("houseWorkId") Long houseWorkId, + @RequestBody @Valid HouseWorkStatusRequestDto req) { return ResponseEntity.ok(houseWorkService.updateHouseWorkStatus(houseWorkId, req.getToBeStatus())); } @Tag(name = "houseWorks") @GetMapping("/success/count") - public ResponseEntity getSuccessCount(@RequestParam(required = true) String scheduledDate, @ApiIgnore @RequestMemberId Long memberId) { + public ResponseEntity getSuccessCount(@RequestParam String scheduledDate, + @ApiIgnore @RequestMemberId Long memberId) { HouseWorkSuccessCountResponseDto houseWorkSuccessCountResponseDto = houseWorkService.getSuccessCount(scheduledDate, memberId); return ResponseEntity.ok(houseWorkSuccessCountResponseDto); } diff --git a/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java b/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java index aaa7ce66..0ae34422 100644 --- a/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java +++ b/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java @@ -16,4 +16,8 @@ public static LocalDateTime convertToLocalDateTime(Date date) { public static LocalDate stringToLocalDate(String localDate) { return LocalDate.parse(localDate, DateTimeFormatter.ISO_DATE); } + + public static String localDateToString(LocalDate localDate) { + return localDate.format(DateTimeFormatter.ISO_DATE); + } } diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java index b6ffbcba..1cc4716b 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java @@ -1,19 +1,7 @@ package com.depromeet.fairer.repository.housework; -import com.depromeet.fairer.domain.housework.HouseWork; -import com.depromeet.fairer.vo.houseWork.HouseWorkDetailVo; - import java.time.LocalDate; -import java.util.List; public interface HouseWorkCustomRepository { Long getHouseWorkSuccessCount(Long memberId, LocalDate startDate, LocalDate endDate); - - List getHouseWorkAndAssignee(Long memberId, LocalDate localDate); - List getHouseWorkAndAssignees(Long memberId, LocalDate localDate); - - List getHouseWorkAndAssigneesByDate(Long reqMemberId, LocalDate localDate); - - - // List getHouseWorkList(LocalDate scheduledDate, Long memberId); } diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java index aa1bd800..44133b9c 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java @@ -1,18 +1,10 @@ package com.depromeet.fairer.repository.housework; -import com.depromeet.fairer.domain.assignment.QAssignment; -import com.depromeet.fairer.domain.housework.HouseWork; -import com.depromeet.fairer.domain.housework.QHouseWork; -import com.depromeet.fairer.domain.member.QMember; -import com.depromeet.fairer.domain.team.QTeam; -import com.depromeet.fairer.vo.houseWork.HouseWorkDetailVo; -import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; import java.time.LocalDate; -import java.util.List; import static com.depromeet.fairer.domain.assignment.QAssignment.assignment; import static com.depromeet.fairer.domain.housework.QHouseWork.houseWork; @@ -35,67 +27,4 @@ public Long getHouseWorkSuccessCount(Long memberId, LocalDate startDate, LocalDa .stream() .count(); } - - @Override - public List getHouseWorkAndAssignee(Long memberId, LocalDate localDate) { - return jpaQueryFactory.selectFrom(houseWork) - .innerJoin(assignment.member, member) - .innerJoin(houseWork.assignments, assignment) - .where(member.memberId.eq(memberId) - .and(houseWork.scheduledDate.eq(localDate))) - .fetch(); - - } - - @Override - public List getHouseWorkAndAssignees(Long memberId, LocalDate localDate) { - QAssignment assignment1 = QAssignment.assignment; - QMember member = QMember.member; - QAssignment assignment2 = QAssignment.assignment; - QHouseWork houseWork = QHouseWork.houseWork; - - return jpaQueryFactory.select(Projections.bean(HouseWorkDetailVo.class, - houseWork.houseWorkId, - houseWork.space, - houseWork.houseWorkName, - houseWork.scheduledTime, - houseWork.successDateTime, - houseWork.success, - member.memberId, - member.memberName, - member.profilePath)) - .from(assignment1) - .innerJoin(houseWork).on(assignment1.houseWork.houseWorkId.eq(houseWork.houseWorkId)) - .innerJoin(assignment2).on(assignment2.houseWork.houseWorkId.eq(houseWork.houseWorkId)) - .innerJoin(member).on(assignment2.member.memberId.eq(member.memberId)) - .where(houseWork.scheduledDate.eq(localDate) - .and(assignment1.member.memberId.eq(memberId))) - .fetch(); - } - - @Override - public List getHouseWorkAndAssigneesByDate(Long reqMemberId, LocalDate localDate) { - QMember reqMember = QMember.member; - QHouseWork houseWork = QHouseWork.houseWork; - QTeam team = QTeam.team; - - return jpaQueryFactory.select(Projections.bean(HouseWorkDetailVo.class, - houseWork.houseWorkId, - houseWork.space, - houseWork.houseWorkName, - houseWork.scheduledTime, - houseWork.successDateTime, - houseWork.success, - member.memberId, - member.memberName, - member.profilePath)) - .from(team) - .innerJoin(reqMember).on(reqMember.team.teamId.eq(team.teamId)) - .innerJoin(member).on(member.team.teamId.eq(team.teamId)) - .innerJoin(assignment).on(assignment.member.memberId.eq(member.memberId)) - .innerJoin(houseWork).on(assignment.houseWork.houseWorkId.eq(houseWork.houseWorkId)) - .where(reqMember.memberId.eq(reqMemberId) - .and(houseWork.scheduledDate.eq(localDate))) - .fetch(); - } } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java index 19e3a49b..6ee486bf 100644 --- a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java @@ -2,24 +2,17 @@ import com.depromeet.fairer.domain.assignment.Assignment; import com.depromeet.fairer.domain.housework.HouseWork; -import com.depromeet.fairer.domain.member.Member; import com.depromeet.fairer.domain.team.Team; -import org.apache.tomcat.jni.Local; -import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import java.time.LocalDate; import java.util.List; -import java.util.Optional; @Repository public interface HouseWorkRepository extends JpaRepository, HouseWorkCustomRepository { List findAllByScheduledDateAndAssignmentsIn(LocalDate scheduledDate, List assignments); - - -// @EntityGraph(attributePaths = {"assignments"}) -// List findHouseWorksByMember(Member member); + List findAllByScheduledDateBetweenAndAssignmentsIn(LocalDate fromDate, LocalDate toDate, List assignments); + List findAllByScheduledDateBetweenAndTeam(LocalDate fromDate, LocalDate toDate, Team team); } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java index fbe6391a..e91f26f8 100644 --- a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java +++ b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java @@ -1,13 +1,9 @@ package com.depromeet.fairer.repository.member; import com.depromeet.fairer.domain.member.Member; -import org.springframework.data.jpa.repository.EntityGraph; import java.util.List; -import java.util.Optional; public interface MemberCustomRepository { List getMemberDtoListByHouseWorkId(Long houseWorkId); - - List getMyTeamMembers(Long memberId); } diff --git a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java index 917bd02c..d0c0ef4f 100644 --- a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java +++ b/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java @@ -1,19 +1,14 @@ package com.depromeet.fairer.repository.member; import com.depromeet.fairer.domain.member.Member; -import com.depromeet.fairer.domain.member.QMember; -import com.depromeet.fairer.domain.team.QTeam; -import com.querydsl.jpa.JPAExpressions; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Repository; import java.util.List; -import java.util.Optional; import static com.depromeet.fairer.domain.assignment.QAssignment.assignment; import static com.depromeet.fairer.domain.member.QMember.member; -import static com.depromeet.fairer.domain.team.QTeam.team; @Repository @RequiredArgsConstructor @@ -28,17 +23,4 @@ public List getMemberDtoListByHouseWorkId(Long houseWorkId){ .where(assignment.houseWork.houseWorkId.eq(houseWorkId)) .fetch(); } - - @Override - public List getMyTeamMembers(Long memberId) { - final QMember member1 = QMember.member; - final QMember member2 = QMember.member; - final QTeam team = QTeam.team; - return jpaQueryFactory.select(member1) - .from(team) - .innerJoin(member2).on(member2.team.eq(team)) - .where(member2.memberId.eq(memberId)) - .fetch(); - } - } diff --git a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java index c4804dd1..996519ad 100644 --- a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java +++ b/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java @@ -14,13 +14,9 @@ import com.depromeet.fairer.repository.member.MemberRepository; import com.depromeet.fairer.service.member.MemberService; import com.depromeet.fairer.service.team.TeamService; -import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeVo; -import com.depromeet.fairer.vo.houseWork.HouseWorkDetailVo; import com.depromeet.fairer.vo.houseWork.HouseWorkUpdateVo; -import com.depromeet.fairer.vo.houseWork.HouseWorkAndAssigneeResponseDto; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.jetbrains.annotations.NotNull; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -74,7 +70,6 @@ private HouseWorkResponseDto createHouseWork(Long memberId, HouseWorkUpdateReque return HouseWorkResponseDto.from(houseWork, memberDtoList); } - @Transactional public HouseWorkResponseDto updateHouseWork(HouseWorkUpdateVo houseWorkUpdateVo) { Member member = memberService.findWithTeam(houseWorkUpdateVo.getMemberId()); HouseWork houseWork = getHouseWorkById(houseWorkUpdateVo.getHouseWorkId()); @@ -109,7 +104,6 @@ public HouseWorkResponseDto updateHouseWork(HouseWorkUpdateVo houseWorkUpdateVo) return HouseWorkResponseDto.from(houseWork, memberDtoList); } - @Transactional public void deleteHouseWork(Long memberId, Long houseWorkId) { try { HouseWork houseWork = houseWorkRepository.getById(houseWorkId); @@ -131,33 +125,7 @@ public HouseWorkSuccessCountResponseDto getSuccessCount(String scheduledDate, Lo return HouseWorkSuccessCountResponseDto.of(count); } -// @Transactional -// public HouseWorkMemberResponseDto getHouseWork(LocalDate scheduledDate, Long memberId){ -// Team team = memberService.findWithTeam(memberId).getTeam(); -// List memberList = memberRepository.findAllByTeam(team); -// -// List houseWorkDateResponseDtos = new ArrayList<>(); -// -// for (Member memberr : memberList){ -// List assignmentList = assignmentRepository.findAllByMember(memberr); -// List houseWorkList = houseWorkRepository.findAllByScheduledDateAndAssignmentsIn(scheduledDate, assignmentList); -// -// List houseWorkResponseDtoList = houseWorkList.stream().map(houseWork -> { -// List memberDtoList = memberRepository.getMemberDtoListByHouseWorkId(houseWork.getHouseWorkId()).stream().map(MemberDto::from).collect(Collectors.toList()); -// -// return HouseWorkResponseDto.from(houseWork, memberDtoList); -// }).collect(Collectors.toList()); -// -// long countDone = houseWorkResponseDtoList.stream().filter(HouseWorkResponseDto::getSuccess).count(); -// long countLeft = houseWorkResponseDtoList.stream().filter(houseWorkResponseDto -> !houseWorkResponseDto.getSuccess()).count(); -// -// houseWorkDateResponseDtos.add(HouseWorkDateResponseDto.from(memberr.getMemberId(), scheduledDate, countDone, countLeft, houseWorkResponseDtoList)); -// } -// -// return HouseWorkMemberResponseDto.from(team.getTeamId(), houseWorkDateResponseDtos); -// } - - @Transactional + @Deprecated public List getHouseWorks(LocalDate scheduledDate, Member member) { List assignmentList = assignmentRepository.findAllByMember(member); List houseWorkList = houseWorkRepository.findAllByScheduledDateAndAssignmentsIn(scheduledDate, assignmentList); @@ -165,15 +133,21 @@ public List getHouseWorks(LocalDate scheduledDate, Member member) { return houseWorkList; } + public List getHouseWorkByDate(Member member, LocalDate fromDate, LocalDate toDate) { + List assignmentList = assignmentRepository.findAllByMember(member); + return houseWorkRepository.findAllByScheduledDateBetweenAndAssignmentsIn(fromDate, toDate, assignmentList); + } + + public List getHouseWorkByDateAndTeam(Team team, LocalDate fromDate, LocalDate toDate) { + return houseWorkRepository.findAllByScheduledDateBetweenAndTeam(fromDate, toDate, team); + } - @Transactional public HouseWorkResponseDto getHouseWorkDetail(Long houseWorkId) { HouseWork houseWork = getHouseWorkById(houseWorkId); List memberDtoList = memberRepository.getMemberDtoListByHouseWorkId(houseWorkId).stream().map(MemberDto::from).collect(Collectors.toList()); return HouseWorkResponseDto.from(houseWork, memberDtoList); } - @Transactional public HouseWorkStatusResponseDto updateHouseWorkStatus(Long houseWorkId, int toBeStatus) { boolean status = toBeStatus == 1; @@ -188,40 +162,4 @@ public HouseWork getHouseWorkById(Long houseWorkId) { return houseWorkRepository.findById(houseWorkId) .orElseThrow(() -> new IllegalArgumentException("존재하지 않는 집안일 입니다.")); } - - public HouseWorkAndAssigneeResponseDto getTheMemberHouseWorks(Long reqMemberId, Long memberId, LocalDate localDate) { - teamService.validateSameTeam(reqMemberId, memberId); - final List houseWorkDetailVoList = houseWorkRepository.getHouseWorkAndAssignees(memberId, localDate); - - List houseWorkAndAssigneeVos = makeHouseWorkAndAssigneeVos(houseWorkDetailVoList); - final long successCount = houseWorkAndAssigneeVos.stream().filter(HouseWorkAndAssigneeVo::getSuccess).count(); - return new HouseWorkAndAssigneeResponseDto(houseWorkAndAssigneeVos, successCount, houseWorkAndAssigneeVos.size() - successCount); - } - - @NotNull - private List makeHouseWorkAndAssigneeVos(List houseWorkDetailVoList) { - Map> houseWorkMap = houseWorkDetailVoList.stream() - .collect(Collectors.groupingBy( - HouseWorkDetailVo::getHouseWorkId, - Collectors.mapping(houseWorkDetailVo -> HouseWorkAndAssigneeVo.MemberVo.builder().memberId(houseWorkDetailVo.getMemberId()).memberName(houseWorkDetailVo.getMemberName()).profilePath(houseWorkDetailVo.getProfilePath()).build(), Collectors.toList()))); - - return houseWorkDetailVoList.stream().map(houseWorkDetailVo -> - HouseWorkAndAssigneeVo.builder() - .houseWorkId(houseWorkDetailVo.getHouseWorkId()) - .space(houseWorkDetailVo.getSpace()) - .houseWorkName(houseWorkDetailVo.getHouseWorkName()) - .scheduledTime(houseWorkDetailVo.getScheduledTime()) - .successDateTime(houseWorkDetailVo.getSuccessDateTime()) - .success(houseWorkDetailVo.getSuccess()) - .assignees(houseWorkMap.get(houseWorkDetailVo.getHouseWorkId())) - .build()) - .distinct().collect(Collectors.toList()); - } - - public HouseWorkAndAssigneeResponseDto getHouseWorkByDate(Long reqMemberId, LocalDate localDate) { - final List houseWorkDetailVos = houseWorkRepository.getHouseWorkAndAssigneesByDate(reqMemberId, localDate); - final List houseWorkAndAssigneeVos = makeHouseWorkAndAssigneeVos(houseWorkDetailVos); - final long successCount = houseWorkAndAssigneeVos.stream().filter(HouseWorkAndAssigneeVo::getSuccess).count(); - return new HouseWorkAndAssigneeResponseDto(houseWorkAndAssigneeVos, successCount, houseWorkDetailVos.size() - successCount); - } } \ No newline at end of file diff --git a/src/main/java/com/depromeet/fairer/service/member/MemberService.java b/src/main/java/com/depromeet/fairer/service/member/MemberService.java index f1a18da5..81f3cd3b 100644 --- a/src/main/java/com/depromeet/fairer/service/member/MemberService.java +++ b/src/main/java/com/depromeet/fairer/service/member/MemberService.java @@ -44,8 +44,4 @@ public Member updateMember(Long memberId, String memberName, String profilePath, member.update(memberName, profilePath, statusMessage); return memberRepository.save(member); } - - public List getMyTeamMembers(Long memberId) { - return memberRepository.getMyTeamMembers(memberId); - } } diff --git a/src/main/java/com/depromeet/fairer/service/team/TeamService.java b/src/main/java/com/depromeet/fairer/service/team/TeamService.java index 07694614..a15e8dd0 100644 --- a/src/main/java/com/depromeet/fairer/service/team/TeamService.java +++ b/src/main/java/com/depromeet/fairer/service/team/TeamService.java @@ -24,6 +24,7 @@ import javax.transaction.Transactional; import java.time.LocalDateTime; import java.util.List; +import java.util.Objects; import java.util.Set; @Slf4j @@ -148,8 +149,11 @@ public Team getTeam(Long memberId) { } - public void validateSameTeam(Long reqMemberId, Long memberId) { - if (memberService.getMyTeamMembers(reqMemberId).stream().noneMatch(m -> m.getMemberId().equals(memberId))) { + public void checkJoinSameTeam(Long teamMemberId, Long memberId) { + Member teamMember = memberService.find(teamMemberId); + Member member = memberService.find(memberId); + + if (!Objects.equals(member.getTeam(), teamMember.getTeam())) { throw new PermissionDeniedException("해당 멤버의 정보를 가져올 수 없습니다."); } } diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeResponseDto.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeResponseDto.java deleted file mode 100644 index be1b175a..00000000 --- a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeResponseDto.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.depromeet.fairer.vo.houseWork; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; - -import java.util.List; - -@Getter -@NoArgsConstructor @AllArgsConstructor -@ApiModel(value = "특정 멤버, 날짜에 할당된 집안일 모두 조회 반환 객체", description = "특정 멤버, 날짜에 할당된 집안일 모두 조회 반환 객체") -public class HouseWorkAndAssigneeResponseDto { - - @ApiModelProperty(value = "집안일, 담당자 객체 리스트") - private List houseWorkAndAssigneeVos; - - @ApiModelProperty(value = "완료한 집안일 갯수") - private int successCount; - - @ApiModelProperty(value = "남은 집안일 갯수") - private int leftCount; - - public HouseWorkAndAssigneeResponseDto(List houseWorkAndAssigneeVos, long successCount, long leftCount) { - this.houseWorkAndAssigneeVos = houseWorkAndAssigneeVos; - this.successCount = (int) successCount; - this.leftCount = (int) leftCount; - } -} diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java deleted file mode 100644 index ca3573dd..00000000 --- a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkAndAssigneeVo.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.depromeet.fairer.vo.houseWork; - -import com.depromeet.fairer.domain.preset.Space; -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.List; - -@Getter @Setter -@Builder -public class HouseWorkAndAssigneeVo { - - private Long houseWorkId; - - private Space space; - - private String houseWorkName; - - private List assignees; - - private LocalTime scheduledTime; - - private LocalDateTime successDateTime; - - private Boolean success; - - @Getter @Setter @Builder - public static class MemberVo{ - private Long memberId; - private String memberName; - private String profilePath; - } -} diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java b/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java deleted file mode 100644 index fa0bcbc7..00000000 --- a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkDetailVo.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.depromeet.fairer.vo.houseWork; - -import com.depromeet.fairer.domain.preset.Space; -import lombok.Getter; -import lombok.Setter; - -import java.time.LocalDateTime; -import java.time.LocalTime; - -@Getter -@Setter -public class HouseWorkDetailVo { - - private Long houseWorkId; - - private Space space; - - private String houseWorkName; - - private LocalTime scheduledTime; - - private LocalDateTime successDateTime; - - private Boolean success; - - private Long memberId; - private String memberName; - private String profilePath; -} From d86353cff218c4caad666999c39d93d024dfd6fd Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Sat, 6 Aug 2022 16:43:38 +0900 Subject: [PATCH 37/51] =?UTF-8?q?refactor:=20=EC=A7=91=EC=95=88=EC=9D=BC?= =?UTF-8?q?=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EB=82=A0=EC=A7=9C=20?= =?UTF-8?q?=EA=B5=AC=EA=B0=84=EC=9C=BC=EB=A1=9C=20=EC=A1=B0=ED=9A=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/depromeet/fairer/api/HouseWorkController.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java index 5451550c..3ff9e09a 100644 --- a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java +++ b/src/main/java/com/depromeet/fairer/api/HouseWorkController.java @@ -119,11 +119,8 @@ public ResponseEntity> getHouseWorkListByT teamService.checkJoinSameTeam(teamMemberId, memberId); Member teamMember = memberService.find(teamMemberId); - List houseWorkList = houseWorkService.getHouseWorkByDate(teamMember, from, to); - Map> houseWorkListGroupByScheduledDate = getHouseWorkListGroupByScheduledDate(houseWorkList); - return ResponseEntity.ok(makeHouseWorkListResponse(teamMemberId, houseWorkListGroupByScheduledDate)); } @@ -137,11 +134,8 @@ public ResponseEntity> getHouseWorkListByD final LocalDate to = DateTimeUtils.stringToLocalDate(toDate); Member member = memberService.find(memberId); - List houseWorkList = houseWorkService.getHouseWorkByDateAndTeam(member.getTeam(), from, to); - Map> houseWorkListGroupByScheduledDate = getHouseWorkListGroupByScheduledDate(houseWorkList); - return ResponseEntity.ok(makeHouseWorkListResponse(memberId, houseWorkListGroupByScheduledDate)); } From 353496ba689c20e97380b9a1a1b12825807ec341 Mon Sep 17 00:00:00 2001 From: seungyoon-kim Date: Fri, 12 Aug 2022 01:30:42 +0900 Subject: [PATCH 38/51] fix: change fcm response --- .../java/com/depromeet/fairer/service/fcm/FCMService.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java index a22f253d..3de8a274 100644 --- a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java +++ b/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java @@ -6,7 +6,6 @@ import com.depromeet.fairer.dto.fcm.request.SaveTokenRequest; import com.depromeet.fairer.dto.fcm.response.FCMMessageResponse; import com.depromeet.fairer.dto.fcm.response.SaveTokenResponse; -import com.depromeet.fairer.global.exception.FairerException; import com.depromeet.fairer.global.factory.RestTemplateFactory; import com.depromeet.fairer.repository.member.MemberRepository; import com.fasterxml.jackson.databind.ObjectMapper; @@ -73,8 +72,7 @@ private void sendFCMMessage(FCMSendRequest fcmSendRequest) { headers.add(HttpHeaders.CONTENT_TYPE, "application/json; UTF-8"); HttpEntity request = new HttpEntity<>(objectMapper.writeValueAsString(fcmSendRequest), headers); - Message message = restTemplate.postForObject(FCM_DOMAIN, request, Message.class); - log.info("Send FCM Message : {}, request : {}", message, fcmSendRequest); + String message = restTemplate.postForObject(FCM_DOMAIN, request, String.class); } catch (Exception e) { log.error("Error to send message.", e); } From 2f636a97abe6821a39d4b6795f1c01ba2a294269 Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Fri, 12 Aug 2022 20:24:22 +0900 Subject: [PATCH 39/51] Create dev-fairer-batch.yml --- .github/workflows/dev-fairer-batch.yml | 72 ++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/dev-fairer-batch.yml diff --git a/.github/workflows/dev-fairer-batch.yml b/.github/workflows/dev-fairer-batch.yml new file mode 100644 index 00000000..73547269 --- /dev/null +++ b/.github/workflows/dev-fairer-batch.yml @@ -0,0 +1,72 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created +# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle + +name: dev-fairer-batch + +on: + workflow_dispatch: + push: + branches: [ develop ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + java-version: '11' + distribution: 'adopt' + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ap-northeast-2 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew # gradle wrapper를 실행할 수 있도록 권한 부여 + shell: bash + + - name: Set timezone to Seoul + run: sudo timedatectl set-timezone Asia/Seoul + shell: bash + + - name: JIB Build with Gradle + run: ./gradlew jib # 프로젝트 빌드 + shell: bash + + - name: Get current time + uses: 1466587594/get-current-time@v2 # 빌드 완료 시간 가져오기 + id: current-time + with: + format: YYYY-MM-DD-HH-mm-ss + utcOffset: "+09:00" + + - name: Show Current Time + run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" # 빌드 완료 시간 출력하기 + shell: bash + + deploy: + needs: build + name: Deploy + runs-on: [ self-hosted, label-development ] + steps: + - name: Docker run + run: | + sudo docker ps -q --filter "name=fairer-batch-dev" | grep -q . && sudo docker stop "fairer-batch-dev" && sudo docker rmi "fairer-batch/fairer-batch-dev:latest" + sudo docker run -d --name fairer-batch-dev --rm -p 8081:8081 fairer-batch/fairer-batch-dev:latest + From aa5607749c538e00ffe47ec7db075d01fa921c35 Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Fri, 12 Aug 2022 21:17:48 +0900 Subject: [PATCH 40/51] Update dev-fairer-batch.yml --- .github/workflows/dev-fairer-batch.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dev-fairer-batch.yml b/.github/workflows/dev-fairer-batch.yml index 73547269..234daa31 100644 --- a/.github/workflows/dev-fairer-batch.yml +++ b/.github/workflows/dev-fairer-batch.yml @@ -46,7 +46,7 @@ jobs: shell: bash - name: JIB Build with Gradle - run: ./gradlew jib # 프로젝트 빌드 + run: ./gradlew :fairer-batch:jib # 프로젝트 빌드 shell: bash - name: Get current time @@ -67,6 +67,5 @@ jobs: steps: - name: Docker run run: | - sudo docker ps -q --filter "name=fairer-batch-dev" | grep -q . && sudo docker stop "fairer-batch-dev" && sudo docker rmi "fairer-batch/fairer-batch-dev:latest" - sudo docker run -d --name fairer-batch-dev --rm -p 8081:8081 fairer-batch/fairer-batch-dev:latest - + sudo docker ps -q --filter "name=fairer-batch-dev" | grep -q . && sudo docker stop "fairer-batch-dev" && sudo docker rmi "fairer-batch:latest" + sudo docker run -d --name fairer-batch-dev --rm -p 8081:8081 fairer-batch:latest From e8c82eff096c94c681dae6231fb86e320dd29fc3 Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Fri, 12 Aug 2022 22:20:42 +0900 Subject: [PATCH 41/51] Update dev-fairer-batch.yml --- .github/workflows/dev-fairer-batch.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/dev-fairer-batch.yml b/.github/workflows/dev-fairer-batch.yml index 234daa31..c1b5a2f4 100644 --- a/.github/workflows/dev-fairer-batch.yml +++ b/.github/workflows/dev-fairer-batch.yml @@ -26,16 +26,11 @@ jobs: java-version: '11' distribution: 'adopt' - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 + - name: Login to Docker Hub + uses: docker/login-action@v1 with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ap-northeast-2 - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Grant execute permission for gradlew run: chmod +x ./gradlew # gradle wrapper를 실행할 수 있도록 권한 부여 @@ -67,5 +62,5 @@ jobs: steps: - name: Docker run run: | - sudo docker ps -q --filter "name=fairer-batch-dev" | grep -q . && sudo docker stop "fairer-batch-dev" && sudo docker rmi "fairer-batch:latest" - sudo docker run -d --name fairer-batch-dev --rm -p 8081:8081 fairer-batch:latest + sudo docker ps -q --filter "name=fairer-batch-dev" | grep -q . && sudo docker stop "fairer-batch-dev" && sudo docker rmi "fairerbe/fairer-batch-dev:latest" + sudo docker run -d --name fairer-batch-dev --rm -p 8081:8081 fairerbe/fairer-batch-dev:latest From 3c0e8a7d847531532566c5ea78366559a89fbfdc Mon Sep 17 00:00:00 2001 From: daseulll Date: Sat, 20 Aug 2022 00:27:53 +0900 Subject: [PATCH 42/51] =?UTF-8?q?fix:=20google=20oauth2=20API=20hd=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80=20=EB=8C=80=EC=9D=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java b/src/main/java/com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java index 6994f5a7..a92fb58a 100644 --- a/src/main/java/com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java +++ b/src/main/java/com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java @@ -28,4 +28,7 @@ public class GoogleUserInfo { @JsonProperty("locale") private String locale; + + @JsonProperty("hd") + private String hd; } From 7d2f865eb6ac5b55ca7f893c7560219037c811e9 Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Sat, 20 Aug 2022 22:26:15 +0900 Subject: [PATCH 43/51] feat: Setting multi module and Spring Batch Project (#126) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 멀티 모듈 구조 - api 모듈 : fairer-api로 이동 - batch 모듈 : fairer-batch로 생성 - 작업 내용 - 스프링 배치 모듈 추가 개발 - 집안일 추가/완료 유도 배치 및 푸시메시지 전송 기능 추가 - 미사용 import/code 제거 - (구) 개발 서버 배포 github actions 제거 --- .ebextensions-dev/00-makeFiles.config | 11 -- ...{dev-fairer-jib.yml => dev-fairer-api.yml} | 5 +- .github/workflows/dev-fairer.yml | 67 --------- build.gradle | 136 ++++-------------- fairer-api/build.gradle | 107 ++++++++++++++ .../com/depromeet/fairer/Application.java | 0 .../fairer/api/HouseWorkController.java | 0 .../fairer/api/MemberController.java | 1 - .../fairer/api/OauthLoginController.java | 5 - .../fairer/api/PresetController.java | 0 .../depromeet/fairer/api/RuleController.java | 0 .../depromeet/fairer/api/TeamController.java | 0 .../fairer/api/fcm/FCMController.java | 0 .../fairer/domain/assignment/Assignment.java | 0 .../fairer/domain/base/BaseTimeEntity.java | 1 - .../fairer/domain/housework/HouseWork.java | 0 .../fairer/domain/member/Member.java | 2 - .../domain/member/constant/ProfileImage.java | 0 .../domain/member/constant/SocialType.java | 0 .../domain/memberToken/MemberToken.java | 1 - .../memberToken/constant/JwtTokenType.java | 0 .../constant/RemainingTokenTime.java | 0 .../fairer/domain/preset/Preset.java | 1 - .../depromeet/fairer/domain/preset/Space.java | 0 .../depromeet/fairer/domain/rule/Rule.java | 0 .../depromeet/fairer/domain/team/Team.java | 0 .../domain/team/constant/TeamConstant.java | 0 .../fairer/dto/common/CommonApiResult.java | 0 .../fairer/dto/fcm/FCMMessageTemplate.java | 13 ++ .../fairer/dto/fcm/FCMSendRequest.java | 0 .../dto/fcm/request/FCMMessageRequest.java | 0 .../dto/fcm/request/SaveTokenRequest.java | 0 .../dto/fcm/response/FCMMessageResponse.java | 0 .../dto/fcm/response/SaveTokenResponse.java | 0 .../request/HouseWorkStatusRequestDto.java | 0 .../request/HouseWorkUpdateRequestDto.java | 0 .../request/HouseWorksCreateRequestDto.java | 0 .../response/HouseWorkDateResponseDto.java | 0 .../response/HouseWorkMemberResponseDto.java | 0 .../response/HouseWorkResponseDto.java | 0 .../response/HouseWorkStatusResponseDto.java | 0 .../HouseWorkSuccessCountResponseDto.java | 0 .../response/HouseWorksCreateResponseDto.java | 0 .../fairer/dto/member/MemberDto.java | 0 .../dto/member/jwt/ResponseJwtTokenDto.java | 0 .../fairer/dto/member/jwt/TokenDto.java | 0 .../dto/member/oauth/GoogleUserInfo.java | 0 .../dto/member/oauth/OAuthAttributes.java | 0 .../dto/member/oauth/OauthLoginDto.java | 0 .../dto/member/oauth/OauthRequestDto.java | 0 .../request/MemberUpdateRequestDto.java | 0 .../MemberProfileImageResponseDto.java | 0 .../member/response/MemberResponseDto.java | 0 .../response/HouseWorkPresetResponseDto.java | 0 .../dto/rule/request/RuleRequestDto.java | 0 .../dto/rule/response/RuleResponseDto.java | 0 .../dto/rule/response/RulesResponseDto.java | 1 - .../fairer/dto/team/TeamLeaveRequestDto.java | 0 .../team/request/TeamCreateRequestDto.java | 0 .../dto/team/request/TeamJoinRequestDto.java | 0 .../team/request/TeamUpdateRequestDto.java | 0 .../team/response/TeamCreateResponseDto.java | 4 - .../team/response/TeamInfoResponseDto.java | 0 .../response/TeamInviteCodeResponseDto.java | 0 .../team/response/TeamJoinResponseDto.java | 0 .../team/response/TeamUpdateResponseDto.java | 0 .../global/aop/ControllerLoggingAspect.java | 0 .../global/config/ArgResolverConfig.java | 0 .../global/config/FeignConfiguration.java | 0 .../fairer/global/config/MapperConfig.java | 0 .../fairer/global/config/QuerydslConfig.java | 0 .../fairer/global/config/SecurityConfig.java | 2 - .../fairer/global/config/SwaggerConfig.java | 0 .../global/config/TaskExecutorConfig.java | 0 .../fairer/global/config/WebConfig.java | 1 - .../fairer/global/config/Workaround.java | 0 .../fairer/global/config/XssConfig.java | 2 - .../config/interceptor/AuthInterceptor.java | 0 .../global/exception/BadRequestException.java | 0 .../exception/CannotJoinTeamException.java | 0 .../global/exception/FairerException.java | 9 -- .../exception/FeignClientException.java | 0 .../MemberTokenNotFoundException.java | 0 .../exception/NoSuchMemberException.java | 2 - .../exception/PermissionDeniedException.java | 0 .../exception/dto/ErrorResponseDto.java | 0 .../FeignClientExceptionErrorDecoder.java | 1 - .../handler/GlobalExceptionHandler.java | 1 - .../global/factory/RestTemplateFactory.java | 0 .../global/resolver/RequestMemberId.java | 2 - .../RequestMemberIdArgumentResolver.java | 1 - .../fairer/global/util/DateTimeUtils.java | 0 .../assignment/AssignmentRepository.java | 0 .../housework/HouseWorkCustomRepository.java | 0 .../HouseWorkCustomRepositoryImpl.java | 0 .../housework/HouseWorkRepository.java | 0 .../member/MemberCustomRepository.java | 0 .../member/MemberCustomRepositoryImpl.java | 0 .../repository/member/MemberRepository.java | 3 - .../memberToken/MemberTokenRepository.java | 1 - .../repository/rule/RuleRepository.java | 0 .../repository/team/TeamRepository.java | 4 - .../fairer/service/fcm/FCMService.java | 24 +++- .../service/housework/HouseWorkService.java | 0 .../fairer/service/member/MemberService.java | 2 - .../service/member/jwt/TokenProvider.java | 0 .../member/oauth/OauthLoginService.java | 0 .../oauth/google/GoogleAuthFeignClient.java | 1 - .../oauth/google/GoogleFeignService.java | 0 .../oauth/google/GoogleInfoFeignClient.java | 1 - .../oauth/google/OauthTokenResponse.java | 0 .../fairer/service/rule/RuleService.java | 2 - .../fairer/service/team/TeamService.java | 5 +- .../vo/houseWork/HouseWorkUpdateVo.java | 0 .../fairer/vo/team/InviteCodeVo.java | 0 .../src}/main/resources/application.yml | 0 .../main/resources/db/migration/V1__init.sql | 0 ...59-firebase-adminsdk-uvxs2-2b35d6203d.json | 0 .../src}/main/resources/logback-spring.xml | 6 +- .../lucy-xss-servlet-filter-rule.xml | 0 .../main/resources/lucy-xss-superset-sax.xml | 0 .../depromeet/fairer/ApplicationTests.java | 0 fairer-batch/build.gradle | 38 +++++ .../com/depromeet/fairer/Application.java | 15 ++ .../config/InduceAddHouseworkJobConfig.java | 91 ++++++++++++ .../NotCompleteHouseworkRemindJobConfig.java | 91 ++++++++++++ .../domain/command/FCMMessageRequest.java | 20 +++ .../domain/command/FCMMessageResponse.java | 10 ++ .../domain/command/FCMMessageTemplate.java | 14 ++ .../command/InduceAddHouseworkCommand.java | 9 ++ .../NotCompleteHouseworkRemindCommand.java | 10 ++ .../config/DomainConfigurationProperties.java | 14 ++ .../domain/config/RestTemplateFactory.java | 13 ++ .../InduceAddHouseworkJobScheduler.java | 33 +++++ ...otCompleteHouseworkRemindJobScheduler.java | 34 +++++ .../src/main/resources/application.yml | 70 +++++++++ .../src/main/resources/logback-spring.xml | 41 ++++++ logs/spring.log | 0 settings.gradle | 2 + .../repository/team/TeamCustomRepository.java | 4 - .../team/TeamCustomRepositoryImpl.java | 5 - 141 files changed, 677 insertions(+), 262 deletions(-) delete mode 100644 .ebextensions-dev/00-makeFiles.config rename .github/workflows/{dev-fairer-jib.yml => dev-fairer-api.yml} (96%) delete mode 100644 .github/workflows/dev-fairer.yml create mode 100644 fairer-api/build.gradle rename {src => fairer-api/src}/main/java/com/depromeet/fairer/Application.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/api/HouseWorkController.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/api/MemberController.java (98%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/api/OauthLoginController.java (91%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/api/PresetController.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/api/RuleController.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/api/TeamController.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/api/fcm/FCMController.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/assignment/Assignment.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/base/BaseTimeEntity.java (96%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/housework/HouseWork.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/member/Member.java (96%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/member/constant/ProfileImage.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/member/constant/SocialType.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/memberToken/MemberToken.java (97%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/memberToken/constant/JwtTokenType.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/memberToken/constant/RemainingTokenTime.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/preset/Preset.java (98%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/preset/Space.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/rule/Rule.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/team/Team.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/domain/team/constant/TeamConstant.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/common/CommonApiResult.java (100%) create mode 100644 fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/FCMMessageTemplate.java rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/fcm/request/FCMMessageRequest.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/fcm/request/SaveTokenRequest.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkStatusRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkUpdateRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/housework/request/HouseWorksCreateRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkDateResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkMemberResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkStatusResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkSuccessCountResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/housework/response/HouseWorksCreateResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/MemberDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/jwt/ResponseJwtTokenDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/jwt/TokenDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/oauth/OAuthAttributes.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/oauth/OauthLoginDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/oauth/OauthRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/request/MemberUpdateRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/response/MemberProfileImageResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/member/response/MemberResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/rule/request/RuleRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/rule/response/RuleResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/rule/response/RulesResponseDto.java (95%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/team/TeamLeaveRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/team/request/TeamCreateRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/team/request/TeamJoinRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/team/request/TeamUpdateRequestDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/team/response/TeamCreateResponseDto.java (88%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/team/response/TeamInfoResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/team/response/TeamInviteCodeResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/team/response/TeamJoinResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/dto/team/response/TeamUpdateResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/ArgResolverConfig.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/FeignConfiguration.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/MapperConfig.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/QuerydslConfig.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/SecurityConfig.java (91%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/TaskExecutorConfig.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/WebConfig.java (97%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/Workaround.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/XssConfig.java (96%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/config/interceptor/AuthInterceptor.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/BadRequestException.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/CannotJoinTeamException.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/FairerException.java (59%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/FeignClientException.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/MemberTokenNotFoundException.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/NoSuchMemberException.java (83%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/PermissionDeniedException.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/dto/ErrorResponseDto.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/handler/FeignClientExceptionErrorDecoder.java (95%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java (99%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/factory/RestTemplateFactory.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/resolver/RequestMemberId.java (85%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/resolver/RequestMemberIdArgumentResolver.java (96%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/assignment/AssignmentRepository.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/member/MemberRepository.java (87%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/memberToken/MemberTokenRepository.java (84%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/rule/RuleRepository.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/repository/team/TeamRepository.java (82%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/fcm/FCMService.java (81%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/member/MemberService.java (98%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/member/jwt/TokenProvider.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/member/oauth/OauthLoginService.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleAuthFeignClient.java (97%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleFeignService.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleInfoFeignClient.java (96%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/member/oauth/google/OauthTokenResponse.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/rule/RuleService.java (92%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/service/team/TeamService.java (95%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkUpdateVo.java (100%) rename {src => fairer-api/src}/main/java/com/depromeet/fairer/vo/team/InviteCodeVo.java (100%) rename {src => fairer-api/src}/main/resources/application.yml (100%) rename {src => fairer-api/src}/main/resources/db/migration/V1__init.sql (100%) rename {src => fairer-api/src}/main/resources/firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json (100%) rename {src => fairer-api/src}/main/resources/logback-spring.xml (84%) rename {src => fairer-api/src}/main/resources/lucy-xss-servlet-filter-rule.xml (100%) rename {src => fairer-api/src}/main/resources/lucy-xss-superset-sax.xml (100%) rename {src => fairer-api/src}/test/java/com/depromeet/fairer/ApplicationTests.java (100%) create mode 100644 fairer-batch/build.gradle create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/Application.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/config/InduceAddHouseworkJobConfig.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/config/NotCompleteHouseworkRemindJobConfig.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageRequest.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageResponse.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageTemplate.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/domain/command/InduceAddHouseworkCommand.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/domain/command/NotCompleteHouseworkRemindCommand.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/domain/config/DomainConfigurationProperties.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/domain/config/RestTemplateFactory.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/scheduler/InduceAddHouseworkJobScheduler.java create mode 100644 fairer-batch/src/main/java/com/depromeet/fairer/scheduler/NotCompleteHouseworkRemindJobScheduler.java create mode 100644 fairer-batch/src/main/resources/application.yml create mode 100644 fairer-batch/src/main/resources/logback-spring.xml delete mode 100644 logs/spring.log delete mode 100644 src/main/java/com/depromeet/fairer/repository/team/TeamCustomRepository.java delete mode 100644 src/main/java/com/depromeet/fairer/repository/team/TeamCustomRepositoryImpl.java diff --git a/.ebextensions-dev/00-makeFiles.config b/.ebextensions-dev/00-makeFiles.config deleted file mode 100644 index 852258da..00000000 --- a/.ebextensions-dev/00-makeFiles.config +++ /dev/null @@ -1,11 +0,0 @@ -files: - "/sbin/appstart" : - mode: "000755" - owner: webapp - group: webapp - content: | - #!/usr/bin/env bash - JAR_PATH=/var/app/current/application.jar - - # run app - java -Dfile.encoding=UTF-8 -Dspring.profiles.active=dev -jar $JAR_PATH \ No newline at end of file diff --git a/.github/workflows/dev-fairer-jib.yml b/.github/workflows/dev-fairer-api.yml similarity index 96% rename from .github/workflows/dev-fairer-jib.yml rename to .github/workflows/dev-fairer-api.yml index 33fb15b1..f4ae2360 100644 --- a/.github/workflows/dev-fairer-jib.yml +++ b/.github/workflows/dev-fairer-api.yml @@ -5,7 +5,7 @@ # This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle -name: dev-fairer +name: dev-fairer-api on: workflow_dispatch: @@ -41,7 +41,7 @@ jobs: shell: bash - name: JIB Build with Gradle - run: ./gradlew jib # 프로젝트 빌드 + run: ./gradlew :fairer-api:jib # 프로젝트 빌드 shell: bash - name: Get current time @@ -64,4 +64,3 @@ jobs: run: | sudo docker ps -q --filter "name=fairer-dev" | grep -q . && sudo docker stop "fairer-dev" && sudo docker rmi "fairerbe/fairer-dev-repo:latest" sudo docker run -d --name fairer-dev --rm -p 8080:8080 fairerbe/fairer-dev-repo:latest - diff --git a/.github/workflows/dev-fairer.yml b/.github/workflows/dev-fairer.yml deleted file mode 100644 index 803ee964..00000000 --- a/.github/workflows/dev-fairer.yml +++ /dev/null @@ -1,67 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle - -name: dev-fairer - -on: - workflow_dispatch: -# push: -# branches: [ develop ] - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up JDK 11 - uses: actions/setup-java@v2 - with: - java-version: '11' - distribution: 'adopt' - - - name: Grant execute permission for gradlew - run: chmod +x ./gradlew # gradle wrapper를 실행할 수 있도록 권한 부여 - shell: bash - - - name: Build with Gradle - run: ./gradlew clean build # 프로젝트 빌드 - shell: bash - - - name: Get current time - uses: 1466587594/get-current-time@v2 # 빌드 완료 시간 가져오기 - id: current-time - with: - format: YYYY-MM-DD-HH-mm-ss - utcOffset: "+09:00" - - - name: Show Current Time - run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" # 빌드 완료 시간 출력하기 - shell: bash - - # gradle build를 통해 만들어진 jar 파일 codedeploy에 배포하기 위한 zip 파일로 만듬 - - name: Generate deployment package - run: | - mkdir -p deploy - cp build/libs/*.jar deploy/fairer-dev.jar - cp deploy.sh deploy/deploy.sh - cd deploy - - - name: aws 세팅 - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} - aws-region: ap-northeast-2 - - - name: S3 업로드 - run: aws deploy push --application-name 2-Team-CodeDeploy --s3-location s3://depromeet11th/2team/fairer_dev/build.zip --source . - - - name: code deploy - run: aws deploy create-deployment --application-name 2-Team-CodeDeploy --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name 2-Team-CodeDeploy-Group --s3-location bucket=depromeet11th,bundleType=zip,key=2team/fairer_dev/build.zip diff --git a/build.gradle b/build.gradle index 7398e7a0..15128f2c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,121 +1,35 @@ -import java.text.SimpleDateFormat - -plugins { - id 'org.springframework.boot' version '2.6.5' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' - // querydsl 추가 - id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" - // jib - id 'com.google.cloud.tools.jib' version '3.2.1' - id 'java' -} - -jib { - from { - image = "adoptopenjdk/openjdk16:x86_64-alpine-jdk-16.0.1_9" +buildscript { + repositories { + mavenCentral() } - to { - image = "registry.hub.docker.com/fairerbe/fairer-dev-repo" - tags = ['latest', new SimpleDateFormat('yyyyMMddHHmmss').format(System.currentTimeMillis())] // 2개의 태그에 모두 push - } - container { - creationTime = "USE_CURRENT_TIMESTAMP" - jvmFlags = ['-Dspring.profiles.active=dev', '-XX:+UseContainerSupport', '-Dfile.encoding=UTF-8'] + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:2.6.5") + classpath "io.spring.gradle:dependency-management-plugin:1.0.11.RELEASE" } } -group = 'com.depromeet' -version = '0.0.1-SNAPSHOT' -sourceCompatibility = '11' - -configurations { - compileOnly { - extendsFrom annotationProcessor - } -} - -ext{ - set('springCloudVersion', "2021.0.2") -} - -dependencyManagement { - imports { - mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" - } -} - -repositories { - mavenCentral() -} - -dependencies { - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-data-jpa' - implementation 'org.springframework.boot:spring-boot-starter-security' - implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' - implementation 'org.springframework.boot:spring-boot-starter-validation' - implementation 'org.springframework.boot:spring-boot-starter-aop' - - //firebase sdk - implementation 'com.google.firebase:firebase-admin:6.8.1' - - //mysql connector - implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.28' - - //modelMapper - implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.1.0' - - //lucy - implementation group: 'com.navercorp.lucy', name: 'lucy-xss-servlet', version: '2.0.1' - - //jwt - implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.2' - - //swagger - implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0' - - implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2' - implementation 'org.jetbrains:annotations:20.1.0' - compileOnly 'org.projectlombok:lombok' - annotationProcessor 'org.projectlombok:lombok' - - testImplementation 'org.springframework.boot:spring-boot-starter-test' - - // feign - implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' - - // logger - implementation 'org.slf4j:jcl-over-slf4j' - implementation 'ch.qos.logback:logback-classic' - - // querydsl - implementation 'com.querydsl:querydsl-jpa' +allprojects { + group = 'com.depromeet' + version = '0.0.1-SNAPSHOT' } -tasks.named('test') { - useJUnitPlatform() -} +subprojects { + apply plugin: 'java' + apply plugin: 'org.springframework.boot' + apply plugin: 'io.spring.dependency-management' -jar { - enabled = false -} + sourceCompatibility = '11' -// querydsl -def querydslDir = "$buildDir/generated/querydsl" + repositories { + mavenCentral() + } -querydsl { - library = "com.querydsl:querydsl-apt" - jpa = true - querydslSourcesDir = querydslDir -} -sourceSets { - main.java.srcDir querydslDir -} -configurations { - querydsl.extendsFrom compileClasspath + dependencies { + //mysql connector + implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.28' -} -compileQuerydsl { - options.annotationProcessorPath = configurations.querydsl -} -// querydsl 끝 + implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.2' + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + } +} \ No newline at end of file diff --git a/fairer-api/build.gradle b/fairer-api/build.gradle new file mode 100644 index 00000000..73f87222 --- /dev/null +++ b/fairer-api/build.gradle @@ -0,0 +1,107 @@ +import java.text.SimpleDateFormat + +plugins { + // querydsl 추가 + id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" + // jib + id 'com.google.cloud.tools.jib' version '3.2.1' +} + +jib { + from { + image = "adoptopenjdk/openjdk11:centos-jre" + } + container { + environment = [TZ:"Asia/Seoul"] + } + to { + image = "registry.hub.docker.com/fairerbe/fairer-dev-repo" + tags = ['latest', new SimpleDateFormat('yyyyMMddHHmmss').format(System.currentTimeMillis())] // 2개의 태그에 모두 push + } + container { + creationTime = "USE_CURRENT_TIMESTAMP" + jvmFlags = ['-Dspring.profiles.active=dev', '-XX:+UseContainerSupport', '-Dfile.encoding=UTF-8', '-Duser.timezone="Asia/Seoul"'] + } +} + +group = 'com.depromeet' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +ext{ + set('springCloudVersion', "2021.0.2") +} + +dependencyManagement { + imports { + mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" + } +} + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.springframework.boot:spring-boot-starter-security' + implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' + implementation 'org.springframework.boot:spring-boot-starter-validation' + implementation 'org.springframework.boot:spring-boot-starter-aop' + + //firebase sdk + implementation 'com.google.firebase:firebase-admin:9.0.0' + + //modelMapper + implementation group: 'org.modelmapper', name: 'modelmapper', version: '3.1.0' + + //lucy + implementation group: 'com.navercorp.lucy', name: 'lucy-xss-servlet', version: '2.0.1' + + //jwt + implementation group: 'io.jsonwebtoken', name: 'jjwt', version: '0.2' + + //swagger + implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0' + + implementation 'org.jetbrains:annotations:20.1.0' + + testImplementation 'org.springframework.boot:spring-boot-starter-test' + + // feign + implementation 'org.springframework.cloud:spring-cloud-starter-openfeign' + + // querydsl + implementation 'com.querydsl:querydsl-jpa' +} + +tasks.named('test') { + useJUnitPlatform() +} + +jar { + enabled = false +} + +// querydsl +def querydslDir = "$buildDir/generated/querydsl" + +querydsl { + library = "com.querydsl:querydsl-apt" + jpa = true + querydslSourcesDir = querydslDir +} +sourceSets { + main.java.srcDir querydslDir +} +configurations { + querydsl.extendsFrom compileClasspath + +} +compileQuerydsl { + options.annotationProcessorPath = configurations.querydsl +} +// querydsl 끝 diff --git a/src/main/java/com/depromeet/fairer/Application.java b/fairer-api/src/main/java/com/depromeet/fairer/Application.java similarity index 100% rename from src/main/java/com/depromeet/fairer/Application.java rename to fairer-api/src/main/java/com/depromeet/fairer/Application.java diff --git a/src/main/java/com/depromeet/fairer/api/HouseWorkController.java b/fairer-api/src/main/java/com/depromeet/fairer/api/HouseWorkController.java similarity index 100% rename from src/main/java/com/depromeet/fairer/api/HouseWorkController.java rename to fairer-api/src/main/java/com/depromeet/fairer/api/HouseWorkController.java diff --git a/src/main/java/com/depromeet/fairer/api/MemberController.java b/fairer-api/src/main/java/com/depromeet/fairer/api/MemberController.java similarity index 98% rename from src/main/java/com/depromeet/fairer/api/MemberController.java rename to fairer-api/src/main/java/com/depromeet/fairer/api/MemberController.java index 68639795..6a3a19dd 100644 --- a/src/main/java/com/depromeet/fairer/api/MemberController.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/api/MemberController.java @@ -7,7 +7,6 @@ import com.depromeet.fairer.dto.member.response.MemberResponseDto; import com.depromeet.fairer.global.resolver.RequestMemberId; import com.depromeet.fairer.service.member.MemberService; -import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiOperation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/depromeet/fairer/api/OauthLoginController.java b/fairer-api/src/main/java/com/depromeet/fairer/api/OauthLoginController.java similarity index 91% rename from src/main/java/com/depromeet/fairer/api/OauthLoginController.java rename to fairer-api/src/main/java/com/depromeet/fairer/api/OauthLoginController.java index b7e02cf9..e1f3abb2 100644 --- a/src/main/java/com/depromeet/fairer/api/OauthLoginController.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/api/OauthLoginController.java @@ -1,25 +1,20 @@ package com.depromeet.fairer.api; -import com.depromeet.fairer.dto.member.oauth.OauthLoginDto; import com.depromeet.fairer.dto.member.oauth.OauthRequestDto; import com.depromeet.fairer.dto.member.jwt.ResponseJwtTokenDto; import com.depromeet.fairer.domain.member.constant.SocialType; import com.depromeet.fairer.service.member.oauth.OauthLoginService; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.EnumUtils; -import org.apache.commons.lang3.StringUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; -import java.security.InvalidParameterException; import java.time.LocalDateTime; @Slf4j diff --git a/src/main/java/com/depromeet/fairer/api/PresetController.java b/fairer-api/src/main/java/com/depromeet/fairer/api/PresetController.java similarity index 100% rename from src/main/java/com/depromeet/fairer/api/PresetController.java rename to fairer-api/src/main/java/com/depromeet/fairer/api/PresetController.java diff --git a/src/main/java/com/depromeet/fairer/api/RuleController.java b/fairer-api/src/main/java/com/depromeet/fairer/api/RuleController.java similarity index 100% rename from src/main/java/com/depromeet/fairer/api/RuleController.java rename to fairer-api/src/main/java/com/depromeet/fairer/api/RuleController.java diff --git a/src/main/java/com/depromeet/fairer/api/TeamController.java b/fairer-api/src/main/java/com/depromeet/fairer/api/TeamController.java similarity index 100% rename from src/main/java/com/depromeet/fairer/api/TeamController.java rename to fairer-api/src/main/java/com/depromeet/fairer/api/TeamController.java diff --git a/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java b/fairer-api/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java similarity index 100% rename from src/main/java/com/depromeet/fairer/api/fcm/FCMController.java rename to fairer-api/src/main/java/com/depromeet/fairer/api/fcm/FCMController.java diff --git a/src/main/java/com/depromeet/fairer/domain/assignment/Assignment.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/assignment/Assignment.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/assignment/Assignment.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/assignment/Assignment.java diff --git a/src/main/java/com/depromeet/fairer/domain/base/BaseTimeEntity.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/base/BaseTimeEntity.java similarity index 96% rename from src/main/java/com/depromeet/fairer/domain/base/BaseTimeEntity.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/base/BaseTimeEntity.java index f592624d..1e38126f 100644 --- a/src/main/java/com/depromeet/fairer/domain/base/BaseTimeEntity.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/domain/base/BaseTimeEntity.java @@ -1,6 +1,5 @@ package com.depromeet.fairer.domain.base; -import lombok.Data; import lombok.Getter; import lombok.Setter; import org.springframework.data.annotation.CreatedDate; diff --git a/src/main/java/com/depromeet/fairer/domain/housework/HouseWork.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/housework/HouseWork.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/housework/HouseWork.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/housework/HouseWork.java diff --git a/src/main/java/com/depromeet/fairer/domain/member/Member.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/member/Member.java similarity index 96% rename from src/main/java/com/depromeet/fairer/domain/member/Member.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/member/Member.java index 20aa3ed9..c6719431 100644 --- a/src/main/java/com/depromeet/fairer/domain/member/Member.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/domain/member/Member.java @@ -3,11 +3,9 @@ import com.depromeet.fairer.domain.base.BaseTimeEntity; import com.depromeet.fairer.dto.member.oauth.OAuthAttributes; import com.depromeet.fairer.domain.assignment.Assignment; -import com.depromeet.fairer.domain.memberToken.MemberToken; import com.depromeet.fairer.domain.team.Team; import com.depromeet.fairer.domain.member.constant.SocialType; import com.depromeet.fairer.global.exception.CannotJoinTeamException; -import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.*; import javax.persistence.*; diff --git a/src/main/java/com/depromeet/fairer/domain/member/constant/ProfileImage.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/member/constant/ProfileImage.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/member/constant/ProfileImage.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/member/constant/ProfileImage.java diff --git a/src/main/java/com/depromeet/fairer/domain/member/constant/SocialType.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/member/constant/SocialType.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/member/constant/SocialType.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/member/constant/SocialType.java diff --git a/src/main/java/com/depromeet/fairer/domain/memberToken/MemberToken.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/memberToken/MemberToken.java similarity index 97% rename from src/main/java/com/depromeet/fairer/domain/memberToken/MemberToken.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/memberToken/MemberToken.java index 679266d8..70b8b96c 100644 --- a/src/main/java/com/depromeet/fairer/domain/memberToken/MemberToken.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/domain/memberToken/MemberToken.java @@ -1,7 +1,6 @@ package com.depromeet.fairer.domain.memberToken; import com.depromeet.fairer.domain.base.BaseTimeEntity; -import com.depromeet.fairer.domain.member.Member; import com.depromeet.fairer.domain.memberToken.constant.RemainingTokenTime; import lombok.*; diff --git a/src/main/java/com/depromeet/fairer/domain/memberToken/constant/JwtTokenType.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/memberToken/constant/JwtTokenType.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/memberToken/constant/JwtTokenType.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/memberToken/constant/JwtTokenType.java diff --git a/src/main/java/com/depromeet/fairer/domain/memberToken/constant/RemainingTokenTime.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/memberToken/constant/RemainingTokenTime.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/memberToken/constant/RemainingTokenTime.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/memberToken/constant/RemainingTokenTime.java diff --git a/src/main/java/com/depromeet/fairer/domain/preset/Preset.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/preset/Preset.java similarity index 98% rename from src/main/java/com/depromeet/fairer/domain/preset/Preset.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/preset/Preset.java index 841e22c8..b5915985 100644 --- a/src/main/java/com/depromeet/fairer/domain/preset/Preset.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/domain/preset/Preset.java @@ -2,7 +2,6 @@ import com.depromeet.fairer.global.exception.FairerException; import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; import lombok.Getter; import java.util.Arrays; diff --git a/src/main/java/com/depromeet/fairer/domain/preset/Space.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/preset/Space.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/preset/Space.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/preset/Space.java diff --git a/src/main/java/com/depromeet/fairer/domain/rule/Rule.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/rule/Rule.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/rule/Rule.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/rule/Rule.java diff --git a/src/main/java/com/depromeet/fairer/domain/team/Team.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/team/Team.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/team/Team.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/team/Team.java diff --git a/src/main/java/com/depromeet/fairer/domain/team/constant/TeamConstant.java b/fairer-api/src/main/java/com/depromeet/fairer/domain/team/constant/TeamConstant.java similarity index 100% rename from src/main/java/com/depromeet/fairer/domain/team/constant/TeamConstant.java rename to fairer-api/src/main/java/com/depromeet/fairer/domain/team/constant/TeamConstant.java diff --git a/src/main/java/com/depromeet/fairer/dto/common/CommonApiResult.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/common/CommonApiResult.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/common/CommonApiResult.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/common/CommonApiResult.java diff --git a/fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/FCMMessageTemplate.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/FCMMessageTemplate.java new file mode 100644 index 00000000..62bc800a --- /dev/null +++ b/fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/FCMMessageTemplate.java @@ -0,0 +1,13 @@ +package com.depromeet.fairer.dto.fcm; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum FCMMessageTemplate { + JOIN_MEMBER_IN_TEAM("%s님이 %s에 참여", "앞으로 함께 평화롭게 집안일 해보아요✨"); + + private final String title; + private final String body; +} diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/FCMSendRequest.java diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/request/FCMMessageRequest.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/request/FCMMessageRequest.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/fcm/request/FCMMessageRequest.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/request/FCMMessageRequest.java diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/request/SaveTokenRequest.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/request/SaveTokenRequest.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/fcm/request/SaveTokenRequest.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/request/SaveTokenRequest.java diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/response/FCMMessageResponse.java diff --git a/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/fcm/response/SaveTokenResponse.java diff --git a/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkStatusRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkStatusRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkStatusRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkStatusRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkUpdateRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkUpdateRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkUpdateRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorkUpdateRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorksCreateRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorksCreateRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorksCreateRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/housework/request/HouseWorksCreateRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkDateResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkDateResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkDateResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkDateResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkMemberResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkMemberResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkMemberResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkMemberResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkStatusResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkStatusResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkStatusResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkStatusResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkSuccessCountResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkSuccessCountResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkSuccessCountResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorkSuccessCountResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorksCreateResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorksCreateResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorksCreateResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/housework/response/HouseWorksCreateResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/MemberDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/MemberDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/MemberDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/MemberDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/jwt/ResponseJwtTokenDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/jwt/ResponseJwtTokenDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/jwt/ResponseJwtTokenDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/jwt/ResponseJwtTokenDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/jwt/TokenDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/jwt/TokenDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/jwt/TokenDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/jwt/TokenDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/oauth/GoogleUserInfo.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/oauth/OAuthAttributes.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/oauth/OAuthAttributes.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/oauth/OAuthAttributes.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/oauth/OAuthAttributes.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/oauth/OauthLoginDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/oauth/OauthLoginDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/oauth/OauthLoginDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/oauth/OauthLoginDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/oauth/OauthRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/oauth/OauthRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/oauth/OauthRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/oauth/OauthRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/request/MemberUpdateRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/request/MemberUpdateRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/request/MemberUpdateRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/request/MemberUpdateRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/response/MemberProfileImageResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/response/MemberProfileImageResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/response/MemberProfileImageResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/response/MemberProfileImageResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/member/response/MemberResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/member/response/MemberResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/member/response/MemberResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/member/response/MemberResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/preset/response/HouseWorkPresetResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/rule/request/RuleRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/rule/request/RuleRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/rule/request/RuleRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/rule/request/RuleRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/rule/response/RuleResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/rule/response/RuleResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/rule/response/RuleResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/rule/response/RuleResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/rule/response/RulesResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/rule/response/RulesResponseDto.java similarity index 95% rename from src/main/java/com/depromeet/fairer/dto/rule/response/RulesResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/rule/response/RulesResponseDto.java index 75da1f31..615bef50 100644 --- a/src/main/java/com/depromeet/fairer/dto/rule/response/RulesResponseDto.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/dto/rule/response/RulesResponseDto.java @@ -1,6 +1,5 @@ package com.depromeet.fairer.dto.rule.response; -import com.depromeet.fairer.domain.rule.Rule; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/depromeet/fairer/dto/team/TeamLeaveRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/TeamLeaveRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/team/TeamLeaveRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/team/TeamLeaveRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/team/request/TeamCreateRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/request/TeamCreateRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/team/request/TeamCreateRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/team/request/TeamCreateRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/team/request/TeamJoinRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/request/TeamJoinRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/team/request/TeamJoinRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/team/request/TeamJoinRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/team/request/TeamUpdateRequestDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/request/TeamUpdateRequestDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/team/request/TeamUpdateRequestDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/team/request/TeamUpdateRequestDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/team/response/TeamCreateResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamCreateResponseDto.java similarity index 88% rename from src/main/java/com/depromeet/fairer/dto/team/response/TeamCreateResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamCreateResponseDto.java index abd15c4f..f3105690 100644 --- a/src/main/java/com/depromeet/fairer/dto/team/response/TeamCreateResponseDto.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamCreateResponseDto.java @@ -1,6 +1,5 @@ package com.depromeet.fairer.dto.team.response; -import com.depromeet.fairer.domain.member.Member; import com.depromeet.fairer.domain.team.Team; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @@ -9,9 +8,6 @@ import lombok.Data; import lombok.NoArgsConstructor; -import java.util.List; -import java.util.stream.Collectors; - @Data @Builder @ApiModel(value = "Team 생성 반환 객체", description = "Team 생성 반환 객체") diff --git a/src/main/java/com/depromeet/fairer/dto/team/response/TeamInfoResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamInfoResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/team/response/TeamInfoResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamInfoResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/team/response/TeamInviteCodeResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamInviteCodeResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/team/response/TeamInviteCodeResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamInviteCodeResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/team/response/TeamJoinResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamJoinResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/team/response/TeamJoinResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamJoinResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/dto/team/response/TeamUpdateResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamUpdateResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/dto/team/response/TeamUpdateResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/dto/team/response/TeamUpdateResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java b/fairer-api/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/aop/ControllerLoggingAspect.java diff --git a/src/main/java/com/depromeet/fairer/global/config/ArgResolverConfig.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/ArgResolverConfig.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/config/ArgResolverConfig.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/ArgResolverConfig.java diff --git a/src/main/java/com/depromeet/fairer/global/config/FeignConfiguration.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/FeignConfiguration.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/config/FeignConfiguration.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/FeignConfiguration.java diff --git a/src/main/java/com/depromeet/fairer/global/config/MapperConfig.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/MapperConfig.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/config/MapperConfig.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/MapperConfig.java diff --git a/src/main/java/com/depromeet/fairer/global/config/QuerydslConfig.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/QuerydslConfig.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/config/QuerydslConfig.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/QuerydslConfig.java diff --git a/src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java similarity index 91% rename from src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java index a97ad292..5839cfb1 100644 --- a/src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/global/config/SecurityConfig.java @@ -2,9 +2,7 @@ import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; -import org.springframework.http.HttpMethod; import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; diff --git a/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/SwaggerConfig.java diff --git a/src/main/java/com/depromeet/fairer/global/config/TaskExecutorConfig.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/TaskExecutorConfig.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/config/TaskExecutorConfig.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/TaskExecutorConfig.java diff --git a/src/main/java/com/depromeet/fairer/global/config/WebConfig.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/WebConfig.java similarity index 97% rename from src/main/java/com/depromeet/fairer/global/config/WebConfig.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/WebConfig.java index 42ddeeb6..467a5bfa 100644 --- a/src/main/java/com/depromeet/fairer/global/config/WebConfig.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/global/config/WebConfig.java @@ -7,7 +7,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; -import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; diff --git a/src/main/java/com/depromeet/fairer/global/config/Workaround.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/Workaround.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/config/Workaround.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/Workaround.java diff --git a/src/main/java/com/depromeet/fairer/global/config/XssConfig.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/XssConfig.java similarity index 96% rename from src/main/java/com/depromeet/fairer/global/config/XssConfig.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/XssConfig.java index 16d2e646..fdc40754 100644 --- a/src/main/java/com/depromeet/fairer/global/config/XssConfig.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/global/config/XssConfig.java @@ -6,8 +6,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import javax.servlet.Filter; - @Configuration public class XssConfig implements WebMvcConfigurer { diff --git a/src/main/java/com/depromeet/fairer/global/config/interceptor/AuthInterceptor.java b/fairer-api/src/main/java/com/depromeet/fairer/global/config/interceptor/AuthInterceptor.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/config/interceptor/AuthInterceptor.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/config/interceptor/AuthInterceptor.java diff --git a/src/main/java/com/depromeet/fairer/global/exception/BadRequestException.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/BadRequestException.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/exception/BadRequestException.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/BadRequestException.java diff --git a/src/main/java/com/depromeet/fairer/global/exception/CannotJoinTeamException.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/CannotJoinTeamException.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/exception/CannotJoinTeamException.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/CannotJoinTeamException.java diff --git a/src/main/java/com/depromeet/fairer/global/exception/FairerException.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/FairerException.java similarity index 59% rename from src/main/java/com/depromeet/fairer/global/exception/FairerException.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/FairerException.java index a4e71d8c..cc0ba177 100644 --- a/src/main/java/com/depromeet/fairer/global/exception/FairerException.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/FairerException.java @@ -1,15 +1,6 @@ package com.depromeet.fairer.global.exception; - public class FairerException extends RuntimeException { - public FairerException(Exception e) { - super(e); - } - - public FairerException() { - super(); - } - public FairerException(String message) { super(message); } diff --git a/src/main/java/com/depromeet/fairer/global/exception/FeignClientException.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/FeignClientException.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/exception/FeignClientException.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/FeignClientException.java diff --git a/src/main/java/com/depromeet/fairer/global/exception/MemberTokenNotFoundException.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/MemberTokenNotFoundException.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/exception/MemberTokenNotFoundException.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/MemberTokenNotFoundException.java diff --git a/src/main/java/com/depromeet/fairer/global/exception/NoSuchMemberException.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/NoSuchMemberException.java similarity index 83% rename from src/main/java/com/depromeet/fairer/global/exception/NoSuchMemberException.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/NoSuchMemberException.java index 082d619f..5ea66c39 100644 --- a/src/main/java/com/depromeet/fairer/global/exception/NoSuchMemberException.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/NoSuchMemberException.java @@ -1,7 +1,5 @@ package com.depromeet.fairer.global.exception; -import java.util.function.Supplier; - public class NoSuchMemberException extends RuntimeException { public NoSuchMemberException(String message) { super(message); diff --git a/src/main/java/com/depromeet/fairer/global/exception/PermissionDeniedException.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/PermissionDeniedException.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/exception/PermissionDeniedException.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/PermissionDeniedException.java diff --git a/src/main/java/com/depromeet/fairer/global/exception/dto/ErrorResponseDto.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/dto/ErrorResponseDto.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/exception/dto/ErrorResponseDto.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/dto/ErrorResponseDto.java diff --git a/src/main/java/com/depromeet/fairer/global/exception/handler/FeignClientExceptionErrorDecoder.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/handler/FeignClientExceptionErrorDecoder.java similarity index 95% rename from src/main/java/com/depromeet/fairer/global/exception/handler/FeignClientExceptionErrorDecoder.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/handler/FeignClientExceptionErrorDecoder.java index d8d3fa96..64c09650 100644 --- a/src/main/java/com/depromeet/fairer/global/exception/handler/FeignClientExceptionErrorDecoder.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/handler/FeignClientExceptionErrorDecoder.java @@ -1,7 +1,6 @@ package com.depromeet.fairer.global.exception.handler; import com.depromeet.fairer.global.exception.FeignClientException; -import feign.FeignException; import feign.Response; import feign.codec.ErrorDecoder; import feign.codec.StringDecoder; diff --git a/src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java similarity index 99% rename from src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java index 5ba4d9ef..0b5f24fc 100644 --- a/src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/global/exception/handler/GlobalExceptionHandler.java @@ -15,7 +15,6 @@ import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; import javax.servlet.http.HttpServletRequest; -import java.nio.file.AccessDeniedException; import java.util.List; @RestControllerAdvice diff --git a/src/main/java/com/depromeet/fairer/global/factory/RestTemplateFactory.java b/fairer-api/src/main/java/com/depromeet/fairer/global/factory/RestTemplateFactory.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/factory/RestTemplateFactory.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/factory/RestTemplateFactory.java diff --git a/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberId.java b/fairer-api/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberId.java similarity index 85% rename from src/main/java/com/depromeet/fairer/global/resolver/RequestMemberId.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberId.java index 28e00486..78ea8f5b 100644 --- a/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberId.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberId.java @@ -1,7 +1,5 @@ package com.depromeet.fairer.global.resolver; -import springfox.documentation.annotations.ApiIgnore; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberIdArgumentResolver.java b/fairer-api/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberIdArgumentResolver.java similarity index 96% rename from src/main/java/com/depromeet/fairer/global/resolver/RequestMemberIdArgumentResolver.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberIdArgumentResolver.java index b2de253e..a3ed9c46 100644 --- a/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberIdArgumentResolver.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/global/resolver/RequestMemberIdArgumentResolver.java @@ -1,6 +1,5 @@ package com.depromeet.fairer.global.resolver; -import com.depromeet.fairer.domain.member.Member; import com.depromeet.fairer.service.member.jwt.TokenProvider; import lombok.extern.slf4j.Slf4j; import org.springframework.core.MethodParameter; diff --git a/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java b/fairer-api/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java similarity index 100% rename from src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java rename to fairer-api/src/main/java/com/depromeet/fairer/global/util/DateTimeUtils.java diff --git a/src/main/java/com/depromeet/fairer/repository/assignment/AssignmentRepository.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/assignment/AssignmentRepository.java similarity index 100% rename from src/main/java/com/depromeet/fairer/repository/assignment/AssignmentRepository.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/assignment/AssignmentRepository.java diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java similarity index 100% rename from src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepository.java diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java similarity index 100% rename from src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkCustomRepositoryImpl.java diff --git a/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java similarity index 100% rename from src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/housework/HouseWorkRepository.java diff --git a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java similarity index 100% rename from src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepository.java diff --git a/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java similarity index 100% rename from src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/member/MemberCustomRepositoryImpl.java diff --git a/src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java similarity index 87% rename from src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java index 9f2dffdf..2b53645e 100644 --- a/src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/repository/member/MemberRepository.java @@ -4,7 +4,6 @@ import com.depromeet.fairer.domain.team.Team; import org.springframework.data.jpa.repository.EntityGraph; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; import java.util.List; @@ -12,8 +11,6 @@ @Repository public interface MemberRepository extends JpaRepository, MemberCustomRepository { - Optional findByEmail(String email); - List findAllByTeam(Team team); @EntityGraph(attributePaths = {"team"}) diff --git a/src/main/java/com/depromeet/fairer/repository/memberToken/MemberTokenRepository.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/memberToken/MemberTokenRepository.java similarity index 84% rename from src/main/java/com/depromeet/fairer/repository/memberToken/MemberTokenRepository.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/memberToken/MemberTokenRepository.java index 4c94867c..0d61c2a6 100644 --- a/src/main/java/com/depromeet/fairer/repository/memberToken/MemberTokenRepository.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/repository/memberToken/MemberTokenRepository.java @@ -2,7 +2,6 @@ import com.depromeet.fairer.domain.memberToken.MemberToken; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.support.SimpleJpaRepository; import org.springframework.stereotype.Repository; import java.util.Optional; diff --git a/src/main/java/com/depromeet/fairer/repository/rule/RuleRepository.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/rule/RuleRepository.java similarity index 100% rename from src/main/java/com/depromeet/fairer/repository/rule/RuleRepository.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/rule/RuleRepository.java diff --git a/src/main/java/com/depromeet/fairer/repository/team/TeamRepository.java b/fairer-api/src/main/java/com/depromeet/fairer/repository/team/TeamRepository.java similarity index 82% rename from src/main/java/com/depromeet/fairer/repository/team/TeamRepository.java rename to fairer-api/src/main/java/com/depromeet/fairer/repository/team/TeamRepository.java index bb59ccc5..19687bfb 100644 --- a/src/main/java/com/depromeet/fairer/repository/team/TeamRepository.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/repository/team/TeamRepository.java @@ -9,10 +9,6 @@ @Repository public interface TeamRepository extends JpaRepository { - - @EntityGraph(attributePaths = {"members"}) - Optional findWithMembersByTeamId(Long teamId); - @EntityGraph(attributePaths = {"members"}) Optional findWithMembersByInviteCode(String inviteCode); } diff --git a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java b/fairer-api/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java similarity index 81% rename from src/main/java/com/depromeet/fairer/service/fcm/FCMService.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java index 3de8a274..e5de0e38 100644 --- a/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/service/fcm/FCMService.java @@ -6,8 +6,10 @@ import com.depromeet.fairer.dto.fcm.request.SaveTokenRequest; import com.depromeet.fairer.dto.fcm.response.FCMMessageResponse; import com.depromeet.fairer.dto.fcm.response.SaveTokenResponse; +import com.depromeet.fairer.global.exception.FairerException; import com.depromeet.fairer.global.factory.RestTemplateFactory; import com.depromeet.fairer.repository.member.MemberRepository; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.auth.oauth2.GoogleCredentials; import com.google.firebase.messaging.Message; @@ -50,31 +52,43 @@ public FCMMessageResponse sendMessage(FCMMessageRequest fcmMessageRequest) { .orElseThrow(() -> new IllegalArgumentException("memberId에 해당하는 회원을 찾지 못했습니다.")); FCMSendRequest fcmSendRequest = createMessage(member.getFcmToken(), fcmMessageRequest.getTitle(), fcmMessageRequest.getBody()); - this.sendFCMMessage(fcmSendRequest); + String body = convertFCMSendRequestToString(fcmSendRequest); + this.sendFCMMessage(body); return FCMMessageResponse.of(fcmMessageRequest.getTitle(), fcmMessageRequest.getBody(), fcmMessageRequest.getMemberId()); } + private String convertFCMSendRequestToString(FCMSendRequest fcmSendRequest) { + try { + return objectMapper.writeValueAsString(fcmSendRequest); + } catch (JsonProcessingException e) { + throw new FairerException("객체 파싱 실패"); + } + } + private FCMSendRequest createMessage(String token, String title, String body) { Message message = Message.builder() .setToken(token) - .setNotification(new Notification(title, body)) + .setNotification(Notification.builder() + .setTitle(title) + .setBody(body) + .build()) .build(); return FCMSendRequest.of(message, false); } @Async(value = "fcmTaskExecutor") - private void sendFCMMessage(FCMSendRequest fcmSendRequest) { + private void sendFCMMessage(String body) { try { HttpHeaders headers = new HttpHeaders(); headers.add(HttpHeaders.AUTHORIZATION, "Bearer " + getAccessToken()); headers.add(HttpHeaders.CONTENT_TYPE, "application/json; UTF-8"); - HttpEntity request = new HttpEntity<>(objectMapper.writeValueAsString(fcmSendRequest), headers); + HttpEntity request = new HttpEntity<>(body, headers); String message = restTemplate.postForObject(FCM_DOMAIN, request, String.class); } catch (Exception e) { - log.error("Error to send message.", e); + log.error("Error to send message. body : {}", body, e); } } diff --git a/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java b/fairer-api/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java similarity index 100% rename from src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java diff --git a/src/main/java/com/depromeet/fairer/service/member/MemberService.java b/fairer-api/src/main/java/com/depromeet/fairer/service/member/MemberService.java similarity index 98% rename from src/main/java/com/depromeet/fairer/service/member/MemberService.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/member/MemberService.java index 81f3cd3b..9f2ab00c 100644 --- a/src/main/java/com/depromeet/fairer/service/member/MemberService.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/service/member/MemberService.java @@ -11,10 +11,8 @@ import javax.transaction.Transactional; -import java.util.ArrayList; import java.util.List; - @Service @Transactional @RequiredArgsConstructor diff --git a/src/main/java/com/depromeet/fairer/service/member/jwt/TokenProvider.java b/fairer-api/src/main/java/com/depromeet/fairer/service/member/jwt/TokenProvider.java similarity index 100% rename from src/main/java/com/depromeet/fairer/service/member/jwt/TokenProvider.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/member/jwt/TokenProvider.java diff --git a/src/main/java/com/depromeet/fairer/service/member/oauth/OauthLoginService.java b/fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/OauthLoginService.java similarity index 100% rename from src/main/java/com/depromeet/fairer/service/member/oauth/OauthLoginService.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/OauthLoginService.java diff --git a/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleAuthFeignClient.java b/fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleAuthFeignClient.java similarity index 97% rename from src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleAuthFeignClient.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleAuthFeignClient.java index 4f5e414b..a0cb10e8 100644 --- a/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleAuthFeignClient.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleAuthFeignClient.java @@ -1,6 +1,5 @@ package com.depromeet.fairer.service.member.oauth.google; -import feign.Headers; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.PostMapping; diff --git a/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleFeignService.java b/fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleFeignService.java similarity index 100% rename from src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleFeignService.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleFeignService.java diff --git a/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleInfoFeignClient.java b/fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleInfoFeignClient.java similarity index 96% rename from src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleInfoFeignClient.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleInfoFeignClient.java index 280d3ae1..1c6e2fc3 100644 --- a/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleInfoFeignClient.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/GoogleInfoFeignClient.java @@ -1,7 +1,6 @@ package com.depromeet.fairer.service.member.oauth.google; import com.depromeet.fairer.dto.member.oauth.GoogleUserInfo; -import feign.Headers; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.stereotype.Component; import org.springframework.web.bind.annotation.*; diff --git a/src/main/java/com/depromeet/fairer/service/member/oauth/google/OauthTokenResponse.java b/fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/OauthTokenResponse.java similarity index 100% rename from src/main/java/com/depromeet/fairer/service/member/oauth/google/OauthTokenResponse.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/member/oauth/google/OauthTokenResponse.java diff --git a/src/main/java/com/depromeet/fairer/service/rule/RuleService.java b/fairer-api/src/main/java/com/depromeet/fairer/service/rule/RuleService.java similarity index 92% rename from src/main/java/com/depromeet/fairer/service/rule/RuleService.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/rule/RuleService.java index 2a6d3ca3..8b407cc6 100644 --- a/src/main/java/com/depromeet/fairer/service/rule/RuleService.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/service/rule/RuleService.java @@ -2,10 +2,8 @@ import com.depromeet.fairer.domain.rule.Rule; import com.depromeet.fairer.domain.team.Team; -import com.depromeet.fairer.dto.rule.request.RuleRequestDto; import com.depromeet.fairer.repository.rule.RuleRepository; import com.depromeet.fairer.service.member.MemberService; -import com.depromeet.fairer.service.team.TeamService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/depromeet/fairer/service/team/TeamService.java b/fairer-api/src/main/java/com/depromeet/fairer/service/team/TeamService.java similarity index 95% rename from src/main/java/com/depromeet/fairer/service/team/TeamService.java rename to fairer-api/src/main/java/com/depromeet/fairer/service/team/TeamService.java index a15e8dd0..eeacb023 100644 --- a/src/main/java/com/depromeet/fairer/service/team/TeamService.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/service/team/TeamService.java @@ -4,6 +4,7 @@ import com.depromeet.fairer.domain.assignment.Assignment; import com.depromeet.fairer.domain.member.Member; import com.depromeet.fairer.domain.team.Team; +import com.depromeet.fairer.dto.fcm.FCMMessageTemplate; import com.depromeet.fairer.dto.fcm.request.FCMMessageRequest; import com.depromeet.fairer.global.exception.BadRequestException; import com.depromeet.fairer.global.exception.CannotJoinTeamException; @@ -76,8 +77,8 @@ private void pushMessageToTeamMember(Set members) { for(Member member : members) { FCMMessageRequest request = new FCMMessageRequest(); request.setMemberId(member.getMemberId()); - request.setTitle(String.format("%s님이 %s에 참여", member.getMemberName(), member.getTeam().getTeamName())); - request.setBody("앞으로 함께 평화롭게 집안일 해보아요✨"); + request.setTitle(String.format(FCMMessageTemplate.JOIN_MEMBER_IN_TEAM.getTitle(), member.getMemberName(), member.getTeam().getTeamName())); + request.setBody(FCMMessageTemplate.JOIN_MEMBER_IN_TEAM.getBody()); fcmService.sendMessage(request); } } diff --git a/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkUpdateVo.java b/fairer-api/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkUpdateVo.java similarity index 100% rename from src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkUpdateVo.java rename to fairer-api/src/main/java/com/depromeet/fairer/vo/houseWork/HouseWorkUpdateVo.java diff --git a/src/main/java/com/depromeet/fairer/vo/team/InviteCodeVo.java b/fairer-api/src/main/java/com/depromeet/fairer/vo/team/InviteCodeVo.java similarity index 100% rename from src/main/java/com/depromeet/fairer/vo/team/InviteCodeVo.java rename to fairer-api/src/main/java/com/depromeet/fairer/vo/team/InviteCodeVo.java diff --git a/src/main/resources/application.yml b/fairer-api/src/main/resources/application.yml similarity index 100% rename from src/main/resources/application.yml rename to fairer-api/src/main/resources/application.yml diff --git a/src/main/resources/db/migration/V1__init.sql b/fairer-api/src/main/resources/db/migration/V1__init.sql similarity index 100% rename from src/main/resources/db/migration/V1__init.sql rename to fairer-api/src/main/resources/db/migration/V1__init.sql diff --git a/src/main/resources/firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json b/fairer-api/src/main/resources/firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json similarity index 100% rename from src/main/resources/firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json rename to fairer-api/src/main/resources/firebase/fairer-def59-firebase-adminsdk-uvxs2-2b35d6203d.json diff --git a/src/main/resources/logback-spring.xml b/fairer-api/src/main/resources/logback-spring.xml similarity index 84% rename from src/main/resources/logback-spring.xml rename to fairer-api/src/main/resources/logback-spring.xml index 5f15a0da..704d2aa3 100644 --- a/src/main/resources/logback-spring.xml +++ b/fairer-api/src/main/resources/logback-spring.xml @@ -4,7 +4,7 @@ - %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-10contextName %logger{36} - %msg%n + %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %-10contextName %logger{36} - %msg%n utf8 @@ -23,7 +23,7 @@ 7 - %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %-10contextName %logger{36} - %msg%n + %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %-10contextName %logger{36} - %msg%n @@ -32,7 +32,7 @@ - + diff --git a/src/main/resources/lucy-xss-servlet-filter-rule.xml b/fairer-api/src/main/resources/lucy-xss-servlet-filter-rule.xml similarity index 100% rename from src/main/resources/lucy-xss-servlet-filter-rule.xml rename to fairer-api/src/main/resources/lucy-xss-servlet-filter-rule.xml diff --git a/src/main/resources/lucy-xss-superset-sax.xml b/fairer-api/src/main/resources/lucy-xss-superset-sax.xml similarity index 100% rename from src/main/resources/lucy-xss-superset-sax.xml rename to fairer-api/src/main/resources/lucy-xss-superset-sax.xml diff --git a/src/test/java/com/depromeet/fairer/ApplicationTests.java b/fairer-api/src/test/java/com/depromeet/fairer/ApplicationTests.java similarity index 100% rename from src/test/java/com/depromeet/fairer/ApplicationTests.java rename to fairer-api/src/test/java/com/depromeet/fairer/ApplicationTests.java diff --git a/fairer-batch/build.gradle b/fairer-batch/build.gradle new file mode 100644 index 00000000..9a7c12cf --- /dev/null +++ b/fairer-batch/build.gradle @@ -0,0 +1,38 @@ +import java.text.SimpleDateFormat + +plugins { + // jib + id 'com.google.cloud.tools.jib' version '3.2.1' +} + +jib { + from { + image = "adoptopenjdk/openjdk11:centos-jre" + } + container { + environment = [TZ:"Asia/Seoul"] + } + to { + image = "registry.hub.docker.com/fairerbe/fairer-batch-dev" + tags = ['latest', new SimpleDateFormat('yyyyMMddHHmmss').format(System.currentTimeMillis())] // 2개의 태그에 모두 push + } + container { + creationTime = "USE_CURRENT_TIMESTAMP" + jvmFlags = ['-Dspring.profiles.active=dev', '-XX:+UseContainerSupport', '-Dfile.encoding=UTF-8', '-Duser.timezone="Asia/Seoul"'] + } +} + +group = 'com.depromeet' +version = '0.0.1-SNAPSHOT' +sourceCompatibility = '11' + +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-batch' + + // https://mvnrepository.com/artifact/de.codecentric/batch-web-spring-boot-starter + implementation 'de.codecentric:batch-web-spring-boot-starter:2.2.0' +} + +jar { + enabled = false +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/Application.java b/fairer-batch/src/main/java/com/depromeet/fairer/Application.java new file mode 100644 index 00000000..a16fa55d --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/Application.java @@ -0,0 +1,15 @@ +package com.depromeet.fairer; + +import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +@EnableBatchProcessing +@EnableScheduling +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/config/InduceAddHouseworkJobConfig.java b/fairer-batch/src/main/java/com/depromeet/fairer/config/InduceAddHouseworkJobConfig.java new file mode 100644 index 00000000..f2875127 --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/config/InduceAddHouseworkJobConfig.java @@ -0,0 +1,91 @@ +package com.depromeet.fairer.config; + +import com.depromeet.fairer.domain.command.FCMMessageRequest; +import com.depromeet.fairer.domain.command.FCMMessageResponse; +import com.depromeet.fairer.domain.command.FCMMessageTemplate; +import com.depromeet.fairer.domain.command.InduceAddHouseworkCommand; +import com.depromeet.fairer.domain.config.DomainConfigurationProperties; +import com.depromeet.fairer.domain.config.RestTemplateFactory; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.Step; +import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; +import org.springframework.batch.core.configuration.annotation.JobScope; +import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; +import org.springframework.batch.core.configuration.annotation.StepScope; +import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.item.database.JdbcCursorItemReader; +import org.springframework.batch.item.database.builder.JdbcCursorItemReaderBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.sql.DataSource; + +@Slf4j +@Configuration +@RequiredArgsConstructor +public class InduceAddHouseworkJobConfig { + private final JobBuilderFactory jobBuilderFactory; + private final StepBuilderFactory stepBuilderFactory; + private final DataSource dataSource; + private final DomainConfigurationProperties properties; + private static final RestTemplate restTemplate = RestTemplateFactory.getRestTemplate(); + + @Bean + public Job induceAddHouseworkJob() { + return jobBuilderFactory.get("InduceAddHouseworkJob") + .start(induceAddHouseworkStep()) + .preventRestart() + .build(); + } + + @Bean + @JobScope + public Step induceAddHouseworkStep() { + return stepBuilderFactory.get("InduceAddHouseworkStep") + .chunk(1) + .reader(induceAddHouseworkReader()) + .writer(induceAddHouseworkWriter()) + .build(); + } + + @Bean + @StepScope + public JdbcCursorItemReader induceAddHouseworkReader() { + return new JdbcCursorItemReaderBuilder() + .name("InduceAddHouseworkReader") + .fetchSize(1) + .dataSource(dataSource) + .rowMapper(new BeanPropertyRowMapper<>(InduceAddHouseworkCommand.class)) + .sql("SELECT member_id, team_name\n" + + "FROM member INNER JOIN team ON team.team_id=member.team_id\n" + + "WHERE member.fcm_token IS NOT NULL") + .saveState(false) + .build(); + } + + @Bean + @StepScope + public ItemWriter induceAddHouseworkWriter() { + return items -> { + for(InduceAddHouseworkCommand item : items) { + String uri = UriComponentsBuilder.fromHttpUrl(properties.getApiUrl()) + .path("/api/fcm/message") + .encode().build().toString(); + + FCMMessageResponse response = restTemplate.postForObject(uri, getFCMMessageRequest(item), FCMMessageResponse.class); + } + }; + } + + private FCMMessageRequest getFCMMessageRequest(InduceAddHouseworkCommand command) { + Long memberId = command.getMemberId(); + String title = FCMMessageTemplate.INDUCE_ADD_HOUSEWORK.getTitle(); + String body = String.format(FCMMessageTemplate.INDUCE_ADD_HOUSEWORK.getBody(), command.getTeamName()); + return FCMMessageRequest.of(memberId, title, body); + } +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/config/NotCompleteHouseworkRemindJobConfig.java b/fairer-batch/src/main/java/com/depromeet/fairer/config/NotCompleteHouseworkRemindJobConfig.java new file mode 100644 index 00000000..aeae5083 --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/config/NotCompleteHouseworkRemindJobConfig.java @@ -0,0 +1,91 @@ +package com.depromeet.fairer.config; + +import com.depromeet.fairer.domain.command.FCMMessageRequest; +import com.depromeet.fairer.domain.command.FCMMessageResponse; +import com.depromeet.fairer.domain.command.FCMMessageTemplate; +import com.depromeet.fairer.domain.command.NotCompleteHouseworkRemindCommand; +import com.depromeet.fairer.domain.config.DomainConfigurationProperties; +import com.depromeet.fairer.domain.config.RestTemplateFactory; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.Step; +import org.springframework.batch.core.configuration.annotation.JobBuilderFactory; +import org.springframework.batch.core.configuration.annotation.JobScope; +import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; +import org.springframework.batch.core.configuration.annotation.StepScope; +import org.springframework.batch.item.ItemWriter; +import org.springframework.batch.item.database.JdbcCursorItemReader; +import org.springframework.batch.item.database.builder.JdbcCursorItemReaderBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.jdbc.core.BeanPropertyRowMapper; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; + +import javax.sql.DataSource; + +@Slf4j +@Configuration +@RequiredArgsConstructor +public class NotCompleteHouseworkRemindJobConfig { + private final JobBuilderFactory jobBuilderFactory; + private final StepBuilderFactory stepBuilderFactory; + private final DataSource dataSource; + private final DomainConfigurationProperties properties; + private static final RestTemplate restTemplate = RestTemplateFactory.getRestTemplate(); + + @Bean + public Job notCompleteHouseworkRemindJob() { + return jobBuilderFactory.get("NotCompleteHouseworkRemindJob") + .start(notCompleteHouseworkRemindStep()) + .preventRestart() + .build(); + } + + @Bean + @JobScope + public Step notCompleteHouseworkRemindStep() { + return stepBuilderFactory.get("NotCompleteHouseworkRemindStep") + .chunk(1) + .reader(notCompleteHouseworkRemindReader()) + .writer(notCompleteHouseworkRemindWriter()) + .build(); + } + + @Bean + @StepScope + public JdbcCursorItemReader notCompleteHouseworkRemindReader() { + return new JdbcCursorItemReaderBuilder() + .name("InduceAddHouseworkReader") + .fetchSize(1) + .dataSource(dataSource) + .rowMapper(new BeanPropertyRowMapper<>(NotCompleteHouseworkRemindCommand.class)) + .sql("SELECT member_id as memberId,count(*) as totalCount, housework_name as houseworkName\n" + + "FROM assignment INNER JOIN housework ON assignment.housework_id=housework.housework_id\n" + + "WHERE success=0 GROUP BY member_id") + .saveState(false) + .build(); + } + + @Bean + @StepScope + public ItemWriter notCompleteHouseworkRemindWriter() { + return items -> { + for(NotCompleteHouseworkRemindCommand item : items) { + String uri = UriComponentsBuilder.fromHttpUrl(properties.getApiUrl()) + .path("/api/fcm/message") + .encode().build().toString(); + + FCMMessageResponse response = restTemplate.postForObject(uri, getFCMMessageRequest(item), FCMMessageResponse.class); + } + }; + } + + private FCMMessageRequest getFCMMessageRequest(NotCompleteHouseworkRemindCommand command) { + Long memberId = command.getMemberId(); + String title = String.format(FCMMessageTemplate.NOT_COMPLETE_HOUSEWORK.getTitle(), command.getTotalCount()); + String body = String.format(FCMMessageTemplate.NOT_COMPLETE_HOUSEWORK.getBody(), command.getHouseworkName()); + return FCMMessageRequest.of(memberId, title, body); + } +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageRequest.java b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageRequest.java new file mode 100644 index 00000000..0b70f1e7 --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageRequest.java @@ -0,0 +1,20 @@ +package com.depromeet.fairer.domain.command; + +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class FCMMessageRequest { + private Long memberId; + private String title; + private String body; + + public static FCMMessageRequest of(Long memberId, String title, String body) { + return FCMMessageRequest.builder() + .memberId(memberId) + .title(title) + .body(body) + .build(); + } +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageResponse.java b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageResponse.java new file mode 100644 index 00000000..ecf33c11 --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageResponse.java @@ -0,0 +1,10 @@ +package com.depromeet.fairer.domain.command; + +import lombok.Data; + +@Data +public class FCMMessageResponse { + private String title; + private String body; + private Long memberId; +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageTemplate.java b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageTemplate.java new file mode 100644 index 00000000..1bf96e80 --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/FCMMessageTemplate.java @@ -0,0 +1,14 @@ +package com.depromeet.fairer.domain.command; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum FCMMessageTemplate { + NOT_COMPLETE_HOUSEWORK("아직 끝내지 못한 집안일 %s개", "'%s'이 남아있어요!\uD83D\uDE22"), + INDUCE_ADD_HOUSEWORK("오늘 할 집안일을 추가해보세요!", "오늘도 평화롭고 깨끗한 %s 만들어봐요!"); + + private final String title; + private final String body; +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/InduceAddHouseworkCommand.java b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/InduceAddHouseworkCommand.java new file mode 100644 index 00000000..41c1cf0f --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/InduceAddHouseworkCommand.java @@ -0,0 +1,9 @@ +package com.depromeet.fairer.domain.command; + +import lombok.Data; + +@Data +public class InduceAddHouseworkCommand { + private Long memberId; + private String teamName; +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/NotCompleteHouseworkRemindCommand.java b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/NotCompleteHouseworkRemindCommand.java new file mode 100644 index 00000000..202a7033 --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/domain/command/NotCompleteHouseworkRemindCommand.java @@ -0,0 +1,10 @@ +package com.depromeet.fairer.domain.command; + +import lombok.Data; + +@Data +public class NotCompleteHouseworkRemindCommand { + private Long memberId; + private Long totalCount; + private String houseworkName; +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/domain/config/DomainConfigurationProperties.java b/fairer-batch/src/main/java/com/depromeet/fairer/domain/config/DomainConfigurationProperties.java new file mode 100644 index 00000000..cde8e85a --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/domain/config/DomainConfigurationProperties.java @@ -0,0 +1,14 @@ +package com.depromeet.fairer.domain.config; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; + +@Setter +@Getter +@Component +@ConfigurationProperties(prefix = "domain") +public class DomainConfigurationProperties { + private String apiUrl; +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/domain/config/RestTemplateFactory.java b/fairer-batch/src/main/java/com/depromeet/fairer/domain/config/RestTemplateFactory.java new file mode 100644 index 00000000..9e76b773 --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/domain/config/RestTemplateFactory.java @@ -0,0 +1,13 @@ +package com.depromeet.fairer.domain.config; + +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class RestTemplateFactory { + public static RestTemplate getRestTemplate() { + return new RestTemplateBuilder() + .build(); + } +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/scheduler/InduceAddHouseworkJobScheduler.java b/fairer-batch/src/main/java/com/depromeet/fairer/scheduler/InduceAddHouseworkJobScheduler.java new file mode 100644 index 00000000..5f3bc0c4 --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/scheduler/InduceAddHouseworkJobScheduler.java @@ -0,0 +1,33 @@ +package com.depromeet.fairer.scheduler; + +import com.depromeet.fairer.config.InduceAddHouseworkJobConfig; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.batch.core.*; +import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +import java.util.HashMap; +import java.util.Map; + +@Slf4j +@Configuration +@RequiredArgsConstructor +public class InduceAddHouseworkJobScheduler { + private final JobLauncher jobLauncher; + private final InduceAddHouseworkJobConfig induceAddHouseworkJobConfig; + + @Scheduled(cron = "0 0 9 * * *") + public void induceAddHouseworkJobScheduler() { + Map confMap = new HashMap<>(); + confMap.put("time", new JobParameter(System.currentTimeMillis())); + JobParameters jobParameters = new JobParameters(confMap); + + try { + jobLauncher.run(induceAddHouseworkJobConfig.induceAddHouseworkJob(), jobParameters); + } catch (Exception e) { + log.error("[{}] Error.", induceAddHouseworkJobConfig.induceAddHouseworkJob().getName(), e.getMessage()); + } + } +} diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/scheduler/NotCompleteHouseworkRemindJobScheduler.java b/fairer-batch/src/main/java/com/depromeet/fairer/scheduler/NotCompleteHouseworkRemindJobScheduler.java new file mode 100644 index 00000000..5f397302 --- /dev/null +++ b/fairer-batch/src/main/java/com/depromeet/fairer/scheduler/NotCompleteHouseworkRemindJobScheduler.java @@ -0,0 +1,34 @@ +package com.depromeet.fairer.scheduler; + +import com.depromeet.fairer.config.NotCompleteHouseworkRemindJobConfig; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.batch.core.JobParameter; +import org.springframework.batch.core.JobParameters; +import org.springframework.batch.core.launch.JobLauncher; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.Scheduled; + +import java.util.HashMap; +import java.util.Map; + +@Slf4j +@Configuration +@RequiredArgsConstructor +public class NotCompleteHouseworkRemindJobScheduler { + private final JobLauncher jobLauncher; + private final NotCompleteHouseworkRemindJobConfig notCompleteHouseworkRemindJobConfig; + + @Scheduled(cron = "0 0 21 * * *") + public void notCompleteHouseworkRemindJobScheduler() { + Map confMap = new HashMap<>(); + confMap.put("time", new JobParameter(System.currentTimeMillis())); + JobParameters jobParameters = new JobParameters(confMap); + + try { + jobLauncher.run(notCompleteHouseworkRemindJobConfig.notCompleteHouseworkRemindJob(), jobParameters); + } catch (Exception e) { + log.error("[{}] Error.", notCompleteHouseworkRemindJobConfig.notCompleteHouseworkRemindJob().getName(), e.getMessage()); + } + } +} diff --git a/fairer-batch/src/main/resources/application.yml b/fairer-batch/src/main/resources/application.yml new file mode 100644 index 00000000..425d3d26 --- /dev/null +++ b/fairer-batch/src/main/resources/application.yml @@ -0,0 +1,70 @@ +server: + port: 8081 + +spring: + profiles: + active: "local" + batch: + job: + enabled: false + jdbc: + initialize-schema: never + main: + allow-bean-definition-overriding: true + +logging: + level: + root: info + +# spring actuator endpoints 기본으로 disable 적용 +management: + endpoints: + enabled-by-default: false + +--- + +spring: + config: + activate: + on-profile: ["local"] + + datasource: + url: jdbc:mysql://fairer-db.crfymtbz3gz1.ap-northeast-2.rds.amazonaws.com:3306/fairer_dev + driverClassName: com.mysql.cj.jdbc.Driver + username: 'fairer' + password: '>BRLtas~%j2>(\6#eC2M' + +domain: + apiUrl: http://localhost:8080 + +--- + +spring: + config: + activate: + on-profile: ["dev"] + + datasource: + url: jdbc:mysql://fairer-db.crfymtbz3gz1.ap-northeast-2.rds.amazonaws.com:3306/fairer_dev + driverClassName: com.mysql.cj.jdbc.Driver + username: 'fairer' + password: '>BRLtas~%j2>(\6#eC2M' + +domain: + apiUrl: http://ec2-3-39-60-64.ap-northeast-2.compute.amazonaws.com:8080 + +--- + +spring: + config: + activate: + on-profile: "real" + + datasource: + url: jdbc:mysql://fairer-db.crfymtbz3gz1.ap-northeast-2.rds.amazonaws.com:3306/fairer + driverClassName: com.mysql.cj.jdbc.Driver + username: 'fairer' + password: '>BRLtas~%j2>(\6#eC2M' + +domain: + apiUrl: http://fairer-env.eba-synb99hd.ap-northeast-2.elasticbeanstalk.com:8080 \ No newline at end of file diff --git a/fairer-batch/src/main/resources/logback-spring.xml b/fairer-batch/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..704d2aa3 --- /dev/null +++ b/fairer-batch/src/main/resources/logback-spring.xml @@ -0,0 +1,41 @@ + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %-10contextName %logger{36} - %msg%n + utf8 + + + + + logs/spring.log + + + ${LOG_PATH_NAME}/%d{yyyy-MM-dd}.%i.log + + + 50MB + + + 7 + + + %d{yyyy-MM-dd HH:mm:ss.SSS} %-5level [%t] %-10contextName %logger{36} - %msg%n + + + + + + + + + + + + + + + diff --git a/logs/spring.log b/logs/spring.log deleted file mode 100644 index e69de29b..00000000 diff --git a/settings.gradle b/settings.gradle index 96fb72e0..4b087005 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1,3 @@ rootProject.name = 'fairer' +include 'fairer-api' +include 'fairer-batch' diff --git a/src/main/java/com/depromeet/fairer/repository/team/TeamCustomRepository.java b/src/main/java/com/depromeet/fairer/repository/team/TeamCustomRepository.java deleted file mode 100644 index e1c91658..00000000 --- a/src/main/java/com/depromeet/fairer/repository/team/TeamCustomRepository.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.depromeet.fairer.repository.team; - -public interface TeamCustomRepository { -} diff --git a/src/main/java/com/depromeet/fairer/repository/team/TeamCustomRepositoryImpl.java b/src/main/java/com/depromeet/fairer/repository/team/TeamCustomRepositoryImpl.java deleted file mode 100644 index 2d00bab6..00000000 --- a/src/main/java/com/depromeet/fairer/repository/team/TeamCustomRepositoryImpl.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.depromeet.fairer.repository.team; - -public class TeamCustomRepositoryImpl implements TeamCustomRepository { - -} From 2c99d1a1cd60ed3a5a26528f4f03d7a660631c37 Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Sun, 21 Aug 2022 13:19:14 +0900 Subject: [PATCH 44/51] =?UTF-8?q?fix:=20=EC=9D=B4=EB=B2=88=EC=A3=BC=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C=20=EC=A7=91=EC=95=88=EC=9D=BC=20=EA=B0=9C?= =?UTF-8?q?=EC=88=98=20=EA=B8=B0=EA=B0=84=20=EC=88=98=EC=A0=95=20(#129)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../depromeet/fairer/service/housework/HouseWorkService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fairer-api/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java b/fairer-api/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java index 996519ad..1440c545 100644 --- a/fairer-api/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/service/housework/HouseWorkService.java @@ -119,8 +119,8 @@ public void deleteHouseWork(Long memberId, Long houseWorkId) { } public HouseWorkSuccessCountResponseDto getSuccessCount(String scheduledDate, Long memberId) { - LocalDate startDate = LocalDate.parse(scheduledDate).with(TemporalAdjusters.previous(DayOfWeek.MONDAY)); - LocalDate endDate = LocalDate.parse(scheduledDate).with(TemporalAdjusters.previous(DayOfWeek.SUNDAY)).plusWeeks(1); + LocalDate startDate = LocalDate.parse(scheduledDate).with(TemporalAdjusters.previousOrSame(DayOfWeek.SUNDAY)); + LocalDate endDate = LocalDate.parse(scheduledDate).with(TemporalAdjusters.nextOrSame(DayOfWeek.SATURDAY)); Long count = houseWorkRepository.getHouseWorkSuccessCount(memberId, startDate, endDate); return HouseWorkSuccessCountResponseDto.of(count); } From a9cf1209ca45d24d261fa496e92227acc9c8bca1 Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Mon, 22 Aug 2022 21:42:23 +0900 Subject: [PATCH 45/51] =?UTF-8?q?fix:=20=EC=83=88=EB=A1=9C=EC=9A=B4=20?= =?UTF-8?q?=EB=A9=A4=EB=B2=84=20=EC=B0=B8=EC=97=AC=20=EC=8B=9C=20=ED=91=B8?= =?UTF-8?q?=EC=8B=9C=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=88=98=EC=A0=95=20?= =?UTF-8?q?(#131)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/depromeet/fairer/service/team/TeamService.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fairer-api/src/main/java/com/depromeet/fairer/service/team/TeamService.java b/fairer-api/src/main/java/com/depromeet/fairer/service/team/TeamService.java index eeacb023..76c8400f 100644 --- a/fairer-api/src/main/java/com/depromeet/fairer/service/team/TeamService.java +++ b/fairer-api/src/main/java/com/depromeet/fairer/service/team/TeamService.java @@ -68,15 +68,15 @@ public Team joinTeam(Long memberId, String inviteCode) { Member member = reqMember.joinTeam(team); - pushMessageToTeamMember(team.getMembers()); + pushMessageToTeamMember(member, team.getMembers()); return member.getTeam(); } - private void pushMessageToTeamMember(Set members) { - for(Member member : members) { + private void pushMessageToTeamMember(Member member, Set teamMemberList) { + for(Member teamMember : teamMemberList) { FCMMessageRequest request = new FCMMessageRequest(); - request.setMemberId(member.getMemberId()); + request.setMemberId(teamMember.getMemberId()); request.setTitle(String.format(FCMMessageTemplate.JOIN_MEMBER_IN_TEAM.getTitle(), member.getMemberName(), member.getTeam().getTeamName())); request.setBody(FCMMessageTemplate.JOIN_MEMBER_IN_TEAM.getBody()); fcmService.sendMessage(request); From cbb4d7469f4f474d4d90d0a47ae26c9f4da6054e Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Tue, 23 Aug 2022 21:25:37 +0900 Subject: [PATCH 46/51] =?UTF-8?q?feat:=20=EC=9A=B4=EC=98=81=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20=EB=B0=B0=EC=B9=98=20=EC=84=B8=ED=8C=85=20(#133)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ebextensions-real/00-makeFiles.config | 6 ++++-- .github/workflows/real-fairer.yml | 11 ++++++++--- appspec.yml | 16 ---------------- deploy.sh | 18 ------------------ .../src/main/resources/application.yml | 2 +- 5 files changed, 13 insertions(+), 40 deletions(-) delete mode 100644 appspec.yml delete mode 100644 deploy.sh diff --git a/.ebextensions-real/00-makeFiles.config b/.ebextensions-real/00-makeFiles.config index e880de45..42e67271 100644 --- a/.ebextensions-real/00-makeFiles.config +++ b/.ebextensions-real/00-makeFiles.config @@ -5,7 +5,9 @@ files: group: webapp content: | #!/usr/bin/env bash - JAR_PATH=/var/app/current/application.jar + API_JAR_PATH=/var/app/current/fairer-api.jar + BATCH_JAR_PATH=/var/app/current/fairer-batch.jar # run app - java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar $JAR_PATH \ No newline at end of file + java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar $API_JAR_PATH + java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar $BATCH_JAR_PATH \ No newline at end of file diff --git a/.github/workflows/real-fairer.yml b/.github/workflows/real-fairer.yml index 7dd9fa6a..9c3e58e2 100644 --- a/.github/workflows/real-fairer.yml +++ b/.github/workflows/real-fairer.yml @@ -30,8 +30,12 @@ jobs: run: chmod +x ./gradlew # gradle wrapper를 실행할 수 있도록 권한 부여 shell: bash - - name: Build with Gradle - run: ./gradlew clean build # 프로젝트 빌드 + - name: Build API with Gradle + run: ./gradlew :fairer-api:build # 프로젝트 빌드 + shell: bash + + - name: Build Batch with Gradle + run: ./gradlew :fairer-batch:build # 프로젝트 빌드 shell: bash - name: Get current time @@ -49,7 +53,8 @@ jobs: - name: Generate deployment package run: | mkdir -p deploy - cp build/libs/*.jar deploy/application.jar + cp build/libs/fairer-api/*.jar deploy/fairer-api.jar + cp build/libs/fairer-batch/*.jar deploy/fairer-batch.jar cp Procfile deploy/Procfile cp -r .ebextensions-real deploy/.ebextensions cp -r .platform deploy/.platform diff --git a/appspec.yml b/appspec.yml deleted file mode 100644 index 7588c25c..00000000 --- a/appspec.yml +++ /dev/null @@ -1,16 +0,0 @@ -version: 0.0 -os: linux - -files: - - source: /deploy - destination: /home/ec2-user -permissions: - - object: /home/ec2-user - owner: ec2-user - group: ec2-user - mode: 755 -hooks: - AfterInstall: - - location: deploy.sh - timeout: 60 - runas: ec2-user \ No newline at end of file diff --git a/deploy.sh b/deploy.sh deleted file mode 100644 index 04f86140..00000000 --- a/deploy.sh +++ /dev/null @@ -1,18 +0,0 @@ -# deploy.sh -#!/usr/bin/env bash - -REPOSITORY=/home/ec2-user -cd $REPOSITORY - -JAR_NAME=fairer-dev.jar -JAR_PATH=$REPOSITORY/$JAR_NAME - -CURRENT_PID=$(pgrep -f $JAR_NAME) - -if ! [ -z $CURRENT_PID ] -then - kill $CURRENT_PID - sleep 5 -fi - -nohup java -jar -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=dev $JAR_PATH & \ No newline at end of file diff --git a/fairer-batch/src/main/resources/application.yml b/fairer-batch/src/main/resources/application.yml index 425d3d26..e7a155d6 100644 --- a/fairer-batch/src/main/resources/application.yml +++ b/fairer-batch/src/main/resources/application.yml @@ -67,4 +67,4 @@ spring: password: '>BRLtas~%j2>(\6#eC2M' domain: - apiUrl: http://fairer-env.eba-synb99hd.ap-northeast-2.elasticbeanstalk.com:8080 \ No newline at end of file + apiUrl: https://fairer-env.eba-synb99hd.ap-northeast-2.elasticbeanstalk.com \ No newline at end of file From fd252f069b1700102cce688c5627b9d266761fdc Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Wed, 24 Aug 2022 23:28:46 +0900 Subject: [PATCH 47/51] =?UTF-8?q?feat:=20=EC=9A=B4=EC=98=81=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20=EB=B0=B0=EC=B9=98=20=EC=84=B8=ED=8C=85=20(#135)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/real-fairer.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/real-fairer.yml b/.github/workflows/real-fairer.yml index 9c3e58e2..2336e8ff 100644 --- a/.github/workflows/real-fairer.yml +++ b/.github/workflows/real-fairer.yml @@ -53,8 +53,8 @@ jobs: - name: Generate deployment package run: | mkdir -p deploy - cp build/libs/fairer-api/*.jar deploy/fairer-api.jar - cp build/libs/fairer-batch/*.jar deploy/fairer-batch.jar + cp fairer-api/build/libs/*.jar deploy/fairer-api.jar + cp fairer-batch/build/libs/*.jar deploy/fairer-batch.jar cp Procfile deploy/Procfile cp -r .ebextensions-real deploy/.ebextensions cp -r .platform deploy/.platform From e88505ceaef3a81efcacefa4f2171d076b09ba93 Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Wed, 24 Aug 2022 23:40:00 +0900 Subject: [PATCH 48/51] =?UTF-8?q?feat:=20=EC=9A=B4=EC=98=81=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20=EB=B0=B0=EC=B9=98=20=EC=84=B8=ED=8C=85=20(#136)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ebextensions-real/00-makeFiles.config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ebextensions-real/00-makeFiles.config b/.ebextensions-real/00-makeFiles.config index 42e67271..70f6892f 100644 --- a/.ebextensions-real/00-makeFiles.config +++ b/.ebextensions-real/00-makeFiles.config @@ -9,5 +9,5 @@ files: BATCH_JAR_PATH=/var/app/current/fairer-batch.jar # run app - java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar $API_JAR_PATH - java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar $BATCH_JAR_PATH \ No newline at end of file + nohup java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar $API_JAR_PATH & + nohup java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar $BATCH_JAR_PATH & \ No newline at end of file From 19e43bb6e778f981357469c718d042eb811f750e Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Wed, 24 Aug 2022 23:51:02 +0900 Subject: [PATCH 49/51] =?UTF-8?q?feat:=20=EC=9A=B4=EC=98=81=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20=EB=B0=B0=EC=B9=98=20=EC=84=B8=ED=8C=85=20(#137)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ebextensions-real/00-makeFiles.config | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.ebextensions-real/00-makeFiles.config b/.ebextensions-real/00-makeFiles.config index 70f6892f..a823db86 100644 --- a/.ebextensions-real/00-makeFiles.config +++ b/.ebextensions-real/00-makeFiles.config @@ -4,10 +4,6 @@ files: owner: webapp group: webapp content: | - #!/usr/bin/env bash - API_JAR_PATH=/var/app/current/fairer-api.jar - BATCH_JAR_PATH=/var/app/current/fairer-batch.jar - # run app - nohup java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar $API_JAR_PATH & - nohup java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar $BATCH_JAR_PATH & \ No newline at end of file + nohup java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar /var/app/current/fairer-api.jar & + nohup java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar /var/app/current/fairer-batch.jar & \ No newline at end of file From 87f84d65c2d1eb34a1faca4506981a8cf9104a50 Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Thu, 25 Aug 2022 00:24:30 +0900 Subject: [PATCH 50/51] =?UTF-8?q?fix:=20=EB=AF=B8=EC=99=84=EB=A3=8C=20?= =?UTF-8?q?=EC=A7=91=EC=95=88=EC=9D=BC=20=EA=B0=9C=EC=88=98=20=EB=8B=B9?= =?UTF-8?q?=EC=9D=BC=20=EA=B2=83=EB=A7=8C=20=EC=B9=B4=EC=9A=B4=ED=8A=B8=20?= =?UTF-8?q?=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20(#138)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fairer/config/NotCompleteHouseworkRemindJobConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fairer-batch/src/main/java/com/depromeet/fairer/config/NotCompleteHouseworkRemindJobConfig.java b/fairer-batch/src/main/java/com/depromeet/fairer/config/NotCompleteHouseworkRemindJobConfig.java index aeae5083..d30063f3 100644 --- a/fairer-batch/src/main/java/com/depromeet/fairer/config/NotCompleteHouseworkRemindJobConfig.java +++ b/fairer-batch/src/main/java/com/depromeet/fairer/config/NotCompleteHouseworkRemindJobConfig.java @@ -63,7 +63,7 @@ public JdbcCursorItemReader notCompleteHousew .rowMapper(new BeanPropertyRowMapper<>(NotCompleteHouseworkRemindCommand.class)) .sql("SELECT member_id as memberId,count(*) as totalCount, housework_name as houseworkName\n" + "FROM assignment INNER JOIN housework ON assignment.housework_id=housework.housework_id\n" + - "WHERE success=0 GROUP BY member_id") + "WHERE success=0 and scheduled_date=curdate() GROUP BY member_id") .saveState(false) .build(); } From 940aa2a7e6386e7b3fb1fe213c2fef2f029a02fe Mon Sep 17 00:00:00 2001 From: SeungYoon Kim Date: Thu, 25 Aug 2022 20:37:29 +0900 Subject: [PATCH 51/51] =?UTF-8?q?fix:=20=EC=9A=B4=EC=98=81=20=EC=8B=A4?= =?UTF-8?q?=ED=96=89=20=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD=20(#139)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ebextensions-real/00-makeFiles.config | 14 +++++++++++--- Procfile | 3 ++- fairer-api/src/main/resources/application.yml | 4 ++++ fairer-api/src/main/resources/logback-spring.xml | 2 +- fairer-batch/src/main/resources/application.yml | 2 ++ fairer-batch/src/main/resources/logback-spring.xml | 2 +- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.ebextensions-real/00-makeFiles.config b/.ebextensions-real/00-makeFiles.config index a823db86..a54d1b59 100644 --- a/.ebextensions-real/00-makeFiles.config +++ b/.ebextensions-real/00-makeFiles.config @@ -1,9 +1,17 @@ files: - "/sbin/appstart" : + "/sbin/api_start" : mode: "000755" owner: webapp group: webapp content: | # run app - nohup java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar /var/app/current/fairer-api.jar & - nohup java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar /var/app/current/fairer-batch.jar & \ No newline at end of file + kill `ps -ef | grep fairer-api | awk '{print $2}'` + java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar /var/app/current/fairer-api.jar + "/sbin/batch_start" : + mode: "000755" + owner: webapp + group: webapp + content: | + # run app + kill `ps -ef | grep fairer-batch | awk '{print $2}'` + java -Duser.timezone="Asia/Seoul" -Dspring.profiles.active=real -jar /var/app/current/fairer-batch.jar \ No newline at end of file diff --git a/Procfile b/Procfile index 58dab8d4..ae9b293b 100644 --- a/Procfile +++ b/Procfile @@ -1 +1,2 @@ -web: appstart \ No newline at end of file +api: api_start +batch: batch_start \ No newline at end of file diff --git a/fairer-api/src/main/resources/application.yml b/fairer-api/src/main/resources/application.yml index b443f8b0..91a96326 100644 --- a/fairer-api/src/main/resources/application.yml +++ b/fairer-api/src/main/resources/application.yml @@ -2,6 +2,10 @@ spring: profiles: active: "local" +logging: + file: + name: spring-api.log + --- spring: diff --git a/fairer-api/src/main/resources/logback-spring.xml b/fairer-api/src/main/resources/logback-spring.xml index 704d2aa3..3646f5fc 100644 --- a/fairer-api/src/main/resources/logback-spring.xml +++ b/fairer-api/src/main/resources/logback-spring.xml @@ -10,7 +10,7 @@ - logs/spring.log + logs/spring-api.log ${LOG_PATH_NAME}/%d{yyyy-MM-dd}.%i.log diff --git a/fairer-batch/src/main/resources/application.yml b/fairer-batch/src/main/resources/application.yml index e7a155d6..281f76ea 100644 --- a/fairer-batch/src/main/resources/application.yml +++ b/fairer-batch/src/main/resources/application.yml @@ -15,6 +15,8 @@ spring: logging: level: root: info + file: + name: spring-batch.log # spring actuator endpoints 기본으로 disable 적용 management: diff --git a/fairer-batch/src/main/resources/logback-spring.xml b/fairer-batch/src/main/resources/logback-spring.xml index 704d2aa3..c3cb3c15 100644 --- a/fairer-batch/src/main/resources/logback-spring.xml +++ b/fairer-batch/src/main/resources/logback-spring.xml @@ -10,7 +10,7 @@ - logs/spring.log + logs/spring-batch.log ${LOG_PATH_NAME}/%d{yyyy-MM-dd}.%i.log