Skip to content

Commit

Permalink
Merge branch 'Kernel360:develop' into Temp/mentor
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonseon12 authored Jan 26, 2024
2 parents 7b59e75 + c569b1d commit 5cc5584
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ private void increaseViewCount(CoffeeChat coffeeChat) {
coffeeChat.increaseViewCount();
}

public CustomPageResponse<FindCoffeeChatListResponse> findHostCoffeeChatList(Long memberId, Pageable pageable) {
public CustomPageResponse findHostCoffeeChatList(Long memberId, Pageable pageable) {
Page<FindCoffeeChatListResponse> findCoffeeChatPage = coffeeChatRepository.findAllByMemberIdAndIsDeletedFalse(
memberId, pageable)
.map(FindCoffeeChatListResponse::of);

return new CustomPageResponse<>(findCoffeeChatPage);
return CustomPageResponse.of(findCoffeeChatPage);
}

@Transactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

http.cors(corsCustomizer -> corsCustomizer.configurationSource(request -> {
CorsConfiguration config = new CorsConfiguration();
config.setAllowedOrigins(List.of("http://localhost:3000"));
config.setAllowedOrigins(List.of("http://localhost:3000", "https://peaceful-sopapillas-36c089.netlify.app"));
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE"));
config.setAllowedHeaders(List.of("*"));
config.setMaxAge(3600L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ public UpdateFavoriteResponse create(Long memberId, UpdateFavoriteRequest update
InflearnCourse findInflearnCourse = inflearnCourseRepository.findById(
updateFavoriteRequest.getLectureId())
.orElseThrow(() -> new ApiException(InflearncourseErrorCode.NOT_FOUND_INFLEARN_COURSE));

return favoriteRepository.findFavoriteByMemberIdAndInflearnCourseId(memberId,
updateFavoriteRequest.getLectureId())
.map(favorite -> UpdateFavoriteResponse.of(favorite.getId()))
.orElseGet(() -> createNewFavorite(findMember, findInflearnCourse));
}

Favorite favorite = new Favorite(findMember, findInflearnCourse);
private UpdateFavoriteResponse createNewFavorite(Member member, InflearnCourse inflearnCourse) {
Favorite favorite = new Favorite(member, inflearnCourse);
Favorite savedFavorite = favoriteRepository.save(favorite);

return UpdateFavoriteResponse.of(savedFavorite.getId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@

import org.springframework.data.domain.Page;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class CustomPageResponse<T> {

private List<T> content;
private PageInfo pageInfo;

public CustomPageResponse(Page<T> page) {
this.content = page.getContent();
this.pageInfo = new PageInfo(page);
public static CustomPageResponse of(Page page) {
return new CustomPageResponse(page.getContent(), new PageInfo(page));
}

@Getter
public class PageInfo implements Serializable {
public static class PageInfo implements Serializable {

private Integer pageNumber;
private Integer pageSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
import kernel.jdon.jobcategory.domain.JobCategory;
import kernel.jdon.wantedjd.domain.WantedJd;
import lombok.AccessLevel;
Expand All @@ -20,10 +19,7 @@
@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "skill_history",
uniqueConstraints = {
@UniqueConstraint(columnNames = {"job_category_id", "wanted_jd_id", "keyword"})
})
@Table(name = "skill_history")
public class SkillHistory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand Down

0 comments on commit 5cc5584

Please sign in to comment.