diff --git a/.github/workflows/main-cicd.yml b/.github/workflows/main-cicd.yml index b9f176cc..fa4b693e 100644 --- a/.github/workflows/main-cicd.yml +++ b/.github/workflows/main-cicd.yml @@ -32,6 +32,15 @@ jobs: env: APPLICATION_MAIN: ${{ secrets.APPLICATION_MAIN }} + - name: logback.xml 설정 + run: | + cd ./src/main/resources + touch ./logback.xml + echo "LOGBACK" > ./logback.xml + env: + LOGBACK_CONFIG: ${{ secrets.LOGBACK }} + + - name: Gradle Caching uses: actions/cache@v3 with: diff --git a/.gitignore b/.gitignore index 35cb6fbe..a41e741e 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,9 @@ out/ **/src/main/resources/** +### Log ### +**/logs/** + + .DS_Store diff --git a/src/main/java/ussum/homepage/application/post/service/PostManageService.java b/src/main/java/ussum/homepage/application/post/service/PostManageService.java index 34cb9dd6..c33df8d5 100644 --- a/src/main/java/ussum/homepage/application/post/service/PostManageService.java +++ b/src/main/java/ussum/homepage/application/post/service/PostManageService.java @@ -95,7 +95,8 @@ public class PostManageService { "감사기구게시판", (post, isAuthor, ignored, user, another_ignored1, categoryName, fileResponseList, another_ignored2, another_ignored3) -> AuditPostDetailResponse.of(post, isAuthor, user, categoryName, fileResponseList), "청원게시판", (post, isAuthor, isLiked, user, likeCount, categoryName, fileResponseList, postOfficialCommentResponseList, another_ignored3) -> PetitionPostDetailResponse.of(post, isAuthor, isLiked, user, likeCount, categoryName, fileResponseList, postOfficialCommentResponseList), "건의게시판", (post, isAuthor, ignored, user, another_ignored1, categoryName, fileResponseList, postOfficialCommentResponseList, another_ignored3) -> SuggestionPostDetailResponse.of(post, isAuthor, user, categoryName, fileResponseList, postOfficialCommentResponseList), - "인권신고게시판", (post, isAuthor, ignored, user, another_ignored1,categoryName, fileResponseList,postOfficialCommentResponseList,rightsDetailList) -> RightsPostDetailResponse.of(post,isAuthor,user,categoryName,fileResponseList,postOfficialCommentResponseList, rightsDetailList) + "인권신고게시판", (post, isAuthor, ignored, user, another_ignored1,categoryName, fileResponseList,postOfficialCommentResponseList,rightsDetailList) -> RightsPostDetailResponse.of(post,isAuthor,user,categoryName,fileResponseList,postOfficialCommentResponseList, rightsDetailList), + "서비스공지사항", (post, isAuthor, another_ignored, user, another_ignored2, another_ignored3, fileResponseList, another_ignored4, another_ignored5) -> ServicePostDetailResponse.of(post,isAuthor,user,fileResponseList) ); private final PostMapper postMapper; @@ -193,7 +194,7 @@ public PostDetailRes getPost(Long userId, String boardCode, Long postId) { .map(postOfficialComment -> postOfficialCommentFormatter.format(postOfficialComment, userId)) .toList(); response = responseFunction.apply(post, isAuthor, null, user, null, post.getCategory(), fileResponseList, postOfficialCommentResponses,null); - } else if (board.getName().equals("제휴게시판") || board.getName().equals("공지사항게시판") || board.getName().equals("감사기구게시판")) { + } else if (board.getName().equals("제휴게시판") || board.getName().equals("공지사항게시판") || board.getName().equals("감사기구게시판") || board.getName().equals("서비스공지사항")) { response = responseFunction.apply(post, isAuthor, null, user, null, post.getCategory(), fileResponseList, null,null); } else if (board.getName().equals("분실물게시판")) { response = responseFunction.apply(post, isAuthor, null, user, null, post.getCategory(), fileResponseList, null,null); //분실물 게시판은 파일첨부 제외 diff --git a/src/main/java/ussum/homepage/application/post/service/dto/response/postDetail/ServicePostDetailResponse.java b/src/main/java/ussum/homepage/application/post/service/dto/response/postDetail/ServicePostDetailResponse.java new file mode 100644 index 00000000..e5affc5c --- /dev/null +++ b/src/main/java/ussum/homepage/application/post/service/dto/response/postDetail/ServicePostDetailResponse.java @@ -0,0 +1,33 @@ +package ussum.homepage.application.post.service.dto.response.postDetail; + +import java.util.List; +import lombok.Builder; +import lombok.Getter; +import ussum.homepage.application.post.service.dto.response.FileResponse; +import ussum.homepage.domain.post.Post; +import ussum.homepage.domain.user.User; + +@Getter +public class ServicePostDetailResponse extends PostDetailResDto{ + private final List fileResponseList; + + @Builder + private ServicePostDetailResponse(Long postId, String categoryName, String authorName, String title, String content, String createdAt, String lastEditedAt, Boolean isAuthor, + List fileResponseList, List canAuthority) { + super(postId, categoryName, authorName, title, content, createdAt, lastEditedAt, isAuthor, canAuthority); + this.fileResponseList = fileResponseList; + } + + public static ServicePostDetailResponse of(Post post, Boolean isAuthor, User user, List fileResponseList) { + return ServicePostDetailResponse.builder() + .postId(post.getId()) + .authorName(user.getName()) + .title(post.getTitle()) + .content(post.getContent()) + .createdAt(post.getCreatedAt()) + .lastEditedAt(post.getLastEditedAt()) + .isAuthor(isAuthor) + .fileResponseList(fileResponseList) + .build(); + } +} diff --git a/src/main/java/ussum/homepage/application/post/service/dto/response/postList/ServiceNoticePostResponse.java b/src/main/java/ussum/homepage/application/post/service/dto/response/postList/ServiceNoticePostResponse.java new file mode 100644 index 00000000..5d424e1d --- /dev/null +++ b/src/main/java/ussum/homepage/application/post/service/dto/response/postList/ServiceNoticePostResponse.java @@ -0,0 +1,26 @@ +package ussum.homepage.application.post.service.dto.response.postList; + +import lombok.Builder; +import lombok.Getter; +import ussum.homepage.domain.post.Post; + +@Getter +public class ServiceNoticePostResponse extends PostListResDto{ + private final String status; + + @Builder + protected ServiceNoticePostResponse(Long postId, String title, String content, String date, String category, String status) { + super(postId, title, content, date, category); + this.status = status; + } + + public static ServiceNoticePostResponse of(Post post) { + return ServiceNoticePostResponse.builder() + .postId(post.getId()) + .title(post.getTitle()) + .category(post.getCategory()) + .date(post.getCreatedAt()) + .status(post.getStatus()) + .build(); + } +} diff --git a/src/main/java/ussum/homepage/domain/acl/service/post/PostAclHandler.java b/src/main/java/ussum/homepage/domain/acl/service/post/PostAclHandler.java index ac65f5dd..36ed044b 100644 --- a/src/main/java/ussum/homepage/domain/acl/service/post/PostAclHandler.java +++ b/src/main/java/ussum/homepage/domain/acl/service/post/PostAclHandler.java @@ -36,6 +36,9 @@ public void applyPermissionsToPostDetail(PostDetailRes postDetailRes, Long us if (boardCode.equals("청원게시판") && postAclManager.hasPermission(userId, boardCode, "REACTION")) { allowedAuthorities.add("REACTION"); } + if (boardCode.equals("서비스공지사항") && postAclManager.hasPermission(userId, boardCode, "EDIT")) { + allowedAuthorities.add("EDIT"); + } } postDetailRes.validAuthority(allowedAuthorities); @@ -93,6 +96,9 @@ private void addPermissionAuthorities(List allowedAuthorities, List batchIds = queryFactory .select(postEntity.id) .from(postEntity) - .where(postEntity.boardEntity.id.eq(2L) // 공지사항 게시판 ID가 1이라고 가정 + .where(postEntity.boardEntity.id.in(2L,9L) // 공지사항 게시판 ID가 2이라고 가정 .and(postEntity.status.ne(Status.GENERAL)) // 상태가 GENERAL이 아닌 것 .and(postEntity.createdAt.before(threeDaysAgo))) // 3일 이전에 생성된 것 .limit(batchSize) diff --git a/src/main/java/ussum/homepage/infra/jpa/post/entity/BoardCode.java b/src/main/java/ussum/homepage/infra/jpa/post/entity/BoardCode.java index 3894bd3b..8dc0d87e 100644 --- a/src/main/java/ussum/homepage/infra/jpa/post/entity/BoardCode.java +++ b/src/main/java/ussum/homepage/infra/jpa/post/entity/BoardCode.java @@ -18,7 +18,8 @@ public enum BoardCode { PETITION("청원게시판", 5), DATA("자료집게시판", 6), SUGGESTION("건의게시판", 7), - RIGHTS("인권신고게시판", 8); + RIGHTS("인권신고게시판", 8), + SERVICE_NOTICE("서비스공지사항",9); private final String stringBoardCode; private final int boardId; diff --git a/src/main/java/ussum/homepage/infra/jpa/post/entity/Category.java b/src/main/java/ussum/homepage/infra/jpa/post/entity/Category.java index 387f5b8a..3b4504a4 100644 --- a/src/main/java/ussum/homepage/infra/jpa/post/entity/Category.java +++ b/src/main/java/ussum/homepage/infra/jpa/post/entity/Category.java @@ -34,6 +34,7 @@ public enum Category { RECEIVED("접수완료"), ANSWERED("답변완료"), COMPLETED("종료됨"), + //건의 게시판(답변완료, 답변대기) PENDING("답변대기"), @@ -59,6 +60,7 @@ public enum Category { //인권신고게시판 STAND_BY("접수대기"), + //중앙 : 총학생회, 중앙운영위원회, 중앙선거관리위원회, 동아리연합회 //단과대 : IT대학, 인문대학, 융합특성화자유전공학부, 사회과학대학, 공과대학, 경영대학, 경제통상대학, 자연과학대학, 법과대학 STUDENT_COUNCIL("총학생회"), diff --git a/src/test/java/ussum/homepage/application/comment/service/CommentServiceTest.java b/src/test/java/ussum/homepage/application/comment/service/CommentServiceTest.java new file mode 100644 index 00000000..d63dea93 --- /dev/null +++ b/src/test/java/ussum/homepage/application/comment/service/CommentServiceTest.java @@ -0,0 +1,16 @@ +package ussum.homepage.application.comment.service; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +public class CommentServiceTest { + @Autowired + private CommentService commentService; + + @Test + void deletePostWhileCreateComment(){ + + } +}