Skip to content

Commit

Permalink
Merge pull request #117 from TEAM-DAWM/feat/116
Browse files Browse the repository at this point in the history
[feat] 동기화 기능 추가 및 카테고리와 스케줄 db 저장 로직 구현
  • Loading branch information
minwoo0419 authored Jul 19, 2024
2 parents 119e133 + e50fc04 commit f4f4e1f
Show file tree
Hide file tree
Showing 15 changed files with 438 additions and 154 deletions.
6 changes: 3 additions & 3 deletions src/main/java/nutshell/server/config/AsyncConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ public class AsyncConfig {
@Bean
public Executor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(2);
executor.setMaxPoolSize(5);
executor.setQueueCapacity(10);
executor.setCorePoolSize(5);
executor.setMaxPoolSize(10);
executor.setQueueCapacity(15);
executor.setThreadNamePrefix("Async-");
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
executor.initialize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,12 @@ public ResponseEntity<GoogleEmailsDto> getCategories(
) {
return ResponseEntity.ok(googleCalendarService.getCategories(userId));
}

@PostMapping("/google/calendars/sync")
public ResponseEntity<Void> getSyncs(
@UserId final Long userId
) {
googleCalendarService.getSyncs(userId);
return ResponseEntity.noContent().build();
}
}
31 changes: 31 additions & 0 deletions src/main/java/nutshell/server/domain/GoogleCategory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package nutshell.server.domain;


import jakarta.persistence.Id;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;

@Getter
@RedisHash(value="google_category")
@NoArgsConstructor(access= AccessLevel.PROTECTED)
public class GoogleCategory {
@Id
private String id;
@Indexed
private Long googleCalendarId;
private String name;
private String color;


@Builder
public GoogleCategory(String id, Long googleCalendarId, String name, String color) {
this.id = id;
this.googleCalendarId = googleCalendarId;
this.name = name;
this.color = color;
}
}
37 changes: 37 additions & 0 deletions src/main/java/nutshell/server/domain/GoogleSchedule.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package nutshell.server.domain;

import jakarta.persistence.Id;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import nutshell.server.dto.googleCalender.response.GoogleSchedulesDto;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.index.Indexed;

import java.util.List;

@Getter
@RedisHash(value="google_schedule")
@NoArgsConstructor(access= AccessLevel.PROTECTED)
public class GoogleSchedule {
@Id
private String id;
@Indexed
private Long googleCalendarId;
@Indexed
private String googleCategoryId;
private String name;
private String color;
private List<GoogleSchedulesDto.GoogleScheduleDto> schedules;

@Builder
public GoogleSchedule(String id, Long googleCalendarId, String googleCategoryId, String name, String color, List<GoogleSchedulesDto.GoogleScheduleDto> schedules) {
this.id = id;
this.googleCalendarId = googleCalendarId;
this.googleCategoryId = googleCategoryId;
this.name = name;
this.color = color;
this.schedules = schedules;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nutshell.server.repository;

import nutshell.server.domain.GoogleCategory;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface GoogleCategoryRepository extends CrudRepository<GoogleCategory, String> {
List<GoogleCategory> findAllByGoogleCalendarId(final Long googleCalendarId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package nutshell.server.repository;

import nutshell.server.domain.GoogleSchedule;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

public interface GoogleScheduleRepository extends CrudRepository<GoogleSchedule, String> {
List<GoogleSchedule> findAllByGoogleCalendarId(Long googleCalendarId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void unlink(final String token) {
googleUnlinkClient.googleUnlink(token);
}

public GoogleTokenResponse reissue(final GoogleReissueRequest request) {
public GoogleTokenResponse reissue(final GoogleReissueRequest request) throws Exception {
return googleReissueClient.googleReissue(request);
}
}
Loading

0 comments on commit f4f4e1f

Please sign in to comment.