Skip to content

Commit

Permalink
Merge pull request #83 from Team-UMC/fix/#82/project-data-modify
Browse files Browse the repository at this point in the history
[FIX] ๋จน์ด์ฃผ๊ธฐ ํƒ€์ž…์ถ”๊ฐ€ ๋ฐ ํ”„๋กœ์ ํŠธ ๊ด€๋ จ์ˆ˜์ •
  • Loading branch information
junseokkim authored Feb 18, 2024
2 parents a5dd435 + 01c8671 commit 15ca2d8
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(lastActiveInterceptor)
.addPathPatterns("/**") // ๋ชจ๋“  ์š”์ฒญ์— ๋Œ€ํ•ด ์ธํ„ฐ์…‰ํ„ฐ ์ ์šฉ
.excludePathPatterns("/v3/**", "/swagger-ui/**") // ์Šค์›จ๊ฑฐ ์š”์ฒญ์€ ์ œ์™ธ
.excludePathPatterns("/members/login"); // ๋กœ๊ทธ์ธ API ์ œ์™ธ
.excludePathPatterns("/members/login", "/members", "/members/attend", "/invites/**"); // ๋กœ๊ทธ์ธ ๋ฐ ํšŒ์›๊ฐ€์ž… API ์ œ์™ธ
}

