Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPS-121] 어드민 API 추가 #114

Merged
merged 11 commits into from
Mar 24, 2025
Prev Previous commit
Next Next commit
feat: 암장 난이도 개수 표시 view 추가
  • Loading branch information
big-cir committed Mar 22, 2025
commit 4fb343dcad62ccc046754372bbcf7311e809dcaf
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ class AdminService(
private val gradeAdminRepository: GradeAdminRepository
) {

fun getAllCrag(): List<Crag> {
return cragAdminRepository.findAll()
fun getAllCrag(): List<CragResult.WithGradeCount> {
return cragAdminRepository.findAll().map { crag ->
val gradeCount = gradeAdminRepository.findByCrag(crag).size
CragResult.WithGradeCount(
cragResult = CragResult.from(crag),
gradeCount = gradeCount
)
}
}

fun createCrag(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ data class CragResult(
)
}
}

data class WithGradeCount(
val cragResult: CragResult,
val gradeCount: Int
)
}
33 changes: 5 additions & 28 deletions clog-admin/src/main/resources/templates/admin/cragList.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h1 class="h3 mb-2 text-gray-800">암장 관리</h1>
<th>암장 ID</th>
<th>암장 이름</th>
<th>도로명 주소</th>
<th>난이도 개수</th>
<!-- <th>경도</th>-->
<!-- <th>위도</th>-->
<!-- <th>카카오 맵 ID</th>-->
Expand All @@ -57,10 +58,11 @@ <h1 class="h3 mb-2 text-gray-800">암장 관리</h1>
<tbody>
<tr th:each="crag : ${crags}">
<td>
<a th:href="@{/admin/crags/{id}/details(id=${crag.id})}" th:text="${crag.id}"></a>
<a th:href="@{/admin/crags/{id}/details(id=${crag.cragResult.id})}" th:text="${crag.cragResult.id}"></a>
</td>
<td th:text="${crag.name}"></td>
<td th:text="${crag.roadAddress}"></td>
<td th:text="${crag.cragResult.name}"></td>
<td th:text="${crag.cragResult.roadAddress}"></td>
<td th:text="${crag.gradeCount}"></td>
<!-- <td th:text="${crag.coordinate.latitude}"></td>-->
<!-- <td th:text="${crag.coordinate.longitude}"></td>-->
<!-- <td th:text="${crag.kakaoPlaceId}"></td>-->
Expand Down Expand Up @@ -93,30 +95,5 @@ <h1 class="h3 mb-2 text-gray-800">암장 관리</h1>
</a>
<th:block th:replace="~{fragments/admin/fragments.html :: admJS}"/>

<script th:src="@{/webjars/jquery/jquery.min.js}"></script>
<script th:src="@{/webjars/datatables/js/jquery.dataTables.min.js}"></script>

<script>
$(document).ready(function() {
$('#dataTable').DataTable({
"processing": true,
"serverSide": true,
"ajax": {
"url": "/admin/index",
"type": "GET",
"data": function (d) {
d.page = d.start / d.length; // DataTables가 요청하는 page 계산
d.size = d.length; // DataTables가 요청하는 size
}
},
"columns": [
{ "data": "id" },
{ "data": "name" },
{ "data": "roadAddress" }
]
});
});
</script>

</body>
</html>