Skip to content

Commit

Permalink
Merge pull request #43 from GPGT-Algorithm-Study/develop
Browse files Browse the repository at this point in the history
[Feat] 크롤링, 경고 On/Off 기능 추가
  • Loading branch information
fing9 authored Jun 4, 2024
2 parents 6feaac4 + 70fcf8d commit dd5aee1
Show file tree
Hide file tree
Showing 70 changed files with 897 additions and 286 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.auth0:java-jwt:4.2.0'
implementation 'org.jsoup:jsoup:1.15.3'
implementation 'mysql:mysql-connector-java:8.0.32'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
package com.randps.randomdefence.domain.board.controller;

import com.randps.randomdefence.domain.board.domain.Board;
import com.randps.randomdefence.domain.board.dto.*;
import com.randps.randomdefence.domain.board.dto.BoardDetail;
import com.randps.randomdefence.domain.board.dto.BoardPublishRequest;
import com.randps.randomdefence.domain.board.dto.BoardSimple;
import com.randps.randomdefence.domain.board.dto.BoardUpdateRequest;
import com.randps.randomdefence.domain.board.dto.SearchCondition;
import com.randps.randomdefence.domain.board.service.BoardService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.query.Param;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.randps.randomdefence.domain.board.dto;

import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
import com.randps.randomdefence.domain.image.service.port.BoardImageRepository;
import com.randps.randomdefence.domain.image.service.port.ImageRepository;
import com.randps.randomdefence.domain.notify.enums.NotifyType;
import com.randps.randomdefence.domain.notify.service.NotifyService;
import com.randps.randomdefence.global.aws.s3.service.S3Service;
import com.randps.randomdefence.global.event.notify.entity.NotifyToAllEvent;
import java.util.ArrayList;
import java.util.List;
import javax.transaction.Transactional;
import lombok.Builder;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
Expand All @@ -41,7 +42,7 @@ public class BoardService {

private final BoardImageRepository boardImageRepository;

private final NotifyService notifyService;
private final ApplicationContext applicationContext;

/*
* 게시글 저장
Expand All @@ -60,8 +61,9 @@ public Board save(String type, String bojHandle, String title, String content, I

// 만약 공지라면 전체 유저에게 알림을 발행한다.
if (type.equals("notice")) {
notifyService.systemPublishToAll("📣 새로운 공지가 등록되었습니다. 확인해보세요! [" + board.getTitle() + "]",
NotifyType.NOTICE, board.getId());
applicationContext.publishEvent(
new NotifyToAllEvent(this, "📣 새로운 공지가 등록되었습니다. 확인해보세요! [" + board.getTitle() + "]",
NotifyType.NOTICE, board.getId()));
}

if (images.isBlank() || images.isEmpty()) {
Expand Down Expand Up @@ -105,8 +107,9 @@ public Board update(Long boardId, String type, String bojHandle, String title, S

// 만약 공지라면 전체 유저에게 알림을 발행한다.
if (type.equals("notice")) {
notifyService.systemPublishToAll("📣 공지에 변화가 있습니다. 확인해보세요! [" + board.getTitle() + "]",
NotifyType.NOTICE, board.getId());
applicationContext.publishEvent(
new NotifyToAllEvent(this, "📣 공지에 변화가 있습니다. 확인해보세요! [" + board.getTitle() + "]",
NotifyType.NOTICE, board.getId()));
}

if (images.isBlank() || images.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.randps.randomdefence.domain.boolshit.controller;

import com.randps.randomdefence.domain.boolshit.domain.Boolshit;
import com.randps.randomdefence.domain.boolshit.dto.BoolshitLastResponse;
import com.randps.randomdefence.domain.boolshit.dto.BoolshitResponse;
import com.randps.randomdefence.domain.boolshit.service.BoolshitService;
import java.util.List;
import lombok.RequiredArgsConstructor;
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("/api/v1/boolshit")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.randps.randomdefence.domain.boolshit.dto;

import java.time.LocalDateTime;
import lombok.Builder;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class BoolshitLastResponse {
private Long id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
import com.randps.randomdefence.domain.comment.dto.CommentPublishRequest;
import com.randps.randomdefence.domain.comment.dto.CommentUpdateRequest;
import com.randps.randomdefence.domain.comment.service.CommentService;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.randps.randomdefence.domain.comment.dto;

import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import com.randps.randomdefence.domain.comment.dto.CommentUpdateRequest;
import com.randps.randomdefence.domain.comment.service.port.CommentRepository;
import com.randps.randomdefence.domain.notify.enums.NotifyType;
import com.randps.randomdefence.domain.notify.service.NotifyService;
import com.randps.randomdefence.domain.user.domain.User;
import com.randps.randomdefence.domain.user.service.port.UserRepository;
import com.randps.randomdefence.global.event.notify.entity.NotifyToUserBySystemEvent;
import java.util.List;
import javax.transaction.Transactional;
import lombok.Builder;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
Expand All @@ -29,7 +30,7 @@ public class CommentService {

private final CommentRepository commentRepository;

private final NotifyService notifyService;
private final ApplicationContext applicationContext;

/**
* 코멘트 저장
Expand Down Expand Up @@ -59,18 +60,20 @@ public Comment save(CommentPublishRequest commentPublishRequest) {
() -> new NotFoundException("존재하지 않는 유저입니다."));
if (!parentCommenter.getBojHandle().equals(commenter.getBojHandle())
&& !parentComment.getBojHandle().equals(board.getBojHandle())) {
notifyService.systemPublish(parentCommenter.getBojHandle(),
"[" + board.getTitle() + "] 에 작성한 댓글에 [" + commenter.getNotionId()
+ "] 님이 댓글을 작성했습니다." + " - \"" + commentPublishRequest.getContent() + "\"",
NotifyType.SYSTEM, commentPublishRequest.getBoardId());
applicationContext.publishEvent(
new NotifyToUserBySystemEvent(this, parentCommenter.getBojHandle(),
"[" + board.getTitle() + "] 에 작성한 댓글에 [" + commenter.getNotionId()
+ "] 님이 댓글을 작성했습니다." + " - \"" + commentPublishRequest.getContent() + "\"",
NotifyType.SYSTEM, commentPublishRequest.getBoardId()));
}
}
if (!commenter.getBojHandle().equals(board.getBojHandle())) {
// 글쓴이에게 보내는 알림을 발행한다.
notifyService.systemPublish(board.getBojHandle(),
"작성한 글 [" + board.getTitle() + "] 에 [" + commenter.getNotionId()
+ "] 님이 댓글을 작성했습니다." + " - \"" + commentPublishRequest.getContent() + "\"",
NotifyType.SYSTEM, commentPublishRequest.getBoardId());
applicationContext.publishEvent(
new NotifyToUserBySystemEvent(this, board.getBojHandle(),
"작성한 글 [" + board.getTitle() + "] 에 [" + commenter.getNotionId()
+ "] 님이 댓글을 작성했습니다." + " - \"" + commentPublishRequest.getContent() + "\"",
NotifyType.SYSTEM, commentPublishRequest.getBoardId()));
}

return comment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import com.randps.randomdefence.domain.complaint.enums.ProcessType;
import com.randps.randomdefence.domain.complaint.service.port.ComplaintRepository;
import com.randps.randomdefence.domain.notify.enums.NotifyType;
import com.randps.randomdefence.domain.notify.service.NotifyService;
import com.randps.randomdefence.domain.user.domain.User;
import com.randps.randomdefence.domain.user.service.port.UserRepository;
import com.randps.randomdefence.global.event.notify.entity.NotifyToUserBySystemEvent;
import javax.transaction.Transactional;
import lombok.Builder;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
Expand All @@ -22,7 +23,7 @@ public class ComplaintProcessorService {

private final UserRepository userRepository;

private final NotifyService notifyService;
private final ApplicationContext applicationContext;

/*
* 민원의 상태를 바꾼다.
Expand All @@ -43,18 +44,20 @@ public void changeProcessType(ComplaintProcessorUpdateRequest request, String bo
}
if (request.getProcessType().equals(ProcessType.WAITING)) {
complaint.setProcessWAITING();
notifyService.systemPublish(complaint.getRequester(), "😴 내 민원이 [대기] 상태로 변경되었습니다.",
NotifyType.ADMIN, null);
applicationContext.publishEvent(
new NotifyToUserBySystemEvent(this, complaint.getRequester(), "😴 내 민원이 [대기] 상태로 변경되었습니다.",
NotifyType.ADMIN, null));
}
if (request.getProcessType().equals(ProcessType.PROCESSING)) {
complaint.setProcessPROCESSING();
notifyService.systemPublish(complaint.getRequester(), "😎 내 민원이 [처리 중] 상태로 변경되었습니다.",
NotifyType.ADMIN, null);
applicationContext.publishEvent(new NotifyToUserBySystemEvent(this, complaint.getRequester(),
"😎 내 민원이 [처리 중] 상태로 변경되었습니다.", NotifyType.ADMIN, null));
}
if (request.getProcessType().equals(ProcessType.DONE)) {
complaint.setProcessDONE();
notifyService.systemPublish(complaint.getRequester(), "🥳 내 민원이 [처리 완료] 상태로 변경되었습니다.",
NotifyType.ADMIN, null);

applicationContext.publishEvent(new NotifyToUserBySystemEvent(this, complaint.getRequester(),
"🥳 내 민원이 [처리 완료] 상태로 변경되었습니다.", NotifyType.ADMIN, null));
}
if (request.getReply() != null) {
complaint.updateProcessorAndReply(request.getProcessor(), request.getReply());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import com.randps.randomdefence.domain.complaint.dto.ComplaintUpdateRequest;
import com.randps.randomdefence.domain.complaint.service.port.ComplaintRepository;
import com.randps.randomdefence.domain.notify.enums.NotifyType;
import com.randps.randomdefence.domain.notify.service.NotifyService;
import com.randps.randomdefence.domain.user.domain.User;
import com.randps.randomdefence.domain.user.service.port.UserRepository;
import com.randps.randomdefence.global.event.notify.entity.NotifyToAdminEvent;
import com.randps.randomdefence.global.event.notify.entity.NotifyToUserBySystemEvent;
import javax.transaction.Transactional;
import lombok.Builder;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.stereotype.Service;

Expand All @@ -24,7 +26,7 @@ public class ComplaintRequesterService {

private final UserRepository userRepository;

private final NotifyService notifyService;
private final ApplicationContext applicationContext;

/*
* 민원인의 민원을 생성한다.
Expand All @@ -39,8 +41,9 @@ public Complaint makeNewComplaint(ComplaintSaveRequest request, String bojHandle
if (!request.getRequester().equals(bojHandle) && !user.getManager()) {
throw new AccessDeniedException("이 민원을 생성할 권한이 없습니다.");
}
notifyService.systemPublishToAdmins("[" + user.getNotionId() + "]님이 작성한 새로운 민원이 등록되었습니다.",
NotifyType.ADMIN, null);
applicationContext.publishEvent(
new NotifyToAdminEvent(this, "[" + user.getNotionId() + "]님이 작성한 새로운 민원이 등록되었습니다.",
NotifyType.ADMIN, null));
return complaintRepository.save(ComplaintSaveRequest.to(request));
}

Expand Down Expand Up @@ -81,11 +84,12 @@ public void delete(ComplaintDeleteRequest request, String bojHandle)
throw new AccessDeniedException("삭제 권한이 없습니다.");
}

notifyService.systemPublish(complaint.getRequester(), "😈 내 민원이 삭제되었습니다.",
NotifyType.ADMIN, null);
notifyService.systemPublishToAdmins(
applicationContext.publishEvent(new NotifyToUserBySystemEvent(this,
complaint.getRequester(), "😈 내 민원이 삭제되었습니다.",
NotifyType.ADMIN, null));
applicationContext.publishEvent(new NotifyToAdminEvent(this,
"[" + requester.getNotionId() + "]님이 작성한 기존의 민원을 " + user.getNotionId() + "님이 삭제했습니다.",
NotifyType.ADMIN, null);
NotifyType.ADMIN, null));

complaintRepository.delete(complaint);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import com.randps.randomdefence.domain.event.dto.EventPointDto;
import com.randps.randomdefence.domain.event.service.EventPointSearchService;
import java.util.List;
import lombok.RequiredArgsConstructor;
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("/api/v1/event/point")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.randps.randomdefence.domain.event.dto;

import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.randps.randomdefence.domain.event.dto;

import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@Builder
@AllArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.randps.randomdefence.domain.event.dto;

import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@Builder
@AllArgsConstructor
Expand Down
Loading

0 comments on commit dd5aee1

Please sign in to comment.