-
Notifications
You must be signed in to change notification settings - Fork 2
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 #25 from potenday-23/feature/ticket_folder
Feature -> Develop: 스티커 api 추가
- Loading branch information
Showing
7 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/project/backend/domain/sticker/controller/StickerController.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 project.backend.domain.sticker.controller; | ||
|
||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import project.backend.domain.sticker.dto.StickerRetrieveDto; | ||
import project.backend.domain.sticker.entity.Sticker; | ||
import project.backend.domain.sticker.mapper.StickerMapper; | ||
import project.backend.domain.sticker.service.StickerService; | ||
|
||
import java.util.List; | ||
|
||
@Api(tags = "스티커 API") | ||
@RestController | ||
@RequestMapping("/api/stickers") | ||
@RequiredArgsConstructor | ||
public class StickerController { | ||
|
||
private final StickerService stickerService; | ||
private final StickerMapper stickerMapper; | ||
|
||
@ApiOperation(value = "스티커 리스트 조회") | ||
@GetMapping | ||
public ResponseEntity getSticker() { | ||
List<Sticker> stickers = stickerService.getStickerList(); | ||
List<StickerRetrieveDto> stickerRetrieveDtos = stickerMapper.stickersToStickerRetrieveDto(stickers); | ||
return ResponseEntity.status(HttpStatus.OK).body(stickerRetrieveDtos); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/project/backend/domain/sticker/dto/StickerRetrieveDto.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 project.backend.domain.sticker.dto; | ||
|
||
import lombok.*; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class StickerRetrieveDto { | ||
public String title; | ||
public String content; | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/project/backend/domain/sticker/entity/Sticker.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 project.backend.domain.sticker.entity; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
import project.backend.domain.common.entity.BaseEntity; | ||
|
||
import javax.persistence.Entity; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
|
||
@Entity | ||
@Getter | ||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Sticker extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
public Long id; | ||
public String imageUrl; | ||
|
||
@Builder | ||
public Sticker(String imageUrl) { | ||
this.imageUrl = imageUrl; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/project/backend/domain/sticker/mapper/StickerMapper.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,14 @@ | ||
package project.backend.domain.sticker.mapper; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.ReportingPolicy; | ||
import project.backend.domain.sticker.dto.StickerRetrieveDto; | ||
import project.backend.domain.sticker.entity.Sticker; | ||
|
||
import java.util.List; | ||
|
||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
public interface StickerMapper { | ||
|
||
List<StickerRetrieveDto> stickersToStickerRetrieveDto(List<Sticker> sticker); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/project/backend/domain/sticker/repository/StickerRepository.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 project.backend.domain.sticker.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import project.backend.domain.sticker.entity.Sticker; | ||
|
||
public interface StickerRepository extends JpaRepository<Sticker, Long> { | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/project/backend/domain/sticker/service/StickerService.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,20 @@ | ||
package project.backend.domain.sticker.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import project.backend.domain.sticker.entity.Sticker; | ||
import project.backend.domain.sticker.repository.StickerRepository; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class StickerService { | ||
private final StickerRepository stickerRepository; | ||
|
||
public List<Sticker> getStickerList() { | ||
return stickerRepository.findAll(); | ||
} | ||
} |
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