Skip to content

Commit

Permalink
๐Ÿ› Fix: ํ‹ฐํด ๋ฌธ๋‹ต ๋ฒ„๊ทธ ์ˆ˜์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
lej8924 committed Jul 22, 2024
1 parent 3ce6f4a commit 8e41733
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class QuestionController {

@Operation(summary = "ํ‹ฐํด๋ฌธ๋‹ต",description = "Jwt token์„ ํ†ตํ•ด userId๋ฅผ ๊ฐ€์ ธ์˜จ ํ›„ ํ‹ฐํด๋ฌธ๋‹ต์˜ ์งˆ๋ฌธ๋“ค์„ ๊ฐ€์ ธ์˜ด")
@GetMapping("/my-question")
public ResponseEntity<ResponseTemplate<Object>> getMyQuestions(@AuthenticationPrincipal CustomUserDetails customUserDetails, @PageableDefault(page=0,size=9,sort="created_date",direction = Sort.Direction.DESC) Pageable pageable){
public ResponseEntity<ResponseTemplate<Object>> getMyQuestions(@AuthenticationPrincipal CustomUserDetails customUserDetails, @PageableDefault(page=0,size=9,sort="createdDate",direction = Sort.Direction.DESC) Pageable pageable){

Long userId = customUserDetails.getUserId();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.ticle.server.global.dto.ResponseTemplate;
import com.ticle.server.mypage.dto.response.SavedTicleResponse;
import com.ticle.server.mypage.service.MyPageService;
import com.ticle.server.scrapped.domain.Scrapped;
import com.ticle.server.scrapped.dto.ScrappedDto;
import com.ticle.server.user.domain.type.Category;
import com.ticle.server.user.jwt.CustomUserDetails;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -14,10 +16,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

import java.util.List;

Expand Down Expand Up @@ -46,4 +45,5 @@ public ResponseEntity<ResponseTemplate<Object>> getSavedTicles(@AuthenticationPr
}



}
17 changes: 14 additions & 3 deletions src/main/java/com/ticle/server/mypage/service/MyPageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import com.ticle.server.scrapped.domain.Scrapped;
import com.ticle.server.opinion.domain.Opinion;
import com.ticle.server.user.domain.type.Category;
import com.ticle.server.user.exception.UserNotFoundException;
import com.ticle.server.user.exception.errorcode.UserErrorCode;
import com.ticle.server.user.repository.UserRepository;
import com.ticle.server.user.jwt.CustomUserDetails;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -46,7 +48,12 @@ public List<SavedTicleResponse> getSavedArticles(CustomUserDetails customUserDet
// Pageable pageable = PageRequest.of(page-1,SIZE);
log.info("Pageable: page={}, size={}, sort={}", pageable.getPageNumber(), pageable.getPageSize(), pageable.getSort());

Long userId = customUserDetails.getUserId();
Long userId;
try{
userId = customUserDetails.getUserId();
}catch (UserNotFoundException e){
throw new UserNotFoundException(UserErrorCode.USER_NOT_FOUND);
}
Page<Scrapped> scraps = scrappedRepository.findByUserId(userId,pageable);

return scraps.stream()
Expand All @@ -57,8 +64,12 @@ public List<SavedTicleResponse> getSavedArticles(CustomUserDetails customUserDet
public List<SavedTicleResponse> getSavedArticlesByCategory(CustomUserDetails customUserDetails, Category category, Pageable pageable) {
// Pageable pageable = PageRequest.of(page-1,SIZE);
log.info("Pageable: page={}, size={}, sort={}", pageable.getPageNumber(), pageable.getPageSize(), pageable.getSort());

Long userId = customUserDetails.getUserId();
Long userId;
try{
userId = customUserDetails.getUserId();
}catch (UserNotFoundException e){
throw new UserNotFoundException(UserErrorCode.USER_NOT_FOUND);
}
Page<Scrapped> scraps = scrappedRepository.findByUserIdAndPostCategory(userId, category,pageable);

return scraps.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class EmailController {
private final EmailService emailService;

@Operation(summary = "์ด๋ฉ”์ผ ์ธ์ฆ", description = "์ด๋ฉ”์ผ ์ธ์ฆ์ฝ”๋“œ")
@PostMapping("/emailSend")
@PostMapping("/email-send")
public String mailConfirm(@RequestParam(value = "email", required = false) String email) throws Exception{
String code = emailService.sendSimpleMessage(email);
return code;
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/com/ticle/server/user/service/EmailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,29 @@ public void sendEmail(String email, Post topPost) {

private static String getContent(Post latestPost) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
String content = "<div style='margin:20px; background-color: lightblue;'>"
+ "<br>"
+ "<h1 style='color: white; text-align: center;'>์ƒˆ๋กœ์šด ์•„ํ‹ฐํด์„ ๋งŒ๋‚˜๋ณด์„ธ์š”!</h1>"
+ "<br>"
+ "<div align='center' style='font-family:verdana; color:black'>"
+ "<h2 style='text-align: center;'>" + latestPost.getTitle() + "</h2>"
+ "<p style='font-size: 15px; text-align: center;'>" + latestPost.getAuthor() + " | "
+ simpleDateFormat.format(latestPost.getCreatedDate())+ "</p>"
+ "<br>"
+ "<p style='font-size: 15px; text-align: center;'>" + latestPost.getContent() + "</p>";
String content = "<div style='margin:20px; padding:20px; background-color:#f9f9f9; border:1px solid #ddd; border-radius:10px;'>"
+ "<div style='text-align:center;'>"
+ "<h1 style='color:#333;'>์ƒˆ๋กœ์šด ์•„ํ‹ฐํด์„ ๋งŒ๋‚˜๋ณด์„ธ์š”!</h1>"
+ "</div>"
+ "<div style='text-align:center; font-family:Verdana, sans-serif; color:#333;'>"
+ "<h2 style='font-size:24px;'>" + latestPost.getTitle() + "</h2>"
+ "<p style='font-size:14px; color:#666;'>" + latestPost.getAuthor() + " | " + simpleDateFormat.format(latestPost.getCreatedDate()) + "</p>"
+ "<p style='font-size:16px; margin-top:20px;'>" + latestPost.getContent() + "</p>";

if (latestPost.getImage() != null) {
content += "<br>"
+ "<p style='font-size: 15px; text-align: center;'> <img src='" + latestPost.getImage().getImageUrl() + "' width='300'></p>";
content += "<div style='margin-top:20px;'>"
+ "<img src='" + latestPost.getImage().getImageUrl() + "' style='width:100%; max-width:500px; border-radius:10px;' alt='Article Image'>"
+ "</div>";
}

content += "<br>" + "<br>"
+ "<p style='font-size: 17px; text-align: center;'>"
+ "๋‹ค์–‘ํ•˜๊ณ  ์žฌ๋ฏธ์žˆ๋Š” ๊ธ€๊ณผ ์ธ์‚ฌ์ดํŠธ๋ฅผ ์–ป๊ณ  ์‹ถ๋‹ค๋ฉด " + "<span style='font-weight: bold;'>" + "ํ‹ฐํด" + "</span>"
+ "์„ ๋‹ค์‹œ ๋ฐฉ๋ฌธํ•ด์ฃผ์„ธ์š”!" + "</p>"
+ "<br>"
content += "<div style='margin-top:30px; text-align:center;'>"
+ "<p style='font-size:16px;'>"
+ "๋‹ค์–‘ํ•˜๊ณ  ์žฌ๋ฏธ์žˆ๋Š” ๊ธ€๊ณผ ์ธ์‚ฌ์ดํŠธ๋ฅผ ์–ป๊ณ  ์‹ถ๋‹ค๋ฉด <span style='font-weight:bold; color:#007BFF;'>ํ‹ฐํด</span>์„ ๋‹ค์‹œ ๋ฐฉ๋ฌธํ•ด์ฃผ์„ธ์š”!"
+ "</p>"
+ "</div>"
+ "</div>";

return content;
}

}

0 comments on commit 8e41733

Please sign in to comment.