-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from Tave100Shot/46-feat-추천-문제-정보-추가하여-반환
46 feat 추천 문제 정보 추가하여 반환
- Loading branch information
Showing
10 changed files
with
221 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/com/api/TaveShot/domain/recommend/converter/StringListConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.api.TaveShot.domain.recommend.converter; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import jakarta.persistence.AttributeConverter; | ||
import jakarta.persistence.Converter; | ||
|
||
import java.util.List; | ||
|
||
@Converter | ||
public class StringListConverter implements AttributeConverter<List<String>, String> { | ||
|
||
private final ObjectMapper mapper = new ObjectMapper(); | ||
|
||
@Override | ||
public String convertToDatabaseColumn(List<String> dataList){ | ||
try{ | ||
return mapper.writeValueAsString(dataList); | ||
} catch(JsonProcessingException e){ | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
@Override | ||
public List<String> convertToEntityAttribute(String data) { | ||
try{ | ||
return mapper.readValue(data, List.class); | ||
} catch (JsonProcessingException e){ | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/com/api/TaveShot/domain/recommend/domain/ProblemElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.api.TaveShot.domain.recommend.domain; | ||
|
||
import com.api.TaveShot.domain.recommend.converter.StringListConverter; | ||
import jakarta.persistence.*; | ||
import lombok.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Table(name = "Problem") | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
@Getter | ||
@AllArgsConstructor | ||
@Builder | ||
public class ProblemElement { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
private Integer problemId; | ||
|
||
private String title; | ||
private Integer acceptedUserCount; | ||
private Integer bojLevel; | ||
|
||
private String bojKey; | ||
private String bojTagId; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/api/TaveShot/domain/recommend/dto/RecProDetailResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.api.TaveShot.domain.recommend.dto; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@ToString | ||
@Builder | ||
public class RecProDetailResponseDto { | ||
|
||
private String title; | ||
private String problemId; | ||
private String tier; | ||
private List<String> bojTag; | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/com/api/TaveShot/domain/recommend/dto/RecProRequestDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.api.TaveShot.domain.recommend.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
public class RecProRequestDto { | ||
|
||
private int solvedRecentId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/com/api/TaveShot/domain/recommend/repository/ProblemElementRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.api.TaveShot.domain.recommend.repository; | ||
|
||
import com.api.TaveShot.domain.recommend.domain.ProblemElement; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Query; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Optional; | ||
|
||
@Repository | ||
public interface ProblemElementRepository extends JpaRepository<ProblemElement, Long> { | ||
|
||
@Query("select p from ProblemElement as p where p.problemId=:problemId") | ||
ProblemElement findByProblemId(Integer problemId); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.