-
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 #20 from potenday-23/feature/login_exception
Feature/login exception
- Loading branch information
Showing
40 changed files
with
563 additions
and
515 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
107 changes: 0 additions & 107 deletions
107
src/main/java/project/backend/domain/jwt/controller/JwtController.java
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
src/main/java/project/backend/domain/jwt/dto/JwtRequestDto.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
32 changes: 32 additions & 0 deletions
32
src/main/java/project/backend/domain/media/controller/MediaController.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.media.controller; | ||
|
||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import project.backend.domain.media.entity.Media; | ||
import project.backend.domain.media.mapper.MediaMapper; | ||
import project.backend.domain.media.service.MediaService; | ||
|
||
@Api(tags = "C. 미디어") | ||
@RestController | ||
@RequestMapping("/api/media") | ||
@RequiredArgsConstructor | ||
public class MediaController { | ||
|
||
private final MediaService mediaService; | ||
private final MediaMapper mediaMapper; | ||
|
||
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) | ||
@ApiOperation(value = "미디어 생성") | ||
public ResponseEntity createMedia( | ||
@RequestPart(value = "file", required = true) MultipartFile file | ||
) { | ||
Media media = mediaService.createMedia(file); | ||
return ResponseEntity.status(HttpStatus.CREATED).body(mediaMapper.mediaToMediaDto(media)); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/project/backend/domain/media/controller/MediasController.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,44 @@ | ||
package project.backend.domain.media.controller; | ||
|
||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestPart; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import project.backend.domain.media.dto.MediaDto; | ||
import project.backend.domain.media.entity.Media; | ||
import project.backend.domain.media.mapper.MediaMapper; | ||
import project.backend.domain.media.service.MediaService; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Api(tags = "C. 미디어") | ||
@RestController | ||
@RequestMapping("/api/medias") | ||
@RequiredArgsConstructor | ||
public class MediasController { | ||
|
||
private final MediaService mediaService; | ||
private final MediaMapper mediaMapper; | ||
|
||
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) | ||
@ApiOperation(value = "미디어 다중 생성") | ||
public ResponseEntity createMedias( | ||
@RequestPart(value = "files", required = true) List<MultipartFile> files | ||
) { | ||
List<Media> medias = files.stream() | ||
.map(mediaService::createMedia) | ||
.collect(Collectors.toList()); | ||
List<MediaDto> mediaDtos = medias.stream() | ||
.map(mediaMapper::mediaToMediaDto) | ||
.collect(Collectors.toList()); | ||
return ResponseEntity.status(HttpStatus.CREATED).body(mediaDtos); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/project/backend/domain/media/dto/MediaDto.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,12 @@ | ||
package project.backend.domain.media.dto; | ||
|
||
import lombok.*; | ||
|
||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class MediaDto { | ||
private String media_url; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/project/backend/domain/media/entity/Media.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,28 @@ | ||
package project.backend.domain.media.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 Media extends BaseEntity { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
public Long id; | ||
|
||
public String media_url; | ||
|
||
@Builder | ||
public Media(String media_url){ | ||
this.media_url = media_url; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/project/backend/domain/media/mapper/MediaMapper.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,11 @@ | ||
package project.backend.domain.media.mapper; | ||
|
||
import org.mapstruct.Mapper; | ||
import org.mapstruct.ReportingPolicy; | ||
import project.backend.domain.media.dto.MediaDto; | ||
import project.backend.domain.media.entity.Media; | ||
|
||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) | ||
public interface MediaMapper { | ||
MediaDto mediaToMediaDto(Media media); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/project/backend/domain/media/repository/MediaRepository.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.media.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import project.backend.domain.media.entity.Media; | ||
|
||
public interface MediaRepository extends JpaRepository<Media, Long> { | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/project/backend/domain/media/service/MediaService.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 project.backend.domain.media.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import project.backend.domain.media.entity.Media; | ||
import project.backend.domain.media.mapper.MediaMapper; | ||
import project.backend.domain.media.repository.MediaRepository; | ||
import project.backend.global.error.exception.BusinessException; | ||
import project.backend.global.error.exception.ErrorCode; | ||
import project.backend.global.s3.service.ImageService; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class MediaService { | ||
private final MediaRepository mediaRepository; | ||
private final MediaMapper mediaMapper; | ||
private final ImageService imageService; | ||
|
||
public Media createMedia(MultipartFile file) { | ||
String media_url = imageService.updateImage(file, "Media", "media_url"); | ||
Media media = Media.builder().media_url(media_url).build(); | ||
mediaRepository.save(media); | ||
return media; | ||
} | ||
} |
Oops, something went wrong.