//cors ์—๋Ÿฌ ํ•ด๊ฒฐ
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public enum ProjectInfo {
OWORI("์˜ค์›”์ด", " ๋ชจ์—ฌ๋ด์š” ์šฐ๋ฆฌ๊ฐ€์กฑ, ์šฐ๋ฆฌ๊ฐ€์กฑ๋งŒ์˜ ์†Œ์ค‘ํ•œ ์ถ”์–ต์„ ๊ธฐ๋กํ•˜๊ณ  ์†Œํ†ตํ•ด์š”", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FOURTH/%EC%98%A4%EC%9B%94%EC%9D%B4+%EB%A1%9C%EA%B3%A0.png", List.of("๊ฐ€์กฑ", "์†Œํ†ต", "์ถ”์–ต"), Semester.FOURTH, List.of(ProjectType.IOS)),
ARF("์•Œํ”„", "๊ต๋‚ด ์žฌํ•™์ƒ - ๊ตํ™˜ํ•™์ƒ ์ปค๋ฎค๋‹ˆํ‹ฐ ๋ฐ ๋ชจ์ž„ ํ”Œ๋žซํผ", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FOURTH/%EC%95%8C%ED%94%84.png", List.of("์•ˆ์ „", "์™ธ๊ตญ์ธ", "๋Œ€ํ•™์ƒ"), Semester.FOURTH, List.of(ProjectType.IOS)),
MYOJIPSA("๋ฌ˜์ง‘์‚ฌ", "๋ฏธ์…˜ํ˜• ์ปค๋ฎค๋‹ˆํ‹ฐ ์„œ๋น„์Šค", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FOURTH/%EB%AC%98%EC%A7%91%EC%82%AC.svg", List.of("์ปค๋ฎค๋‹ˆํ‹ฐ", "ํ† ๋ผ", "๋ฏธ์…˜"), Semester.FOURTH, List.of(ProjectType.AOS)),

EM_SAM("์— ์Œค", "MBTI ๊ณ ๋ฏผ ์ƒ๋‹ด์†Œ, ๋„์™€์ค˜์š” M์Œค!", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FOURTH/%EC%97%A0%EC%8C%A4.png", List.of("MBTI", "์ƒ๋‹ด", "์ฑ„ํŒ…"), Semester.FOURTH, List.of(ProjectType.WEB)),

// 5๊ธฐ
// GACI
Expand All @@ -40,7 +40,7 @@ public enum ProjectInfo {
BLOOD_TRAIL("BloodTrail", "ํ—Œํ˜ˆ ์›ํฌ์ธํŠธ ์–ดํ”Œ", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/%5B%ED%81%B4%EB%B0%8B%5D.svg", List.of("ํ—Œํ˜ˆ", "์ปค๋ฎค๋‹ˆํ‹ฐ"), Semester.FIFTH, List.of(ProjectType.WEB)),
NANGMAN_CAT("๋‚ญ๋งŒ ๊ณ ์–‘์ด", "๋งˆ์Œ์„ ์ „๋‹ฌํ•˜๋Š” ๋ชจ๋ฐ”์ผ ํŽธ์ง€ ์„œ๋น„์Šค", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/%EB%82%AD%EB%A7%8C+%EA%B3%A0%EC%96%91%EC%9D%B4.png", List.of("๋Š๋ฆฐ ์šฐ์ฒดํ†ต", "๊ฐœ์„ฑ", "์†Œํ†ต"), Semester.FIFTH, List.of(ProjectType.WEB)),
UJU_JEONGGEOJANG("์šฐ์ฃผ ์ •๊ฑฐ์žฅ", "๋‚˜๋ฅผ ์œ„ํ•œ ๊ธ€์“ฐ๊ธฐ", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/%EC%9A%B0%EC%A3%BC%EC%A0%95%EA%B1%B0%EC%9E%A5_.svg", List.of("๊ธ€์“ฐ๊ธฐ", "๋ชฐ์ž…", "์ž๊ธฐ๊ฐœ๋ฐœ"),Semester.FIFTH, List.of(ProjectType.WEB)),
HOMEAT("Homeat", "์ฑŒ๋ฆฐ์ง€ํ˜• ์‹๋น„ ๊ด€๋ฆฌ ์ปค๋ฎค๋‹ˆํ‹ฐ ์–ดํ”Œ", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/Friend+-.jpg", List.of("1์ธ๊ฐ€๊ตฌ", "์‹๋น„๊ด€๋ฆฌ", "์ •๋ณด๊ณต์œ "), Semester.FIFTH, List.of(ProjectType.IOS)),
HOMEAT("Homeat", "์ฑŒ๋ฆฐ์ง€ํ˜• ์‹๋น„ ๊ด€๋ฆฌ ์ปค๋ฎค๋‹ˆํ‹ฐ ์–ดํ”Œ", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/Homeat(%ED%99%88%EC%9E%87).png", List.of("1์ธ๊ฐ€๊ตฌ", "์‹๋น„๊ด€๋ฆฌ", "์ •๋ณด๊ณต์œ "), Semester.FIFTH, List.of(ProjectType.IOS)),
FORGRAD("FORGRAD", "๋‹น์‹ ์˜ ์กธ์—…์„ ์œ„ํ•œ ๋ชจ๋“  ๊ฒƒ! ์กธ์—…์ •๋ณด์„œ๋น„์Šค", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/%ED%8F%AC%EC%96%B4%EA%B7%B8%EB%9E%98%EB%93%9C.svg", List.of("์กธ์—…", "์†Œํ†ต", "ํŽธ๋ฆฌํ•จ"), Semester.FIFTH, List.of(ProjectType.AOS)),
INTERPHONE("์ธํ„ฐํฐ!", "์ž์‹ ์—๊ฒŒ ๋งž๋Š” ๊ธฐ์—…์ถ”์ฒœ ์„œ๋น„์Šค", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/%EC%9D%B8%ED%84%B0%ED%8F%B0.svg", List.of("์ธํ„ด", "๋Œ€ํ•™์ƒ", "์ŠคํŽ™์Œ“๊ธฐ"), Semester.FIFTH, List.of(ProjectType.WEB)),
DONGNEHYEONG("๋™๋„คํ˜•", "๋‹น์‹  ๊ทผ์ฒ˜์˜ โ€˜๋™๋„คํ˜•โ€™์—๊ฒŒ ์šด๋™์„ ๋ฐฐ์šฐ์„ธ์š”.", "", List.of("ํ—ฌ์Šค", "PT"), Semester.FIFTH, List.of(ProjectType.WEB)),
Expand Down Expand Up @@ -116,7 +116,7 @@ public enum ProjectInfo {
JJIKJJIKI("์ฐ์ฐ์ด", "๊ฐค๋Ÿฌ๋ฆฌ์—์„œ ๋‹ค๋ฅธ ์‚ฌ์ง„๋“ค๊ณผ ์†Œ์ค‘ํ•œ ์ถ”์–ต ์„ž์–ด ๋ณด๊ด€ํ•˜์ง€ ๋ง์ž!!!", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/%EC%B0%8D%EC%B0%8D%EC%9D%B4.svg", List.of("๋„ค์ปท์‚ฌ์ง„", "์•จ๋ฒ”", "์ถ”์–ต"), Semester.FIFTH, List.of(ProjectType.IOS)),
CUPI("ํํ”ผ", "๋‹น์‹ ์˜ ํ˜ธ๊ธฐ์‹ฌ์„ ์ฐ์ „๋ฌธ๊ฐ€๊ฐ€ ํ•ด๊ฒฐํ•ด์ค๋‹ˆ๋‹ค!", "", List.of("์ „๋ฌธ๊ฐ€", "๋‹ต๋ณ€"), Semester.FIFTH, List.of(ProjectType.AOS, ProjectType.WEB)),
ONANDOFF("์˜จ์•ค์˜คํ”„", "ํšŒ๊ณ ๋ฅผ ํ†ตํ•ด ์ผ์ž˜๋Ÿฌ๋กœ ์„ฑ์žฅํ•˜๊ณ , ์ผ์˜ on&off ๋ฅผ ๋„์™€์ฃผ๋Š” ์›Œ๋ผ๋ฒจ ์„œ๋น„์Šค", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/ONNOFF.png", List.of("ํšŒ๊ณ ", "์ง์žฅ์ธ", "์›Œ๋ผ๋ฒจ"), Semester.FIFTH, List.of(ProjectType.IOS)),
VI_NO("VI.NO", "์˜์ƒ๋ณด๋‹ค ๊ธ€์ด ํŽธํ•œ ๋‹น์‹ ์„ ์œ„ํ•œ, ์˜์ƒ ๋ธ”๋กœ๊ทธํ™” ์†”๋ฃจ์…˜","https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/UMC+Matching+Center.png", List.of("์˜์ƒ์ •๋ฆฌ", "์˜์ƒ์š”์•ฝ", "์ƒ์„ฑํ˜•AI"), Semester.FIFTH, List.of(ProjectType.WEB)),
VI_NO("VI.NO", "์˜์ƒ๋ณด๋‹ค ๊ธ€์ด ํŽธํ•œ ๋‹น์‹ ์„ ์œ„ํ•œ, ์˜์ƒ ๋ธ”๋กœ๊ทธํ™” ์†”๋ฃจ์…˜","https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/Vi.NO.svg", List.of("์˜์ƒ์ •๋ฆฌ", "์˜์ƒ์š”์•ฝ", "์ƒ์„ฑํ˜•AI"), Semester.FIFTH, List.of(ProjectType.WEB)),
MOAMOA("๋ชจ์•„๋ชจ์•„", "์ƒํ’ˆ์„ ๋ชจ์•„ ์‚ฌ๋žŒ์„ ๋ชจ์•„ ๋‹น์‹ ์˜ ํ•ฉ๋ฆฌ์  ์†Œ๋น„๋ฅผ ๋•๊ธฐ ์œ„ํ•œ ๊ณต๋™ ๊ตฌ๋งค ํ”Œ๋žซํผ", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/%EB%AA%A8%EC%95%84%EB%AA%A8%EC%95%84.svg", List.of("๊ณต๋™ ๊ตฌ๋งค", "ํ•ฉ๋ฆฌ์  ์†Œ๋น„", "์ด์›ƒ"), Semester.FIFTH, List.of(ProjectType.WEB)),
WITHYOU("with 'You'", "์—ฌํ–‰์„ ํ•จ๊ป˜ํ•˜๋Š” ๊ทธ ์‚ฌ๋žŒ(๋‹น์‹ )๊ณผ์˜ Travel Log / ์ถ”์–ต ์ €์žฅ์†Œ", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/with+%E2%80%98You%E2%80%99.svg", List.of("ํ•จ๊ป˜ ์“ฐ๋Š” ์—ฌํ–‰", "with who?!"), Semester.FIFTH, List.of(ProjectType.IOS)),
ECOLINK("์—์ฝ”๋งํฌ", "์„œ์šธ ๋‚ด ๋‹ค์–‘ํ•œ ์ง€์—ญ์—์„œ ์šด์˜๋˜๊ณ  ์žˆ๋Š” ์ œ๋กœ์›จ์ด์ŠคํŠธ ์ƒต๋“ค์˜ ์œ„์น˜์™€ ํŒ๋งค ์ œํ’ˆ ์ •๋ณด, ๋งค์žฅ ์ด์šฉ ๋ฐฉ๋ฒ•, ๊ทธ๋ฆฌ๊ณ  ๋งค์žฅ ๋ณ„ ๋‹ค์–‘ํ•œ ์ด๋ฒคํŠธ๋ฅผ ํ•œ๋ˆˆ์— ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ํ”Œ๋žซํผ ์„œ๋น„์Šค", "https://umc-service-bucket.s3.ap-northeast-2.amazonaws.com/project/FIFTH/5%EA%B8%B0+%ED%94%8C%EC%A0%9D+%EC%82%AC%EC%A7%84/Map+To+Zero.svg", List.of("์นœํ™˜๊ฒฝ"), Semester.FIFTH, List.of(ProjectType.WEB)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ public enum ProjectMemberInfo {
BORA("๋ณด๋ผ", "์œ ์ง€์ˆ˜", Part.PM, ProjectInfo.TODAYSGYM.getName()),
CHOROK("์ดˆ๋ก", "์œค์ง€๋ฏผ", Part.DESIGN, ProjectInfo.TODAYSGYM.getName()),
BEX_1("๋ฒก์Šค", "๊น€์ค€์„", Part.ANDROID, ProjectInfo.TODAYSGYM.getName()),
BORA_1("๋ณด๋ผ", "์œ ์ง€์ˆ˜", Part.SPRING, ProjectInfo.TODAYSGYM.getName()),
HERON("ํ—ค๋ก ", "๋ฐ•์„ธ์›…", Part.SPRING, ProjectInfo.TODAYSGYM.getName()),

// 4๊ธฐ
ARI("์•„๋ฆฌ", "ํ—ˆ์˜์€", Part.PM, ProjectInfo.OWORI.getName()),
LIBER_1("๋ฆฌ๋ฒ„", "์ด๊ฒฝ์ˆ˜", Part.IOS, ProjectInfo.OWORI.getName()),
BEX_2("๋ฒก์Šค", "๊น€์ค€์„", Part.SPRING, ProjectInfo.OWORI.getName()),

HANA_1("ํ•˜๋‚˜", "์‹ฌ์„ธ์›", Part.ANDROID, ProjectInfo.MYOJIPSA.getName()),

YENI_1("์˜ˆ๋‹ˆ", "๋‚˜์˜ˆ์€", Part.IOS, ProjectInfo.ARF.getName()),
MANGO("๋ง๊ณ ", "์ด์žฌ์›", Part.SPRING, ProjectInfo.ARF.getName()),
BORA_1("๋ณด๋ผ", "์œ ์ง€์ˆ˜", Part.PM, ProjectInfo.EM_SAM.getName()),
HERON_1("ํ—ค๋ก ", "๋ฐ•์„ธ์›…", Part.SPRING, ProjectInfo.EM_SAM.getName()),
JINRO_1("์ง„๋กœ", "๋ฐ•์ง€์šด", Part.SPRING, ProjectInfo.EM_SAM.getName()),
LIU_1("๋ฆฌ์šฐ", "์†ก๋ฏผํ˜", Part.SPRING, ProjectInfo.EM_SAM.getName()),


// 5๊ธฐ
LIBER("๋ฆฌ๋ฒ„", "์ด๊ฒฝ์ˆ˜", Part.PM, ProjectInfo.UMC_NETWORKING_SERVICE.getName()),
DELO("๋ธ๋กœ", "์˜ค์ •ํ˜„", Part.DESIGN, ProjectInfo.UMC_NETWORKING_SERVICE.getName()),
DEUGI("๋”๊ธฐ", "์–‘์œ ์ง„", Part.DESIGN, ProjectInfo.UMC_NETWORKING_SERVICE.getName()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
@Getter
@RequiredArgsConstructor
public enum PointType {
PUDDING("์€ํ•˜์ˆ˜๋ฅผ ์‚ด์ง ์–น์€ ์ปค์Šคํ„ฐ๋“œ ํ‘ธ๋”ฉ", 5L, null),
DOUGHNUT("์€ํ•˜์Šคํ”„๋งํด ๋„๋„›", 10L, null);
PUDDING("์€ํ•˜์ˆ˜๋ฅผ ์‚ด์ง ์–น์€ ์ปค์Šคํ„ฐ๋“œ ํ‘ธ๋”ฉ", 1L, null),
DOUGHNUT("์€ํ•˜์Šคํ”„๋งํด ๋„๋„›", 5L, null),
ICE_CREAM("ํƒœ์–‘์ด ๋ฌผ๋“  ์„ ์ƒค์ธ ์ƒค๋ฒ ํŠธ ์•„์ด์Šคํฌ๋ฆผ", 10L, null),
ROLL_CAKE("์ฐฌ๋ž€ํ•œ ๋ณ„๋“ค์ด ์‘ฅ์‘ฅ ๋ฐ•ํžŒ ์šฐ์ฃผ๋ง› ๋กค์ผ€์ดํฌ", 30L, null),
;

private final String description;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ public MemberSearchInfosResponse searchMemberInfo(Member loginMember, String key
public MemberAttendResponse attendMember(Member loingMember) {

Member member = loadEntity(loingMember.getId());
LocalDate lastActiveDate = member.getLastActiveTime().toLocalDate();
LocalDateTime lastActiveTime = member.getLastActiveTime();

if (!lastActiveDate.equals(LocalDate.now())) {
if (lastActiveTime == null || !lastActiveTime.toLocalDate().equals(LocalDate.now())) {
member.addRemainPoint(1L);
return new MemberAttendResponse(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
@NoArgsConstructor
public class ProjectAllResponse {
private List<ProjectInfo> projects;
private boolean hasNext;
private int page;
private int totalPages;
private int totalElements;
private Boolean isFirst;
private Boolean isLast;


@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class Project extends BaseEntity {
private List<ProjectType> types = new ArrayList<>();

@ColumnDefault("0")
private Long hitCount;
private int hitCount;

@ColumnDefault("0")
private int heartCount; //์ข‹์•„์š” ์ˆ˜
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import com.umc.networkingService.domain.project.dto.response.ProjectDetailResponse;
import com.umc.networkingService.domain.project.entity.Project;
import com.umc.networkingService.domain.project.entity.ProjectMember;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Component;

import java.awt.print.Pageable;
import java.util.List;


Expand All @@ -32,6 +34,17 @@ public ProjectMember toProjectMember(ProjectCreateRequest.ProjectMemberInfo memb
.build();
}

public ProjectAllResponse toProjectAllResponse(Page<Project> pageInfo, List<ProjectAllResponse.ProjectInfo> projects) {
return ProjectAllResponse.builder()
.projects(projects)
.page(pageInfo.getNumber())
.totalPages(pageInfo.getTotalPages())
.totalElements((int) pageInfo.getTotalElements())
.isFirst(pageInfo.isFirst())
.isLast(pageInfo.isLast())
.build();
}

public ProjectAllResponse.ProjectInfo toProjectInfo(Project project, boolean isLike) {
return ProjectAllResponse.ProjectInfo.builder()
.projectId(project.getId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ public interface ProjectRepository extends JpaRepository<Project, UUID> {
Page<Project> findAllBySemesterAndTypesContains(Semester semester, ProjectType type, Pageable pageable);
@Query("SELECT DISTINCT p FROM Project p JOIN p.tags t WHERE p.name LIKE %:keyword% OR t LIKE %:keyword%")
Page<Project> findByNameContainsOrTagContains(@Param("keyword") String keyword, Pageable pageable);
@Query("SELECT p FROM Project p ORDER BY (p.hitCount * 1 + p.heartCount * 3) DESC")
Page<Project> findHotProjects(Pageable pageable);
boolean existsByName(String name);
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,46 +110,35 @@ public ProjectAllResponse inquiryProjects(Member member, Semester semester, Proj
.orElseGet(() -> projectRepository.findAllBySemester(semester, pageable));
}

return new ProjectAllResponse(
return projectMapper.toProjectAllResponse(
projects,
projects.stream().map(
project -> projectMapper.toProjectInfo(project, isLikeProject(member, project.getId()))
).toList(),
projects.hasNext()
);
).toList());
}

@Override
public ProjectAllResponse inquiryHotProjects(Member member, Pageable pageable) {
// ์กฐํšŒ์ˆ˜ 1์ , ํ•˜ํŠธ์ˆ˜ 3์ ์œผ๋กœ ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐํ•ด ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ
List<Project> projects = projectRepository.findAll();
List<Project> hotProjects = projects.stream()
.sorted(Comparator.comparingLong(this::calculateScore).reversed()) //์ ์ˆ˜ ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ
.skip(pageable.getOffset()) // page * size ๋งŒํผ skip
.limit(pageable.getPageSize()) // size ๋งŒํผ limit
.toList();

Page<Project> hotProjects = projectRepository.findHotProjects(pageable);

return ProjectAllResponse.builder()
.projects(hotProjects.stream().map(
return projectMapper.toProjectAllResponse(
hotProjects,
hotProjects.stream().map(
project -> projectMapper.toProjectInfo(project, isLikeProject(member, project.getId()))
).toList())
.build();
).toList());
}

private Long calculateScore(Project project) { // ์กฐํšŒ์ˆ˜ 1์ , ํ•˜ํŠธ์ˆ˜ 3์ ์œผ๋กœ ์ ์ˆ˜๋ฅผ ๊ณ„์‚ฐ
return project.getHitCount() + (project.getHeartCount() * 3L);
}

@Override
public ProjectAllResponse searchProject(Member member ,String keyword, Pageable pageable){
Page<Project> projects = projectRepository.findByNameContainsOrTagContains(keyword, pageable);

return new ProjectAllResponse(
return projectMapper.toProjectAllResponse(
projects,
projects.stream().map(
project -> projectMapper.toProjectInfo(project, isLikeProject(member, project.getId()))
).toList(),
projects.hasNext()
);
).toList());
}

@Override
Expand Down

0 comments on commit 15ca2d8

Please sign in to comment.