Merge branch 'main' into yoon

This commit is contained in:
yoon 2025-02-03 14:44:49 +09:00
commit 856dd1b618
2 changed files with 25 additions and 3 deletions

View File

@ -41,6 +41,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
@Value("${filePath.boardfile}")
private String boardFilePath;
@Value("${filePath.profile}")
private String uploadPath;
@Override
public void addInterceptors(InterceptorRegistry registry) {
@ -58,6 +61,9 @@ public class WebMvcConfig implements WebMvcConfigurer {
//게시판 에디터 이미지 업로드 경로
registry.addResourceHandler("/upload/img/board/**")
.addResourceLocations("file:" + boardFilePath);
//프로필 이미지 업로드 경로
registry.addResourceHandler("/upload/img/profile/**")
.addResourceLocations("file:" + uploadPath);
}
// Controller의 파라미터를 처리할 Resolver 등록

View File

@ -23,6 +23,7 @@ import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class localbordService {
private final localbordMapper boardMapper;
private static final long MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
public List<MapDto> getNotices(MapDto map) {
List<MapDto> posts = boardMapper.getNotices(map);
@ -55,13 +56,28 @@ public class localbordService {
boardMapper.createBoard(map);
return (BigInteger) map.get("LOCBRDSEQ");
}
public void addAttachment(MapDto map) {
String boardSeqStr = (String) map.get("CMNBRDSEQ");
Long boardSeq = Long.parseLong(boardSeqStr);
map.put("CMNBRDSEQ", boardSeq);
String newFilename = UUID.randomUUID().toString();
map.put("CMNFLENAM", newFilename);
public void addAttachment(MapDto map) {
String newFilename = UUID.randomUUID().toString();
map.put("CMNFLENAM", newFilename);
boardMapper.addAttachment(map);
}
public void validateAttachmentsSize(List<MapDto> attachments) {
long totalSize = attachments.stream()
.mapToLong(attachment -> (Long) attachment.get("size"))
.sum();
if (totalSize > MAX_FILE_SIZE) {
throw new IllegalArgumentException("첨부파일의 총 용량이 5MB를 초과합니다.");
}
}
public MapDto getBoardDetail(Long boardId) {
incrementViewCount(boardId);
MapDto boardDetail = boardMapper.selectBoardDetail(boardId);