Skip to content

Commit

Permalink
Merge pull request #25 from potenday-23/feature/ticket_folder
Browse files Browse the repository at this point in the history
Feature -> Develop: 스티커 api 추가
  • Loading branch information
rrosiee authored Aug 4, 2024
2 parents f0d61e5 + b122851 commit 0ec0da1
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 1 deletion.
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);
}
}
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 src/main/java/project/backend/domain/sticker/entity/Sticker.java
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;
}
}
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);
}
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> {
}
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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@NoArgsConstructor
@AllArgsConstructor
public class TicketRetrieveDto {
// TODO(sprint4) : Category, place 연결 미구현 상태
// TODO(sprint4) : place 연결 미구현 상태
public Long id;
public String title;
public String mainImageUrl;
Expand Down

0 comments on commit 0ec0da1

Please sign in to comment.