Skip to content

Commit

Permalink
Merge pull request #42 from kanghanju/develop
Browse files Browse the repository at this point in the history
fix: modify header
  • Loading branch information
dhktjr0204 authored Mar 20, 2024
2 parents 0c9b210 + 7988a74 commit 7bdbd71
Show file tree
Hide file tree
Showing 21 changed files with 983 additions and 684 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

@Controller
public class AlgorithmController {

@GetMapping("/doumiAlgorithm")
@Operation(summary = "알고리즘 메인 페이지를 조회할 수 있는 API")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "알고리즘 메인 HTML을 반환",
content = @Content(mediaType = "text/html"))
@ApiResponse(responseCode = "200", description = "알고리즘 메인 HTML을 반환",
content = @Content(mediaType = "text/html"))
})
public String index() {

Expand All @@ -29,7 +30,17 @@ public String timecomplexity() {
}

@GetMapping("/codingtest/stack")
public String stack(){
public String stack() {
return "algorithm/stackAndQueue";
}

// @GetMapping("/codingtest/bruteforce")
// public String bruteforce() {
// return "algorithm/bruteforce";
// }

@GetMapping("/codingtest/sets&maps")
public String setsAndMaps() {
return "algorithm/setsAndMaps";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.example.doumiproject.dto.PostDto;
import com.example.doumiproject.entity.Comment;
import com.example.doumiproject.entity.User;
import com.example.doumiproject.exception.user.NotValidateUserException;
import com.example.doumiproject.service.CodingTestService;
import com.example.doumiproject.service.CommentService;
import com.example.doumiproject.service.QuizService;
Expand Down Expand Up @@ -31,6 +32,7 @@
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -158,7 +160,7 @@ public String myPage(@PathVariable("userId") Long userId, HttpSession session, M
content = @Content(mediaType = "text/html"))
})
public String getCodingTestPost(@PathVariable("userId") Long userId, HttpSession session,
@RequestParam(defaultValue = "1", value = "page") int page, Model model) {
@RequestParam(defaultValue = "1", value = "page") int page, Model model) {
int totalPages = codingTestService.getTotalPagesForMyPage(userId, "COTE", pageSize);

List<PostDto> userCoteList = codingTestService.findByUserId(userId, page, pageSize);
Expand All @@ -175,7 +177,7 @@ public String getCodingTestPost(@PathVariable("userId") Long userId, HttpSession
content = @Content(mediaType = "text/html"))
})
public String getQuizPost(@PathVariable("userId") Long userId, HttpSession session,
@RequestParam(defaultValue = "1", value = "page") int page, Model model) {
@RequestParam(defaultValue = "1", value = "page") int page, Model model) {

int totalPages = quizService.getTotalPagesForMyPage(userId, "QUIZ", pageSize);

Expand All @@ -193,7 +195,7 @@ public String getQuizPost(@PathVariable("userId") Long userId, HttpSession sessi
content = @Content(mediaType = "text/html"))
})
public String getCommentPost(@PathVariable("userId") Long userId, HttpSession session,
@RequestParam(defaultValue = "1", value = "page") int page, Model model) {
@RequestParam(defaultValue = "1", value = "page") int page, Model model) {

int totalPages = commentService.getTotalPagesForMyPage(userId, pageSize);

Expand All @@ -204,7 +206,8 @@ public String getCommentPost(@PathVariable("userId") Long userId, HttpSession se
return "myPage/myPageComment";
}

private void setPaginationAttributes(Model model, int page, int totalPages, Long userId, List<?> contents) {
private void setPaginationAttributes(Model model, int page, int totalPages, Long userId,
List<?> contents) {

if (page < 1) {
page = 1;
Expand All @@ -220,4 +223,17 @@ private void setPaginationAttributes(Model model, int page, int totalPages, Long
model.addAttribute("totalPages", totalPages);
model.addAttribute("userId", userId);
}

@DeleteMapping("/user/{id}/delete")
public ResponseEntity<Void> withdraw(@PathVariable Long id, HttpSession session) {
long userId = (long) session.getAttribute("userId");

if (userId != id) {
throw new NotValidateUserException();
}

userService.deleteUser(userId);

return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public User findByUserId(String userId) {
public List<User> findAllUser() {
return null;
}

@Override
public List<Comment> findAllUserCommentPosts(Long userId) {
String sql = "SELECT user_id,post_id,type,contents,updated_at FROM comment WHERE user_id = ?";
Expand All @@ -77,4 +77,11 @@ public List<Comment> findAllUserCommentPosts(Long userId) {
});
}

@Override
public void deleteUser(Long userId) {
String sql = "DELETE FROM user WHERE id = ?";

jdbcTemplate.update(sql, userId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,7 @@ default RowMapper<User> userRowMapper() {
return user;
});
}
}

void deleteUser(Long userId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ public List<Comment> getAllUserCommentPosts(Long userId) {
List<Comment> userCommentPosts = userRepository.findAllUserCommentPosts(userId);
return userCommentPosts;
}


public void deleteUser(Long userId) {
userRepository.deleteUser(userId);
}
}
82 changes: 25 additions & 57 deletions src/main/resources/static/Js/myPage.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,29 @@
function clickToGoMyCodingtestPost() {
let id = document.getElementById('myPage_userName').getAttribute(
'data-userid');
switchHighlight('coteType');
$.ajax({
//JS에 백틱을 써서 템플릿 리터럴을 사용했다
url: `/user/${id}/codingtest/posts`,
type: "GET",
success: function (data) {
$('.show_user_wrote .table_container .postList').html(data);
console.log(data);
},
error: function (error) {
console.log(error);
}
});
}

function clickToGoMyQuizPost() {
let id = document.getElementById('myPage_userName').getAttribute(
'data-userid');
switchHighlight('quizType');
$.ajax({
url: `/user/${id}/quiz/posts`,
type: "GET",
success: function (data) {
$('.show_user_wrote .table_container .postList').html(data);
console.log(data);
},
error: function (error) {
console.log(error);
}
});
}
function clickToGoLeaveMembership(event) {
event.preventDefault();

function clickToGoMyCommentPost() {
let id = document.getElementById('myPage_userName').getAttribute(
'data-userid');
switchHighlight('commentType');
$.ajax({
url: `/user/${id}/comment/posts`,
type: "GET",
success: function (data) {
$('.show_user_wrote .table_container .postList').html(data);
console.log(data);
},
error: function (error) {
console.log(error);
}
});
}
const isConfirmed = confirm("Bend Doumi에서 탈퇴하시겠습니까?");

function switchHighlight(selectedId) {
let items = ['coteType', 'quizType', 'commentType'];
if (isConfirmed) {
// 사용자 ID 가져오기
let id = document.getElementById('myPage_userName').getAttribute(
'data-userid');

items.forEach(function (id) {
document.getElementById(id).style.color = ''; // 원래 색상으로 초기화
});

document.getElementById(selectedId).style.color = '#04B45F';
fetch(`/user/${id}/delete`, {
method: 'DELETE',
})
.then(response => {
if (response.ok) {
alert("탈퇴 처리가 완료되었습니다.");
window.location.replace('/user/login');
} else {
alert("탈퇴 처리 중 오류가 발생했습니다.");
}
})
.catch(error => {
console.error('탈퇴 요청 실패:', error);
alert("탈퇴 처리 중 문제가 발생했습니다.");
});
} else {
alert("탈퇴 절차가 취소되었습니다.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ body {

/*header 파트*/
.move_to_algorithm {
/*color: #04B45F;*/
color: #04B45F;
}


Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/static/css/codingtest/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ body {
}

/*header 파트*/
.move_to_algorithm {
/*color: #04B45F*/
.move_to_codingtest {
color: #04B45F
}

/*main 파트*/
Expand Down
50 changes: 25 additions & 25 deletions src/main/resources/static/css/fragments/footer.css
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
html,
body {
height: 100%;
min-height: 100vh;
}

body {
display: flex;
flex-direction: column;
display: flex;
flex-direction: column;
}

main {
flex: 1;
width: 100%;
flex: 1;
width: 100%;
}

footer{
width: 100%;
padding: 70px 0 40px 0;
/*border-top: 1px solid #C4C4C4;*/
footer {
width: 100%;
padding: 70px 0 40px 0;
/*border-top: 1px solid #C4C4C4;*/
}

.footer-wrapper{
display: flex;
justify-content: space-between;
max-width: 900px;
margin: 0 auto;
.footer-wrapper {
display: flex;
justify-content: space-between;
max-width: 900px;
margin: 0 auto;
}

.boot-camp-info{
font-size: 13px;
font-weight: 500;
display: flex;
align-items: center;
.boot-camp-info {
font-size: 13px;
font-weight: 500;
display: flex;
align-items: center;
}

.footer-img{
width: 40px;
.footer-img {
width: 40px;
}

.helper{
font-size: 13px;
display: flex;
align-items: center;
.helper {
font-size: 13px;
display: flex;
align-items: center;
}
22 changes: 22 additions & 0 deletions src/main/resources/static/css/myPage.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,28 @@ body {
cursor: pointer;
}

.user_delete_btn {
padding: 10px;
font-size: 1rem;
line-height: 1.5;
color: #363636;
cursor: pointer;
text-align: center;
background-color: #FFFFFF;
border: 1px solid #dbdbdb;
border-radius: 10px;
}

.user_delete_btn {
color: #FFFFFF;
background-color: #04B45F;
}

.user_delete_btn:hover {
background-color: #04B45F;
filter: brightness(90%);
}

/*게시판*/
.show_user_wrote {
padding: 1.0rem 0.75rem;
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/static/css/quiz/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ body {

/*header 파트*/
.move_to_quiz {
/*color: #04B45F*/
color: #04B45F
}

/*main 파트*/
Expand Down Expand Up @@ -106,7 +106,7 @@ body {
.title {
width: 40%;
margin-right: 10px;

white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/algorithm/bruteforce.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ <h3>브루트 포스는 알고리즘을 배우는 초기 단계에서 매우 유
</div>
</section>
</main>
<script src="../../static/Js/header.js" th:src="@{/Js/header.js}"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</body>
Expand Down
Loading

0 comments on commit 7bdbd71

Please sign in to comment.