-
Notifications
You must be signed in to change notification settings - Fork 1
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
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
spring/src/main/java/com/bancow/bancowback/domain/sub/howto/Mapper/HowtoMapper.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,17 @@ | ||
package com.bancow.bancowback.domain.sub.howto.Mapper; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import com.bancow.bancowback.domain.sub.howto.entity.Howto; | ||
|
||
@Component | ||
public class HowtoMapper { | ||
|
||
public Howto toHowto(Howto howto) { | ||
return Howto.builder() | ||
.id(howto.getId()) | ||
.movieName(howto.getMovieName()) | ||
.movieUrl("https://kr.object.ncloudstorage.com/bancowback/" + howto.getMovieUrl()) | ||
.build(); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
spring/src/main/java/com/bancow/bancowback/domain/sub/howto/controller/HowtoController.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,24 @@ | ||
package com.bancow.bancowback.domain.sub.howto.controller; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.bancow.bancowback.domain.common.dto.Response; | ||
import com.bancow.bancowback.domain.sub.howto.service.HowtoService; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RestController | ||
@RequiredArgsConstructor | ||
@RequestMapping("/api/howto") | ||
public class HowtoController { | ||
|
||
private final HowtoService howtoService; | ||
|
||
@GetMapping() | ||
public Response<?> getHowto(){ | ||
return new Response<>(howtoService.getHowto(), HttpStatus.OK); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
spring/src/main/java/com/bancow/bancowback/domain/sub/howto/entity/Howto.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.bancow.bancowback.domain.sub.howto.entity; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
@Entity | ||
public class Howto { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(name = "movie_name", nullable = false) | ||
private String movieName; | ||
|
||
@Column(name = "movie_url", nullable = false) | ||
private String movieUrl; | ||
} |
8 changes: 8 additions & 0 deletions
8
spring/src/main/java/com/bancow/bancowback/domain/sub/howto/repository/HowtoRepository.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,8 @@ | ||
package com.bancow.bancowback.domain.sub.howto.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import com.bancow.bancowback.domain.sub.howto.entity.Howto; | ||
|
||
public interface HowtoRepository extends JpaRepository<Howto, Long> { | ||
} |
27 changes: 27 additions & 0 deletions
27
spring/src/main/java/com/bancow/bancowback/domain/sub/howto/service/HowtoService.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,27 @@ | ||
package com.bancow.bancowback.domain.sub.howto.service; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import com.bancow.bancowback.domain.sub.howto.Mapper.HowtoMapper; | ||
import com.bancow.bancowback.domain.sub.howto.entity.Howto; | ||
import com.bancow.bancowback.domain.sub.howto.repository.HowtoRepository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class HowtoService { | ||
|
||
private final HowtoRepository howtoRepository; | ||
private final HowtoMapper howtoMapper; | ||
|
||
public List<Howto> getHowto() { | ||
|
||
return howtoRepository.findAll().stream() | ||
.map(howto -> howtoMapper.toHowto(howto)) | ||
.collect(Collectors.toList()); | ||
} | ||
} |