Merge branch 'main' of http://192.168.0.251:3000/localnet/localhost-back.git into main
This commit is contained in:
commit
f2c330577a
@ -42,6 +42,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||||||
@Value("${filePath.boardfile}")
|
@Value("${filePath.boardfile}")
|
||||||
private String boardFilePath;
|
private String boardFilePath;
|
||||||
|
|
||||||
|
@Value("${filePath.profile}")
|
||||||
|
private String uploadPath;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
// 여기서 인터셉터를 추가할 수 있음
|
// 여기서 인터셉터를 추가할 수 있음
|
||||||
@ -58,6 +61,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
|||||||
//게시판 에디터 안 이미지 업로드 경로
|
//게시판 에디터 안 이미지 업로드 경로
|
||||||
registry.addResourceHandler("/upload/img/board/**")
|
registry.addResourceHandler("/upload/img/board/**")
|
||||||
.addResourceLocations("file:" + boardFilePath);
|
.addResourceLocations("file:" + boardFilePath);
|
||||||
|
//프로필 이미지 업로드 경로
|
||||||
|
registry.addResourceHandler("/upload/img/profile/**")
|
||||||
|
.addResourceLocations("file:" + uploadPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Controller의 파라미터를 처리할 Resolver 등록
|
// Controller의 파라미터를 처리할 Resolver 등록
|
||||||
|
|||||||
@ -38,11 +38,10 @@ public class FileService {
|
|||||||
* 파일 업로드
|
* 파일 업로드
|
||||||
*
|
*
|
||||||
* @param file
|
* @param file
|
||||||
* @param directory
|
|
||||||
* @return
|
* @return
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public String uploadFile(MultipartFile file, String directory) {
|
public String uploadFile(MultipartFile file) {
|
||||||
try {
|
try {
|
||||||
// 원본 파일명
|
// 원본 파일명
|
||||||
String originalFilename = file.getOriginalFilename();
|
String originalFilename = file.getOriginalFilename();
|
||||||
@ -52,7 +51,7 @@ public class FileService {
|
|||||||
String newFilename = UUID.randomUUID().toString() + "." + extension;
|
String newFilename = UUID.randomUUID().toString() + "." + extension;
|
||||||
|
|
||||||
// 최종 저장 경로 생성 (기본경로 + 하위디렉토리 + 파일명)
|
// 최종 저장 경로 생성 (기본경로 + 하위디렉토리 + 파일명)
|
||||||
Path targetPath = Paths.get(uploadPath, directory, newFilename);
|
Path targetPath = Paths.get(uploadPath, newFilename);
|
||||||
// 저장될 디렉토리가 없는 경우 생성
|
// 저장될 디렉토리가 없는 경우 생성
|
||||||
Files.createDirectories(targetPath.getParent());
|
Files.createDirectories(targetPath.getParent());
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ public class FileService {
|
|||||||
Files.copy(file.getInputStream(), targetPath, StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(file.getInputStream(), targetPath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
// 저장된 파일의 상대 경로 반환
|
// 저장된 파일의 상대 경로 반환
|
||||||
return directory + "/" + newFilename;
|
return newFilename;
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException("파일 업로드 실패: " + e.getMessage());
|
throw new RuntimeException("파일 업로드 실패: " + e.getMessage());
|
||||||
|
|||||||
@ -43,7 +43,7 @@ public class netmemberService {
|
|||||||
*/
|
*/
|
||||||
public int register(MultipartFile memberPrf, MapDto map) {
|
public int register(MultipartFile memberPrf, MapDto map) {
|
||||||
// 프로필 이미지 저장, 저장된 경로 가져옴
|
// 프로필 이미지 저장, 저장된 경로 가져옴
|
||||||
String profilePath = fileService.uploadFile(memberPrf, "profiles");
|
String profilePath = fileService.uploadFile(memberPrf);
|
||||||
map.put("memberPrf", profilePath);
|
map.put("memberPrf", profilePath);
|
||||||
|
|
||||||
// 비밀번호 암호화 및 저장
|
// 비밀번호 암호화 및 저장
|
||||||
@ -54,7 +54,7 @@ public class netmemberService {
|
|||||||
map.put("memberRol", "ROLE_MEMBER");
|
map.put("memberRol", "ROLE_MEMBER");
|
||||||
map.put("memberPos", 500107);
|
map.put("memberPos", 500107);
|
||||||
map.put("memberTkn", "Null");
|
map.put("memberTkn", "Null");
|
||||||
map.put("memberPrm", "N");
|
map.put("memberPrm", "Y");
|
||||||
map.put("memberDel", "N");
|
map.put("memberDel", "N");
|
||||||
map.put("memberLea", "N");
|
map.put("memberLea", "N");
|
||||||
map.put("memberRdt", LocalDateTime.now());
|
map.put("memberRdt", LocalDateTime.now());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user