Skip to content

Commit

Permalink
Merge pull request #103 from Team-UniVoice/refactor/#101-codebase_ref…
Browse files Browse the repository at this point in the history
…actoring

Refactor/#101 codebase refactoring
  • Loading branch information
softmoca authored Aug 6, 2024
2 parents db5f5d2 + 32421d0 commit 295d318
Show file tree
Hide file tree
Showing 30 changed files with 427 additions and 782 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class Affiliation extends BaseTimeEntity {
@OneToMany(mappedBy = "affiliation", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Member> members;

// 새로운 생성자 추가
@Builder
public Affiliation(Role role, String affiliation) {
this.role = role;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import sopt.univoice.domain.auth.dto.MemberSignInRequest;
import sopt.univoice.domain.auth.dto.UserLoginResponse;
import sopt.univoice.domain.auth.service.AuthService;
import sopt.univoice.domain.universityData.dto.UniversityNameRequest;
import sopt.univoice.infra.common.dto.SuccessMessage;
import sopt.univoice.infra.common.dto.SuccessStatusResponse;
import sopt.univoice.infra.common.exception.message.BusinessException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import lombok.NoArgsConstructor;


@Getter
@NoArgsConstructor
public class CheckEmailRequest {
private String email;

public record CheckEmailRequest(String email) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class MemberSignInRequest {
private String email;
private String password;
public record MemberSignInRequest(String email, String password) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private void setResponse(HttpServletResponse response) throws IOException {
ErrorResponse.of(
ErrorMessage.JWT_UNAUTHORIZED_EXCEPTION.getStatus(),
ErrorMessage.JWT_UNAUTHORIZED_EXCEPTION.getMessage(),
null // 추가된 필드
null
)
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ protected void doFilterInternal(@NonNull HttpServletRequest request,
System.out.println("Exception during token validation: " + exception.getMessage());
throw new UnauthorizedException(ErrorMessage.JWT_UNAUTHORIZED_EXCEPTION);
}
System.out.println("ㅇㅇㅇㅇㅇㅇㅇㅇㅇㅇ");
filterChain.doFilter(request, response);
System.out.println("ㅇㅇㅇㅇ");
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public class AuthService {

@Value("${slack.webhook-url}")
private String webhookUrl;
private static final String S3_BUCKET_URL = "https://uni-voice-bucket.s3.ap-northeast-2.amazonaws.com/";
@Value("${aws-property.s3-bucket-url}")
private String s3BucketUrl;

private final AuthRepository authRepository;
private final S3Service s3Service;
Expand Down Expand Up @@ -81,10 +82,10 @@ public void signUp(MemberCreateRequest memberCreateRequest) {

@Transactional
public UserLoginResponse logineMember(MemberSignInRequest memberSignInRequest) {
Member member = authRepository.findByEmail(memberSignInRequest.getEmail())
Member member = authRepository.findByEmail(memberSignInRequest.email())
.orElseThrow(() -> new UnauthorizedException(ErrorMessage.JWT_LOGIN_PASSWORD_EXCEPTION));

if (!passwordEncoder.matches(memberSignInRequest.getPassword(), member.getPassword())) {
if (!passwordEncoder.matches(memberSignInRequest.password(), member.getPassword())) {
throw new UnauthorizedException(ErrorMessage.JWT_LOGIN_PASSWORD_EXCEPTION);
}

Expand All @@ -99,7 +100,7 @@ public UserLoginResponse logineMember(MemberSignInRequest memberSignInRequest) {


public boolean isDuplicateEmail(CheckEmailRequest checkEmailRequest) {
return authRepository.existsByEmail(checkEmailRequest.getEmail());
return authRepository.existsByEmail(checkEmailRequest.email());
}

private String uploadStudentCardImage(MultipartFile studentCardImage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
import org.springframework.web.bind.annotation.RestController;
import sopt.univoice.domain.mypage.dto.response.GetMypageReponseDto;
import sopt.univoice.domain.mypage.service.MypageService;
import sopt.univoice.domain.notice.dto.NoticeSaveDTO;
import sopt.univoice.infra.common.dto.SuccessMessage;
import sopt.univoice.infra.common.dto.SuccessStatusResponse;

import java.util.List;

@RestController
@RequestMapping("/api/v1/mypage")
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import sopt.univoice.domain.notice.dto.*;
import sopt.univoice.domain.notice.entity.Notice;
import sopt.univoice.domain.notice.service.NoticeService;
import sopt.univoice.domain.universityData.entity.Department;
import sopt.univoice.infra.common.dto.SuccessMessage;
import sopt.univoice.infra.common.dto.SuccessStatusResponse;

Expand All @@ -22,7 +21,6 @@ public class NoticeController {

@PostMapping("/create")
public ResponseEntity<SuccessStatusResponse<Void>> createPost(@ModelAttribute NoticeCreateRequest noticeCreateRequest) {
System.out.println("createPost method called with request: " + noticeCreateRequest);
noticeService.createPost(noticeCreateRequest);
return ResponseEntity.status(HttpStatus.CREATED)
.body(SuccessStatusResponse.of(SuccessMessage.CREATE_NOTICE_SUCCESS, null));
Expand Down Expand Up @@ -60,10 +58,12 @@ public ResponseEntity<SuccessStatusResponse<Object>> saveCancleNotice(@PathVaria
.body(SuccessStatusResponse.of(SuccessMessage.SAVE_CANCLE_NOTICE_SUCCESS, null));
}



@GetMapping("/save/all")
public ResponseEntity<SuccessStatusResponse<List<NoticeSaveDTO>>> getSaveNoticeByUser() {
public ResponseEntity<SuccessStatusResponse<List<NoticeSaveListByUserResponse>>> getSaveNoticeByUser() {

List<NoticeSaveDTO> notices = noticeService.getSaveNoticeByUser();
List<NoticeSaveListByUserResponse> notices = noticeService.getSaveNoticeByUser();
return ResponseEntity.status(HttpStatus.OK)
.body(SuccessStatusResponse.of(SuccessMessage.SAVE_ALL_NOTICE_SUCCESS, notices));
}
Expand All @@ -84,9 +84,15 @@ public ResponseEntity<SuccessStatusResponse<Object>> viewCheck(@PathVariable Lon
.body(SuccessStatusResponse.of(SuccessMessage.VIEW_CHECK_NOTICE_SUCCESS, null));
}


// dto 체크 시작
// dto 체크 시작
// dto 체크 시작
// dto 체크 시작

@GetMapping("/quickhead")
public ResponseEntity<SuccessStatusResponse<Object>> quickhead() {
QuickScanDTO response = noticeService.quickhead();
QuickScanStoryHeadResponse response = noticeService.quickhead();
return ResponseEntity.status(HttpStatus.OK)
.body(SuccessStatusResponse.of(SuccessMessage.GET_QUCIK_HEAD_SUCCESS, response));
}
Expand All @@ -102,7 +108,7 @@ public ResponseEntity<SuccessStatusResponse<Object>> getAllNoticeByUserUniversit

@GetMapping("/university")
public ResponseEntity<SuccessStatusResponse<Object>> getUniversityNoticeByUserUniversity() {
List<NoticeDTO> response = noticeService.getUniversityNoticeByUserUniversity();
List<NoticeResponseDTO> response = noticeService.getUniversityNoticeByUserUniversity();
return ResponseEntity.status(HttpStatus.OK)
.body(SuccessStatusResponse.of(SuccessMessage.GET_ALL_UNIVERSITY_NOTICE_SUCCESS, response));
}
Expand All @@ -128,17 +134,17 @@ public ResponseEntity<SuccessStatusResponse<Object>> getDepartmentNoticeByUserUn
}

@PostMapping ("/quick")
public ResponseEntity<SuccessStatusResponse<List<QuickQueryNoticeDTO>>> getQuickNoticeByUserUniversity(@RequestBody AffiliationRequestDTO request) {
public ResponseEntity<SuccessStatusResponse<List<QuickNoticeListResponse>>> getQuickNoticeByUserUniversity(@RequestBody AffiliationRequest request) {

List<QuickQueryNoticeDTO> response = noticeService.getQuickNoticeByUserUniversity(request.getAffiliation());
List<QuickNoticeListResponse> response = noticeService.getQuickNoticeByUserUniversity(request.affiliation());
return ResponseEntity.status(HttpStatus.OK)
.body(SuccessStatusResponse.of(SuccessMessage.GET_QUICK_NOTICE_SUCCESS, response));
}


@GetMapping("/{noticeId}")
public ResponseEntity<SuccessStatusResponse<NoticeDetailResponseDTO>> getNoticeById(@PathVariable Long noticeId) {
NoticeDetailResponseDTO response = noticeService.getNoticeById(noticeId);
public ResponseEntity<SuccessStatusResponse<Notice>> getNoticeById(@PathVariable Long noticeId) {
Notice response = noticeService.getNoticeById(noticeId);
return ResponseEntity.status(HttpStatus.OK)
.body(SuccessStatusResponse.of(SuccessMessage.GET_Detail_NOTICE_SUCCESS, response));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package sopt.univoice.domain.notice.dto;

public record AffiliationRequest(String affiliation) {
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,14 @@
import java.util.List;
import java.util.Optional;

@Setter
@Getter
@NoArgsConstructor
//@AllArgsConstructor
public class NoticeCreateRequest {


private String title;

private String content;

private String target;
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private LocalDateTime startTime;

@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private LocalDateTime endTime;

private List<MultipartFile> noticeImages;

public record NoticeCreateRequest(
String title,
String content,
String target,
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
LocalDateTime startTime,
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
LocalDateTime endTime,
List<MultipartFile> noticeImages
) {
}
27 changes: 0 additions & 27 deletions src/main/java/sopt/univoice/domain/notice/dto/NoticeDTO.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package sopt.univoice.domain.notice.dto;

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

public record NoticeDetailResponse(
Long id,
String title,
String content,
Long noticeLike,
Long viewCount,
String target,
LocalDateTime startTime,
LocalDateTime endTime,
String category,
String contentSummary,
Long memberId,
String writeAffiliation,
List<String> noticeImages,
LocalDateTime createdAt, // 추가된 부분
Boolean likeCheck,
Boolean saveCheck,
String dayOfWeek
) {
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@

import java.time.LocalDateTime;

@Getter
@NoArgsConstructor
@AllArgsConstructor
public class NoticeResponseDTO {
private Long id;
private LocalDateTime startTime;
private LocalDateTime endTime;
private String title;
private Long likeCount;
private Long viewCount; // 조회수로 수정
private String category;
private LocalDateTime createdAt;
private String image; // 이미지 추가
public record NoticeResponseDTO(
Long id,
LocalDateTime startTime,
LocalDateTime endTime,
String title,
Long likeCount,
Long viewCount,
String category,
LocalDateTime createdAt,
String image
) {
}
Loading

0 comments on commit 295d318

Please sign in to comment.