Skip to content

Commit

Permalink
#77 DAILYLIFE2-25 팔로우 추가 및 파일 이미지 저장 경로 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
shihhhdm310 committed Aug 1, 2022
1 parent 2f4f22f commit 661ccec
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,4 @@ public class BoardCreateRequest {

private MultipartFile[] imageName;



}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
import com.dailylife.domain.follow.dto.FollowingRequest;
import com.dailylife.domain.follow.entity.Follow;
import com.dailylife.domain.follow.service.FollowingService;
import com.dailylife.global.dto.ApplicationResponse;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
Expand Down Expand Up @@ -44,9 +46,9 @@ public ResponseEntity<List<Follow>> getFollower() {

@ApiOperation(value = "팔로우를 확인합니다", notes = "팔로우를 확인합니다.")
@PostMapping("/getFollow")
public String getFollow() {
followingService.getFollow();
return null;
public ApplicationResponse<List<Follow>> getFollow() {
List<Follow> follow = followingService.getFollow();
return ApplicationResponse.create("팔로워를 불러왔습니다" , HttpStatus.CREATED , follow);
}

}
14 changes: 5 additions & 9 deletions src/main/java/com/dailylife/global/fileUpload/ImageRemove.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dailylife.global.fileUpload;

import com.dailylife.global.fileUpload.exception.NotFoundFileException;
import org.springframework.stereotype.Component;

import java.io.File;
Expand All @@ -9,20 +10,15 @@ public class ImageRemove {
public void deleteFile(String fileName) {

// 파일의 경로 + 파일명
String filePath = "C:\\dailylife_server3\\src\\main\\resources\\images\\"+fileName; // 우선 절대경로 설정

// String filePath = "C:\\dailylife_server3\\src\\main\\resources\\images\\"+fileName; // 우선 절대경로 설정
String filePath = "/home/ubuntu/images/"+fileName; //
File deleteFile = new File(filePath);

// 파일이 존재하는지 체크 존재할경우 true, 존재하지않을경우 false
if(deleteFile.exists()) {

// 파일을 삭제합니다.
deleteFile.delete();

System.out.println("파일을 삭제하였습니다.");

throw new NotFoundFileException();
} else {
System.out.println("파일이 존재하지 않습니다.");
throw new NotFoundFileException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@Log4j2
public class MultiUpload {
public List<String> FileUpload(MultipartFile[] file) throws IOException {
String uploadPath = "/images"; // 우선 절대경로 설정
String uploadPath = "/home/ubuntu/images"; // 우선 절대경로 설정
// String uploadPath = "C:\\Users\\sdm03\\OneDrive\\바탕 화면\\dailylife (1)\\dailylife_server3\\src\\main\\resources\\images";

ArrayList<String> fileName = new ArrayList<>(); // 파일 이름들을 저장할 리스트 생성
Expand All @@ -40,7 +40,6 @@ public List<String> FileUpload(MultipartFile[] file) throws IOException {
file[i].transferTo(target);
fileName.add(saveFileName); // 리스트에 파일이름 갯수만큼 저장


}
return fileName; // 리스트 리턴
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.dailylife.global.fileUpload.exception;

import com.dailylife.global.exception.ApplicationException;

public class NotExistFileException extends ApplicationException {
public NotExistFileException() {
super(302, "파일이 존재하지 않습니다.");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.dailylife.global.fileUpload.exception;

import com.dailylife.global.exception.ApplicationException;

public class NotFoundFileException extends ApplicationException {

public NotFoundFileException() {
super(301, "파일을 찾을수 없습니다.");
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/dailylife/global/init/InitDB.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void initDB() throws IOException {
if(ddlAutoConfig.equals("create")){

UserJoinRequest userReq1 = UserJoinRequest.builder()
.userId("d1")
.userId("dl1")
.userPassword("dl")
.userName("dailyLife")
.userEmail("[email protected]").userJoinDate(LocalDateTime.now()).build();
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://146.56.39.196:3306/dailylife?useUnicode=yes&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Seoul
username: dailylife
password: 1234
url: jdbc:mysql://localhost:3306/jpashop?useUnicode=yes&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Seoul
username: sa
password: km971gb5!!

mvc:
pathmatch:
Expand Down

0 comments on commit 661ccec

Please sign in to comment.