Skip to content

Commit

Permalink
Merge pull request #167 from stoneHee99/main
Browse files Browse the repository at this point in the history
style: add style for home page
  • Loading branch information
c0olcode authored Nov 21, 2023
2 parents cd26377 + 26e778f commit db1654a
Show file tree
Hide file tree
Showing 12 changed files with 183 additions and 121 deletions.
4 changes: 3 additions & 1 deletion src/main/java/kr/kernel/teachme/common/aop/LogAspect.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public class LogAspect {

@Pointcut("within(kr.kernel.teachme.domain.crawler.controller.*) || " +
"within(kr.kernel.teachme.domain.lecture.controller.*) || " +
"within(kr.kernel.teachme.domain.member.controller.*)")
"within(kr.kernel.teachme.domain.member.controller.*) || " +
"within(kr.kernel.teachme.domain.report.controller.*) || " +
"within(kr.kernel.teachme.domain.review.controller.*)")
public void controller(){

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kr.kernel.teachme.domain.lecture.controller;

import io.swagger.annotations.ApiOperation;
import kr.kernel.teachme.domain.lecture.dto.PaginationResponse;
import kr.kernel.teachme.domain.lecture.dto.SearchRequest;
import kr.kernel.teachme.domain.lecture.entity.Lecture;
import kr.kernel.teachme.domain.lecture.service.LectureService;
Expand All @@ -10,7 +9,6 @@
import kr.kernel.teachme.domain.review.entity.Review;
import kr.kernel.teachme.domain.review.service.ReviewService;
import lombok.RequiredArgsConstructor;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
Expand All @@ -20,7 +18,6 @@
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Optional;

@RequiredArgsConstructor
Expand All @@ -36,7 +33,7 @@ public class LectureController {
@GetMapping("/list")
public String showLectureList(@RequestParam(defaultValue = "1") int page, Model model, @ModelAttribute SearchRequest search) {
Pageable pageable = PageRequest.of(page -1, 10, Sort.Direction.DESC, "id");
PaginationResponse<List<Lecture>> lectureApiList = lectureService.searchList(pageable, search);
Page<Lecture> lectureApiList = lectureService.searchList(pageable, search);
model.addAttribute("lecturePage", lectureApiList);
return "lecture/list";
}
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/kr/kernel/teachme/domain/lecture/dto/Pagination.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package kr.kernel.teachme.domain.lecture.service;

import kr.kernel.teachme.domain.lecture.dto.PaginationResponse;
import kr.kernel.teachme.domain.lecture.dto.SearchRequest;
import kr.kernel.teachme.domain.lecture.entity.Lecture;
import kr.kernel.teachme.domain.lecture.dto.Pagination;

import kr.kernel.teachme.domain.lecture.repository.LectureRepository;
import lombok.RequiredArgsConstructor;
Expand All @@ -25,32 +23,15 @@ public List<Lecture> getLatestLectures() {
return lectureRepository.findByOrderByIdDesc(PageRequest.of(0, 12));
}

public PaginationResponse<List<Lecture>> searchList(Pageable pageable, SearchRequest search) {
Page<Lecture> page = findLectures(pageable, search);
Pagination pagination = createPagination(page);
return buildPaginationResponse(page, pagination);
public Page<Lecture> searchList(Pageable pageable, SearchRequest search) {
return findLectures(pageable, search);
}

private Page<Lecture> findLectures(Pageable pageable, SearchRequest searchRequest) {
return lectureRepository.findBySearchOption(pageable, searchRequest);
}

private Pagination createPagination(Page<Lecture> page) {
return Pagination.builder()
.page(page.getNumber())
.size(page.getSize())
.currentElements(page.getNumberOfElements())
.totalElements(page.getTotalElements())
.totalPage(page.getTotalPages())
.build();
}

private PaginationResponse<List<Lecture>> buildPaginationResponse(Page<Lecture> page, Pagination pagination) {
return PaginationResponse.<List<Lecture>>builder()
.body(page.getContent())
.pagination(pagination)
.build();
}

public Optional<Lecture> getLectureDetail(Long lectureId) {
return lectureRepository.findById(lectureId);
Expand Down
61 changes: 58 additions & 3 deletions src/main/resources/static/css/home.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@

#list-item-wrapper {
width: 383px;
margin: 0 auto;
margin-bottom: 200px;
margin: 0 auto 100px;
}

.list-item {
Expand All @@ -62,4 +61,60 @@
.list-item#on {
color: black;
font-size: 42px;
}
}

.emoji_area {
width: 80%;
margin: 0 auto;
}

.emoji_title {
display: inline-block;
}

.emoji_box {
display: inline-block;
margin: 0 10px;
}

.title_span {
font-weight: 900;
letter-spacing: -.05em;
line-height: 36px;
font-size: 21px;
text-decoration-line: underline;
position: relative;
bottom: 7px;
}

.mimoji_img {
width: 90px;
height: 90px;
}

.teach_me {
color: #007F48;
}

.mimoji_comment {
display: inline-block;
position: relative;
background: white;
border-radius: 10px;
padding: 10px;
width: 400px;
text-align: center;
margin-left: 5px;
}

.mimoji_comment .tail {
position: absolute;
left: -20px;
top: 10px;
width: 0;
height: 0;
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-right: 20px solid white;
}

33 changes: 23 additions & 10 deletions src/main/resources/static/js/home.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
const listStyleChangeStartY = 1300;
const listStyleChangeEndY = 2085;

const listItems = document.querySelectorAll(".list-item");
const listItemWrapper = document.getElementById("list-item-wrapper");



const division = (listStyleChangeEndY - listStyleChangeStartY) / listItems.length;
window.addEventListener("resize", setDynamicPositions);
window.addEventListener("scroll", handleScroll);

window.addEventListener("scroll", () => {
if(document.getElementById("on")) document.getElementById("on").removeAttribute("id");
function setDynamicPositions() {
const wrapperRect = listItemWrapper.getBoundingClientRect();
const windowHeight = window.innerHeight;

if(window.scrollY > listStyleChangeStartY && window.scrollY < listStyleChangeEndY) {
const targetIndex = Math.round((window.scrollY - listStyleChangeStartY) /division)
window.listStyleChangeStartY = wrapperRect.top + window.scrollY - (windowHeight / 2);
window.listStyleChangeEndY = wrapperRect.bottom + window.scrollY - (windowHeight / 2);
}

if(listItems[targetIndex]) listItems[targetIndex].id = "on";
function handleScroll() {
if (document.getElementById("on")) document.getElementById("on").removeAttribute("id");

if (window.scrollY > window.listStyleChangeStartY && window.scrollY < window.listStyleChangeEndY) {
const division = (window.listStyleChangeEndY - window.listStyleChangeStartY) / listItems.length;
const targetIndex = Math.round((window.scrollY - window.listStyleChangeStartY) / division);

if (listItems[targetIndex]) listItems[targetIndex].id = "on";
}
})
}

// 최초 로드 시 위치 설정
setDynamicPositions();
42 changes: 37 additions & 5 deletions src/main/resources/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,43 @@
<li class="list-item">🙀Github actions</li>
<li class="list-item">🕸️kubernatis</li>
</ul>
<main>
<section>

</section>
</main>
<div class="emoji_area">
<h1 class="emoji_title">👀</h1>
<span class="title_span">솔직후기</span>
<h1 style="font-size: calc(1rem + 1.3vw); font-weight: bolder"><b class="teach_me">티치미</b>를 경험한 사람들의 반응은?</h1>
</div>
<div style="width: 90%; margin: 10px auto 0 auto; text-align: center;">
<div class="emoji_box">
<img class="mimoji_img" alt="mimoji" src="https://mblogthumb-phinf.pstatic.net/MjAyMTA4MDFfMjIx/MDAxNjI3ODE1MTkyMjI2.MttKEaAXsLAtJbii9P-5OGX06s6-uVzMSVa6Db7D96gg.qITLHjb_-CZGx0pt3JXbKybmOaY54vrI1tqO7qP7mscg.PNG.brotherm1n/IMG_3219.PNG?type=w800">
<div class="mimoji_comment">
<div class="tail"></div>
<span>어떤 강의를 선택해야할 지 알 수 있었어요!</span>
</div>
</div>
<div class="emoji_box">
<img class="mimoji_img" alt="mimoji" src="https://images.velog.io/images/chang626/post/c9533c4f-adbb-4411-bce4-b09293d64fbf/A03EACB4-4DFA-439A-A3FE-084635A89FE6.png">
<div class="mimoji_comment">
<div class="tail"></div>
<span>1분당 가격을 확인해서 가성비 좋은 강의를 듣고 있어요</span>
</div>
</div>
</div>
<div style="width: 90%; margin: 10px auto 150px auto; text-align: center;">
<div class="emoji_box">
<img class="mimoji_img" alt="mimoji" src="https://www.techm.kr/news/photo/202107/86116_89524_203.png">
<div class="mimoji_comment">
<div class="tail"></div>
<span>여러 리뷰를 보고 강의를 고르는데 도움을 받았어요</span>
</div>
</div>
<div class="emoji_box">
<img class="mimoji_img" alt="mimoji" src="https://openads-real.s3.amazonaws.com/openadsAdmin/ckeditor/images/14_%EC%9D%B4%EB%AA%A8%ED%8B%B0%EC%BD%98.png">
<div class="mimoji_comment">
<div class="tail"></div>
<span>좋은 강의를 선택해서 결국 취업까지 달성할 수 있었어요!</span>
</div>
</div>
</div>
<script th:src="@{/js/home.js}"></script>
</div>
</body>
Expand Down
14 changes: 7 additions & 7 deletions src/main/resources/templates/lecture/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
</tr>
</thead>
<tbody>
<tr th:if="${#lists.size(lecturePage.body) == 0}">
<tr th:if="${#lists.size(lecturePage) == 0}">
<td colspan="7">검색된 강의가 없습니다.🥲</td>
</tr>
<tr th:each="lecture : ${lecturePage.body}">
<tr th:each="lecture : ${lecturePage}">
<td><img th:src="${lecture.img}" style="width: 150px; height: 90px; border-radius: 10px;" alt="..."></td>
<td style="max-width: 200px;"><a class="lecture_title" th:href="@{|/lecture/${lecture.id}|}" th:text="${lecture.title}" style="font-weight: bolder; font-size: 13px;"></a></td>
<td style="max-width: 130px;">
Expand Down Expand Up @@ -88,16 +88,16 @@
</table>
<nav aria-label="Page navigation example" style="width: 80%; margin: 0 auto; margin-top:50px; ">
<ul class="pagination" style="justify-content: center;">
<li class="page-item" th:classappend="${(lecturePage.pagination.page == 0) ? 'disabled': ''}">
<a class="page-link" th:href="@{/lecture/list(page=${lecturePage.pagination.page}, searchFilter=${param.searchFilter}, searchSort=${param.searchSort}, searchSelect=${param.searchSelect}, searchInput=${param.searchInput})}" aria-label="Previous">
<li class="page-item" th:classappend="${lecturePage.hasPrevious() ? '': 'disabled'}">
<a class="page-link" th:href="@{/lecture/list(page=${lecturePage.number}, searchFilter=${param.searchFilter}, searchSort=${param.searchSort}, searchSelect=${param.searchSelect}, searchInput=${param.searchInput})}" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
</a>
</li>
<li class="page-item active">
<a class="page-link" th:href="@{/lecture/list(page=${lecturePage.pagination.page + 1})}" th:text="${lecturePage.pagination.page + 1}"></a>
<a class="page-link" th:href="@{/lecture/list(page=${lecturePage.number + 1})}" th:text="${lecturePage.number + 1}"></a>
</li>
<li class="page-item" th:classappend="${!(lecturePage.pagination.page + 1 == lecturePage.pagination.totalPage) && (lecturePage.pagination.totalPage != 0) ? '': 'disabled'}">
<a class="page-link" th:href="@{/lecture/list(page=${lecturePage.pagination.page + 2}, searchFilter=${param.searchFilter}, searchSort=${param.searchSort}, searchSelect=${param.searchSelect}, searchInput=${param.searchInput})}" aria-label="Next">
<li class="page-item" th:classappend="${lecturePage.hasNext() ? '': 'disabled'}">
<a class="page-link" th:href="@{/lecture/list(page=${lecturePage.number + 2}, searchFilter=${param.searchFilter}, searchSort=${param.searchSort}, searchSelect=${param.searchSelect}, searchInput=${param.searchInput})}" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package kr.kernel.teachme.common.exception;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class AlreadyRegisteredMemberExceptionTest {

@Test
void testExceptionWithCustomMessage() {
String customMessage = "Custom error message";
AlreadyRegisteredMemberException exception = new AlreadyRegisteredMemberException(customMessage);

assertEquals(customMessage, exception.getMessage());
}

@Test
void testExceptionWithDefaultMessage() {
AlreadyRegisteredMemberException exception = new AlreadyRegisteredMemberException();

assertEquals("이미 등록된 유저입니다.", exception.getMessage());
}
}
Loading

0 comments on commit db1654a

Please sign in to comment.