Skip to content

Commit

Permalink
Merge pull request #20 from potenday-23/feature/login_exception
Browse files Browse the repository at this point in the history
Feature/login exception
  • Loading branch information
rrosiee authored Jul 14, 2024
2 parents 9ff1d63 + cbb87bc commit 8bd9a94
Show file tree
Hide file tree
Showing 40 changed files with 563 additions and 515 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ src/main/generated
.env

### static ###
src/main/java/project/backend/domain/notice
src/main/resources/static
src/main/resources/templates
src/main/resources/firebase-service-key.json
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ tasks.named('test') {
}

// Querydsl 설정부
def generated = 'src/main/generated'
def generated = 'build/generated'

// querydsl QClass 파일 생성 위치를 지정
tasks.withType(JavaCompile) {
Expand Down
107 changes: 0 additions & 107 deletions src/main/java/project/backend/domain/jwt/controller/JwtController.java

This file was deleted.

29 changes: 0 additions & 29 deletions src/main/java/project/backend/domain/jwt/dto/JwtRequestDto.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
@Builder
public class KakaoUserInfo {
private String kakaoId;
private String profileUrl;
private String profileImageUrl;
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public KakaoUserInfo getKakaoUserInfo(String token) {

//dto에 저장하기
kakaoUserInfo.setKakaoId(element.getAsJsonObject().get("id").getAsString());
kakaoUserInfo.setProfileUrl(element.getAsJsonObject().get("properties").getAsJsonObject().get("profile_image").getAsString());
kakaoUserInfo.setProfileImageUrl(element.getAsJsonObject().get("properties").getAsJsonObject().get("profile_image").getAsString());

} catch (IOException e) {
e.printStackTrace();
Expand Down
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));
}
}
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 src/main/java/project/backend/domain/media/dto/MediaDto.java
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 src/main/java/project/backend/domain/media/entity/Media.java
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 src/main/java/project/backend/domain/media/mapper/MediaMapper.java
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);
}
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> {
}
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;
}
}
Loading

0 comments on commit 8bd9a94

Please sign in to comment.