Skip to content

Commit

Permalink
Merge pull request #34 from Team-UniVoice/feat/#33-fix-with-validation
Browse files Browse the repository at this point in the history
Feat/#33 fix with validation
  • Loading branch information
softmoca authored Jul 14, 2024
2 parents f8e0185 + 4b49220 commit b6a375c
Show file tree
Hide file tree
Showing 17 changed files with 173 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Affiliation extends BaseTimeEntity {

private String affiliationLogoImage;

private String affiliationUniversityName;

@OneToMany(mappedBy = "affiliation", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Member> members;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
import org.springframework.data.jpa.repository.JpaRepository;
import sopt.univoice.domain.affiliation.entity.Affiliation;

public interface AffiliationRepository extends JpaRepository<Affiliation, Integer> {
public interface AffiliationRepository extends JpaRepository<Affiliation, Long> {
Affiliation findByAffiliationAndAffiliationUniversityName(String affiliation, String affiliationUniversityName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ public ResponseEntity<SuccessStatusResponse<Void>> checkEmail(@RequestBody Check


@PostMapping("/signin")
public ResponseEntity<UserLoginResponse> signIn(@RequestBody MemberSignInRequest memberSignInRequest) {
public ResponseEntity<SuccessStatusResponse<UserLoginResponse>>signIn(@RequestBody MemberSignInRequest memberSignInRequest) {

UserLoginResponse userLoginResponse = authService.logineMember(memberSignInRequest);

return ResponseEntity.status(HttpStatus.CREATED)
.header("Location", userLoginResponse.userId())
.body(
userLoginResponse
);
return ResponseEntity.status(HttpStatus.OK)
.body(SuccessStatusResponse.of(SuccessMessage.SIGNIN_SUCCESS, userLoginResponse));
}

@PostMapping("/signup")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package sopt.univoice.domain.auth.dto;

public record UserLoginResponse(
String accessToken,
String userId
String accessToken
) {

public static UserLoginResponse of(
String accessToken,
String userId
String accessToken
) {
return new UserLoginResponse(accessToken, userId);
return new UserLoginResponse(accessToken);
}
}
10 changes: 2 additions & 8 deletions src/main/java/sopt/univoice/domain/auth/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public UserLoginResponse logineMember(
.orElseThrow(() -> new UnauthorizedException(ErrorMessage.JWT_UNAUTHORIZED_EXCEPTION));

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

Long memberId = member.getId();
Expand All @@ -219,13 +219,7 @@ public UserLoginResponse logineMember(
UserAuthentication.createUserAuthentication(memberId, authorities)
);

return UserLoginResponse.of(accessToken, memberId.toString());
return UserLoginResponse.of(accessToken);
}







}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public ResponseEntity<SuccessStatusResponse<Object>> viewCount(@PathVariable Lon
public ResponseEntity<SuccessStatusResponse<Object>> quickhead() {
QuickScanDTO response = noticeService.quickhead();
return ResponseEntity.status(HttpStatus.OK)
.body(SuccessStatusResponse.of(SuccessMessage.GET_ALL_NOTICE_SUCCESS, response));
.body(SuccessStatusResponse.of(SuccessMessage.GET_QUCIK_HEAD_SUCCESS, response));
}

@GetMapping("/all")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public class NoticeCreateRequest {
@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)
private LocalDateTime endTime;

private List<MultipartFile> studentCardImages;
private List<MultipartFile> noticeImages;

}
7 changes: 7 additions & 0 deletions src/main/java/sopt/univoice/domain/notice/dto/NoticeDTO.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,11 @@ public class NoticeDTO {
private Long likeCount;
private Long saveCount;
private String category;
private LocalDateTime createdAt; // 추가된 부분
private LocalDateTime updatedAt; // 추가된 부분

public LocalDateTime getCreatedAt() {
return createdAt;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ public class NoticeDetailResponseDTO {
private Long memberId;
private String writeAffiliation;
private List<String> noticeImages;
private LocalDateTime createdAt; // 추가된 부분
private LocalDateTime updatedAt; // 추가된 부분
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ public class NoticeResponseDTO {
private Long likeCount;
private Long saveCount;
private String category;
private LocalDateTime createdAt; // 추가된 부분
private LocalDateTime updatedAt; // 추가된 부분
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ public class NoticeSaveDTO {
private String category;
private LocalDateTime startTime;
private LocalDateTime endTime;
private LocalDateTime createdAt; // 추가된 부분
private LocalDateTime updatedAt; // 추가된 부분
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ public class QuickQueryNoticeDTO {
private Long likeCount;
private Long saveCount;
private String category;
private LocalDateTime createdAt; // 추가된 부분
private LocalDateTime updatedAt; // 추가된 부분
}

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@
public class QuickScanDTO {
private String universityName;
private int universityNameCount;
private String universityLogoImage;


private String collegeDepartmentName;
private int collegeDepartmentCount;
private String collegeDepartmentLogoImage;

private String departmentName;
private int departmentCount;
private String departmentLogoImage;
}

Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import sopt.univoice.domain.user.entity.Member;
import sopt.univoice.infra.persistence.BaseTimeEntity;


@Entity
@Getter
@NoArgsConstructor
public class SaveNotice {
public class SaveNotice extends BaseTimeEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
Expand Down
Loading

0 comments on commit b6a375c

Please sign in to comment.