-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
201 additions
and
168 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
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
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
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
6 changes: 0 additions & 6 deletions
6
src/main/java/net/skhu/likelion12thteam03be/location/api/dto/request/LocationSaveReqDto.java
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...ain/java/net/skhu/likelion12thteam03be/location/api/dto/request/LocationUpdateReqDto.java
This file was deleted.
Oops, something went wrong.
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
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
23 changes: 23 additions & 0 deletions
23
src/main/java/net/skhu/likelion12thteam03be/mood/api/dto/MoodController.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,23 @@ | ||
package net.skhu.likelion12thteam03be.mood.api.dto; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import net.skhu.likelion12thteam03be.mood.api.dto.response.MoodListResDto; | ||
import net.skhu.likelion12thteam03be.mood.application.MoodService; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/moods") | ||
public class MoodController { | ||
private final MoodService moodService; | ||
|
||
@GetMapping | ||
public ResponseEntity<MoodListResDto> moodFindAll() { | ||
MoodListResDto moodListResDto = moodService.moodFindAll(); | ||
return new ResponseEntity<>(moodListResDto, HttpStatus.OK); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/net/skhu/likelion12thteam03be/mood/api/dto/response/MoodInfoResDto.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 net.skhu.likelion12thteam03be.mood.api.dto.response; | ||
|
||
import lombok.Builder; | ||
import net.skhu.likelion12thteam03be.mood.domain.Mood; | ||
|
||
@Builder | ||
public record MoodInfoResDto( | ||
Long moodId, | ||
String name | ||
) { | ||
public static MoodInfoResDto from(Mood mood) { | ||
return MoodInfoResDto.builder() | ||
.name(mood.getName()) | ||
.build(); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/net/skhu/likelion12thteam03be/mood/api/dto/response/MoodListResDto.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 net.skhu.likelion12thteam03be.mood.api.dto.response; | ||
|
||
import lombok.Builder; | ||
|
||
import java.util.List; | ||
|
||
@Builder | ||
public record MoodListResDto( | ||
List<MoodInfoResDto> moodList | ||
) { | ||
public static MoodListResDto from(List<MoodInfoResDto> moodList) { | ||
return MoodListResDto.builder() | ||
.moodList(moodList) | ||
.build(); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/net/skhu/likelion12thteam03be/mood/application/MoodService.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,29 @@ | ||
package net.skhu.likelion12thteam03be.mood.application; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import net.skhu.likelion12thteam03be.mood.api.dto.response.MoodInfoResDto; | ||
import net.skhu.likelion12thteam03be.mood.api.dto.response.MoodListResDto; | ||
import net.skhu.likelion12thteam03be.mood.domain.Mood; | ||
import net.skhu.likelion12thteam03be.mood.domain.repository.MoodRepository; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@Transactional | ||
@RequiredArgsConstructor | ||
public class MoodService { | ||
private final MoodRepository moodRepository; | ||
|
||
@Transactional | ||
public MoodListResDto moodFindAll() { | ||
List<Mood> moods = moodRepository.findAll(); | ||
|
||
List<MoodInfoResDto> moodInfoResDtoList = moods.stream() | ||
.map(MoodInfoResDto::from) | ||
.toList(); | ||
|
||
return MoodListResDto.from(moodInfoResDtoList); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/net/skhu/likelion12thteam03be/mood/domain/Mood.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,34 @@ | ||
package net.skhu.likelion12thteam03be.mood.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import jakarta.persistence.*; | ||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import net.skhu.likelion12thteam03be.post.domain.Post; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Mood { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "moodId") | ||
private Long moodId; | ||
|
||
private String name; | ||
|
||
@JsonIgnore | ||
@OneToMany(mappedBy = "mood", cascade = CascadeType.ALL, orphanRemoval = true) | ||
private List<Post> postList = new ArrayList<>(); | ||
|
||
@Builder | ||
public Mood(String name) { | ||
this.name = name; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/net/skhu/likelion12thteam03be/mood/domain/repository/MoodRepository.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,7 @@ | ||
package net.skhu.likelion12thteam03be.mood.domain.repository; | ||
|
||
import net.skhu.likelion12thteam03be.mood.domain.Mood; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface MoodRepository extends JpaRepository<Mood, Long> { | ||
} |
Oops, something went wrong.