Skip to content

Commit

Permalink
v1.2.0 (#585)
Browse files Browse the repository at this point in the history
* 알림 기능 추가(#483)

* [feat] FCM 연결 로직 추가(#483)

* [feat] Alarm 테이블 및 Update API 추가

* [feat] Mypage 조회시 알림 정보 추가

* [feat] Alarm Update API에 Validation 추가

* [feat] Alarm API RestDoc 문서에 추가

* 기존 유저 Alarm 정보 추가 기능 설정 (#526)

* 일반 로그인 로직 제거 (#525)

* [chore] metricsConfig 삭제(#507) (#529)

* [refactor] 감정어 통계 로직 변경 (#531)

* [refactor] 감정어 통계 로직 오타 수정(#532) (#533)

* [fix] setAllowCredentials false 설정 (#535)

* 회원가입/로그인 분산락 적용 (#537)

* [feat] 회원가입/로그인에 Lettuce 분산락 적용

* [feat] 인증 트랜잭션 범위 축소 - 프록시 내부 호출 관련 작업

* [refactor] AuthService 에서 @transactional 제거

* [refactor] 락 획득을 위한 @lockname 설정 파라미터 변경 (#539)

- 이메일 기반 락 생성

* [Search] 검색 기능 수정 (#541)

* [refactor] 검색 기능 수정

* [refactor] 일기 content,회고 answer 조건에 맞게 파싱

* [refactor] 검색시 Diary response 간략화

* [Search] 검색 문장 파싱시 '... ' 추가

* [feat] 후원자 인증 기능 (#545)

* [feat] 엔티티 생성(#540)

* [feat] 후원자 기능 구현(#540)

* [feat] 예외처리(#540)

* [feat] 검색 response에 type 추가 (#547)

* [refactor] LogRepository save 메서드에서 REQUIRES_NEW 제거 (#549)

* [Docs] 검색 API 문서 수정 (#552)

* [docs] 검색 API 문서 수정

* 후원자 등록시 Redis 분산락으로 동시성 처리 (#553)

* [feat] Lock name에 method name 추가

* [feat] 후원자 등록시 분산락으로 동시성 처리

* [feat] 후원자 인증 기능 문서 작성(#555)

* [Search] 사용자 식별값 추가 (#557)

* [feat] 일기, 회고 조회시 사용자 식별값 추가

* [refactor] 검색 관련 문자열 파싱 수정

* [refactor] 검색 관련 문자열 파싱 - 문장 잘림 수정 (#559)

* [refactor] 감정어 로직 변경(#562)

* [refactor] 감정어 정렬 고정(#564)

* [refactor] 반복문 수정(#566)

* [refactor] @transactional 제거(#567)

* [refactor] 감정어 반복해서 나오는 문제 해결 (#568)

* [refactor] @transactional 제거(#563)

* [refactor] 감정어 반복해서 나오는 문제 수정(#563)

* [refactor] 조건문 추가(#569)

* [refactor] 검색시 회고 질문 번호 순서 기준으로 변경 (#571)

* [refactor] 회고 조회 API (#573)

* [refactor] 회고 주차 추가(#574)

* [feat] 회고 답변 예외처리 (#575)

* [refactor] 회고 주차 추가(#572)

* [feat] 회고 답변 예외처리

* 검색 API 분리 (#577)

* [feat] 검색 API 분리

* [test] 검색 TC 수정

* 서비스 사용일수 로직 수정 (#579)

* 지표 추출 후 엑셀 다운로드 기능 (#581)

* [feat] dau 지표 엑셀 추출(#580)

* [feat] wau 지표 엑셀 추출(#580)

* [feat] 일간 가입자 수엑셀 추출(#580)

* [feat] 유저별 회고 진행한 횟수 엑셀 추출(#580)

* [refactor] 회고 조회 API 통합과 관련된 로직들 수정 (#582)

* [refactor] 회고탭 API 응답에 retrospectId 추가

* [refactor] 일반 회고 조회, 검색 시 회고 조회 API 통합

* [refactor] 회고수정, 삭제 API 수정

* [refactor] 문서 변경, 관련 수정할 지점 수정

* [refactor] readOnly True 제거

* 회고 조회 ver2 (#584)

* [refactor] 하위 호환성을 위해 V2 패키지 생성, 통합 API 해당 패키지로 이동

* [feat] retrospect v2 API 문서 작성(#583)

* [refactor] 기존 코드로 롤백(#583)

* [refactor] 테스트 코드 기존 코드로 롤백(#583)

* [refactor] API 문서 반영(#583)

* [refactor] ReadOnly 제거(#583)

---------

Co-authored-by: imdh <[email protected]>
  • Loading branch information
isprogrammingfun and jjddhh authored Aug 24, 2023
1 parent c0772e8 commit 64aa853
Show file tree
Hide file tree
Showing 104 changed files with 6,334 additions and 607 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Dockerfile-dev
*.yml
prometheus.yml
grafana_data
logs
pinpoint-agent-2.5.0

### STS ###
.apt_generated
Expand Down
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ dependencies {
implementation("com.slack.api:bolt-jetty:1.27.3")
implementation('com.github.maricn:logback-slack-appender:1.6.1')

// Push Alarm
implementation 'com.google.firebase:firebase-admin:8.1.0'

// Email 인증
implementation 'org.springframework.boot:spring-boot-starter-mail'

Expand All @@ -90,6 +93,10 @@ dependencies {
implementation 'com.bucket4j:bucket4j-jcache:8.1.1'
implementation 'javax.cache:cache-api:1.1.1'
implementation 'org.redisson:redisson:3.19.0'

// Apache POI
implementation 'org.apache.poi:poi:5.0.0'
implementation 'org.apache.poi:poi-ooxml:5.0.0'
}

tasks.named('test') {
Expand Down
12 changes: 12 additions & 0 deletions src/docs/asciidoc/Alarm-API.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[Alarm-API]]
== Alarm API

[[Alarm-일기-알림-변경]]
=== Alarm 일기 알림 변경
operation::alarm-controller-test/일기_알림_변경[snippets='http-request,request-fields,http-response,response-fields']

---

[[Alarm-회고-알림-변경]]
=== Alarm 회고 알림 변경
operation::alarm-controller-test/회고_알림_변경[snippets='http-request,request-fields,http-response,response-fields']
25 changes: 25 additions & 0 deletions src/docs/asciidoc/Retrospect-API-V2.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[[Retrospect-API-V2]]
== Retrospect API V2

[[Retrospect-회고-탭-v2]]
=== Retrospect 회고 탭 v2
operation::retrospect-controller-test-v2/회고_탭[snippets='http-request,request-headers,request-parameters,http-response,response-fields']

---

[[Retrospect-회고-조회-v2]]
=== Retrospect 회고 조회 v2
operation::retrospect-controller-test-v2/회고_조회[snippets='http-request,request-headers,request-parameters,http-response,response-fields']

---

[[Retrospect-회고-수정-v2]]
=== Retrospect 회고 수정 v2
operation::retrospect-controller-test-v2/회고_수정[snippets='http-request,request-headers,request-fields,http-response,response-fields']

---

[[Retrospect-회고-삭제-v2]]
=== Retrospect 회고 삭제 v2
operation::retrospect-controller-test-v2/회고_삭제[snippets='http-request,request-headers,http-response,response-fields']

7 changes: 5 additions & 2 deletions src/docs/asciidoc/Search-API.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
== Search API

[[Search-검색]]
=== Search 검색
operation::search-controller-test/검색[snippets='http-request,request-headers,request-parameters,http-response,response-fields']
=== Search 일기 검색
operation::search-controller-test/일기_검색[snippets='http-request,request-headers,request-parameters,http-response,response-fields']

=== Search 회고 검색
operation::search-controller-test/회고_검색[snippets='http-request,request-headers,request-parameters,http-response,response-fields']
6 changes: 6 additions & 0 deletions src/docs/asciidoc/Sponsor-API.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[[Sponsor-API]]
== Sponsor API

[[Sponsor-후원자]]
=== Sponsor 후원자 인증
operation::sponsor-controller-test/후원자_인증[snippets='http-request,request-headers,request-fields,http-response,response-fields']
6 changes: 6 additions & 0 deletions src/docs/asciidoc/api.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ include::OnBoarding-API.adoc[]

include::MyPage-API.adoc[]

include::Alarm-API.adoc[]

include::Diary-API.adoc[]

include::Retrospect-API.adoc[]

include::Retrospect-API-V2.adoc[]

include::Search-API.adoc[]

include::Sponsor-API.adoc[]

25 changes: 22 additions & 3 deletions src/main/java/com/nanal/backend/domain/TestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.websocket.server.PathParam;

@Slf4j
@RequiredArgsConstructor
@RestController
Expand All @@ -21,4 +20,24 @@ public void logTest() {
log.warn("warn");
log.error("error");
}

@GetMapping("/test/gc")
public void gcTest(@PathParam("loop") Integer loop) {

long initHeapSize = Long.parseLong(System.getProperty("sun.arch.data.model")) == 32 ?
Integer.getInteger("sun.arch.data.model") : Long.getLong("sun.arch.data.model");
System.out.println("Initial Heap Size: " + initHeapSize / 1024 / 1024 + "MB");


// 최대 힙 사이즈 (Xmx 옵션으로 설정한 값)
long maxHeapSize = Runtime.getRuntime().maxMemory();
System.out.println("Max Heap Size: " + maxHeapSize / 1024 / 1024 + "MB");

String tmp = null;
for (int i = 0; i < loop; i++) {
tmp = new String("gc");
}

System.out.println(tmp);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.nanal.backend.domain.alarm.controller;

import com.nanal.backend.domain.alarm.dto.ReqUpdateDiaryAlarm;
import com.nanal.backend.domain.alarm.dto.ReqUpdateRetrospectAlarm;
import com.nanal.backend.domain.alarm.service.AlarmService;
import com.nanal.backend.global.response.CommonResponse;
import com.nanal.backend.global.response.ErrorCode;
import com.nanal.backend.global.security.User;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RequiredArgsConstructor
@RestController
public class AlarmController {

private final AlarmService alarmService;

@PutMapping("/alarm/diary")
public CommonResponse<?> updateDiaryAlarm(
@AuthenticationPrincipal User user,
@RequestBody @Valid ReqUpdateDiaryAlarm reqUpdateDiaryAlarm) {

alarmService.updateDiaryAlarm(user.getSocialId(), reqUpdateDiaryAlarm);

return new CommonResponse<>(ErrorCode.SUCCESS);
}

@PutMapping("/alarm/retrospect")
public CommonResponse<?> updateRetrospectAlarm(
@AuthenticationPrincipal User user,
@RequestBody @Valid ReqUpdateRetrospectAlarm reqUpdateRetrospectAlarm) {

alarmService.updateRetrospectAlarm(user.getSocialId(), reqUpdateRetrospectAlarm);

return new CommonResponse<>(ErrorCode.SUCCESS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.nanal.backend.domain.alarm.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class ReqUpdateDiaryAlarm {

@NotNull(message = "diaryAlarmActive 값이 올바르지 않습니다.")
private Boolean diaryAlarmActive;

@NotBlank(message = "diaryAlarmTime 는 비어있을 수 없습니다.")
@Pattern(message = "diaryAlarmTime 값이 올바르지 않습니다.",
regexp = "^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$")
private String diaryAlarmTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.nanal.backend.domain.alarm.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@NoArgsConstructor
@AllArgsConstructor
@Data
public class ReqUpdateRetrospectAlarm {

@NotNull(message = "retrospectAlarmActive 값이 올바르지 않습니다.")
private Boolean retrospectAlarmActive;

@NotBlank(message = "retrospectAlarmTime 는 비어있을 수 없습니다.")
@Pattern(message = "retrospectAlarmTime 값이 올바르지 않습니다.",
regexp = "^(0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])$")
private String retrospectAlarmTime;
}
59 changes: 59 additions & 0 deletions src/main/java/com/nanal/backend/domain/alarm/entity/Alarm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.nanal.backend.domain.alarm.entity;

import com.nanal.backend.domain.alarm.dto.ReqUpdateDiaryAlarm;
import com.nanal.backend.domain.alarm.dto.ReqUpdateRetrospectAlarm;
import com.nanal.backend.domain.auth.entity.Member;
import com.nanal.backend.global.config.BaseTime;
import lombok.*;

import javax.persistence.*;

@Getter
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@Table(name = "alarm")
@Entity
public class Alarm extends BaseTime {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "alarm_id")
private Long alarmId;

@Column(nullable = false)
private Boolean diaryActive;

@Column(length = 5, nullable = false)
private String diaryTime;

@Column(nullable = false)
private Boolean retrospectActive;

@Column(length = 5, nullable = false)
private String retrospectTime;

@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member;

public static Alarm createAlarm(Member member) {
return Alarm.builder()
.diaryActive(true)
.diaryTime("20:00")
.retrospectActive(true)
.retrospectTime("20:00")
.member(member)
.build();
}

public void updateDiaryAlarm(ReqUpdateDiaryAlarm reqUpdateDiaryAlarm) {
this.diaryActive = reqUpdateDiaryAlarm.getDiaryAlarmActive();
this.diaryTime = reqUpdateDiaryAlarm.getDiaryAlarmTime();
}

public void updateRetrospectAlarm(ReqUpdateRetrospectAlarm reqUpdateRetrospectAlarm) {
this.retrospectActive = reqUpdateRetrospectAlarm.getRetrospectAlarmActive();
this.retrospectTime = reqUpdateRetrospectAlarm.getRetrospectAlarmTime();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.nanal.backend.domain.alarm.repository;

import com.nanal.backend.domain.alarm.entity.Alarm;
import com.nanal.backend.domain.auth.entity.Member;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface AlarmRepository extends JpaRepository<Alarm, Long> {

Optional<Alarm> findByMember(Member member);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.nanal.backend.domain.alarm.service;

import com.nanal.backend.domain.alarm.dto.ReqUpdateDiaryAlarm;
import com.nanal.backend.domain.alarm.dto.ReqUpdateRetrospectAlarm;
import com.nanal.backend.domain.alarm.entity.Alarm;
import com.nanal.backend.domain.alarm.repository.AlarmRepository;
import com.nanal.backend.domain.auth.entity.Member;
import com.nanal.backend.domain.auth.repository.MemberRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;

@Transactional
@RequiredArgsConstructor
@Service
public class AlarmService {

private final MemberRepository memberRepository;

public void updateDiaryAlarm(String socialId, ReqUpdateDiaryAlarm reqUpdateDiaryAlarm) {
// socialId 로 유저 조회
Member member = memberRepository.findMember(socialId);

Alarm alarm = member.getAlarm();

alarm.updateDiaryAlarm(reqUpdateDiaryAlarm);
}

public void updateRetrospectAlarm(String socialId, ReqUpdateRetrospectAlarm reqUpdateRetrospectAlarm) {
// socialId 로 유저 조회
Member member = memberRepository.findMember(socialId);

Alarm alarm = member.getAlarm();

alarm.updateRetrospectAlarm(reqUpdateRetrospectAlarm);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public interface AuthLogRepository extends JpaRepository<AuthLog, Long> {

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Transactional
AuthLog save(AuthLog authLog);

// @Query(value = "SELECT new com.nanal.backend.domain.analysis.dto.resp.DayDto(DAY(al.createdAt), COUNT(DISTINCT al.userEmail)) " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.nanal.backend.domain.analysis.dto.resp.DayDto;
import com.nanal.backend.domain.analysis.entity.DiaryLog;
import com.nanal.backend.domain.excel.dto.resp.DauDto;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Propagation;
Expand All @@ -19,6 +20,15 @@ public interface DiaryLogRepository extends JpaRepository<DiaryLog, Long> {
"GROUP BY DAY(dl.createdAt)")
List<DayDto> dauQuery(LocalDateTime from, LocalDateTime to);

@Query(value = "SELECT new com.nanal.backend.domain.excel.dto.resp.DauDto(dl.createdAt, COUNT(DISTINCT dl.userEmail)) " +
"FROM DiaryLog dl " +
"WHERE dl.createdAt >= :from AND dl.createdAt < :to AND dl.serviceName = 'getCalendar' "+
"GROUP BY dl.createdAt")
List<DauDto> excelDauQuery(LocalDateTime from, LocalDateTime to);

@Query("SELECT dl FROM DiaryLog dl WHERE dl.createdAt >= :from AND dl.createdAt < :to AND dl.serviceName = 'getCalendar'")
List<DiaryLog> findLogsBetweenDates(LocalDateTime from, LocalDateTime to);

@Query(value = "SELECT COUNT(DISTINCT dl.userEmail) " +
"FROM DiaryLog dl " +
"WHERE dl.createdAt >= :from AND dl.createdAt < :to AND dl.serviceName = 'writeDiary'")
Expand All @@ -29,6 +39,6 @@ public interface DiaryLogRepository extends JpaRepository<DiaryLog, Long> {
"WHERE dl.createdAt >= :from AND dl.createdAt < :to AND dl.serviceName = 'getCalendar'")
Integer loginDAU(LocalDateTime from, LocalDateTime to);

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Transactional
DiaryLog save(DiaryLog diaryLog);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

public interface MypageLogRepository extends JpaRepository<MypageLog, Long> {

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Transactional
MypageLog save(MypageLog mypageLog);
}
Loading

0 comments on commit 64aa853

Please sign in to comment.