월별, 임산물 sql에러 수정

This commit is contained in:
주우성
2025-06-14 20:25:19 +09:00
parent c909821d5b
commit 944b9475b1
5 changed files with 86 additions and 122 deletions

View File

@@ -3,7 +3,18 @@ package app.module.front.usecase.info.monthly.getMonthlysUI.adapters.web;
import app.module.core.config.application.util.CommonUtil;
import app.module.core.usecase.household.getHousehold.ports.GetHouseholdPortIn;
import app.module.core.usecase.household.getHousehold.ports.application.domain.GetHouseholdCmd;
import app.module.core.usecase.monthly.getMonthlyInputStatus.ports.application.domain.GetMonthlyInputStatus;
import app.module.core.usecase.monthly.getMonthlyInputStatuss.ports.GetMonthlyInputStatussPortIn;
import app.module.core.usecase.monthly.getMonthlyInputStatuss.ports.application.domain.GetMonthlyInputStatuss;
import app.module.core.usecase.monthly.getMonthlyInputStatuss.ports.application.domain.GetMonthlyInputStatussCmd;
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNotices;
import app.module.core.usecase.notice.getNotices.ports.application.domain.GetNoticesCmd;
import app.module.front.usecase.info.monthly.getMonthlysUI.adapters.web.model.GetMontylyssReqVO;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.PageableDefault;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@@ -12,14 +23,23 @@ import org.springframework.web.bind.annotation.GetMapping;
@RequiredArgsConstructor
class GetMontylysUIController {
private final GetHouseholdPortIn getHouseholdPortIn;
private final GetMonthlyInputStatussPortIn portIn;
@GetMapping(path = "/info/monthly")
String operate(Model model) {
String operate(Model model,
@PageableDefault(sort = "month", direction = Sort.Direction.DESC, page = 0, size = 13) Pageable pageable,
GetMontylyssReqVO reqVO) {
model.addAttribute("userInfo",
getHouseholdPortIn.operate(new GetHouseholdCmd(CommonUtil.getLoginUsername())).orElseThrow());
Page<GetMonthlyInputStatuss> notices =
portIn.operate(
pageable,
new GetMonthlyInputStatussCmd(
reqVO.getSearchField(), reqVO.getSearchValue()));
model.addAttribute("reqVO", reqVO);
model.addAttribute("list", notices);
return "info/monthly/monthlys";
}
}

View File

@@ -0,0 +1,16 @@
package app.module.front.usecase.info.monthly.getMonthlysUI.adapters.web.model;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@EqualsAndHashCode
public class GetMontylyssReqVO {
private String searchField;
private String searchValue;
}

View File

@@ -2,126 +2,54 @@
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:th="http://www.thymeleaf.org">
<div layout:fragment="content">
<main id="content" role="main">
<style>
label {
display: inline-block;
width: 150px;
}
div {
margin-bottom: 15px;
}
.invalid-feedback {
display: none;
font-size: 12px;
font-weight: bold;
}
.is-invalid + .invalid-feedback {
display: block;
}
input[readonly] {
background-color: #e9ecef;
color: #6c757d;
cursor: not-allowed;
}
</style>
<div>
<form
method="get"
name="reqForm"
th:action="@{/user/info}" th:object="${userInfo}">
<input type="hidden" name="id" th:value="*{seq}">
<div>
<label for="householdNum">임가번호</label>
<input id="householdNum" name="householdNum" placeholder="아이디" readonly="readonly" th:field="*{householdNum}"
type="text">
<div class="invalid-feedback field-id"></div>
</div>
<div>
<label for="ownerName">경영주</label>
<input id="ownerName" name="ownerName" placeholder="경영주 이름" th:field="*{ownerName}" type="text">
<div class="invalid-feedback field-id"></div>
</div>
<div>
<label for="ownerAge">만나이</label>
<input id="ownerAge" name="ownerAge" placeholder="나이" th:field="*{ownerAge}" type="text">
<div class="invalid-feedback field-id"></div>
</div>
<div>
<label for="tel">가구연락처</label>
<input id="tel" name="tel" placeholder="가구연락처" th:field="*{tel}" type="text">
<div class="invalid-feedback field-id"></div>
</div>
<div>
<label for="phone">핸드폰번호</label>
<input id="phone" name="phone" placeholder="핸드폰번호" th:field="*{phone}" type="text">
<div class="invalid-feedback field-id"></div>
</div>
<!-- <div>-->
<!-- <label for="region">시.도</label>-->
<!-- <input id="region" name="region" placeholder="시.도" th:field="*{region}" type="text">-->
<!-- <div class="invalid-feedback field-id"></div>-->
<!-- </div>-->
<!-- <div>-->
<!-- <label for="city">시.군.도</label>-->
<!-- <input id="city" name="city" placeholder="시.군.도" th:field="*{city}" type="text">-->
<!-- <div class="invalid-feedback field-id"></div>-->
<!-- </div>-->
<div>
<label for="addressDetail">전체 주소</label>
<input id="addressDetail" name="addressDetail" placeholder="세부 주소" th:field="*{address}" type="text">
<div class="invalid-feedback field-id"></div>
</div>
</form>
<button onclick="updateUser();">수정하기</button>
</div>
</main>
<div layout:fragment="content" th:classappend="'mypage-wrap'">
<main id="content" role="main">
<div class="inner">
<hgroup class="tit-group">
<h3>
월별 등록된 <strong>임산물 현황</strong>을 <br> 확인하세요.
</h3>
</hgroup>
<ul class="product-col-list">
<li>
<a href="">
<p class="list-tit">2025년 5월</p>
<span class="tag">미등록</span>
</a>
</li>
<li class="complete">
<a href="">
<p class="list-tit">2025년 5월</p>
<span class="tag">등록완료</span>
</a>
</li>
<li class="complete">
<a href="">
<p class="list-tit">2025년 5월</p>
<span class="tag">등록완료</span>
</a>
</li>
</ul>
</div>
</main>
</div>
<section layout:fragment="script">
<script>
const updateUser = () => {
const f = document.reqForm;
const obj = $(f).serializeObject();
<script th:inline="javascript">
let ENV = {
httpUrl: {
root: /*[[#{uri.front.info.notice.path}]]*/'detailUrl',
notice: /*[[#{uri.front.info.notice.path}]]*/'noticeUrl'
},
module:{
confirmPopup : null
},
submitted: false,
};
let formControl = {
init(){
// 기존 에러 메세지 초기화
$('.is-invalid').removeClass('is-invalid');
$.ajax({
method: 'PATCH',
url: '/api/front/household/update',
data: obj,
beforeSend: function (xhr) {
xhr.setRequestHeader(
$("meta[name='_csrf_header']").attr("content"),
$("meta[name='_csrf']").attr("content"));
},
success(res) {
if (confirm(`'${res.ownerName} 님의' 정보가 수정되었습니다.`)) {
location.reload();
}
},
statusCode: {
'422': (res) => {
const fieldErrors = res.responseJSON.fieldErrors;
$(fieldErrors).each(function (idx, error) {
let target = $(f).find('[name=' + error.field + ']');
target.addClass('is-invalid');
target.parent().find('.invalid-feedback').text(error.message);
});
}
}
})
}
}
</script>