Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
585faa4
login : make jwt using Security
mariasoo May 7, 2024
23eefcc
oauth : google OAuth2
mariasoo May 9, 2024
df2d7b8
OAuth2 : google, kakao
mariasoo May 13, 2024
a98dcb6
fix application naver
sanscout1 May 22, 2024
5db5801
Merge pull request #78 from SSGProjectStarRoad/hotfix/builderror
SSGProjectStarRoad May 22, 2024
c2cfa6f
ReviewLike : reviewlike cancle and add Task /API binding
choijh9023 May 23, 2024
57b0d3b
Merge pull request #80 from SSGProjectStarRoad/feature/store
sanscout1 May 23, 2024
fd51bc1
reward-process: fix coupon-history
sanscout1 May 23, 2024
d8be8a3
Merge pull request #81 from SSGProjectStarRoad/feature/issueCoupon
SSGProjectStarRoad May 23, 2024
48f7209
reward-process: fix reward every monday
sanscout1 May 23, 2024
571ed97
Merge branch 'develop' of https://github.com/SSGProjectStarRoad/StarR…
sanscout1 May 23, 2024
c06570b
reward-process: fix reward every monday
sanscout1 May 23, 2024
7adc929
Merge pull request #82 from SSGProjectStarRoad/feature/issueCoupon
SSGProjectStarRoad May 23, 2024
715cc52
#84 Like method : finish Like method
choijh9023 May 24, 2024
83d7cb6
login : make security
mariasoo May 24, 2024
1d3713d
Merge branch 'develop' into featrue/login
sanscout1 May 24, 2024
e336b21
Merge pull request #86 from SSGProjectStarRoad/featrue/login
sanscout1 May 24, 2024
450e079
login : fix security
mariasoo May 24, 2024
98b6f3d
Merge pull request #87 from SSGProjectStarRoad/featrue/loginfix
sanscout1 May 24, 2024
d5fcfa1
Merge branch 'develop' into feature/store
sanscout1 May 24, 2024
548b3a8
Merge pull request #85 from SSGProjectStarRoad/feature/store
sanscout1 May 24, 2024
cce9689
fix: cors
sanscout1 May 24, 2024
5cf38d5
Merge pull request #88 from SSGProjectStarRoad/hotfix/security
SSGProjectStarRoad May 24, 2024
5385a63
fix: websecurity
sanscout1 May 24, 2024
9b5b047
Merge pull request #89 from SSGProjectStarRoad/hotfix/security
SSGProjectStarRoad May 24, 2024
6b798ce
fix: webconfig
sanscout1 May 24, 2024
e5d746d
Merge pull request #90 from SSGProjectStarRoad/hotfix/security
SSGProjectStarRoad May 24, 2024
69a2842
fix: fix userRegister
sanscout1 May 24, 2024
140ad76
Merge pull request #91 from SSGProjectStarRoad/hotfix/security
SSGProjectStarRoad May 24, 2024
6b4195c
fix: fix corsconfig
sanscout1 May 24, 2024
2f3029d
Merge pull request #92 from SSGProjectStarRoad/hotfix/security
SSGProjectStarRoad May 24, 2024
aec5db0
stash
choijh9023 May 25, 2024
7cb049c
Resolved merge conflicts
choijh9023 May 25, 2024
c14823d
fix: oauth db method
sanscout1 May 25, 2024
129946b
Merge pull request #93 from SSGProjectStarRoad/hotfix/security
SSGProjectStarRoad May 25, 2024
4ac7ef6
fix: oauth db method
sanscout1 May 25, 2024
b8fefa8
Merge pull request #94 from SSGProjectStarRoad/hotfix/security
SSGProjectStarRoad May 25, 2024
2b34d31
fix: oauth nickname
sanscout1 May 25, 2024
1f2ee7a
Merge pull request #95 from SSGProjectStarRoad/hotfix/security
SSGProjectStarRoad May 25, 2024
e13714b
#96 StoreReviewFilter : Filter about commonFeedback
choijh9023 May 25, 2024
b736171
#24 리뷰 사진 업로드 기능 수정
ekmbjh May 26, 2024
a2e6170
Merge branch 'refs/heads/develop' into feature/review
ekmbjh May 26, 2024
b27d580
Merge pull request #97 from SSGProjectStarRoad/feature/store
sanscout1 May 27, 2024
78d97a2
Merge branch 'refs/heads/develop' into feature/review
ekmbjh May 27, 2024
296d7a5
merge
mariasoo May 27, 2024
628ce81
fix: fix api id to email
sanscout1 May 27, 2024
a12640c
Merge pull request #98 from SSGProjectStarRoad/hotfix/url
SSGProjectStarRoad May 27, 2024
7d0ddde
fix: fix api id to email
sanscout1 May 27, 2024
7598527
Merge pull request #99 from SSGProjectStarRoad/hotfix/url
SSGProjectStarRoad May 27, 2024
8ba5a1f
fix: fix api id to email
sanscout1 May 27, 2024
4161ac2
Merge pull request #100 from SSGProjectStarRoad/hotfix/url
SSGProjectStarRoad May 27, 2024
522cd51
fix: delete cors other files
sanscout1 May 27, 2024
f161075
Merge pull request #101 from SSGProjectStarRoad/hotfix/url
SSGProjectStarRoad May 27, 2024
e0d7fac
fix: change port
sanscout1 May 27, 2024
ced9132
Merge pull request #102 from SSGProjectStarRoad/hotfix/url
SSGProjectStarRoad May 27, 2024
4254cf1
fix: change port
sanscout1 May 27, 2024
ce894b2
Merge pull request #103 from SSGProjectStarRoad/hotfix/url
SSGProjectStarRoad May 27, 2024
f7757a3
fix: add url at config
sanscout1 May 27, 2024
f0e6875
Merge pull request #104 from SSGProjectStarRoad/hotfix/url
SSGProjectStarRoad May 27, 2024
a334622
Merge branch 'refs/heads/develop' into feature/review
ekmbjh May 27, 2024
7adc9b5
fix: fix issue dto
sanscout1 May 27, 2024
7f8a0db
Merge pull request #105 from SSGProjectStarRoad/hotfix/url
SSGProjectStarRoad May 27, 2024
9f16188
add
mariasoo May 28, 2024
7805f51
Merge branch 'develop' of https://github.com/SSGProjectStarRoad/StarR…
mariasoo May 28, 2024
d1c024a
event : add event
sanscout1 May 28, 2024
8537b87
Merge pull request #108 from SSGProjectStarRoad/feature/event
SSGProjectStarRoad May 28, 2024
4c6cfca
hotfix : reward image
sanscout1 May 28, 2024
956802a
Merge pull request #109 from SSGProjectStarRoad/hotfix/reward
SSGProjectStarRoad May 28, 2024
60a5ae0
feature:loginupdate
mariasoo May 29, 2024
902d66f
Merge pull request #110 from SSGProjectStarRoad/feature/loginupdate
sanscout1 May 29, 2024
01463dc
temp : 리뷰 기능 수정중
ekmbjh May 29, 2024
74d80c5
Merge branch 'refs/heads/develop' into feature/review
ekmbjh May 29, 2024
5253e2e
Hotfix : about StoreReview likedSort
choijh9023 May 29, 2024
7b590e4
Merge pull request #111 from SSGProjectStarRoad/feature/store
SSGProjectStarRoad May 29, 2024
b438702
mypage : add myreview
sanscout1 May 29, 2024
c5af36a
Merge pull request #112 from SSGProjectStarRoad/hotfix/mypage
SSGProjectStarRoad May 29, 2024
4299432
리뷰 팔로우, 좋아요, 포인트/경험치, OCR 키 설정, Summary api, id -> 사용자 email 기능 수정
ekmbjh May 29, 2024
65d7715
Merge branch 'develop' into feature/review
sanscout1 May 29, 2024
1e188dc
Merge pull request #113 from SSGProjectStarRoad/feature/review
sanscout1 May 29, 2024
739c95e
누락파일 추가
ekmbjh May 29, 2024
f7ade15
Merge remote-tracking branch 'origin/feature/review' into feature/review
ekmbjh May 29, 2024
7d7da33
Merge branch 'refs/heads/develop' into feature/review
ekmbjh May 29, 2024
48ec0aa
hotfix : fix review merge part
sanscout1 May 29, 2024
65b926c
Merge pull request #114 from SSGProjectStarRoad/hotfix/review
SSGProjectStarRoad May 29, 2024
8536ebc
follow 페이지 관련 프론트 isfollowed undefined에 따른 오류 조치
ekmbjh May 30, 2024
c9bcd04
Merge branch 'develop' into feature/review
sanscout1 May 30, 2024
d675fe2
Merge pull request #115 from SSGProjectStarRoad/feature/review
sanscout1 May 30, 2024
f8f2066
Keyword Filter : Create about keyword filter in StoreReview
choijh9023 May 30, 2024
b527aa8
Merge branch 'develop' into feature/store
SSGProjectStarRoad May 30, 2024
fdc8e46
Merge pull request #116 from SSGProjectStarRoad/feature/store
SSGProjectStarRoad May 30, 2024
a9c3e24
hotfix : fix review merge part
sanscout1 May 30, 2024
8c03969
Merge pull request #117 from SSGProjectStarRoad/hotfix/fixerror
SSGProjectStarRoad May 30, 2024
01f18fa
리뷰 페이지 팔로우 버튼 관련 오류 조치
ekmbjh May 30, 2024
0ff7f38
Merge pull request #118 from SSGProjectStarRoad/feature/review
sanscout1 May 30, 2024
0a27ff8
hotfix : fix permit about password
sanscout1 May 30, 2024
aa705f3
Merge pull request #119 from SSGProjectStarRoad/hotfix/fixerror
SSGProjectStarRoad May 30, 2024
5e8c528
Follow : in StoreReview
choijh9023 May 30, 2024
5f5c9dc
Merge pull request #120 from SSGProjectStarRoad/feature/newStore
sanscout1 May 31, 2024
8a3abd1
hotfix : fix account withdraw
sanscout1 May 31, 2024
4e516f0
Merge pull request #121 from SSGProjectStarRoad/hotfix/fixerror
SSGProjectStarRoad May 31, 2024
6abfb83
리뷰 매장 정보 추가 로직 및 전체보기 정렬
ekmbjh May 31, 2024
ad16485
Merge pull request #122 from SSGProjectStarRoad/feature/review
sanscout1 May 31, 2024
319ab80
refact : image resizing
JJuuuunn Jun 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@ repositories {

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
// implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
// implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-mail:3.0.5'
implementation 'com.sun.mail:jakarta.mail:2.0.1' // 버전을 2.0.1로 변경
implementation 'org.springframework.boot:spring-boot-starter-validation'


// LOMBOK
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'

// SPRING BOOT DEVTOOLS
developmentOnly 'org.springframework.boot:spring-boot-devtools'
Expand All @@ -46,19 +51,28 @@ dependencies {
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"


// JWT Support
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
// JSON 처리를 위해 jackson 연동 모듈 추가

// AWS S3
implementation 'com.amazonaws:aws-java-sdk-s3'
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

// JSON
implementation 'org.json:json:20231013'

// thumbnailator
implementation 'net.coobird:thumbnailator:0.4.14'


// TEST IMPLEMENTATION ========================
// TEST DATABASE H2
testImplementation 'com.h2database:h2'
testImplementation 'org.springframework.boot:spring-boot-starter-test'


// TEST JUNIT
testImplementation 'org.springframework.boot:spring-boot-starter-test'
// testImplementation 'org.springframework.security:spring-security-test'
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/ssg/starroad/board/DTO/BoardContentDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.ssg.starroad.board.DTO;

import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class BoardContentDTO {
private Long id;
private LocalDateTime createdAt;
private LocalDateTime modifiedAt;
private String imagePath;
private Long boardId;
}
21 changes: 21 additions & 0 deletions src/main/java/com/ssg/starroad/board/DTO/BoardDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.ssg.starroad.board.DTO;

import lombok.*;

import java.time.LocalDateTime;

@Getter
@Setter
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class BoardDTO {
private Long id;
private LocalDateTime createdAt;
private LocalDateTime modifiedAt;
private Long managerId;
private String category;
private String content;
private String title;
private Long userId;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
package com.ssg.starroad.board.controller;

import com.ssg.starroad.board.DTO.BoardDTO;
import com.ssg.starroad.board.service.BoardService;
import com.ssg.starroad.coupon.DTO.CouponDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequiredArgsConstructor
@RestController
@RequestMapping("/board")
public class BoardController {
private final BoardService boardService;


@GetMapping("/list")
public ResponseEntity<List<BoardDTO>> getBoardList() {
List<BoardDTO> boardDTOS = boardService.getEventBoards();
if (boardDTOS.isEmpty()) {
return ResponseEntity.noContent().build(); // 내용이 없을 경우 No Content (204) 반환
}
return ResponseEntity.ok(boardDTOS); // 내용이 있을 경우 OK (200)와 함께 데이터 반환
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
package com.ssg.starroad.board.controller;

import com.ssg.starroad.board.DTO.BoardContentDTO;
import com.ssg.starroad.board.DTO.BoardDTO;
import com.ssg.starroad.board.service.BoardImageService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequiredArgsConstructor
@RestController
@RequestMapping("/board-image")
public class BoardImageController {
private final BoardImageService boardImageService;

@GetMapping("/content/{boardId}")
public ResponseEntity<BoardContentDTO> getBoardContent(@PathVariable Long boardId) {
BoardContentDTO boardContent = boardImageService.getEventContent(boardId);
if (boardContent==null) {
return ResponseEntity.noContent().build(); // 내용이 없을 경우 No Content (204) 반환
}
return ResponseEntity.ok(boardContent); // 내용이 있을 경우 OK (200)와 함께 데이터 반환
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
import org.springframework.data.jpa.repository.JpaRepository;

public interface BoardImageRepository extends JpaRepository<BoardImage, Long> {

public BoardImage findByBoardId(Long boardId);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.ssg.starroad.board.repository;

import com.ssg.starroad.board.entity.Board;
import com.ssg.starroad.board.enums.BoardCategory;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;

public interface BoardRepository extends JpaRepository<Board, Long> {

public List<Board> findByCategory(BoardCategory category);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package com.ssg.starroad.board.service;

import com.ssg.starroad.board.DTO.BoardContentDTO;

public interface BoardImageService {

public BoardContentDTO getEventContent (Long boardid);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
package com.ssg.starroad.board.service;

import com.ssg.starroad.board.DTO.BoardDTO;

import java.util.List;

public interface BoardService {

public List<BoardDTO> getEventBoards();
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package com.ssg.starroad.board.service.impl;

import com.ssg.starroad.board.DTO.BoardContentDTO;
import com.ssg.starroad.board.repository.BoardImageRepository;
import com.ssg.starroad.board.service.BoardImageService;
import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class BoardImageServiceImpl implements BoardImageService {
private final BoardImageRepository boardImageRepository;
private final ModelMapper modelMapper;
@Override
public BoardContentDTO getEventContent(Long boardid) {
return modelMapper.map(boardImageRepository.findByBoardId(boardid), BoardContentDTO.class);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
package com.ssg.starroad.board.service.impl;

import com.ssg.starroad.board.DTO.BoardDTO;
import com.ssg.starroad.board.enums.BoardCategory;
import com.ssg.starroad.board.repository.BoardRepository;
import com.ssg.starroad.board.service.BoardService;
import lombok.RequiredArgsConstructor;
import org.modelmapper.ModelMapper;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class BoardServiceImpl implements BoardService {

private final BoardRepository boardRepository;
private final ModelMapper modelMapper;

@Override
public List<BoardDTO> getEventBoards() {
return boardRepository.findByCategory(BoardCategory.EVENT).stream().map(board ->
modelMapper.map(board,BoardDTO.class)).toList();
}
}
75 changes: 62 additions & 13 deletions src/main/java/com/ssg/starroad/common/service/S3Uploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
import com.amazonaws.services.s3.model.ObjectMetadata;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
Expand Down Expand Up @@ -43,17 +49,30 @@ public String upload(MultipartFile multipartFile, String dirName) {
String encodedFileName = null;
encodedFileName = Base64.getUrlEncoder().encodeToString(fileName.getBytes(StandardCharsets.UTF_8));


// S3에 저장될 파일명 구성
String s3FileName = dirName + "/" + UUID.randomUUID() + "_" + encodedFileName + "." + extension;

ObjectMetadata objectMetadata = new ObjectMetadata();
// 파일을 byte로 변환
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
objectMetadata.setContentLength(multipartFile.getInputStream().available());
// Thumbnailator를 사용하여 이미지 리사이징
Thumbnails.of(multipartFile.getInputStream())
.size(800, 800)
.outputFormat(extension)
.toOutputStream(outputStream);

byte[] resizedImageBytes = outputStream.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(resizedImageBytes);


objectMetadata.setContentLength(resizedImageBytes.length);
objectMetadata.setContentType(multipartFile.getContentType());
// 권한 공개
objectMetadata.setHeader("x-amz-acl", "public-read");

amazonS3.putObject(bucket, s3FileName, multipartFile.getInputStream(), objectMetadata);
amazonS3.putObject(bucket, s3FileName, inputStream, objectMetadata);
} catch (IOException e) {
log.error("S3 upload fail : " + fileName, e);
return String.format("S3 upload fail: %s", multipartFile.getOriginalFilename());
Expand All @@ -72,27 +91,57 @@ public String upload(MultipartFile multipartFile, String dirName) {
public List<String> upload(MultipartFile[] multipartFile, String dirName) {
List<String> urlList = new ArrayList<>();
for (MultipartFile file : multipartFile) {
// 파일명과 확장자 분리
// Separate file name and extension
String originalFileName = file.getOriginalFilename();
int lastIndex = originalFileName.lastIndexOf('.');
String fileName = originalFileName.substring(0, lastIndex);
String extension = originalFileName.substring(lastIndex + 1);

// 파일명 URL 인코딩
String encodedFileName = null;
encodedFileName = Base64.getUrlEncoder().encodeToString(fileName.getBytes(StandardCharsets.UTF_8));
// URL encode the file name
String encodedFileName = Base64.getUrlEncoder().encodeToString(fileName.getBytes(StandardCharsets.UTF_8));

// S3에 저장될 파일명 구성
// Construct the file name to be stored in S3
String s3FileName = dirName + "/" + UUID.randomUUID() + "_" + encodedFileName + "." + extension;

ObjectMetadata objectMetadata = new ObjectMetadata();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
try {
objectMetadata.setContentLength(file.getInputStream().available());
objectMetadata.setContentType(file.getContentType());
// 권한 공개
objectMetadata.setHeader("x-amz-acl", "public-read");

amazonS3.putObject(bucket, s3FileName, file.getInputStream(), objectMetadata);
if (file.getContentType().contains("image")) {
// Resize the image using Thumbnailator
Thumbnails.of(file.getInputStream())
.size(800, 800)
.outputFormat(extension)
.toOutputStream(outputStream);

byte[] resizedImageBytes = outputStream.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(resizedImageBytes);

objectMetadata.setContentLength(resizedImageBytes.length);
objectMetadata.setContentType("image/jpeg");
// Set public-read permission
objectMetadata.setHeader("x-amz-acl", "public-read");

amazonS3.putObject(bucket, s3FileName, inputStream, objectMetadata);
} else {
// Convert non-image file to a basic image (JPEG) and resize
BufferedImage bufferedImage = new BufferedImage(800, 800, BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = bufferedImage.createGraphics();
g2d.setColor(Color.WHITE); // Set background to white
g2d.fillRect(0, 0, 800, 800);
g2d.setColor(Color.BLACK); // Set text color to black
g2d.drawString("Converted to Image", 50, 400);
g2d.dispose();

ImageIO.write(bufferedImage, "jpg", outputStream);
byte[] imageBytes = outputStream.toByteArray();
ByteArrayInputStream inputStream = new ByteArrayInputStream(imageBytes);

objectMetadata.setContentLength(imageBytes.length);
objectMetadata.setContentType("image/jpeg");
objectMetadata.setHeader("x-amz-acl", "public-read");

amazonS3.putObject(bucket, s3FileName, inputStream, objectMetadata);
}
} catch (IOException e) {
log.error("S3 upload fail : " + file.getOriginalFilename(), e);
urlList.add(String.format("S3 upload fail: %s", file.getOriginalFilename()));
Expand Down
Loading