Skip to content

Commit

Permalink
Merge pull request #38 from olmangjolmang/OMJM-100-fix-subscription
Browse files Browse the repository at this point in the history
구독하기 이메일과 닉네임 삭제
  • Loading branch information
Amepistheo authored Jul 18, 2024
2 parents db8f088 + 136af40 commit face3b2
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 68 deletions.
28 changes: 0 additions & 28 deletions src/main/java/com/ticle/server/home/controller/HomeController.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.ticle.server.global.dto.ResponseTemplate;
import com.ticle.server.home.dto.request.SubscriptionRequest;
import com.ticle.server.home.dto.request.ValidEmailRequest;
import com.ticle.server.home.dto.request.ValidateNickNameRequest;
import com.ticle.server.home.service.HomeService;
import com.ticle.server.user.service.CustomUserDetails;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -28,32 +26,6 @@ public class HomeController {

private final HomeService homeService;

@Operation(summary = "이메일 검증", description = "이메일 유효성 검증 <br>" +
"가입되어 있는 이메일이라면 true, 가입되지 않은 이메일이라면 false를 반환합니다.")
@PostMapping("/validate/email")
public ResponseEntity<ResponseTemplate<Object>> validateEmail(
@RequestBody ValidEmailRequest request) {

Boolean response = homeService.validateEmail(request);

return ResponseEntity
.status(HttpStatus.OK)
.body(ResponseTemplate.from(response));
}

@Operation(summary = "닉네임 검증", description = "닉네임 유효성 검증 <br> " +
"가입되어 있는 닉네임이라면 true, 가입되지 않은 닉네임이라면 false를 반환합니다.")
@PostMapping("/validate/nickname")
public ResponseEntity<ResponseTemplate<Object>> validateNickname(
@RequestBody ValidateNickNameRequest request) {

Boolean response = homeService.validateNickName(request);

return ResponseEntity
.status(HttpStatus.OK)
.body(ResponseTemplate.from(response));
}

@Operation(summary = "구독하기 등록", description = "아티클을 주기적으로 받을 수 있는 구독하기 등록합니다.")
@PostMapping("/subscription")
public ResponseEntity<ResponseTemplate<Object>> uploadSubscription(
Expand Down
10 changes: 1 addition & 9 deletions src/main/java/com/ticle/server/home/domain/Subscription.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public class Subscription extends BaseTimeEntity {
@Column(name = "subs_id")
private Long subsId;

@Column(name = "email")
private String email;

@Column(name = "nick_name")
private String nickName;

@Column(name = "agree_info")
private Boolean agreeInfo;

Expand All @@ -41,9 +35,7 @@ public class Subscription extends BaseTimeEntity {
private User user;

@Builder
public Subscription(String email, String nickName, Boolean agreeInfo, Boolean agreeMarketing, Day subsDay, User user) {
this.email = email;
this.nickName = nickName;
public Subscription(Boolean agreeInfo, Boolean agreeMarketing, Day subsDay, User user) {
this.agreeInfo = agreeInfo;
this.agreeMarketing = agreeMarketing;
this.subsDay = subsDay;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@
import com.ticle.server.home.domain.Subscription;
import com.ticle.server.home.domain.type.Day;
import com.ticle.server.user.domain.User;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotNull;

public record SubscriptionRequest(
@NotNull(message = "이메일을 입력해주세요.")
@Email(message = "이메일 형식에 맞게 입력해주세요.")
String email,
@NotNull(message = "닉네임을 입력해주세요.")
String nickName,
@NotNull(message = "요일을 선택해주세요.")
Day subsDay,
@NotNull(message = "정보 수신 동의 여부를 선택해주세요.")
Expand All @@ -21,8 +15,6 @@ public record SubscriptionRequest(
public Subscription toSubscription(User user) {
return Subscription
.builder()
.email(email)
.nickName(nickName)
.subsDay(subsDay)
.agreeInfo(agreeInfo)
.agreeMarketing(agreeMarketing)
Expand Down

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions src/main/java/com/ticle/server/home/service/HomeService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import com.ticle.server.home.domain.Subscription;
import com.ticle.server.home.dto.request.SubscriptionRequest;
import com.ticle.server.home.dto.request.ValidEmailRequest;
import com.ticle.server.home.dto.request.ValidateNickNameRequest;
import com.ticle.server.home.repository.SubscriptionRepository;
import com.ticle.server.user.domain.User;
import com.ticle.server.user.exception.UserNotFoundException;
Expand All @@ -25,14 +23,6 @@ public class HomeService {
private final UserRepository userRepository;
private final SubscriptionRepository subscriptionRepository;

public Boolean validateEmail(ValidEmailRequest request) {
return userRepository.existsByEmail(request.email());
}

public Boolean validateNickName(ValidateNickNameRequest request) {
return userRepository.existsByNickName(request.nickName());
}

@Transactional
public void uploadSubscription(SubscriptionRequest request, CustomUserDetails userDetails) {
User user = userRepository.findById(userDetails.getUserId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void sendWeeklyPosts() {
Post topPost = postRepository.findTopPostByCategory(subscription.getUser().getCategory())
.orElseThrow(() -> new PostNotFoundException(POST_NOT_FOUND));

emailService.sendEmail(subscription.getEmail(), topPost);
emailService.sendEmail(subscription.getUser().getEmail(), topPost);
}
}
}

0 comments on commit face3b2

Please sign in to comment.