Merge branch 'dev' into 'deploy-dev-front'
SelectBox 확인용 See merge request korea-research/korea-research!1
This commit is contained in:
@@ -3,6 +3,7 @@ package app.module.admin.usecase.admin.saveAdmin.adapters.web;
|
||||
import app.module.admin.usecase.admin.saveAdmin.adapters.web.model.AdminCreateBindingVO;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.usecase.role.list.ports.RoleListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -14,10 +15,14 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
public class AdminCreateGetController {
|
||||
|
||||
private final RoleListPortIn roleListPortIn;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
|
||||
@GetMapping(path = "/settings/admins/create")
|
||||
String operate(Model model, @ModelAttribute("bindingVO") AdminCreateBindingVO bindingVO) {
|
||||
|
||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
||||
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
||||
|
||||
return "admin/adminCreateForm";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.admin.saveAdmin.ports.SaveAdminPortIn;
|
||||
import app.module.core.usecase.role.list.ports.RoleListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -22,6 +23,7 @@ public class AdminCreatePostController {
|
||||
private final RoleListPortIn roleListPortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
private final SaveAdminPortIn savePortIn;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final AdminCreateValidator adminCreateValidator;
|
||||
|
||||
@PostMapping(path = "/settings/admins/create")
|
||||
@@ -34,6 +36,7 @@ public class AdminCreatePostController {
|
||||
adminCreateValidator.validate(bindingVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
||||
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
||||
return "admin/adminCreateForm";
|
||||
}
|
||||
|
||||
@@ -42,6 +45,7 @@ public class AdminCreatePostController {
|
||||
bindingVO.getId(),
|
||||
bindingVO.getPassword(),
|
||||
bindingVO.getEmail(),
|
||||
bindingVO.getRegionMainCode(),
|
||||
bindingVO.getAccountDisabled(),
|
||||
bindingVO.getAccountLocked(),
|
||||
bindingVO.getRoleIds());
|
||||
|
||||
@@ -9,6 +9,7 @@ import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.admin.view.ports.AdminViewPortIn;
|
||||
import app.module.core.usecase.admin.view.ports.application.domain.AdminView;
|
||||
import app.module.core.usecase.role.list.ports.RoleListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -24,6 +25,7 @@ class AdminUpdateGetController {
|
||||
|
||||
private final AdminViewPortIn adminViewPortIn;
|
||||
private final RoleListPortIn roleListPortIn;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@GetMapping(path = "/settings/admins/update/{adminId}")
|
||||
@@ -52,6 +54,7 @@ class AdminUpdateGetController {
|
||||
output.getId(),
|
||||
null,
|
||||
output.getEmail(),
|
||||
output.getRegionMainCode(),
|
||||
output.getPasswordUpdatedAt(),
|
||||
output.getAccountDisabled(),
|
||||
output.getLoginFailCnt(),
|
||||
@@ -60,6 +63,7 @@ class AdminUpdateGetController {
|
||||
|
||||
model.addAttribute("bindingVO", bindingVO);
|
||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
||||
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
||||
|
||||
return "admin/adminUpdateForm";
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.admin.saveAdmin.ports.SaveAdminPortIn;
|
||||
import app.module.core.usecase.role.list.ports.RoleListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
@@ -21,6 +22,7 @@ class AdminUpdatePostController {
|
||||
|
||||
private final AdminUpdateValidator adminUpdateValidator;
|
||||
private final RoleListPortIn roleListPortIn;
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final SaveAdminPortIn saveAdminPortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@@ -34,6 +36,7 @@ class AdminUpdatePostController {
|
||||
adminUpdateValidator.validate(bindingVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
||||
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
||||
return "admin/adminUpdateForm";
|
||||
}
|
||||
|
||||
@@ -42,6 +45,7 @@ class AdminUpdatePostController {
|
||||
bindingVO.getId(),
|
||||
bindingVO.getUpdatePassword(),
|
||||
bindingVO.getEmail(),
|
||||
bindingVO.getRegionMainCode(),
|
||||
bindingVO.getAccountDisabled(),
|
||||
bindingVO.getAccountLocked(),
|
||||
bindingVO.getRoleIds());
|
||||
|
||||
@@ -25,4 +25,5 @@ public class AdminCreateBindingVO {
|
||||
private Boolean accountDisabled;
|
||||
private Boolean accountLocked;
|
||||
private List<String> roleIds;
|
||||
private String regionMainCode;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ public class AdminUpdateBindingVO implements AuditOutput {
|
||||
"^[\\w!#$%&’*+/=?`{|}~^-]+(?:\\.[\\w!#$%&’*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$",
|
||||
message = "{valid.common.email.wrong}")
|
||||
private String email;
|
||||
private String regionMainCode;
|
||||
|
||||
private LocalDateTime passwordUpdatedAt;
|
||||
private Boolean accountDisabled;
|
||||
|
||||
@@ -24,14 +24,23 @@ public class AdminCreateValidator implements Validator {
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "valid.common.required");
|
||||
|
||||
Optional.ofNullable(vo.getPassword())
|
||||
.filter(password -> !password.matches(PASSWORD_REGEX))
|
||||
.ifPresent(password -> errors.rejectValue("password", "valid.common.password.wrong"));
|
||||
.filter(password -> !password.matches(PASSWORD_REGEX))
|
||||
.ifPresent(password -> errors.rejectValue("password", "valid.common.password.wrong"));
|
||||
|
||||
Optional.ofNullable(vo.getRoleIds())
|
||||
.filter(ids -> ids.size() < 1)
|
||||
.ifPresent(
|
||||
ids ->
|
||||
errors.rejectValue(
|
||||
"roleIds", "valid.common.required.size.min", new Object[]{1}, ""));
|
||||
.filter(ids -> ids.size() < 1)
|
||||
.ifPresent(
|
||||
ids ->
|
||||
errors.rejectValue(
|
||||
"roleIds", "valid.common.required.size.min", new Object[]{1}, ""));
|
||||
|
||||
// ROLE_ADMIN이 아닌 경우 regionMainCode null체크
|
||||
Optional.ofNullable(vo.getRoleIds())
|
||||
.filter(ids -> ids.stream().noneMatch(role -> role.equals("ROLE_ADMIN")))
|
||||
.ifPresent(nonAdmins -> {
|
||||
if (vo.getRegionMainCode() == null || vo.getRegionMainCode().isBlank()) {
|
||||
errors.rejectValue("regionMainCode", "valid.common.required");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,14 @@ public class AdminUpdateValidator implements Validator {
|
||||
Optional.ofNullable(vo.getUpdatePassword())
|
||||
.filter(s -> !s.trim().isEmpty() && !s.matches(PASSWORD_REGEX))
|
||||
.ifPresent(s -> errors.rejectValue("updatePassword", "valid.common.password.wrong"));
|
||||
|
||||
// ROLE_ADMIN이 아닌 경우 regionMainCode null체크
|
||||
Optional.ofNullable(vo.getRoleIds())
|
||||
.filter(ids -> ids.stream().noneMatch(role -> role.equals("ROLE_ADMIN")))
|
||||
.ifPresent(nonAdmins -> {
|
||||
if (vo.getRegionMainCode() == null || vo.getRegionMainCode().isBlank()) {
|
||||
errors.rejectValue("regionMainCode", "valid.common.required");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.admin.usecase.household.getHouseholdsStatus.adapters.persistence;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatusCmd;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.GetHouseholdsStatusPortOut;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class GetHouseholdsStatusDao implements GetHouseholdsStatusPortOut {
|
||||
|
||||
@Override
|
||||
public Page<GetHouseholdsStatus> operate(Pageable pageable, GetHouseholdsStatusCmd cmd) {
|
||||
return new PageImpl<>(null, null, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.admin.usecase.household.getHouseholdsStatus.adapters.persistence;
|
||||
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatusCmd;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
@Mapper
|
||||
public interface GetHouseholdsStatusMapper {
|
||||
List<GetHouseholdsStatus> getHouseholdsStatus(@Param("pageable")Pageable pageable, @Param("cmd") GetHouseholdsStatusCmd cmd);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.household.getHouseholdsStatus.ports;
|
||||
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatusCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface GetHouseholdsStatusPortIn {
|
||||
Page<GetHouseholdsStatus> operate(Pageable pageable, GetHouseholdsStatusCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package app.module.admin.usecase.household.getHouseholdsStatus.ports;
|
||||
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatusCmd;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
public interface GetHouseholdsStatusPortOut {
|
||||
Page<GetHouseholdsStatus> operate(Pageable pageable, GetHouseholdsStatusCmd cmd);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.admin.usecase.household.getHouseholdsStatus.ports.application;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatusCmd;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.GetHouseholdsStatusPortIn;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatus.ports.GetHouseholdsStatusPortOut;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
class GetHouseholdsStatusService implements GetHouseholdsStatusPortIn {
|
||||
private final GetHouseholdsStatusPortOut portOut;
|
||||
|
||||
@Override
|
||||
public Page<GetHouseholdsStatus> operate(Pageable pageable, GetHouseholdsStatusCmd cmd) {
|
||||
return portOut.operate(pageable, cmd);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetHouseholdsStatus {
|
||||
private Integer householdSeq;
|
||||
private String householdNum;
|
||||
private String householdName;
|
||||
private String householdPhone;
|
||||
private String regionMainName;
|
||||
private String regionSubName;
|
||||
private String regionDetailName;
|
||||
private String industryLargeName;
|
||||
private String industryMiddleName;
|
||||
private String firstVisitDate;
|
||||
private String secondVisitDate;
|
||||
private Boolean isGiftSent;
|
||||
private String researcherName;
|
||||
private String researcherPhone;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetHouseholdsStatusCmd {
|
||||
// 연월
|
||||
private String month;
|
||||
// 경영주 검색 필드 (전체, 경영주명, 전화번호)
|
||||
private String ownerField;
|
||||
// 경영주 검색어
|
||||
private String ownerValue;
|
||||
// 실사
|
||||
private String regionMainCode;
|
||||
// 지역
|
||||
private String regionSubCode;
|
||||
// 세부지역
|
||||
private String regionDetailCode;
|
||||
// 업종 대분류
|
||||
private String industryLargeCode;
|
||||
// 업종 중분류1
|
||||
private String industryMiddleCode;
|
||||
// 당월 일계부 현황 (전체, 25% 미만, 25~50% 미만, 50~75% 미만, 75% 이상, 100% 완료)
|
||||
private ProgressType progress;
|
||||
// 당월 1차 방문 여부
|
||||
private Boolean isFirstVisited;
|
||||
// 당월 2차 방문 여부
|
||||
private Boolean isSecondVisited;
|
||||
// 답례품 전달
|
||||
private Boolean isGiftSent;
|
||||
// 조사원 검색 필드 (전체, 이름, 전화번호)
|
||||
private String researcherField;
|
||||
// 조사원 검색어
|
||||
private String researcherValue;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum ProgressType {
|
||||
ALL("전체"),
|
||||
PROGRESS_25("25% 미만"),
|
||||
PROGRESS_50("25~50% 미만"),
|
||||
PROGRESS_75("50~75% 미만"),
|
||||
PROGRESS_75_UP("75% 이상"),
|
||||
PROGRESS_100("100% 완료");
|
||||
|
||||
private final String desc;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package app.module.admin.usecase.household.getHouseholesUI;
|
||||
package app.module.admin.usecase.household.getHouseholdsStatusUI;
|
||||
|
||||
import app.module.admin.usecase.household.getHouseholesUI.model.GetHouseholdsUIReqVO;
|
||||
import app.module.admin.usecase.household.getHouseholdsStatusUI.model.GetHouseholdsUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetHouseholdsUIController {
|
||||
class GetHouseholdsStatusUIController {
|
||||
|
||||
@GetMapping(path = "/household/households")
|
||||
String operate(
|
||||
@@ -1,4 +1,4 @@
|
||||
package app.module.admin.usecase.household.getHouseholesUI.model;
|
||||
package app.module.admin.usecase.household.getHouseholdsStatusUI.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper
|
||||
namespace="app.module.admin.usecase.household.getHouseholdsStatus.adapters.persistence.GetHouseholdsStatusMapper">
|
||||
|
||||
<select id="getHouseholdsStatus"
|
||||
resultType="app.module.admin.usecase.household.getHouseholdsStatus.ports.application.domain.GetHouseholdsStatus">
|
||||
/* getHouseholdsStatus : 임가현황 리스트 조회 */
|
||||
SELECT
|
||||
h.seq AS householdSeq,
|
||||
h.household_num AS householdNum,
|
||||
h.owner_name AS householdName,
|
||||
h.phone AS householdPhone,
|
||||
h.region_main_name AS regionMainName,
|
||||
h.region_sub_name AS regionSubName,
|
||||
h.region_detail_name AS regionDetailName,
|
||||
h.industry_large_name AS industryLargeName,
|
||||
h.industry_middle_name AS industryMiddleName,
|
||||
v.first_visit_date AS firstVisitDate,
|
||||
v.second_visit_date AS secondVisitDate,
|
||||
v.is_gift_sent AS isGiftSent,
|
||||
r.researcher_name AS researcherName,
|
||||
r.researcher_phone AS researcherPhone
|
||||
FROM v_household_with_code h
|
||||
LEFT JOIN v_household_visit v ON h.seq = v.household_seq
|
||||
LEFT JOIN v_household_researcher r ON h.seq = r.household_seq
|
||||
ORDER BY h.household_num asc
|
||||
|
||||
-- TODO : where 조건절 추가
|
||||
|
||||
OFFSET #{pageable.offset} ROWS FETCH NEXT #{pageable.pageSize} ROWS ONLY
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -4,116 +4,144 @@
|
||||
|
||||
<section class="fw-bold" layout:fragment="content">
|
||||
|
||||
<form
|
||||
method="post"
|
||||
th:action="@{/settings/admins/create}"
|
||||
th:object="${bindingVO}">
|
||||
<form
|
||||
method="post"
|
||||
th:action="@{/settings/admins/create}"
|
||||
th:object="${bindingVO}">
|
||||
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="id">ID *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="id" th:classappend="${#fields.hasErrors('id')} ? 'is-invalid'"
|
||||
th:field="*{id}"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{id}" th:if="${#fields.hasErrors('id')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="password">Password *</label>
|
||||
<div class="col-sm-4">
|
||||
|
||||
<input class="form-control" id="password" th:classappend="${#fields.hasErrors('password')} ? 'is-invalid'" th:field="*{password}"
|
||||
type="password"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{password}"
|
||||
th:if="${#fields.hasErrors('password')}">
|
||||
에러 메세지
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="id">ID *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="id"
|
||||
th:classappend="${#fields.hasErrors('id')} ? 'is-invalid'"
|
||||
th:field="*{id}"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{id}"
|
||||
th:if="${#fields.hasErrors('id')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="password">Password *</label>
|
||||
<div class="col-sm-4">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="email">Email *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="email" th:classappend="${#fields.hasErrors('email')} ? 'is-invalid'" th:field="*{email}"
|
||||
type="email"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{email}"
|
||||
th:if="${#fields.hasErrors('email')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input class="form-control" id="password"
|
||||
th:classappend="${#fields.hasErrors('password')} ? 'is-invalid'"
|
||||
th:field="*{password}"
|
||||
type="password"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{password}"
|
||||
th:if="${#fields.hasErrors('password')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="roleIds">권한 *</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" id="roleIds" multiple th:classappend="${#fields.hasErrors('roleIds')} ? 'is-invalid'"
|
||||
th:field="*{roleIds}">
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 활성화 -->
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="inlineRadio1">비활성화 여부 *</label>
|
||||
<div class="col-sm-4 pt-1">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="inlineRadio1" name="accountDisabled"
|
||||
type="radio" value="true">
|
||||
<label class="form-check-label" for="inlineRadio1">비활성화</label>
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="email">Email *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="email"
|
||||
th:classappend="${#fields.hasErrors('email')} ? 'is-invalid'"
|
||||
th:field="*{email}"
|
||||
type="email"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{email}"
|
||||
th:if="${#fields.hasErrors('email')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input checked class="form-check-input" id="inlineRadio2"
|
||||
name="accountDisabled" type="radio" value="false">
|
||||
<label class="form-check-label" for="inlineRadio2">활성화</label>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정잠김 -->
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="accountLocked1">계정잠김 여부*</label>
|
||||
<div class="col-sm-4 pt-1">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="accountLocked1" name="accountLocked"
|
||||
type="radio" value="true">
|
||||
<label class="form-check-label" for="accountLocked1">Locked</label>
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="roleIds">권한 *</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" id="roleIds" multiple
|
||||
th:classappend="${#fields.hasErrors('roleIds')} ? 'is-invalid'"
|
||||
th:field="*{roleIds}"
|
||||
onchange="onRoleChange(this);">
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input checked class="form-check-input" id="accountLocked2"
|
||||
name="accountLocked" type="radio" value="false">
|
||||
<label class="form-check-label" for="accountLocked2">Unlocked</label>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary float-end" type="submit">저장</button>
|
||||
<button class="btn btn-light" onclick="gotoList();return false;" type="button">목록으로 이동</button>
|
||||
</form>
|
||||
<div class="row mb-3 regionMainCodeArea" style="display: none;">
|
||||
<label class="col-sm-2 col-form-label" for="regionMainCode">실사 *</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-select" id="regionMainCode" name="regionMainCode"
|
||||
th:field="*{regionMainCode}">
|
||||
<option value="">선택</option>
|
||||
<option th:each="code : ${regionMainCode}"
|
||||
th:value="${code.id}"
|
||||
th:text="${code.codeText}">
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function gotoList() {
|
||||
document.prevAdminParamForm ? document.prevAdminParamForm.submit()
|
||||
: location.href = '/settings/admins';
|
||||
}
|
||||
</script>
|
||||
<!-- 활성화 -->
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="inlineRadio1">비활성화 여부 *</label>
|
||||
<div class="col-sm-4 pt-1">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="inlineRadio1" name="accountDisabled"
|
||||
type="radio" value="true">
|
||||
<label class="form-check-label" for="inlineRadio1">비활성화</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input checked class="form-check-input" id="inlineRadio2"
|
||||
name="accountDisabled" type="radio" value="false">
|
||||
<label class="form-check-label" for="inlineRadio2">활성화</label>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정잠김 -->
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="accountLocked1">계정잠김 여부*</label>
|
||||
<div class="col-sm-4 pt-1">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="accountLocked1" name="accountLocked"
|
||||
type="radio" value="true">
|
||||
<label class="form-check-label" for="accountLocked1">Locked</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input checked class="form-check-input" id="accountLocked2"
|
||||
name="accountLocked" type="radio" value="false">
|
||||
<label class="form-check-label" for="accountLocked2">Unlocked</label>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary float-end" type="submit">저장</button>
|
||||
<button class="btn btn-light" onclick="gotoList();return false;" type="button">목록으로 이동
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
function gotoList() {
|
||||
document.prevAdminParamForm ? document.prevAdminParamForm.submit()
|
||||
: location.href = '/settings/admins';
|
||||
}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const onRoleChange = (el) => {
|
||||
$('.regionMainCodeArea').toggle(el.value !== "ROLE_ADMIN");
|
||||
}
|
||||
</script>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
@@ -4,200 +4,210 @@
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<form method="post" name="adminParamForm" onsubmit="goSearch();"
|
||||
th:action="@{/settings/admins}"
|
||||
th:object="${listStatus}">
|
||||
<form method="post" name="adminParamForm" onsubmit="goSearch();"
|
||||
th:action="@{/settings/admins}"
|
||||
th:object="${listStatus}">
|
||||
|
||||
<!-- hidden parameters -->
|
||||
<input name="page" th:value="${listOutput.pageable.pageNumber}" type="hidden"/>
|
||||
<input name="sort" th:value="${listOutput.pageable.sort}" type="hidden"/>
|
||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
|
||||
<!-- hidden parameters -->
|
||||
<input name="page" th:value="${listOutput.pageable.pageNumber}" type="hidden"/>
|
||||
<input name="sort" th:value="${listOutput.pageable.sort}" type="hidden"/>
|
||||
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
|
||||
|
||||
<div class="row p-2 mb-2 border-secondary border-top border-bottom border-1">
|
||||
<div class="col-5">
|
||||
<label class="col-sm-2 col-form-label" for="searchField">검색필드</label>
|
||||
<select class="form-select d-inline w-25" id="searchField" th:field="*{searchField}">
|
||||
<option selected value="">선택</option>
|
||||
<option value="id">ID</option>
|
||||
<option value="email">Email</option>
|
||||
</select>
|
||||
<label>
|
||||
<input class="form-control d-inline" placeholder="검색어를 입력하세요." style="width: 250px;"
|
||||
th:field="*{searchValue}" type="text">
|
||||
</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="col-sm-2 col-form-label" for="searchRole">권한</label>
|
||||
<select class="form-select d-inline w-50" id="searchRole" th:field="*{searchRole}">
|
||||
<option selected value="">전체</option>
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button class="btn btn-outline-secondary" onclick="goSearch();"
|
||||
type="button">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="goInit();"
|
||||
type="button">초기화
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row p-2 mb-2 border-secondary border-top border-bottom border-1">
|
||||
<div class="col-5">
|
||||
<label class="col-sm-2 col-form-label" for="searchField">검색필드</label>
|
||||
<select class="form-select d-inline w-25" id="searchField"
|
||||
th:field="*{searchField}">
|
||||
<option selected value="">선택</option>
|
||||
<option value="id">ID</option>
|
||||
<option value="email">Email</option>
|
||||
</select>
|
||||
<label>
|
||||
<input class="form-control d-inline" placeholder="검색어를 입력하세요."
|
||||
style="width: 250px;"
|
||||
th:field="*{searchValue}" type="text">
|
||||
</label>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="col-sm-2 col-form-label" for="searchRole">권한</label>
|
||||
<select class="form-select d-inline w-50" id="searchRole" th:field="*{searchRole}">
|
||||
<option selected value="">전체</option>
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button class="btn btn-outline-secondary" onclick="goSearch();"
|
||||
type="button">
|
||||
<i class="bi bi-search"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="goInit();"
|
||||
type="button">초기화
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-start">
|
||||
<div class="fw-bolder text-muted">Total: <span
|
||||
th:text="${listOutput.totalElements}"></span></div>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<i class="bi bi-list-ol"></i>
|
||||
<label>
|
||||
<select class="form-select form-select-sm" id="pageSize" name="pageSize"
|
||||
onchange="goSearch()">
|
||||
<option
|
||||
th:each="item : ${pageRows}"
|
||||
th:selected="${#strings.toString(listOutput.pageable.pageSize) eq item.codeValue}" th:text="${item.codeText}"
|
||||
th:value="${item.codeValue}"></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col text-start">
|
||||
<div class="fw-bolder text-muted">Total: <span
|
||||
th:text="${listOutput.totalElements}"></span></div>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<i class="bi bi-list-ol"></i>
|
||||
<label>
|
||||
<select class="form-select form-select-sm" id="pageSize" name="pageSize"
|
||||
onchange="goSearch()">
|
||||
<option
|
||||
th:each="item : ${pageRows}"
|
||||
th:selected="${#strings.toString(listOutput.pageable.pageSize) eq item.codeValue}"
|
||||
th:text="${item.codeText}"
|
||||
th:value="${item.codeValue}"></option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">
|
||||
<label><input class="form-check-input" onchange="toggleCheckbox(this);" type="checkbox"/></label>
|
||||
</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="id" href="#">ID</a></th>
|
||||
<th class="text-secondary" scope="col">권한</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="email" href="#">Email</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="accountDisabled" href="#">활성화</a>
|
||||
</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="accountLocked" href="#">계정잠김</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="createdAt" href="#">등록일</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="updatedAt" href="#">수정일</a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="item, status : ${listOutput.content}">
|
||||
<th scope="row"
|
||||
th:text="${status.count + (listOutput.pageable.pageNumber * listOutput.pageable.pageSize)}">
|
||||
게시물번호
|
||||
</th>
|
||||
<td><label><input class="form-check-input" name="checkedIds" th:value="${item.id}"
|
||||
type="checkbox"/></label>
|
||||
</td>
|
||||
<td><a th:href="|javascript:goUpdate('${item.id}')|" th:text="${item.id}">아이디</a></td>
|
||||
<td>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">
|
||||
<label><input class="form-check-input" onchange="toggleCheckbox(this);"
|
||||
type="checkbox"/></label>
|
||||
</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="id" href="#">ID</a></th>
|
||||
<th class="text-secondary" scope="col">권한</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="email" href="#">Email</a>
|
||||
</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="accountDisabled"
|
||||
href="#">활성화</a>
|
||||
</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="accountLocked"
|
||||
href="#">계정잠김</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="createdAt" href="#">등록일</a>
|
||||
</th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="updatedAt" href="#">수정일</a>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="item, status : ${listOutput.content}">
|
||||
<th scope="row"
|
||||
th:text="${status.count + (listOutput.pageable.pageNumber * listOutput.pageable.pageSize)}">
|
||||
게시물번호
|
||||
</th>
|
||||
<td><label><input class="form-check-input" name="checkedIds" th:value="${item.id}"
|
||||
type="checkbox"/></label>
|
||||
</td>
|
||||
<td><a th:href="|javascript:goUpdate('${item.id}')|" th:text="${item.id}">아이디</a>
|
||||
</td>
|
||||
<td>
|
||||
<span th:each="role, status : ${item.roles}"
|
||||
th:text="${role.getId()} + ${!status.last ? ', ': ''}"></span>
|
||||
</td>
|
||||
<td th:text="${item.email}">이메일</td>
|
||||
<td th:text="${item.accountDisabled == null || !item.accountDisabled ? 'Y' : 'N' }"></td>
|
||||
<td th:text="${item.accountLocked == null || !item.accountLocked ? 'N' : 'Y' }"></td>
|
||||
<td th:text="${#temporals.format(item.createdAt, 'yyyy-MM-dd hh:mm')}">등록일</td>
|
||||
<td th:text="${#temporals.format(item.updatedAt, 'yyyy-MM-dd hh:mm')}">수정일</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
<td th:text="${item.email}">이메일</td>
|
||||
<td th:text="${item.accountDisabled == null || !item.accountDisabled ? 'Y' : 'N' }"></td>
|
||||
<td th:text="${item.accountLocked == null || !item.accountLocked ? 'N' : 'Y' }"></td>
|
||||
<td th:text="${#temporals.format(item.createdAt, 'yyyy-MM-dd hh:mm')}">등록일</td>
|
||||
<td th:text="${#temporals.format(item.updatedAt, 'yyyy-MM-dd hh:mm')}">수정일</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
</form>
|
||||
|
||||
<div th:replace="common/list-components :: pagination(${listOutput})"></div>
|
||||
<div th:replace="common/list-components :: pagination(${listOutput})"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col text-start">
|
||||
<button class="btn btn-success" onclick="goExcel();" type="button">엑셀 다운로드</button>
|
||||
<div class="row">
|
||||
<div class="col text-start">
|
||||
<button class="btn btn-success" onclick="goExcel();" type="button">엑셀 다운로드</button>
|
||||
</div>
|
||||
<div class="col text-end mb-2">
|
||||
<button class="btn btn-primary" onclick="location.href='/settings/admins/create';"
|
||||
type="button">등록
|
||||
</button>
|
||||
<button class="btn btn-danger" onclick="goRemove();" type="button">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col text-end mb-2">
|
||||
<button class="btn btn-primary" onclick="location.href='/settings/admins/create';"
|
||||
type="button">등록
|
||||
</button>
|
||||
<button class="btn btn-danger" onclick="goRemove();" type="button">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script th:inline="javascript">
|
||||
// 목록 정렬 표기 및 갱신 기능 적용
|
||||
uiUtil.applyListSortNotation([[${listOutput.pageable.pageSize}]],
|
||||
[[${listOutput.pageable.sort.toString()}]]);
|
||||
</script>
|
||||
<script th:inline="javascript">
|
||||
// 목록 정렬 표기 및 갱신 기능 적용
|
||||
uiUtil.applyListSortNotation([[${listOutput.pageable.pageSize}]],
|
||||
[[${listOutput.pageable.sort.toString()}]]);
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
// 검색
|
||||
function goSearch() {
|
||||
const f = document.adminParamForm;
|
||||
f.action = '/settings/admins';
|
||||
f.page.value = 0;
|
||||
f.sort.value = convertToPageableSortValue(f.sort.value);
|
||||
f.method = 'get';
|
||||
f.submit();
|
||||
}
|
||||
|
||||
// 초기화
|
||||
function goInit() {
|
||||
const f = document.adminParamForm;
|
||||
f.searchField.value = '';
|
||||
f.searchValue.value = '';
|
||||
f.searchRole.value = '';
|
||||
}
|
||||
|
||||
// 수정페이지 이동
|
||||
function goUpdate(adminId) {
|
||||
const f = document.adminParamForm;
|
||||
f.action = '/settings/admins/update/' + adminId;
|
||||
f.method = 'get';
|
||||
f.submit();
|
||||
}
|
||||
|
||||
// 체크박스 선택/해제
|
||||
function toggleCheckbox(oj) {
|
||||
$('input[name=checkedIds]').prop("checked", oj.checked);
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
if (!$('input[name=checkedIds]').is(':checked')) {
|
||||
alert(/*[[#{operation.common.remove.choose}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
|
||||
const f = document.adminParamForm;
|
||||
const data = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
'method': 'DELETE',
|
||||
'url': '/api/settings/admin/remove',
|
||||
'data': {
|
||||
'checkedIds': data.checkedIds
|
||||
},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success(res) {
|
||||
alert('선택한 관리자가 삭제되었습니다.');
|
||||
<script th:inline="javascript">
|
||||
// 검색
|
||||
function goSearch() {
|
||||
const f = document.adminParamForm;
|
||||
f.action = '/settings/admins';
|
||||
f.page.value = 0;
|
||||
f.sort.value = convertToPageableSortValue(f.sort.value);
|
||||
f.method = 'get';
|
||||
f.submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function goExcel() {
|
||||
const f = document.adminParamForm;
|
||||
f.action = '/settings/admins/excel';
|
||||
f.sort.value = convertToPageableSortValue(f.sort.value);
|
||||
f.method = 'post';
|
||||
f.submit();
|
||||
}
|
||||
</script>
|
||||
// 초기화
|
||||
function goInit() {
|
||||
const f = document.adminParamForm;
|
||||
f.searchField.value = '';
|
||||
f.searchValue.value = '';
|
||||
f.searchRole.value = '';
|
||||
}
|
||||
|
||||
// 수정페이지 이동
|
||||
function goUpdate(adminId) {
|
||||
const f = document.adminParamForm;
|
||||
f.action = '/settings/admins/update/' + adminId;
|
||||
f.method = 'get';
|
||||
f.submit();
|
||||
}
|
||||
|
||||
// 체크박스 선택/해제
|
||||
function toggleCheckbox(oj) {
|
||||
$('input[name=checkedIds]').prop("checked", oj.checked);
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
if (!$('input[name=checkedIds]').is(':checked')) {
|
||||
alert(/*[[#{operation.common.remove.choose}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
if (confirm(/*[[#{operation.common.remove.ask}]]*/)) {
|
||||
const f = document.adminParamForm;
|
||||
const data = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
'method': 'DELETE',
|
||||
'url': '/api/settings/admin/remove',
|
||||
'data': {
|
||||
'checkedIds': data.checkedIds
|
||||
},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success(res) {
|
||||
alert('선택한 관리자가 삭제되었습니다.');
|
||||
f.method = 'get';
|
||||
f.submit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function goExcel() {
|
||||
const f = document.adminParamForm;
|
||||
f.action = '/settings/admins/excel';
|
||||
f.sort.value = convertToPageableSortValue(f.sort.value);
|
||||
f.method = 'post';
|
||||
f.submit();
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -4,144 +4,177 @@
|
||||
|
||||
<section class="fw-bold" layout:fragment="content">
|
||||
|
||||
<form
|
||||
method="post"
|
||||
th:action="${'/settings/admins/update/' + bindingVO.id}"
|
||||
th:object="${bindingVO}">
|
||||
<form
|
||||
method="post"
|
||||
th:action="${'/settings/admins/update/' + bindingVO.id}"
|
||||
th:object="${bindingVO}">
|
||||
|
||||
<input type="hidden" name="seq" th:field="*{seq}"/>
|
||||
<input type="hidden" name="seq" th:field="*{seq}"/>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="id">ID *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="id" readonly="readonly"
|
||||
th:field="*{id}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="password">Password *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="password" placeholder="암호를 변경하고 싶다면 입력하세요"
|
||||
th:classappend="${#fields.hasErrors('updatePassword')} ? 'is-invalid'"
|
||||
th:field="*{updatePassword}"
|
||||
type="password"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{updatePassword}"
|
||||
th:if="${#fields.hasErrors('updatePassword')}">
|
||||
에러 메세지
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="id">ID *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="id" readonly="readonly"
|
||||
th:field="*{id}"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="email">Email *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="email" th:classappend="${#fields.hasErrors('email')} ? 'is-invalid'" th:field="*{email}"
|
||||
type="email"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{email}"
|
||||
th:if="${#fields.hasErrors('email')}">
|
||||
에러 메세지
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="password">Password *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="password" placeholder="암호를 변경하고 싶다면 입력하세요"
|
||||
th:classappend="${#fields.hasErrors('updatePassword')} ? 'is-invalid'"
|
||||
th:field="*{updatePassword}"
|
||||
type="password"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{updatePassword}"
|
||||
th:if="${#fields.hasErrors('updatePassword')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="roleIds">권한 *</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" id="roleIds" multiple th:classappend="${#fields.hasErrors('roleIds')} ? 'is-invalid'"
|
||||
th:field="*{roleIds}">
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="email">Email *</label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control" id="email"
|
||||
th:classappend="${#fields.hasErrors('email')} ? 'is-invalid'"
|
||||
th:field="*{email}"
|
||||
type="email"/>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{email}"
|
||||
th:if="${#fields.hasErrors('email')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 활성화 -->
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="inlineRadio1">비활성화 여부 *</label>
|
||||
<div class="col-sm-4 pt-1">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="inlineRadio1" th:field="*{accountDisabled}"
|
||||
type="radio" value="true">
|
||||
<label class="form-check-label" for="inlineRadio1">비활성화</label>
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="roleIds">권한 *</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control" id="roleIds" multiple
|
||||
th:classappend="${#fields.hasErrors('roleIds')} ? 'is-invalid'"
|
||||
th:field="*{roleIds}"
|
||||
onchange="onRoleChange(this);">
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="inlineRadio2" th:field="*{accountDisabled}"
|
||||
type="radio" value="false">
|
||||
<label class="form-check-label" for="inlineRadio2">활성화</label>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정잠김 -->
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="accountLocked1">계정잠김 여부*</label>
|
||||
<div class="col-sm-4 pt-1">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="accountLocked1" th:field="*{accountLocked}"
|
||||
type="radio" value="true">
|
||||
<label class="form-check-label" for="accountLocked1">Locked</label>
|
||||
<div class="row mb-3 regionMainCodeArea"
|
||||
th:style="${#lists.contains(bindingVO.roleIds, 'ROLE_ADMIN')} ? 'display: none;' : 'display: flex;'">
|
||||
<label class="col-sm-2 col-form-label" for="regionMainCode">실사 *</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-select" id="regionMainCode" name="regionMainCode"
|
||||
th:classappend="${#fields.hasErrors('regionMainCode')} ? 'is-invalid'"
|
||||
th:field="*{regionMainCode}">
|
||||
<option value="">선택</option>
|
||||
<option th:each="code : ${regionMainCode}"
|
||||
th:value="${code.id}"
|
||||
th:text="${code.codeText}">
|
||||
</option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{regionMainCode}"
|
||||
th:if="${#fields.hasErrors('regionMainCode')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="accountLocked2" th:field="*{accountLocked}"
|
||||
type="radio" value="false">
|
||||
<label class="form-check-label" for="accountLocked2">Unlocked</label>
|
||||
|
||||
<!-- 활성화 -->
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="inlineRadio1">비활성화 여부 *</label>
|
||||
<div class="col-sm-4 pt-1">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="inlineRadio1" th:field="*{accountDisabled}"
|
||||
type="radio" value="true">
|
||||
<label class="form-check-label" for="inlineRadio1">비활성화</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="inlineRadio2" th:field="*{accountDisabled}"
|
||||
type="radio" value="false">
|
||||
<label class="form-check-label" for="inlineRadio2">활성화</label>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
|
||||
<!-- 계정잠김 -->
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label" for="accountLocked1">계정잠김 여부*</label>
|
||||
<div class="col-sm-4 pt-1">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="accountLocked1" th:field="*{accountLocked}"
|
||||
type="radio" value="true">
|
||||
<label class="form-check-label" for="accountLocked1">Locked</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" id="accountLocked2" th:field="*{accountLocked}"
|
||||
type="radio" value="false">
|
||||
<label class="form-check-label" for="accountLocked2">Unlocked</label>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row w-50">
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
</div>
|
||||
<div class="row w-50">
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary float-end" type="submit">저장</button>
|
||||
<button class="btn btn-light" onclick="gotoList();return false;" type="button">목록으로 이동</button>
|
||||
</form>
|
||||
<button class="btn btn-primary float-end" type="submit">저장</button>
|
||||
<button class="btn btn-light" onclick="gotoList();return false;" type="button">목록으로 이동
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- 이전 목록페이지의 검색 및 정렬조건 폼 -->
|
||||
<form method="get" name="prevAdminParamForm"
|
||||
th:action="@{/settings/admins}"
|
||||
th:object="${listStatus}">
|
||||
<input th:field="*{searchField}" type="hidden">
|
||||
<input th:field="*{searchValue}" type="hidden">
|
||||
<input th:field="*{searchRole}" type="hidden">
|
||||
<th:block th:if="${pageable != null}">
|
||||
<input name="page" th:value="${pageable.page}" type="hidden"/>
|
||||
<input name="sort" th:value="${pageable.sort}" type="hidden"/>
|
||||
<!-- 이전 목록페이지의 검색 및 정렬조건 폼 -->
|
||||
<th:block th:if="${listStatus != null}">
|
||||
<form method="get" name="prevAdminParamForm"
|
||||
th:action="@{/settings/admins}"
|
||||
th:object="${listStatus}">
|
||||
<input th:field="*{searchField}" type="hidden">
|
||||
<input th:field="*{searchValue}" type="hidden">
|
||||
<input th:field="*{searchRole}" type="hidden">
|
||||
<th:block th:if="${pageable != null}">
|
||||
<input name="page" th:value="${pageable.page}" type="hidden"/>
|
||||
<input name="sort" th:value="${pageable.sort}" type="hidden"/>
|
||||
</th:block>
|
||||
</form>
|
||||
</th:block>
|
||||
</form>
|
||||
|
||||
<script th:inline="javascript">
|
||||
function gotoList() {
|
||||
if (document.prevParamForm) {
|
||||
const f = document.prevParamForm;
|
||||
f.sort.value = convertToPageableSortValue(f.sort.value);
|
||||
f.submit();
|
||||
} else {
|
||||
location.href = '/settings/admins';
|
||||
}
|
||||
}
|
||||
<script th:inline="javascript">
|
||||
function gotoList() {
|
||||
if (document.prevAdminParamForm) {
|
||||
const f = document.prevAdminParamForm;
|
||||
f.sort.value = convertToPageableSortValue(f.sort.value);
|
||||
f.submit();
|
||||
} else {
|
||||
location.href = '/settings/admins';
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
showAudit([[${bindingVO.id}]], [[${bindingVO.createdBy}]],
|
||||
[[${#temporals.format(bindingVO.createdAt, "yyyy-MM-dd'T'HH:mm:ss")}]],
|
||||
[[${bindingVO.updatedBy}]],
|
||||
[[${#temporals.format(bindingVO.updatedAt, "yyyy-MM-dd'T'HH:mm:ss")}]]);
|
||||
});
|
||||
</script>
|
||||
$(document).ready(() => {
|
||||
showAudit([[${bindingVO.id}]], [[${bindingVO.createdBy}]],
|
||||
[[${#temporals.format(bindingVO.createdAt, "yyyy-MM-dd'T'HH:mm:ss")}]],
|
||||
[[${bindingVO.updatedBy}]],
|
||||
[[${#temporals.format(bindingVO.updatedAt, "yyyy-MM-dd'T'HH:mm:ss")}]]);
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const onRoleChange = (el) => {
|
||||
$('.regionMainCodeArea').toggle(el.value !== "ROLE_ADMIN");
|
||||
}
|
||||
</script>
|
||||
|
||||
</section>
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ class AdminAuthFailHandlerTest {
|
||||
testUsername,
|
||||
"test.1@#$",
|
||||
"xx4@test.com",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));
|
||||
|
||||
@@ -43,6 +43,7 @@ class AdminDetailsServiceTest {
|
||||
username,
|
||||
password,
|
||||
"xx1@test.com",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));
|
||||
|
||||
@@ -39,6 +39,7 @@ class AdminCreateUpdateDaoTest {
|
||||
"admin_for_createDao_test",
|
||||
"test.1@#$",
|
||||
"admin_for_createDao_test@test.com",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));
|
||||
@@ -56,6 +57,7 @@ class AdminCreateUpdateDaoTest {
|
||||
"admin_for_createDao_test",
|
||||
"test.1@#$",
|
||||
"admin_for_createDao_test@test.com",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
List.of("ROLE_STAFF"));
|
||||
|
||||
@@ -52,6 +52,7 @@ class CreateAdminController {
|
||||
reqVO.getId(),
|
||||
reqVO.getPassword(),
|
||||
reqVO.getEmail(),
|
||||
reqVO.getRegionMainCode(),
|
||||
reqVO.getAccountDisabled(),
|
||||
reqVO.getAccountLocked(),
|
||||
reqVO.getRoleIds());
|
||||
|
||||
@@ -28,6 +28,9 @@ public class CreateAdminReqVO {
|
||||
@Schema(description = "email", example = "admin-email@email.com")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "실사지역코드", example = "code.region.main.1")
|
||||
private String regionMainCode;
|
||||
|
||||
@Schema(description = "계정 비활성화", example = "false")
|
||||
private Boolean accountDisabled;
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ class UpdateAdminController {
|
||||
reqVO.getId(),
|
||||
reqVO.getUpdatePassword(),
|
||||
reqVO.getEmail(),
|
||||
reqVO.getRegionMainCode(),
|
||||
reqVO.getAccountDisabled(),
|
||||
reqVO.getAccountLocked(),
|
||||
reqVO.getRoleIds());
|
||||
|
||||
@@ -35,6 +35,9 @@ public class UpdateAdminReqVO {
|
||||
@Schema(description = "email", example = "staff@new-staff.com")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "실사지역코드", example = "code.region.main.1")
|
||||
private String regionMainCode;
|
||||
|
||||
@Schema(description = "계정 비활성화 여부", example = "false")
|
||||
private Boolean accountDisabled;
|
||||
|
||||
|
||||
@@ -30,8 +30,6 @@ public class AuditCommand {
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
this.updatedBy = getCurrentUsername();
|
||||
this.deletedAt = LocalDateTime.now();
|
||||
this.deletedBy = getCurrentUsername();
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ public class InitAdminData implements ApplicationRunner {
|
||||
"test-admin",
|
||||
"admin1@#$",
|
||||
"admin@framework.org",
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
List.of("ROLE_ADMIN"));
|
||||
@@ -43,6 +44,7 @@ public class InitAdminData implements ApplicationRunner {
|
||||
"test-analyst",
|
||||
"analyst1@#$",
|
||||
"analyst@framework.org",
|
||||
"code.region.main.1",
|
||||
false,
|
||||
false,
|
||||
List.of("ROLE_ANALYST"));
|
||||
@@ -53,6 +55,7 @@ public class InitAdminData implements ApplicationRunner {
|
||||
"test-researcher",
|
||||
"researcher1@#$",
|
||||
"researcher@framework.org",
|
||||
"code.region.main.1",
|
||||
false,
|
||||
false,
|
||||
List.of("ROLE_RESEARCHER"));
|
||||
|
||||
@@ -27,23 +27,24 @@ public class InitFrontUserData implements ApplicationRunner {
|
||||
return;
|
||||
}
|
||||
|
||||
createHouseholdPortIn.operate(new CreateHouseholdInCmd(
|
||||
"11111",
|
||||
"테스트임가",
|
||||
58,
|
||||
null,
|
||||
"01011111111",
|
||||
"서울",
|
||||
"마포구",
|
||||
"와와빌딩 2층",
|
||||
14,
|
||||
13,
|
||||
11,
|
||||
10,
|
||||
10,
|
||||
true,
|
||||
null,
|
||||
null
|
||||
));
|
||||
// createHouseholdPortIn.operate(new CreateHouseholdInCmd(
|
||||
// "11111",
|
||||
// "테스트임가",
|
||||
// 58,
|
||||
// null,
|
||||
// "010-1111-1111",
|
||||
// "code.region.main.1", // 서울
|
||||
// "code.region.sub.31", // 경기도
|
||||
// "code.region.detail.9", // 경기
|
||||
// "경기도 성남시 분당구 산성대로 437번길",
|
||||
// null,
|
||||
// null,
|
||||
// null,
|
||||
// null,
|
||||
// null,
|
||||
// true,
|
||||
// null,
|
||||
// null
|
||||
// ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,22 +47,22 @@ public class InitUICodeData implements ApplicationRunner {
|
||||
|
||||
uiCodeSavePortIn.connect(
|
||||
new UICodeSaveCommand(
|
||||
UICODE_PAGEABLE_ROWS + ".10", UICODE_PAGEABLE_ROWS, 1, "10", "10", null, true),
|
||||
UICODE_PAGEABLE_ROWS + ".10", UICODE_PAGEABLE_ROWS, 0, "10", "10", null, true),
|
||||
false);
|
||||
|
||||
uiCodeSavePortIn.connect(
|
||||
new UICodeSaveCommand(
|
||||
UICODE_PAGEABLE_ROWS + ".20", UICODE_PAGEABLE_ROWS, 2, "20", "20", null, true),
|
||||
UICODE_PAGEABLE_ROWS + ".20", UICODE_PAGEABLE_ROWS, 1, "20", "20", null, true),
|
||||
false);
|
||||
|
||||
uiCodeSavePortIn.connect(
|
||||
new UICodeSaveCommand(
|
||||
UICODE_PAGEABLE_ROWS + ".50", UICODE_PAGEABLE_ROWS, 3, "50", "50", null, true),
|
||||
UICODE_PAGEABLE_ROWS + ".50", UICODE_PAGEABLE_ROWS, 2, "50", "50", null, true),
|
||||
false);
|
||||
|
||||
uiCodeSavePortIn.connect(
|
||||
new UICodeSaveCommand(
|
||||
UICODE_PAGEABLE_ROWS + ".100", UICODE_PAGEABLE_ROWS, 4, "100", "100", null, true),
|
||||
UICODE_PAGEABLE_ROWS + ".100", UICODE_PAGEABLE_ROWS, 3, "100", "100", null, true),
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,8 +32,8 @@ public class RemoveInitData implements ApplicationRunner {
|
||||
mapper.deleteAllAdminHasRole();
|
||||
mapper.deleteAllAdmin();
|
||||
|
||||
mapper.deleteAllHouseholdHasRole();
|
||||
mapper.deleteAllHousehold();
|
||||
// mapper.deleteAllHouseholdHasRole();
|
||||
// mapper.deleteAllHousehold();
|
||||
|
||||
mapper.deleteAllRoleHasPrivilege();
|
||||
mapper.deleteAllPrivilege();
|
||||
@@ -44,7 +44,7 @@ public class RemoveInitData implements ApplicationRunner {
|
||||
mapper.deleteAllFrontUserHasRole();
|
||||
mapper.deleteAllFrontUser();
|
||||
|
||||
mapper.deleteAllRole();
|
||||
// mapper.deleteAllRole();
|
||||
|
||||
mapper.deleteAllUicode();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package app.module.core.config.application.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum UiCodeType {
|
||||
REGION_MAIN("code.region.main"),
|
||||
REGION_SUB("code.region.sub");
|
||||
private final String desc;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.core.config.application.exception;
|
||||
|
||||
public class NoRecordDataException extends RuntimeException {
|
||||
/**
|
||||
* 생성자
|
||||
*/
|
||||
public NoRecordDataException() {
|
||||
super("데이터 없음");
|
||||
}
|
||||
|
||||
/**
|
||||
* 생성자
|
||||
*
|
||||
* @param message 예외 메시지
|
||||
*/
|
||||
public NoRecordDataException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ public interface SaveAdminPortIn {
|
||||
String id,
|
||||
String password,
|
||||
String email,
|
||||
String regionMainCode,
|
||||
Boolean accountDisabled,
|
||||
Boolean accountLocked,
|
||||
List<String> roleIds);
|
||||
|
||||
@@ -26,6 +26,7 @@ public class SaveAdminService implements SaveAdminPortIn {
|
||||
String id,
|
||||
String password,
|
||||
String email,
|
||||
String regionMainCode,
|
||||
Boolean accountDisabled,
|
||||
Boolean accountLocked,
|
||||
List<String> roleIds) {
|
||||
@@ -58,6 +59,7 @@ public class SaveAdminService implements SaveAdminPortIn {
|
||||
password,
|
||||
passwordUpdatedAt,
|
||||
email,
|
||||
regionMainCode,
|
||||
accountDisabled,
|
||||
loginFailCnt,
|
||||
accountLocked,
|
||||
|
||||
@@ -16,6 +16,7 @@ public class SaveAdminCmd extends AuditCommand {
|
||||
private String encodedPassword;
|
||||
private LocalDateTime passwordUpdatedAt;
|
||||
private String email;
|
||||
private String regionMainCode;
|
||||
private Boolean accountDisabled;
|
||||
private Integer loginFailCnt;
|
||||
private Boolean accountLocked;
|
||||
|
||||
@@ -17,7 +17,8 @@ public class AdminView implements Serializable {
|
||||
private String password;
|
||||
private String email;
|
||||
private String name;
|
||||
private String contact;
|
||||
private String phone;
|
||||
private String regionMainCode;
|
||||
private Integer inspectionArea;
|
||||
private LocalDateTime passwordUpdatedAt;
|
||||
private Boolean accountDisabled;
|
||||
|
||||
@@ -27,13 +27,14 @@ class CreateHouseholdService implements CreateHouseholdPortIn {
|
||||
inCmd.getTel(),
|
||||
inCmd.getPhone(),
|
||||
passwordEncoder.encode(StringUtils.right(inCmd.getPhone(), 4)), // 비밀번호 핸드폰 뒤 네자리
|
||||
inCmd.getRegion(),
|
||||
inCmd.getCity(),
|
||||
inCmd.getAddressDetail(),
|
||||
inCmd.getRegionMainCode(),
|
||||
inCmd.getRegionSubCode(),
|
||||
inCmd.getRegionDetailCode(),
|
||||
inCmd.getAddress(),
|
||||
inCmd.getIndustryLargeCode(),
|
||||
inCmd.getIndustryMiddleCode(),
|
||||
inCmd.getIndustrySmallCode(),
|
||||
inCmd.getScaleCode(),
|
||||
inCmd.getIndustrySubMiddle(),
|
||||
inCmd.getIndustryDetail(),
|
||||
inCmd.getEmploymentCode(),
|
||||
inCmd.getIsPanel(),
|
||||
inCmd.getMemo(),
|
||||
|
||||
@@ -15,13 +15,14 @@ public class CreateHouseholdInCmd {
|
||||
private Integer ownerAge;
|
||||
private String tel;
|
||||
private String phone;
|
||||
private String region;
|
||||
private String city;
|
||||
private String addressDetail;
|
||||
private String regionMainCode;
|
||||
private String regionSubCode;
|
||||
private String regionDetailCode;
|
||||
private String address;
|
||||
private Integer industryLargeCode;
|
||||
private Integer industryMiddleCode;
|
||||
private Integer industrySmallCode;
|
||||
private Integer scaleCode;
|
||||
private Integer industrySubMiddle;
|
||||
private Integer industryDetail;
|
||||
private Integer employmentCode;
|
||||
private Boolean isPanel;
|
||||
private String memo;
|
||||
|
||||
@@ -19,13 +19,14 @@ public class CreateHouseholdOutCmd extends AuditCommand {
|
||||
private String tel;
|
||||
private String phone;
|
||||
private String encodedPassword;
|
||||
private String region;
|
||||
private String city;
|
||||
private String addressDetail;
|
||||
private String regionMainCode;
|
||||
private String regionSubCode;
|
||||
private String regionDetailCode;
|
||||
private String address;
|
||||
private Integer industryLargeCode;
|
||||
private Integer industryMiddleCode;
|
||||
private Integer industrySmallCode;
|
||||
private Integer scaleCode;
|
||||
private Integer industrySubMiddle;
|
||||
private Integer industryDetail;
|
||||
private Integer employmentCode;
|
||||
private Boolean isPanel;
|
||||
private String memo;
|
||||
|
||||
@@ -22,14 +22,15 @@ public class GetHousehold {
|
||||
private String tel;
|
||||
private String phone;
|
||||
private String password;
|
||||
private String region;
|
||||
private String city;
|
||||
private String addressDetail;
|
||||
private Integer industryLargeCode;
|
||||
private Integer industryMiddleCode;
|
||||
private Integer industrySmallCode;
|
||||
private Integer scaleCode;
|
||||
private Integer employmentCode;
|
||||
private String regionMainCode;
|
||||
private String regionSubCode;
|
||||
private String regionDetailCode;
|
||||
private String address;
|
||||
private String industryLargeCode;
|
||||
private String industryMiddleCode;
|
||||
private String industrySubMiddle;
|
||||
private String industryDetail;
|
||||
private String employmentCode;
|
||||
private Boolean isPanel;
|
||||
private String memo;
|
||||
private String dropReason;
|
||||
|
||||
@@ -18,7 +18,5 @@ public class UpdateFrontHouseholdCmd extends AuditCommand {
|
||||
private Integer ownerAge;
|
||||
private String tel;
|
||||
private String phone;
|
||||
private String region;
|
||||
private String city;
|
||||
private String addressDetail;
|
||||
private String address;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ spring:
|
||||
sql:
|
||||
init:
|
||||
schema-locations: classpath:sql/schema/*.sql
|
||||
data-locations: classpath:sql/data/*.sql
|
||||
|
||||
# ==============================================
|
||||
# 암호화 설정
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
a.password,
|
||||
a.email,
|
||||
a.name,
|
||||
a.contact,
|
||||
a.inspection_area,
|
||||
a.phone,
|
||||
a.region_main_code,
|
||||
a.password_updated_at,
|
||||
a.account_disabled,
|
||||
a.login_fail_cnt,
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
id,
|
||||
password,
|
||||
email,
|
||||
region_main_code,
|
||||
password_updated_at,
|
||||
account_disabled,
|
||||
login_fail_cnt,
|
||||
@@ -22,6 +23,7 @@
|
||||
#{id},
|
||||
#{encodedPassword},
|
||||
#{email},
|
||||
#{regionMainCode},
|
||||
#{passwordUpdatedAt},
|
||||
#{accountDisabled},
|
||||
#{loginFailCnt},
|
||||
@@ -35,6 +37,7 @@
|
||||
SET
|
||||
password = #{encodedPassword},
|
||||
email = #{email},
|
||||
region_main_code = #{regionMainCode},
|
||||
password_updated_at = #{passwordUpdatedAt},
|
||||
account_disabled = #{accountDisabled},
|
||||
login_fail_cnt = #{loginFailCnt},
|
||||
|
||||
@@ -32,8 +32,6 @@
|
||||
</sql>
|
||||
|
||||
<sql id="DeleteBaseSet">
|
||||
updated_by = #{updatedBy},
|
||||
updated_at = #{updatedAt},
|
||||
deleted_by = #{deletedBy},
|
||||
deleted_at = #{deletedAt},
|
||||
is_deleted = true
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
tel,
|
||||
phone,
|
||||
password,
|
||||
region,
|
||||
city,
|
||||
address_detail,
|
||||
region_main_code,
|
||||
region_sub_code,
|
||||
region_detail_code,
|
||||
address,
|
||||
industry_large_code,
|
||||
industry_middle_code,
|
||||
industry_small_code,
|
||||
scale_code,
|
||||
industry_sub_middle,
|
||||
industry_detail,
|
||||
employment_code,
|
||||
is_panel,
|
||||
memo,
|
||||
@@ -37,13 +38,14 @@
|
||||
#{tel},
|
||||
#{phone},
|
||||
#{encodedPassword},
|
||||
#{region},
|
||||
#{city},
|
||||
#{addressDetail},
|
||||
#{regionMainCode},
|
||||
#{regionSubCode},
|
||||
#{regionDetailCode},
|
||||
#{address},
|
||||
#{industryLargeCode},
|
||||
#{industryMiddleCode},
|
||||
#{industrySmallCode},
|
||||
#{scaleCode},
|
||||
#{industrySubMiddle},
|
||||
#{industryDetail},
|
||||
#{employmentCode},
|
||||
#{isPanel},
|
||||
#{memo},
|
||||
|
||||
@@ -14,13 +14,14 @@
|
||||
tel,
|
||||
phone,
|
||||
password,
|
||||
region,
|
||||
city,
|
||||
address_detail,
|
||||
region_main_code,
|
||||
region_sub_code,
|
||||
region_detail_code,
|
||||
address,
|
||||
industry_large_code,
|
||||
industry_middle_code,
|
||||
industry_small_code,
|
||||
scale_code,
|
||||
industry_sub_middle,
|
||||
industry_detail,
|
||||
employment_code,
|
||||
is_panel,
|
||||
memo,
|
||||
|
||||
@@ -11,9 +11,7 @@
|
||||
owner_age = #{ownerAge},
|
||||
tel = #{tel},
|
||||
phone = #{phone},
|
||||
region = #{region},
|
||||
city = #{city},
|
||||
address_detail = #{addressDetail},
|
||||
address = #{address},
|
||||
<include refid="common.fields.UpdateBaseSet" />
|
||||
WHERE seq = ${seq}
|
||||
</update>
|
||||
|
||||
44
core/src/main/resources/sql/data/01_init-data.sql
Normal file
44
core/src/main/resources/sql/data/01_init-data.sql
Normal file
@@ -0,0 +1,44 @@
|
||||
-- 초기 구동시 필요한 권한, 역할 데이터 등록
|
||||
|
||||
-- 권한
|
||||
INSERT INTO privilege
|
||||
(id, description, app_type, order_no, created_at, created_by, updated_at, updated_by, is_deleted)
|
||||
VALUES
|
||||
('ADMIN_API', 'ADMIN API 이용 권한', 'ADMIN', 0, CURRENT_TIMESTAMP, 'INIT_DATA',CURRENT_TIMESTAMP, 'INIT_DATA',false),
|
||||
('ADMIN_ACCESS', 'ADMIN 사이트 접근 권한', 'ADMIN', 1, CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA', false),
|
||||
('FRONT_API', 'Front API 사용권한', 'FRONT', 0, CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA', false),
|
||||
('FRONT_ACCESS', 'Front 사이트 접근 권한', 'FRONT', 1, CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA', false);
|
||||
|
||||
-- 역할
|
||||
INSERT INTO role
|
||||
(id, description, app_type, order_no, created_at, created_by, updated_at, updated_by, is_deleted)
|
||||
VALUES
|
||||
('ROLE_ADMIN', '관리자', 'ADMIN', 0, CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA', false),
|
||||
('ROLE_ANALYST', '연구원', 'ADMIN', 1, CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA', false),
|
||||
('ROLE_RESEARCHER', '조사원', 'ADMIN', 2, CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA', false),
|
||||
('ROLE_GENERAL', '일반 사용자', 'FRONT', 0, CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA', false);
|
||||
|
||||
-- 역할 권한 매핑
|
||||
INSERT INTO role_has_privilege
|
||||
(role_id, privilege_id, created_at, created_by, updated_at, updated_by, is_deleted)
|
||||
VALUES
|
||||
-- ROLE_ADMIN
|
||||
('ROLE_ADMIN', 'ADMIN_API', CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA',
|
||||
false),
|
||||
('ROLE_ADMIN', 'ADMIN_ACCESS', CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA',
|
||||
false),
|
||||
-- ROLE_ANALYST
|
||||
('ROLE_ANALYST', 'ADMIN_API', CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA',
|
||||
false),
|
||||
('ROLE_ANALYST', 'ADMIN_ACCESS', CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA',
|
||||
false),
|
||||
-- ROLE_RESEARCHER
|
||||
('ROLE_RESEARCHER', 'ADMIN_API', CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA',
|
||||
false),
|
||||
('ROLE_RESEARCHER', 'ADMIN_ACCESS', CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA',
|
||||
false),
|
||||
-- ROLE_GENERAL
|
||||
('ROLE_GENERAL', 'FRONT_API', CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA',
|
||||
false),
|
||||
('ROLE_GENERAL', 'FRONT_ACCESS', CURRENT_TIMESTAMP, 'INIT_DATA', CURRENT_TIMESTAMP, 'INIT_DATA',
|
||||
false);
|
||||
134
core/src/main/resources/sql/data/02_uicode.sql
Normal file
134
core/src/main/resources/sql/data/02_uicode.sql
Normal file
@@ -0,0 +1,134 @@
|
||||
-- UI CODE 기본 data 등록
|
||||
INSERT INTO uicode
|
||||
(id, parent_id, code_text, code_value, msg_code, in_use, order_no, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by, is_deleted)
|
||||
VALUES
|
||||
('code', NULL, 'UI Code', '', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.pageable', 'code', 'Pageable', '', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.pageable.rows', 'code.pageable', 'ROW 갯수', '', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.pageable.rows.10', 'code.pageable.rows', '10', '10', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.pageable.rows.20', 'code.pageable.rows', '20', '20', NULL, true, 1, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.pageable.rows.50', 'code.pageable.rows', '50', '50', NULL, true, 2, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.pageable.rows.100', 'code.pageable.rows', '100', '100', NULL, true, 3, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false);
|
||||
|
||||
|
||||
-- ============================================
|
||||
-- 조사지역 관련 UICODE 등록
|
||||
-- ============================================
|
||||
INSERT INTO uicode
|
||||
(id, parent_id, code_text, code_value, msg_code, in_use, order_no, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by, is_deleted)
|
||||
values
|
||||
('code.region', 'code', '조사 지역', '', NULL, true, 1, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false);
|
||||
|
||||
-- 실사
|
||||
INSERT INTO uicode
|
||||
(id, parent_id, code_text, code_value, msg_code, in_use, order_no, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by, is_deleted)
|
||||
values
|
||||
('code.region.main', 'code.region', '실사', '', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.main.1', 'code.region.main', '서울', '1', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.main.2', 'code.region.main', '강원', '2', NULL, true, 1, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.main.3', 'code.region.main', '대전', '3', NULL, true, 2, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.main.4', 'code.region.main', '광주', '4', NULL, true, 3, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.main.5', 'code.region.main', '대구', '5', NULL, true, 4, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.main.6', 'code.region.main', '부산', '6', NULL, true, 5, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false);
|
||||
|
||||
-- 지역
|
||||
INSERT INTO uicode
|
||||
(id, parent_id, code_text, code_value, msg_code, in_use, order_no, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by, is_deleted)
|
||||
VALUES
|
||||
('code.region.sub', 'code.region', '지역', '', NULL, true, 1, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.sub.31', 'code.region.sub', '경기도', '31', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.sub.32', 'code.region.sub', '강원도', '32', NULL, true, 1, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.sub.33', 'code.region.sub', '충청북도', '33', NULL, true, 2, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.sub.34', 'code.region.sub', '충청남도', '34', NULL, true, 3, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.sub.35', 'code.region.sub', '전라북도', '35', NULL, true, 4, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.sub.36', 'code.region.sub', '전라남도', '36', NULL, true, 5, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.sub.37', 'code.region.sub', '경상북도', '37', NULL, true, 6, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.sub.38', 'code.region.sub', '경상남도', '38', NULL, true, 7, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.sub.40', 'code.region.sub', '특광역시', '40', NULL, true, 8, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false);
|
||||
|
||||
-- 세부지역
|
||||
INSERT INTO uicode
|
||||
(id, parent_id, code_text, code_value, msg_code, in_use, order_no, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by, is_deleted)
|
||||
VALUES
|
||||
('code.region.detail', 'code.region', '세부지역', '', NULL, true, 2, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.2', 'code.region.detail', '부산', '2', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.3', 'code.region.detail', '대구', '3', NULL, true, 1, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.5', 'code.region.detail', '광주', '5', NULL, true, 2, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.6', 'code.region.detail', '대전', '6', NULL, true, 3, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.7', 'code.region.detail', '울산', '7', NULL, true, 4, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.8', 'code.region.detail', '세종', '8', NULL, true, 5, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.9', 'code.region.detail', '경기', '9', NULL, true, 6, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.10', 'code.region.detail', '강원', '10', NULL, true, 7, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.11', 'code.region.detail', '충북', '11', NULL, true, 8, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.12', 'code.region.detail', '충남', '12', NULL, true, 9, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.13', 'code.region.detail', '전북', '13', NULL, true, 10, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.14', 'code.region.detail', '전남', '14', NULL, true, 11, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.15', 'code.region.detail', '경북', '15', NULL, true, 12, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.region.detail.16', 'code.region.detail', '경남', '16', NULL, true, 13, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false);
|
||||
|
||||
|
||||
|
||||
-- ============================================
|
||||
-- 업종 관련 UICODE 등록
|
||||
-- ============================================
|
||||
INSERT INTO uicode
|
||||
(id, parent_id, code_text, code_value, msg_code, in_use, order_no, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by, is_deleted)
|
||||
VALUES
|
||||
('code.industry', 'code', '업종', '', NULL, true, 2, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false);
|
||||
|
||||
-- 업종 대분류
|
||||
INSERT INTO uicode
|
||||
(id, parent_id, code_text, code_value, msg_code, in_use, order_no, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by, is_deleted)
|
||||
VALUES
|
||||
('code.industry.large', 'code.industry', '업종 대분류', '', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.large.10', 'code.industry.large', '육림업', '10', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.large.20', 'code.industry.large', '벌목업', '20', NULL, true, 1, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.large.30', 'code.industry.large', '채취업', '30', NULL, true, 2, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.large.40', 'code.industry.large', '수실류재배업', '40', NULL, true, 3, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.large.50', 'code.industry.large', '비수실류재배업', '50', NULL, true, 4, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false);
|
||||
|
||||
-- 업종 중분류
|
||||
INSERT INTO uicode
|
||||
(id, parent_id, code_text, code_value, msg_code, in_use, order_no, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by, is_deleted)
|
||||
VALUES
|
||||
('code.industry.middle', 'code.industry', '업종 중분류', '', NULL, true, 1, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.10', 'code.industry.middle', '육림업', '10', NULL, true, 0, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.20', 'code.industry.middle', '벌목업', '20', NULL, true, 1, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.31', 'code.industry.middle', '송이채취업', '31', NULL, true, 2, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.32', 'code.industry.middle', '기타채취업', '32', NULL, true, 3, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.41', 'code.industry.middle', '밤재배업', '41', NULL, true, 4, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.42', 'code.industry.middle', '대추재배업', '42', NULL, true, 5, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.43', 'code.industry.middle', '은행·오가재배업', '43', NULL, true, 6, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.44', 'code.industry.middle', '기타수실류', '44', NULL, true, 7, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.51', 'code.industry.middle', '표고버섯재배업', '51', NULL, true, 8, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.52', 'code.industry.middle', '광산송이재배업', '52', NULL, true, 9, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.53', 'code.industry.middle', '양송이류재배업', '53', NULL, true, 10, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false),
|
||||
('code.industry.middle.54', 'code.industry.middle', '산나물재배업', '54', NULL, true, 11, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', NULL, NULL, false);
|
||||
|
||||
|
||||
|
||||
-- ============================================
|
||||
-- 일계부 관련 UICODE 등록
|
||||
-- ============================================
|
||||
INSERT INTO uicode
|
||||
(id, parent_id, code_text, code_value, msg_code, in_use, order_no, created_at, created_by, updated_at, updated_by, deleted_at, deleted_by, is_deleted)
|
||||
VALUES
|
||||
-- 일계부
|
||||
('code.record', 'code', '일계부 Code', NULL, NULL, true, 0, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
|
||||
-- 재배형태
|
||||
('code.record.crop', 'code.record', '재배형태', NULL, NULL, true, 0, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
('code.record.crop.11', 'code.record.crop', '당년산/일반', '11', NULL, true, 0, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
('code.record.crop.12', 'code.record.crop', '당년산/유기농', '12', NULL, true, 1, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
('code.record.crop.13', 'code.record.crop', '당년산/무농약', '13', NULL, true, 2, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
('code.record.crop.15', 'code.record.crop', '당년산/GAP 인증', '15', NULL, true, 3, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
|
||||
-- 단위 Code
|
||||
('code.record.unit', 'code.record', '단위 Code', NULL, NULL, true, 0, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
('code.record.unit.gram', 'code.record.unit', 'g', 'g', NULL, true, 0, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
('code.record.unit.kg', 'code.record.unit', 'kg', 'kg', NULL, true, 1, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
|
||||
-- 수입 종류
|
||||
('code.record.income', 'code.record', '단위 Code', NULL, NULL, true, 0, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
('code.record.income.01', 'code.record.income', '종류1', '01', NULL, true, 0, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false),
|
||||
('code.record.income.02', 'code.record.income', '종류2', '02', NULL, true, 1, NOW(), 'khj', NOW(), 'khj', NULL, NULL, false);
|
||||
49
core/src/main/resources/sql/data/03_admin.sql
Normal file
49
core/src/main/resources/sql/data/03_admin.sql
Normal file
@@ -0,0 +1,49 @@
|
||||
-- 관리자
|
||||
INSERT INTO admin
|
||||
(seq, id, email, "password", password_updated_at, "name", contact, region_main_code,
|
||||
account_disabled, login_fail_cnt, account_locked,
|
||||
created_at, created_by, updated_at, updated_by, is_deleted)
|
||||
values
|
||||
(1, 'test-admin', 'admin@test.com', crypt('admin1@#$', gen_salt('bf')), NOW(), '관리자', NULL, NULL,
|
||||
false, 0, false, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', false),
|
||||
|
||||
(2, 'test-analyst', 'analyst@test.com', crypt('analyst1@#$', gen_salt('bf')), NOW(), '연구자', NULL, 'code.region.main.1',
|
||||
false, 0, false, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', false),
|
||||
|
||||
(3, 'test-researcher', 'researcher@test.com', crypt('researcher1@#$', gen_salt('bf')), NOW(), '조사원', NULL, 'code.region.main.1',
|
||||
false, 0, false, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', false),
|
||||
|
||||
(4, 'researcher1', 'researcher1@test.com', crypt('researcher1@#$', gen_salt('bf')), NOW(), '송지영', '010-9900-8202', 'code.region.main.1',
|
||||
false, 0, false, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', false),
|
||||
|
||||
(5, 'researcher2', 'researcher2@test.com', crypt('researcher1@#$', gen_salt('bf')), NOW(), '여문자', '010-8337-1634', 'code.region.main.1',
|
||||
false, 0, false, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', false),
|
||||
|
||||
(6, 'researcher3', 'researcher3@test.com', crypt('researcher1@#$', gen_salt('bf')), NOW(), '유정화', '010-2777-5371', 'code.region.main.1',
|
||||
false, 0, false, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', false),
|
||||
|
||||
(7, 'researcher4', 'researcher4@test.com', crypt('researcher1@#$', gen_salt('bf')), NOW(), '최명주', '010-3550-0903', 'code.region.main.1',
|
||||
false, 0, false, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', false),
|
||||
|
||||
(8, 'researcher5', 'researcher5@test.com', crypt('researcher1@#$', gen_salt('bf')), NOW(), '허인순', '010-2320-4943', 'code.region.main.1',
|
||||
false, 0, false, NOW(), 'INIT_DATA', NOW(), 'INIT_DATA', false);
|
||||
|
||||
|
||||
-- 관리자 역할 매핑
|
||||
-- 관리자
|
||||
INSERT INTO admin_has_role (admin_seq, role_id, created_at, created_by, is_deleted)
|
||||
VALUES (1, 'ROLE_ADMIN', NOW(), 'INIT_DATA', false);
|
||||
|
||||
-- 연구원
|
||||
INSERT INTO admin_has_role (admin_seq, role_id, created_at, created_by, is_deleted)
|
||||
VALUES (2, 'ROLE_ANALYST', NOW(), 'INIT_DATA', false);
|
||||
|
||||
-- 조사원
|
||||
INSERT INTO admin_has_role (admin_seq, role_id, created_at, created_by, is_deleted)
|
||||
VALUES
|
||||
(3, 'ROLE_RESEARCHER', NOW(), 'INIT_DATA', false),
|
||||
(4, 'ROLE_RESEARCHER', NOW(), 'INIT_DATA', false),
|
||||
(5, 'ROLE_RESEARCHER', NOW(), 'INIT_DATA', false),
|
||||
(6, 'ROLE_RESEARCHER', NOW(), 'INIT_DATA', false),
|
||||
(7, 'ROLE_RESEARCHER', NOW(), 'INIT_DATA', false),
|
||||
(8, 'ROLE_RESEARCHER', NOW(), 'INIT_DATA', false);
|
||||
@@ -13,6 +13,24 @@ DROP TABLE IF EXISTS researcher_has_household;
|
||||
DROP TABLE IF EXISTS researcher_has_area;
|
||||
DROP TABLE IF EXISTS research_area;
|
||||
|
||||
-- NEW 일계부 연관 테이블(hj)
|
||||
DROP TABLE IF EXISTS daily_income;
|
||||
DROP TABLE IF EXISTS daily_expense;
|
||||
DROP TABLE IF EXISTS daily_work;
|
||||
DROP TABLE IF EXISTS daily_power;
|
||||
DROP TABLE IF EXISTS daily_forestry;
|
||||
DROP TABLE IF EXISTS daily_farming;
|
||||
DROP TABLE IF EXISTS daily_record;
|
||||
DROP TABLE IF EXISTS daily_day_group;
|
||||
|
||||
DROP SEQUENCE IF EXISTS daily_income_seq;
|
||||
DROP SEQUENCE IF EXISTS daily_expense_seq;
|
||||
DROP SEQUENCE IF EXISTS daily_work_seq;
|
||||
DROP SEQUENCE IF EXISTS daily_power_seq;
|
||||
DROP SEQUENCE IF EXISTS daily_forestry_seq;
|
||||
DROP SEQUENCE IF EXISTS daily_farming_seq;
|
||||
DROP SEQUENCE IF EXISTS daily_record_seq;
|
||||
|
||||
-- household 연관 테이블
|
||||
DROP TABLE IF EXISTS suggestion;
|
||||
DROP TABLE IF EXISTS upload_receipt_files;
|
||||
|
||||
@@ -186,8 +186,8 @@ CREATE TABLE admin (
|
||||
password varchar(255), -- 비밀번호
|
||||
password_updated_at timestamp(6) NOT NULL, -- 비밀번호 수정일
|
||||
name varchar(4), -- 관리자 이름
|
||||
contact varchar(15), -- 연락처
|
||||
inspection_area varchar(10), -- 실사지역
|
||||
phone varchar(255), -- 연락처
|
||||
region_main_code varchar(255), -- 실사(공통코드)
|
||||
account_disabled boolean, -- 계정 비활성화 여부
|
||||
login_fail_cnt integer, -- 로그인 실패 횟수
|
||||
account_locked boolean, -- 계정 잠김 여부
|
||||
@@ -210,8 +210,8 @@ COMMENT ON COLUMN admin.email IS '이메일';
|
||||
COMMENT ON COLUMN admin.password IS '비밀번호';
|
||||
COMMENT ON COLUMN admin.password_updated_at IS '비밀번호 수정일';
|
||||
COMMENT ON COLUMN admin.name IS '관리자 이름';
|
||||
COMMENT ON COLUMN admin.contact IS '연락처';
|
||||
COMMENT ON COLUMN admin.inspection_area IS '실사지역';
|
||||
COMMENT ON COLUMN admin.phone IS '연락처';
|
||||
COMMENT ON COLUMN admin.region_main_code IS '실사';
|
||||
COMMENT ON COLUMN admin.account_disabled IS '계정 비활성화 여부';
|
||||
COMMENT ON COLUMN admin.login_fail_cnt IS '로그인 실패 횟수';
|
||||
COMMENT ON COLUMN admin.account_locked IS '계정 잠김 여부';
|
||||
@@ -270,52 +270,53 @@ COMMENT ON COLUMN admin_has_role.is_deleted IS '삭제여부';
|
||||
CREATE SEQUENCE household_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE;
|
||||
|
||||
CREATE TABLE household (
|
||||
seq bigint NOT NULL DEFAULT nextval('household_seq'), -- 가구 일련번호 (PK)
|
||||
household_num varchar(255) NOT NULL, -- 가구 번호
|
||||
owner_name varchar(10) NOT NULL, -- 소유자 이름
|
||||
owner_age integer NOT NULL, -- 소유자 나이
|
||||
tel varchar(20), -- 유선 전화번호
|
||||
phone varchar(15) NOT NULL, -- 휴대폰 번호
|
||||
password varchar(255) NOT NULL, -- 비밀번호
|
||||
region varchar(255), -- 지역
|
||||
city varchar(255), -- 도시
|
||||
address_detail varchar(100), -- 상세 주소
|
||||
industry_large_code varchar(255), -- 산업 대분류 코드(매핑코드)
|
||||
industry_middle_code varchar(255), -- 산업 중분류 코드(매핑코드)
|
||||
industry_small_code varchar(255), -- 산업 소분류 코드(매핑코드)
|
||||
scale_code varchar(255), -- 사업장 규모 코드(매핑코드)
|
||||
employment_code varchar(255), -- 전/겸업 코드(매핑코드)
|
||||
is_panel boolean DEFAULT true, -- 패널 여부
|
||||
memo varchar(255), -- 메모
|
||||
drop_reason varchar(50), -- 탈락 사유
|
||||
created_at timestamp(6), -- 생성일시
|
||||
created_by varchar(255), -- 생성자
|
||||
updated_at timestamp(6), -- 수정일시
|
||||
updated_by varchar(255), -- 수정자
|
||||
deleted_at timestamp(6), -- 삭제일시
|
||||
deleted_by varchar(255), -- 삭제자
|
||||
is_deleted boolean DEFAULT false NOT NULL, -- 삭제 여부
|
||||
seq bigint NOT NULL DEFAULT nextval('household_seq'), -- 가구 일련번호 (PK)
|
||||
household_num varchar(255) NOT NULL, -- 가구 번호
|
||||
owner_name varchar(255) NOT NULL, -- 경영주 이름
|
||||
owner_age integer NOT NULL, -- 경영주 나이
|
||||
tel varchar(20), -- 유선 전화번호
|
||||
phone varchar(255) NOT NULL, -- 휴대폰 번호
|
||||
password varchar(255) NOT NULL, -- 비밀번호
|
||||
region_main_code varchar(255), -- 실사(공통코드)
|
||||
region_sub_code varchar(255), -- 지역(공통코드)
|
||||
region_detail_code varchar(255), -- 상세지역(공통코드)
|
||||
address varchar(255), -- 전체 주소
|
||||
industry_large_code varchar(255), -- 업종 대분류 코드(공통코드)
|
||||
industry_middle_code varchar(255), -- 업종 중분류1 코드(공통코드)
|
||||
industry_sub_middle varchar(255), -- 업종 중분류2
|
||||
industry_detail varchar(255), -- 규모/세부품목
|
||||
employment_code varchar(255), -- 전/겸업 코드(공통코드) -- TODO: 필요한지 체크
|
||||
is_panel boolean DEFAULT true, -- 패널 여부
|
||||
memo varchar(255), -- 메모
|
||||
drop_reason varchar(50), -- 탈락 사유
|
||||
created_at timestamp(6), -- 생성일시
|
||||
created_by varchar(255), -- 생성자
|
||||
updated_at timestamp(6), -- 수정일시
|
||||
updated_by varchar(255), -- 수정자
|
||||
deleted_at timestamp(6), -- 삭제일시
|
||||
deleted_by varchar(255), -- 삭제자
|
||||
is_deleted boolean DEFAULT false NOT NULL, -- 삭제 여부
|
||||
|
||||
CONSTRAINT household_pkey PRIMARY KEY (seq)
|
||||
);
|
||||
|
||||
COMMENT ON TABLE household IS '가구(패널) 정보 테이블';
|
||||
|
||||
COMMENT ON COLUMN household.seq IS '가구 일련번호 (PK)';
|
||||
COMMENT ON COLUMN household.household_num IS '가구 번호';
|
||||
COMMENT ON COLUMN household.owner_name IS '소유자 이름';
|
||||
COMMENT ON COLUMN household.owner_age IS '소유자 나이';
|
||||
COMMENT ON COLUMN household.owner_name IS '경영주 이름';
|
||||
COMMENT ON COLUMN household.owner_age IS '경영주 나이';
|
||||
COMMENT ON COLUMN household.tel IS '유선 전화번호';
|
||||
COMMENT ON COLUMN household.phone IS '휴대폰 번호';
|
||||
COMMENT ON COLUMN household.password IS '비밀번호';
|
||||
COMMENT ON COLUMN household.region IS '지역';
|
||||
COMMENT ON COLUMN household.city IS '도시';
|
||||
COMMENT ON COLUMN household.address_detail IS '상세 주소';
|
||||
COMMENT ON COLUMN household.industry_large_code IS '산업 대분류 코드 (매핑코드)';
|
||||
COMMENT ON COLUMN household.industry_middle_code IS '산업 중분류 코드(매핑코드)';
|
||||
COMMENT ON COLUMN household.industry_small_code IS '산업 소분류 코드(매핑코드)';
|
||||
COMMENT ON COLUMN household.scale_code IS '사업장 규모 코드(매핑코드)';
|
||||
COMMENT ON COLUMN household.employment_code IS '전/겸업 코드(매핑코드)';
|
||||
COMMENT ON COLUMN household.region_main_code IS '실사(공통코드)';
|
||||
COMMENT ON COLUMN household.region_sub_code IS '지역(공통코드)';
|
||||
COMMENT ON COLUMN household.region_detail_code IS '상세지역(공통코드)';
|
||||
COMMENT ON COLUMN household.address IS '전체 주소';
|
||||
COMMENT ON COLUMN household.industry_large_code IS '업종 대분류 코드(공통코드)';
|
||||
COMMENT ON COLUMN household.industry_middle_code IS '업종 중분류1 코드(공통코드)';
|
||||
COMMENT ON COLUMN household.industry_sub_middle IS '업종 중분류2';
|
||||
COMMENT ON COLUMN household.industry_detail IS '규모/세부품목';
|
||||
COMMENT ON COLUMN household.employment_code IS '전/겸업 코드(공통코드)';
|
||||
COMMENT ON COLUMN household.is_panel IS '패널 여부';
|
||||
COMMENT ON COLUMN household.memo IS '메모';
|
||||
COMMENT ON COLUMN household.drop_reason IS '탈락 사유';
|
||||
@@ -749,8 +750,8 @@ CREATE TABLE uicode(
|
||||
code_text varchar(255),
|
||||
code_value varchar(255),
|
||||
msg_code varchar(255),
|
||||
in_use boolean ,
|
||||
order_no integer ,
|
||||
in_use boolean,
|
||||
order_no integer,
|
||||
created_at timestamp(6),
|
||||
created_by varchar(255),
|
||||
updated_at timestamp(6),
|
||||
@@ -1019,8 +1020,7 @@ CREATE TABLE researcher_household_visit (
|
||||
admin_seq bigint NOT NULL, -- 관리자 일련번호 (조사원)
|
||||
household_seq bigint NOT NULL, -- 임가 일련번호
|
||||
is_gift_sent boolean, -- 답례품 전달 여부
|
||||
is_recall boolean, -- 회수 여부
|
||||
note varchar(255), -- 특이사항 기재란
|
||||
memo varchar(255), -- 메모
|
||||
visit_date date, -- 방문 날짜(yyyy-mm-dd)
|
||||
created_at timestamp(6), -- 생성일
|
||||
created_by varchar(255), -- 생성자
|
||||
@@ -1041,8 +1041,7 @@ COMMENT ON COLUMN researcher_household_visit.id IS '조사원임가방문정보
|
||||
COMMENT ON COLUMN researcher_household_visit.admin_seq IS '관리자 일련번호(조사원)';
|
||||
COMMENT ON COLUMN researcher_household_visit.household_seq IS '임가 일련번호';
|
||||
COMMENT ON COLUMN researcher_household_visit.is_gift_sent IS '답례품 전달 여부';
|
||||
COMMENT ON COLUMN researcher_household_visit.is_recall IS '회수 여부';
|
||||
COMMENT ON COLUMN researcher_household_visit.note IS '특이사항 기재란';
|
||||
COMMENT ON COLUMN researcher_household_visit.memo IS '메모';
|
||||
COMMENT ON COLUMN researcher_household_visit.visit_date IS '방문날짜(yyyy-mm-dd)';
|
||||
COMMENT ON COLUMN researcher_household_visit.created_at IS '생성일';
|
||||
COMMENT ON COLUMN researcher_household_visit.created_by IS '생성자';
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
-- ============================================
|
||||
-- 임가 일계부 입력 관련 테이블 S
|
||||
-- ============================================
|
||||
|
||||
/*
|
||||
DROP TABLE IF EXISTS daily_income;
|
||||
DROP TABLE IF EXISTS daily_expense;
|
||||
DROP TABLE IF EXISTS daily_work;
|
||||
@@ -19,6 +19,7 @@ DROP SEQUENCE IF EXISTS daily_power_seq;
|
||||
DROP SEQUENCE IF EXISTS daily_forestry_seq;
|
||||
DROP SEQUENCE IF EXISTS daily_farming_seq;
|
||||
DROP SEQUENCE IF EXISTS daily_record_seq;
|
||||
*/
|
||||
|
||||
|
||||
-- ============================================
|
||||
@@ -84,7 +85,7 @@ CREATE SEQUENCE daily_record_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE;
|
||||
CREATE TABLE daily_record (
|
||||
id bigint DEFAULT nextval('daily_record_seq') NOT NULL, -- 일계부 작성상태 ID
|
||||
household_seq bigint NOT NULL, -- 임가 일련번호 (FK)
|
||||
month varchar(7) NOT NULL, -- 조사시행 월 (yyyy-mm)
|
||||
record_month varchar(7) NOT NULL, -- 조사시행 월 (yyyy-mm)
|
||||
day_group_no smallint, -- 일계부 작성일자 그룹 번호
|
||||
start_date date, -- 작성시작일(yyyy-mm-dd)
|
||||
end_date date, -- 작성종료일(yyyy-mm-dd)
|
||||
@@ -111,7 +112,7 @@ COMMENT ON TABLE daily_record IS '일계부 일별 작성상태';
|
||||
|
||||
COMMENT ON COLUMN daily_record.id IS '일계부 작성상태 ID';
|
||||
COMMENT ON COLUMN daily_record.household_seq IS '임가 일련번호';
|
||||
COMMENT ON COLUMN daily_record.month IS '조사시행 월 (yyyy-mm)';
|
||||
COMMENT ON COLUMN daily_record.record_month IS '조사시행 월 (yyyy-mm)';
|
||||
COMMENT ON COLUMN daily_record.start_date IS '작성시작일(yyyy-mm-dd)';
|
||||
COMMENT ON COLUMN daily_record.end_date IS '작성종료일(yyyy-mm-dd)';
|
||||
COMMENT ON COLUMN daily_record.day_group_no IS '일계부 작성일자 그룹 번호';
|
||||
@@ -140,15 +141,16 @@ CREATE SEQUENCE daily_income_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE;
|
||||
CREATE TABLE daily_income (
|
||||
id bigint DEFAULT nextval('daily_income_seq') NOT NULL, -- 일계부 수입 ID
|
||||
daily_record_seq bigint NOT NULL, -- 일계부 작성상태 일련번호 (FK)
|
||||
input_type varchar(5), -- 입력 구분(SELF, OCR)
|
||||
is_credit boolean, -- 외상판매 여부
|
||||
crop_code varchar(255), -- 재배형태 코드 (매핑코드)
|
||||
category_code varchar(255) NOT NULL, -- 수입 종류(매핑코드)
|
||||
category_name varchar(30) NOT NULL, -- 수입 종류(직접입력)
|
||||
category_code varchar(255), -- 수입 종류(매핑코드)
|
||||
category_self varchar(30), -- 수입 종류(직접입력)
|
||||
source_purpose varchar(10), -- 수입원(용도)
|
||||
quantity decimal(6,2) NOT NULL, -- 수량
|
||||
unit_code varchar(10) NOT NULL, -- 단위 (매핑코드)
|
||||
price integer NOT NULL, -- 현금(원)
|
||||
estimated_value integer NOT NULL, -- 현물(평가액)
|
||||
quantity decimal(6,2), -- 수량
|
||||
unit_code varchar(255), -- 단위 (매핑코드)
|
||||
price integer, -- 현금(원)
|
||||
estimated_value integer, -- 현물(평가액)
|
||||
created_at timestamp(6), -- 생성일
|
||||
created_by varchar(255), -- 생성자
|
||||
updated_at timestamp(6), -- 수정일
|
||||
@@ -165,10 +167,11 @@ COMMENT ON TABLE daily_income IS '수입내역 - 일계부';
|
||||
|
||||
COMMENT ON COLUMN daily_income.id IS '일계부 수입 ID';
|
||||
COMMENT ON COLUMN daily_income.daily_record_seq IS '일계부 작성상태 일련번호';
|
||||
COMMENT ON COLUMN daily_income.input_type IS '입력 구분(SELF, OCR)';
|
||||
COMMENT ON COLUMN daily_income.is_credit IS '외상판매 여부';
|
||||
COMMENT ON COLUMN daily_income.crop_code IS '재배형태 코드 (매핑코드)';
|
||||
COMMENT ON COLUMN daily_income.category_code IS '수입 종류(매핑코드)';
|
||||
COMMENT ON COLUMN daily_income.category_name IS '수입 종류(직접입력)';
|
||||
COMMENT ON COLUMN daily_income.category_self IS '수입 종류(직접입력)';
|
||||
COMMENT ON COLUMN daily_income.source_purpose IS '수입원(용도)';
|
||||
COMMENT ON COLUMN daily_income.quantity IS '수량';
|
||||
COMMENT ON COLUMN daily_income.unit_code IS '단위 (매핑코드)';
|
||||
@@ -192,15 +195,16 @@ CREATE SEQUENCE daily_expense_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE;
|
||||
CREATE TABLE daily_expense (
|
||||
id bigint DEFAULT nextval('daily_expense_seq') NOT NULL, -- 일계부 지출 ID
|
||||
daily_record_seq bigint NOT NULL, -- 일계부 작성상태 일련번호 (FK)
|
||||
input_type varchar(5), -- 입력 구분(SELF, OCR)
|
||||
is_credit boolean, -- 외상판매 여부
|
||||
crop_code varchar(255), -- 재배형태 코드 (매핑코드)
|
||||
category_code varchar(255) NOT NULL, -- 지출 종류(매핑코드)
|
||||
category_name varchar(30) NOT NULL, -- 지출 종류(직접입력)
|
||||
source_purpose varchar(10), -- 지출원(용도)
|
||||
quantity decimal(6,2) NOT NULL, -- 수량
|
||||
unit_code varchar(10) NOT NULL, -- 단위 (매핑코드)
|
||||
price integer NOT NULL, -- 현금(원)
|
||||
estimated_value integer NOT NULL, -- 현물(평가액)
|
||||
category_code varchar(255), -- 수입 종류(매핑코드)
|
||||
category_self varchar(30), -- 수입 종류(직접입력)
|
||||
source_purpose varchar(10), -- 수입원(용도)
|
||||
quantity decimal(6,2), -- 수량
|
||||
unit_code varchar(255), -- 단위 (매핑코드)
|
||||
price integer, -- 현금(원)
|
||||
estimated_value integer, -- 현물(평가액)
|
||||
created_at timestamp(6), -- 생성일
|
||||
created_by varchar(255), -- 생성자
|
||||
updated_at timestamp(6), -- 수정일
|
||||
@@ -217,10 +221,11 @@ COMMENT ON TABLE daily_expense IS '지출내역 - 일계부';
|
||||
|
||||
COMMENT ON COLUMN daily_expense.id IS '일계부 지출 ID';
|
||||
COMMENT ON COLUMN daily_expense.daily_record_seq IS '일계부 작성상태 일련번호';
|
||||
COMMENT ON COLUMN daily_expense.input_type IS '입력 구분(SELF, OCR)';
|
||||
COMMENT ON COLUMN daily_expense.is_credit IS '외상판매 여부';
|
||||
COMMENT ON COLUMN daily_expense.crop_code IS '재배형태 코드 (매핑코드)';
|
||||
COMMENT ON COLUMN daily_expense.category_code IS '지출 종류(매핑코드)';
|
||||
COMMENT ON COLUMN daily_expense.category_name IS '지출 종류(직접입력)';
|
||||
COMMENT ON COLUMN daily_expense.category_self IS '지출 종류(직접입력)';
|
||||
COMMENT ON COLUMN daily_expense.source_purpose IS '지출원(용도)';
|
||||
COMMENT ON COLUMN daily_expense.quantity IS '수량';
|
||||
COMMENT ON COLUMN daily_expense.unit_code IS '단위 (매핑코드)';
|
||||
|
||||
73
core/src/main/resources/sql/schema/04_create-view.sql
Normal file
73
core/src/main/resources/sql/schema/04_create-view.sql
Normal file
@@ -0,0 +1,73 @@
|
||||
-- DROP VIEW
|
||||
DROP VIEW v_uicode_view_name;
|
||||
DROP VIEW v_household_with_code;
|
||||
|
||||
|
||||
-- CREATE VIEW
|
||||
-- ============================================
|
||||
-- VIEW : v_uicode_view_name
|
||||
-- DESC : 코드값과 텍스트를 조합하여 표시용 이름(name)으로 제공
|
||||
-- ============================================
|
||||
CREATE VIEW v_uicode_view_name AS
|
||||
SELECT
|
||||
id,
|
||||
code_value || '. ' || code_text AS name
|
||||
FROM uicode;
|
||||
|
||||
|
||||
-- ============================================
|
||||
-- VIEW : v_household_with_code
|
||||
-- DESC : household 테이블과 코드명 정보를 조인한 임가 정보 뷰
|
||||
-- ============================================
|
||||
CREATE VIEW v_household_with_code AS
|
||||
SELECT
|
||||
h.seq,
|
||||
h.household_num,
|
||||
h.owner_name,
|
||||
h.phone,
|
||||
h.region_main_code,
|
||||
main.code_text AS region_main_name,
|
||||
h.region_sub_code,
|
||||
sub.name AS region_sub_name,
|
||||
h.region_detail_code,
|
||||
detail.name AS region_detail_name,
|
||||
h.industry_large_code,
|
||||
ind_large.name AS industry_large_name,
|
||||
h.industry_middle_code,
|
||||
ind_middle.name AS industry_middle_name
|
||||
FROM household h
|
||||
LEFT JOIN uicode main ON h.region_main_code = main.id
|
||||
LEFT JOIN v_uicode_view_name sub ON h.region_sub_code = sub.id
|
||||
LEFT JOIN v_uicode_view_name detail ON h.region_detail_code = detail.id
|
||||
LEFT JOIN v_uicode_view_name ind_large ON h.industry_large_code = ind_large.id
|
||||
LEFT JOIN v_uicode_view_name ind_middle ON h.industry_middle_code = ind_middle.id;
|
||||
|
||||
|
||||
-- ============================================
|
||||
-- VIEW : v_household_visit
|
||||
-- DESC : 임가별 방문 정보 뷰 (1차 방문일, 2차 방문일 정보 제공)
|
||||
-- ============================================
|
||||
CREATE VIEW v_household_visit AS
|
||||
SELECT
|
||||
rhh.household_seq AS household_seq,
|
||||
MIN(v.visit_date) AS first_visit_date,
|
||||
MAX(v.visit_date) AS second_visit_date,
|
||||
BOOL_OR(v.is_gift_sent) AS is_gift_sent
|
||||
FROM researcher_household_visit v
|
||||
JOIN researcher_has_household rhh ON v.household_seq = rhh.household_seq
|
||||
WHERE rhh.is_deleted = false
|
||||
GROUP BY rhh.household_seq;
|
||||
|
||||
|
||||
-- ============================================
|
||||
-- VIEW : v_household_researcher
|
||||
-- DESC : 임가별 매핑된 조사원 정보 뷰
|
||||
-- ============================================
|
||||
CREATE VIEW v_household_researcher AS
|
||||
SELECT
|
||||
rhh.household_seq,
|
||||
a.name AS researcher_name,
|
||||
a.phone AS researcher_phone
|
||||
FROM researcher_has_household rhh
|
||||
JOIN admin a ON rhh.admin_seq = a.seq
|
||||
WHERE rhh.is_deleted = false;
|
||||
4
front/.gitignore
vendored
4
front/.gitignore
vendored
@@ -31,3 +31,7 @@ build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Project
|
||||
**/resources/static/pages/**
|
||||
**/resources/static/guide/**
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package app.module.front.config.adapters.persistence.component;
|
||||
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.front.config.application.security.FrontHouseholdUser;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class FrontAuditCommand {
|
||||
private Long householdSeq;
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
private LocalDateTime deletedAt;
|
||||
private String deletedBy;
|
||||
|
||||
public void create() {
|
||||
this.householdSeq = getCurrentUserSeq();
|
||||
this.createdAt = LocalDateTime.now();
|
||||
this.createdBy = getCurrentUsername();
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
this.updatedBy = getCurrentUsername();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
this.householdSeq = getCurrentUserSeq();
|
||||
this.updatedAt = LocalDateTime.now();
|
||||
this.updatedBy = getCurrentUsername();
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
this.householdSeq = getCurrentUserSeq();
|
||||
this.deletedAt = LocalDateTime.now();
|
||||
this.deletedBy = getCurrentUsername();
|
||||
}
|
||||
|
||||
private Long getCurrentUserSeq() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
Object principal = authentication.getPrincipal();
|
||||
Long userseq = null;
|
||||
|
||||
if (principal instanceof UserDetails) {
|
||||
userseq = ((FrontHouseholdUser) principal).getHouseholdSeq();
|
||||
}
|
||||
|
||||
return userseq;
|
||||
}
|
||||
|
||||
private String getCurrentUsername() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
return authentication != null && authentication.isAuthenticated()
|
||||
? CommonUtil.getLoginUsername() : "INIT_DATA";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package app.module.front.config.application.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApiResponse<T> {
|
||||
private String code;
|
||||
private String message;
|
||||
private T data;
|
||||
|
||||
public ApiResponse(String code, String message, T data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> success(T data) {
|
||||
return new ApiResponse<>("SUCCESS", null, data);
|
||||
}
|
||||
public static <T> ApiResponse<T> success(String message) {
|
||||
return new ApiResponse<>("SUCCESS", message, null);
|
||||
}
|
||||
|
||||
|
||||
public static <T> ApiResponse<T> failure(T data) {
|
||||
return new ApiResponse<>("ERROR", null, data);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> failure(String message) {
|
||||
return new ApiResponse<>("ERROR", message, null);
|
||||
}
|
||||
|
||||
|
||||
public static <T> ApiResponse<T> make(String errorCode, String message,T data) {
|
||||
return new ApiResponse<>(errorCode, message, data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class FrontDetailService implements UserDetailsService {
|
||||
.orElseThrow(() -> new UsernameNotFoundException("Invalid username or password."));
|
||||
|
||||
return new FrontHouseholdUser(
|
||||
getHousehold.getSeq(),
|
||||
getHousehold.getHouseholdNum(),
|
||||
getHousehold.getPassword(),
|
||||
true,
|
||||
|
||||
@@ -8,9 +8,11 @@ import org.springframework.security.core.userdetails.User;
|
||||
@Getter
|
||||
public class FrontHouseholdUser extends User {
|
||||
|
||||
private Long householdSeq;
|
||||
private String ownerName;
|
||||
|
||||
public FrontHouseholdUser(
|
||||
Long householdSeq,
|
||||
String householdNum,
|
||||
String password,
|
||||
boolean enabled,
|
||||
@@ -27,6 +29,7 @@ public class FrontHouseholdUser extends User {
|
||||
credentialsNonExpired,
|
||||
accountNonLocked,
|
||||
authorities);
|
||||
this.householdSeq = householdSeq;
|
||||
this.ownerName = ownerName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package app.module.front.config.application.util;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
|
||||
public class AuditUtil {
|
||||
private AuditUtil() {}
|
||||
|
||||
public static <T extends FrontAuditCommand> T create(T cmd) {
|
||||
cmd.create();
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public static <T extends FrontAuditCommand> T update(T cmd) {
|
||||
cmd.update();
|
||||
return cmd;
|
||||
}
|
||||
|
||||
public static <T extends FrontAuditCommand> T delete(T cmd) {
|
||||
cmd.delete();
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package app.module.front.config.application.util;
|
||||
|
||||
import app.module.core.config.adapters.web.security.domain.SocialUser;
|
||||
import app.module.front.config.application.security.FrontHouseholdUser;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AuthUtil {
|
||||
public static Long getUserSeq() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Object principal = authentication.getPrincipal();
|
||||
Long userseq = null;
|
||||
|
||||
if (principal instanceof UserDetails) {
|
||||
userseq = ((FrontHouseholdUser) principal).getHouseholdSeq();
|
||||
}
|
||||
|
||||
return userseq;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package app.module.front.usecase.daily.calendar.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordCalendarDto;
|
||||
import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordStatusDto;
|
||||
import app.module.front.usecase.daily.calendar.web.model.RecordCalendarUIReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
||||
import app.module.front.usecase.daily.record.persistence.model.UpdateDailyRecordStatusCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface RecordCalendarMapper {
|
||||
|
||||
List<DailyRecordCalendarDto> getCalendarByDailyRecord(RecordCalendarUIReqVO reqVO);
|
||||
|
||||
DailyRecordStatusDto getDailyRecordStatus(RecordCalendarUIReqVO reqVO);
|
||||
|
||||
int getStartDayByDailyGroupNo(@Param("groupNo") Integer groupNo);
|
||||
|
||||
/**
|
||||
* 일계부 등록 여부
|
||||
* @param householdSeq
|
||||
* @param recordMonth
|
||||
* @param dayGroupNo
|
||||
* @return
|
||||
*/
|
||||
Long getDailyRecordExistCount(@Param("householdSeq") Long householdSeq, @Param("recordMonth") String recordMonth, @Param("dayGroupNo") Integer dayGroupNo);
|
||||
|
||||
/**
|
||||
* 일계부 등록(생성)
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
Long createDailyRecord(CreateDailyRecordReqVO command);
|
||||
|
||||
/**
|
||||
* 일계부 상태 수정
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
int updateDailyRecordStatus(UpdateDailyRecordStatusCmd command);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.front.usecase.daily.calendar.persistence.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyRecordCalendarDto {
|
||||
private String groupNo;
|
||||
private Integer startDay;
|
||||
private Integer endDay;
|
||||
private String startDate;
|
||||
private String dailyId;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package app.module.front.usecase.daily.calendar.persistence.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class DailyRecordStatusDto {
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyId;
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
/**
|
||||
* 특정일 입력 상태 TODO enum
|
||||
*/
|
||||
private String allStatus;
|
||||
/**
|
||||
* 수입 입력 상태 TODO enum
|
||||
*/
|
||||
private String incomeStatus;
|
||||
/**
|
||||
* 수입 입력 개수
|
||||
*/
|
||||
private Integer incomeCount;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.front.usecase.daily.calendar.service;
|
||||
|
||||
|
||||
import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordCalendarDto;
|
||||
import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordStatusDto;
|
||||
import app.module.front.usecase.daily.calendar.web.model.RecordCalendarUIReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface RecordCalendarService {
|
||||
List<DailyRecordCalendarDto> getCalendarByDailyRecord(RecordCalendarUIReqVO reqVO);
|
||||
|
||||
DailyRecordStatusDto getDailyRecordStatus(RecordCalendarUIReqVO reqVO);
|
||||
|
||||
int getStartDayByDailyGroupNo(RecordCalendarUIReqVO reqVO);
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package app.module.front.usecase.daily.calendar.service;
|
||||
|
||||
import app.module.front.usecase.daily.calendar.persistence.RecordCalendarMapper;
|
||||
import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordCalendarDto;
|
||||
import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordStatusDto;
|
||||
import app.module.front.usecase.daily.calendar.web.model.RecordCalendarUIReqVO;
|
||||
import app.module.front.usecase.daily.record.persistence.DailyRecordMapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RecordCalendarServiceImpl implements RecordCalendarService {
|
||||
private final RecordCalendarMapper recordCalendarMapper;
|
||||
|
||||
@Override
|
||||
public List<DailyRecordCalendarDto> getCalendarByDailyRecord(RecordCalendarUIReqVO reqVO) {
|
||||
int lastDay = reqVO.getSearchDate().withDayOfMonth(reqVO.getSearchDate().lengthOfMonth()).getDayOfMonth();
|
||||
|
||||
List<DailyRecordCalendarDto> list = recordCalendarMapper.getCalendarByDailyRecord(reqVO);
|
||||
|
||||
List<DailyRecordCalendarDto> refineList = new ArrayList<DailyRecordCalendarDto>();
|
||||
for (DailyRecordCalendarDto record : list) {
|
||||
record.setStartDate(reqVO.getSearchMonth() + String.format("%02d", record.getStartDay()));
|
||||
|
||||
if ((lastDay == 28 || lastDay == 30) && record.getStartDay() == lastDay) {
|
||||
record.setEndDay(lastDay);
|
||||
refineList.add(record);
|
||||
} else if (record.getStartDay() <= lastDay && record.getEndDay() <= lastDay) {
|
||||
refineList.add(record);
|
||||
}
|
||||
}
|
||||
|
||||
return refineList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyRecordStatusDto getDailyRecordStatus(RecordCalendarUIReqVO reqVO) {
|
||||
return recordCalendarMapper.getDailyRecordStatus(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDayByDailyGroupNo(RecordCalendarUIReqVO reqVO) {
|
||||
return recordCalendarMapper.getStartDayByDailyGroupNo(reqVO.getGroupNo());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package app.module.front.usecase.daily.calendar.web;
|
||||
|
||||
import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordCalendarDto;
|
||||
import app.module.front.usecase.daily.calendar.persistence.model.DailyRecordStatusDto;
|
||||
import app.module.front.usecase.daily.calendar.service.RecordCalendarService;
|
||||
import app.module.front.usecase.daily.calendar.web.model.RecordCalendarUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/record/calendar")
|
||||
public class RecordCalendarController {
|
||||
private final RecordCalendarService recordCalendarService;
|
||||
|
||||
@GetMapping(path = "")
|
||||
public String index(Model model, @RequestParam(value = "searchDay", required = false) String searchDay) {
|
||||
RecordCalendarUIReqVO reqVO = new RecordCalendarUIReqVO(searchDay, getAccessId());
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("calendarList", recordCalendarService.getCalendarByDailyRecord(reqVO));
|
||||
|
||||
return "record/calendar";
|
||||
}
|
||||
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String detail(Model model
|
||||
, @PathVariable(required = true) String searchMonth
|
||||
, @PathVariable(required = true) String groupNo) {
|
||||
|
||||
RecordCalendarUIReqVO reqVO = new RecordCalendarUIReqVO();
|
||||
reqVO.setSearchMonth(searchMonth);
|
||||
reqVO.setGroupNo(Integer.parseInt(groupNo));
|
||||
reqVO.setHouseholdSeq(getAccessId());
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
DailyRecordStatusDto detail = recordCalendarService.getDailyRecordStatus(reqVO);
|
||||
if (detail == null) {
|
||||
int startDay = recordCalendarService.getStartDayByDailyGroupNo(reqVO);
|
||||
reqVO.setSearchDay(reqVO.getSearchMonth() + String.format("%02d", startDay));
|
||||
}
|
||||
|
||||
//uiCodeListPortIn.connect("code.pageable.rows");
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("detail", detail);
|
||||
|
||||
return "record/calendar-wrap";
|
||||
}
|
||||
|
||||
// TODO : 로그인 SEQ
|
||||
private Long getAccessId() {
|
||||
return 2L;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package app.module.front.usecase.daily.calendar.web.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.apache.tika.utils.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class RecordCalendarUIReqVO {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RecordCalendarUIReqVO.class);
|
||||
|
||||
public RecordCalendarUIReqVO() {
|
||||
}
|
||||
|
||||
public RecordCalendarUIReqVO(String searchDay, Long accessId) {
|
||||
if (StringUtils.isBlank(searchDay) || searchDay.length() != 8) {
|
||||
searchDay = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
}
|
||||
|
||||
try {
|
||||
SimpleDateFormat beforeSdf = new SimpleDateFormat("yyyyMMdd", Locale.KOREAN);
|
||||
SimpleDateFormat afterSdf = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREAN);
|
||||
SimpleDateFormat monthSdf = new SimpleDateFormat("yyyyMM", Locale.KOREAN);
|
||||
|
||||
Date formatDate = beforeSdf.parse(searchDay);
|
||||
|
||||
setSearchDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||
setSearchMonth(monthSdf.format(formatDate));
|
||||
setSearchDay(beforeSdf.format(formatDate));
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("[DateParse] target={}", searchDay, e);
|
||||
}
|
||||
|
||||
setHouseholdSeq(accessId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 검색 일(yyyyMMdd)
|
||||
*/
|
||||
private String searchDay;
|
||||
|
||||
/**
|
||||
* 검색 월(yyyyMM)
|
||||
*/
|
||||
private String searchMonth;
|
||||
private Integer groupNo;
|
||||
|
||||
/**
|
||||
* 검색 일(yyyy-MM-dd)
|
||||
*/
|
||||
private LocalDate searchDate;
|
||||
|
||||
/**
|
||||
* 임가회원 일련번호
|
||||
*/
|
||||
private Long householdSeq;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package app.module.front.usecase.daily.income.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.income.persistence.model.CreateDailyIncomeCmd;
|
||||
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
|
||||
import app.module.front.usecase.daily.income.persistence.model.RemoveDailyIncomeCmd;
|
||||
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DailyIncomeMapper {
|
||||
/**
|
||||
* 수입내역 목록 조회
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 수입내역 데이터 존재 여부
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
Integer getRecordExistCount(DailyIncomeUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 수입내역 등록
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
void createDailyIncome(CreateDailyIncomeCmd command);
|
||||
|
||||
/**
|
||||
* 수입내역 수정
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
int updateDailyIncome(CreateDailyIncomeCmd command);
|
||||
|
||||
/**
|
||||
* 수입내역 삭제
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
int removeDailyIncome(RemoveDailyIncomeCmd command);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package app.module.front.usecase.daily.income.persistence.model;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class CreateDailyIncomeCmd extends FrontAuditCommand {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
// SELF, OCR
|
||||
private String inputType;
|
||||
private Boolean credit;
|
||||
private String cropCode;
|
||||
// TODO : 수입종류의 코드맵핑 여부 판단
|
||||
private String categoryCode;
|
||||
private String categorySelf;
|
||||
private String sourcePurpose;
|
||||
// TODO : 데이터 타입 재정의 여부
|
||||
private Integer quantity;
|
||||
private String unitCode;
|
||||
private Integer price;
|
||||
private Integer estimatedValue;
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package app.module.front.usecase.daily.income.persistence.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class DailyIncomeDto {
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
// SELF, OCR
|
||||
private String inputType;
|
||||
private Boolean credit;
|
||||
private String cropCode;
|
||||
private String cropLabel;
|
||||
private String categoryCode;
|
||||
private String categoryLabel;
|
||||
private String categorySelf;
|
||||
private String sourcePurpose;
|
||||
private Integer quantity;
|
||||
private String unitCode;
|
||||
private String unitLabel;
|
||||
private Integer price;
|
||||
private Integer estimatedValue;
|
||||
|
||||
public boolean isUpdated() {
|
||||
return this.id != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package app.module.front.usecase.daily.income.persistence.model;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class RemoveDailyIncomeCmd extends FrontAuditCommand {
|
||||
private String searchMonth;
|
||||
private Integer groupNo;
|
||||
private Long id;
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package app.module.front.usecase.daily.income.service;
|
||||
|
||||
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
|
||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
||||
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
|
||||
import app.module.front.usecase.daily.income.web.model.RemoveDailyIncomeReqVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DailyIncomeService {
|
||||
/**
|
||||
* 수입내역 목록 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return
|
||||
*/
|
||||
List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 수입내역 조회
|
||||
*
|
||||
* @param reqVO 검색 조건
|
||||
* @return
|
||||
*/
|
||||
DailyIncomeDto getDailyIncome(DailyIncomeUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 수입내역 등록
|
||||
*
|
||||
* @param formVO 등록 데이터
|
||||
*/
|
||||
void create(CreateDailyIncomeReqVO formVO);
|
||||
|
||||
/**
|
||||
* 수입내역 삭제
|
||||
*
|
||||
* @param formVO 검색 조건
|
||||
*/
|
||||
void remove(RemoveDailyIncomeReqVO formVO);
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package app.module.front.usecase.daily.income.service;
|
||||
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import app.module.front.config.application.util.AuditUtil;
|
||||
import app.module.front.usecase.daily.income.persistence.DailyIncomeMapper;
|
||||
import app.module.front.usecase.daily.income.persistence.model.CreateDailyIncomeCmd;
|
||||
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
|
||||
import app.module.front.usecase.daily.income.persistence.model.RemoveDailyIncomeCmd;
|
||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
||||
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
|
||||
import app.module.front.usecase.daily.income.web.model.RemoveDailyIncomeReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyIncomeServiceImpl implements DailyIncomeService {
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyIncomeMapper dailyIncomeMapper;
|
||||
|
||||
@Override
|
||||
public List<DailyIncomeDto> getDailyIncomeList(DailyIncomeUIReqVO reqVO) {
|
||||
return this.getRefineIncomeList(reqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DailyIncomeDto getDailyIncome(DailyIncomeUIReqVO reqVO) {
|
||||
List<DailyIncomeDto> list = this.getRefineIncomeList(reqVO);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
private List<DailyIncomeDto> getRefineIncomeList(DailyIncomeUIReqVO reqVO) {
|
||||
List<DailyIncomeDto> list = dailyIncomeMapper.getDailyIncomeList(reqVO);
|
||||
|
||||
List<UICodeElement> recordIncome = uiCodeListPortIn.connect("code.record.income");
|
||||
List<UICodeElement> recordCrop = uiCodeListPortIn.connect("code.record.crop");
|
||||
List<UICodeElement> recordUnit = uiCodeListPortIn.connect("code.record.unit");
|
||||
|
||||
for (DailyIncomeDto dto : list) {
|
||||
dto.setCategoryLabel(this.getCodeLabel(dto.getCategoryCode(), recordIncome));
|
||||
dto.setCropLabel(this.getCodeLabel(dto.getCropCode(), recordCrop));
|
||||
dto.setUnitLabel(this.getCodeLabel(dto.getUnitCode(), recordUnit));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 코드명 조회
|
||||
* @param code 코드
|
||||
* @param codeList 공통 코드 목록
|
||||
* @return
|
||||
*/
|
||||
private String getCodeLabel(String code, List<UICodeElement> codeList) {
|
||||
String returnValue = null;
|
||||
for (UICodeElement codeSetup : codeList) {
|
||||
if (codeSetup.getCodeValue().equalsIgnoreCase(code)) {
|
||||
returnValue = codeSetup.getCodeText();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void create(CreateDailyIncomeReqVO formVO) {
|
||||
CreateDailyIncomeCmd command = AuditUtil.create(
|
||||
new CreateDailyIncomeCmd(
|
||||
formVO.getId(),
|
||||
formVO.getDailyRecordSeq(),
|
||||
formVO.getInputType(),
|
||||
formVO.getCredit(),
|
||||
formVO.getCropCode(),
|
||||
formVO.getCategoryCode(),
|
||||
formVO.getCategorySelf(),
|
||||
formVO.getSourcePurpose(),
|
||||
formVO.getQuantity(),
|
||||
formVO.getUnitCode(),
|
||||
formVO.getPrice(),
|
||||
formVO.getEstimatedValue()));
|
||||
|
||||
DailyIncomeUIReqVO existReqVO = new DailyIncomeUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
|
||||
existReqVO.setId(formVO.getId());
|
||||
|
||||
Integer existCount = dailyIncomeMapper.getRecordExistCount(existReqVO);
|
||||
if (existCount == 0) {
|
||||
dailyIncomeMapper.createDailyIncome(command);
|
||||
|
||||
log.debug("[CreateDailyIncome] record={}", command);
|
||||
} else {
|
||||
dailyIncomeMapper.updateDailyIncome(command);
|
||||
|
||||
log.debug("[UpdateDailyIncome] record={}", command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemoveDailyIncomeReqVO formVO) {
|
||||
Long id = formVO.getId() != null ? Long.parseLong(formVO.getId()) : null;
|
||||
RemoveDailyIncomeCmd command = AuditUtil.delete(
|
||||
new RemoveDailyIncomeCmd(
|
||||
formVO.getSearchMonth(),
|
||||
formVO.getGroupNo(),
|
||||
id,
|
||||
formVO.getDailyRecordSeq()));
|
||||
|
||||
DailyIncomeUIReqVO existReqVO = new DailyIncomeUIReqVO(formVO.getSearchMonth(), formVO.getGroupNo());
|
||||
existReqVO.setId(id);
|
||||
|
||||
Integer existCount = dailyIncomeMapper.getRecordExistCount(existReqVO);
|
||||
if (existCount != 0) {
|
||||
dailyIncomeMapper.removeDailyIncome(command);
|
||||
|
||||
log.debug("[RemoveDailyIncome] record={}", command);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package app.module.front.usecase.daily.income.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.core.config.application.util.CoreUtil;
|
||||
import app.module.front.usecase.daily.income.service.DailyIncomeService;
|
||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
||||
import app.module.front.usecase.daily.income.web.model.RemoveDailyIncomeReqVO;
|
||||
import app.module.front.usecase.daily.income.web.validator.CreateDailyIncomeValidator;
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/api/record/income")
|
||||
public class DailyIncomeController {
|
||||
private final DailyRecordService dailyRecordService;
|
||||
private final DailyIncomeService dailyIncomeService;
|
||||
private final CreateDailyIncomeValidator createDailyIncomeValidator;
|
||||
private final CoreUtil coreUtil;
|
||||
|
||||
/**
|
||||
* 일계부 수입내역 등록 처리
|
||||
*
|
||||
* @param searchMonth
|
||||
* @param groupNo
|
||||
* @param id
|
||||
* @param formVO
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @PathVariable("id") String id
|
||||
, @Valid @RequestBody CreateDailyIncomeReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
createDailyIncomeValidator.validate(formVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
// return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
// .body(bindingResult.getFieldErrors());
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
formVO.setSearchMonth(searchMonth);
|
||||
formVO.setGroupNo(Integer.parseInt(groupNo));
|
||||
formVO.setId(Long.parseLong(id));
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
dailyIncomeService.create(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/none")
|
||||
ResponseEntity<?> updateByTodayNone(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
RemoveDailyIncomeReqVO formVO = new RemoveDailyIncomeReqVO();
|
||||
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
dailyRecordService.updateDailyRecordStatus(dailyRecord.getRecordMonth(), dailyRecord.getGroupNo(),
|
||||
"INCOME", DailyTargetStatus.TODAY_NONE.name());
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 수입내역 삭제 처리
|
||||
*
|
||||
* @param searchMonth
|
||||
* @param groupNo
|
||||
* @param formVO
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/remove")
|
||||
ResponseEntity<?> remove(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @Valid @RequestBody RemoveDailyIncomeReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
log.debug("formVO: {}", formVO);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
dailyIncomeService.remove(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 수입내역 전체 삭제 처리
|
||||
*
|
||||
* @param searchMonth
|
||||
* @param groupNo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/reset")
|
||||
ResponseEntity<?> removeAll(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
RemoveDailyIncomeReqVO formVO = new RemoveDailyIncomeReqVO();
|
||||
formVO.setSearchMonth(dailyRecord.getRecordMonth());
|
||||
formVO.setGroupNo(dailyRecord.getGroupNo());
|
||||
formVO.setDailyRecordSeq(dailyRecord.getId());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
dailyIncomeService.remove(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(formVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 유효성 체크 및 데이터 조회
|
||||
*
|
||||
* @param searchMonth
|
||||
* @param groupNo
|
||||
* @return
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("getRecordUIReq: {}", reqVO);
|
||||
|
||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package app.module.front.usecase.daily.income.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoRecordDataException;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import app.module.front.usecase.daily.income.persistence.model.DailyIncomeDto;
|
||||
import app.module.front.usecase.daily.income.service.DailyIncomeService;
|
||||
import app.module.front.usecase.daily.income.web.model.DailyIncomeUIReqVO;
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/record/income")
|
||||
public class DailyIncomeUIController {
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final DailyRecordService dailyRecordService;
|
||||
private final DailyIncomeService dailyIncomeService;
|
||||
|
||||
/**
|
||||
* 일계부 수입내역 목록 화면
|
||||
*
|
||||
* @param model Model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String index(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
|
||||
DailyRecordDto dailyRecord = this.vaildGetDailyRecord(searchMonth, groupNo);
|
||||
|
||||
DailyIncomeUIReqVO reqVO = new DailyIncomeUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
List<DailyIncomeDto> incomeList = dailyIncomeService.getDailyIncomeList(reqVO);
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
model.addAttribute("incomeList", incomeList);
|
||||
|
||||
return "record/income/index";
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 수입내역 등록 화면
|
||||
*
|
||||
* @param model
|
||||
* @param searchMonth
|
||||
* @param groupNo
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}/form/{id}")
|
||||
public String formBySelf(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @PathVariable("id") String id) {
|
||||
|
||||
DailyIncomeUIReqVO reqVO = new DailyIncomeUIReqVO(searchMonth, groupNo);
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
reqVO.setId(0L);
|
||||
} else {
|
||||
reqVO.setId(Long.parseLong(id));
|
||||
}
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
DailyIncomeDto detail = new DailyIncomeDto();
|
||||
if (reqVO.getId() != 0L) {
|
||||
detail = dailyIncomeService.getDailyIncome(reqVO);
|
||||
if (detail == null || !detail.isUpdated()) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
}
|
||||
|
||||
model.addAttribute("recordIncome", uiCodeListPortIn.connect("code.record.income"));
|
||||
model.addAttribute("recordCrop", uiCodeListPortIn.connect("code.record.crop"));
|
||||
model.addAttribute("recordUnit", uiCodeListPortIn.connect("code.record.unit"));
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("detail", detail);
|
||||
|
||||
return "record/income/form";
|
||||
}
|
||||
|
||||
/**
|
||||
* 일계부 유효성 체크 및 데이터 조회
|
||||
*
|
||||
* @param searchMonth
|
||||
* @param groupNo
|
||||
* @return
|
||||
*/
|
||||
private DailyRecordDto vaildGetDailyRecord(String searchMonth, String groupNo) {
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("getRecordUIReq: {}", reqVO);
|
||||
|
||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
||||
if (dailyRecord == null || dailyRecord.getId() == null) {
|
||||
throw new NoRecordDataException();
|
||||
}
|
||||
|
||||
return dailyRecord;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package app.module.front.usecase.daily.income.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class CreateDailyIncomeReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 수입 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
/**
|
||||
* 등록 유형(SELF, OCR)
|
||||
*/
|
||||
private String inputType;
|
||||
/**
|
||||
* 외상판매 여부
|
||||
*/
|
||||
private Boolean credit;
|
||||
/**
|
||||
* 재배형태 코드
|
||||
*/
|
||||
private String cropCode;
|
||||
/**
|
||||
* 수입의 종류 코드
|
||||
*/
|
||||
@NotBlank(message = "수입 종류를 선택해 주세요.")
|
||||
private String categoryCode;
|
||||
/**
|
||||
* 수입의 종류 직접입력
|
||||
*/
|
||||
private String categorySelf;
|
||||
/**
|
||||
* 수입원
|
||||
*/
|
||||
@NotBlank(message = "수입원을 입력해 주세요.")
|
||||
private String sourcePurpose;
|
||||
/**
|
||||
* 수량
|
||||
*/
|
||||
private Integer quantity;
|
||||
/**
|
||||
* 단위 코드
|
||||
*/
|
||||
private String unitCode;
|
||||
/**
|
||||
* 현금
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 현물평가액
|
||||
*/
|
||||
private Integer estimatedValue;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package app.module.front.usecase.daily.income.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import org.apache.tika.utils.StringUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class DailyIncomeUIReqVO extends DailyUIReqVO {
|
||||
public DailyIncomeUIReqVO(String month, String no) {
|
||||
setSearchMonth(month);
|
||||
if (!StringUtils.isBlank(no)) {
|
||||
setGroupNo(Integer.parseInt(no));
|
||||
}
|
||||
}
|
||||
|
||||
public DailyIncomeUIReqVO(String month, Integer no) {
|
||||
setSearchMonth(month);
|
||||
setGroupNo(no);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수입 일련번호
|
||||
*/
|
||||
private Long id;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package app.module.front.usecase.daily.income.web.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.web.model.DailyUIReqVO;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class RemoveDailyIncomeReqVO extends DailyUIReqVO {
|
||||
/**
|
||||
* 수입 일련번호
|
||||
*/
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String id;
|
||||
/**
|
||||
* 일계부 일련번호
|
||||
*/
|
||||
private Long dailyRecordSeq;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package app.module.front.usecase.daily.income.web.validator;
|
||||
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.front.usecase.daily.income.web.model.CreateDailyIncomeReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.tika.utils.StringUtils;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CreateDailyIncomeValidator implements Validator {
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
return CreateDailyIncomeReqVO.class.equals(clazz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(Object target, Errors errors) {
|
||||
CreateDailyIncomeReqVO vo = (CreateDailyIncomeReqVO) target;
|
||||
|
||||
if (StringUtils.isBlank(vo.getCategoryCode())) {
|
||||
errors.rejectValue(
|
||||
"categoryCode", "valid.common.required",
|
||||
"수입 종류를 입력해 주세요.");
|
||||
}
|
||||
|
||||
if ("SELF".equals(vo.getCategoryCode()) && StringUtils.isBlank(vo.getCategorySelf())) {
|
||||
errors.rejectValue(
|
||||
"categorySelf", "valid.common.required",
|
||||
"수입 종류를 입력해 주세요.");
|
||||
}
|
||||
|
||||
if (vo.getPrice() == null && vo.getEstimatedValue() == null) {
|
||||
errors.rejectValue(
|
||||
"price", "valid.common.required",
|
||||
"현금 또는 현물평가액을 입력 해주세요.");
|
||||
errors.rejectValue(
|
||||
"estimatedValue", "valid.common.required",
|
||||
"현금 또는 현물평가액을 입력 해주세요.");
|
||||
}
|
||||
|
||||
// TODO : valid
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package app.module.front.usecase.daily.record.persistence;
|
||||
|
||||
import app.module.front.usecase.daily.record.persistence.model.CreateDailyRecordCmd;
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import app.module.front.usecase.daily.record.persistence.model.UpdateDailyRecordStatusCmd;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface DailyRecordMapper {
|
||||
|
||||
DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 등록 여부
|
||||
*
|
||||
* @param reqVO
|
||||
* @return
|
||||
*/
|
||||
Integer getDailyRecordExistCount(DailyRecordUIReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 일계부 등록(생성)
|
||||
*
|
||||
* @param command
|
||||
*/
|
||||
void createDailyRecord(CreateDailyRecordCmd command);
|
||||
|
||||
/**
|
||||
* 일계부 상태 수정
|
||||
*
|
||||
* @param command
|
||||
* @return
|
||||
*/
|
||||
int updateDailyRecordStatus(UpdateDailyRecordStatusCmd command);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package app.module.front.usecase.daily.record.persistence.model;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class CreateDailyRecordCmd extends FrontAuditCommand {
|
||||
private Long id;
|
||||
private String recordMonth;
|
||||
private int dayGroupNo;
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
private DailyStatus allStatus;
|
||||
private DailyTargetStatus incomeStatus;
|
||||
private DailyTargetStatus workStatus;
|
||||
private DailyTargetStatus expenseStatus;
|
||||
private DailyTargetStatus powerStatus;
|
||||
private DailyTargetStatus forestryStatus;
|
||||
private DailyTargetStatus farmingStatus;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package app.module.front.usecase.daily.record.persistence.model;
|
||||
|
||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
||||
import lombok.Data;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class DailyRecordDto {
|
||||
// household_seq, record_month, day_group_no, start_date, end_date
|
||||
// , all_status, income_status, work_status, expense_status, power_status, forestry_status
|
||||
// , created_at, created_by, is_deleted
|
||||
|
||||
private String recordMonth;
|
||||
private Integer groupNo;
|
||||
private Integer startDay;
|
||||
private Integer endDay;
|
||||
|
||||
private Long id;
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
private DailyStatus allStatus;
|
||||
private DailyTargetStatus incomeStatus;
|
||||
private DailyTargetStatus workStatus;
|
||||
private DailyTargetStatus expenseStatus;
|
||||
private DailyTargetStatus powerStatus;
|
||||
private DailyTargetStatus forestryStatus;
|
||||
private DailyTargetStatus farmingStatus;
|
||||
|
||||
public boolean isUpdated() {
|
||||
return this.id != null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package app.module.front.usecase.daily.record.persistence.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class UpdateDailyRecordDto {
|
||||
private String monthly;
|
||||
private String updatedBy;
|
||||
private String statusType;
|
||||
private String statusCode;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.front.usecase.daily.record.persistence.model;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyStatus;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
public class UpdateDailyRecordStatusCmd extends FrontAuditCommand {
|
||||
private String recordMonth;
|
||||
private Integer dayGroupNo;
|
||||
private String allStatus;
|
||||
private String targetType;
|
||||
private String targetStatus;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package app.module.front.usecase.daily.record.service;
|
||||
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
|
||||
public interface DailyRecordService {
|
||||
DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO);
|
||||
|
||||
void createDailyRecord(CreateDailyRecordReqVO reqVO);
|
||||
|
||||
void updateDailyRecordStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus);
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package app.module.front.usecase.daily.record.service;
|
||||
|
||||
import app.module.front.config.application.util.AuditUtil;
|
||||
import app.module.front.usecase.daily.record.persistence.DailyRecordMapper;
|
||||
import app.module.front.usecase.daily.record.persistence.model.CreateDailyRecordCmd;
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.persistence.model.UpdateDailyRecordStatusCmd;
|
||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DailyRecordServiceImpl implements DailyRecordService {
|
||||
private final DailyRecordMapper dailyRecordMapper;
|
||||
|
||||
@Override
|
||||
public DailyRecordDto getDailyRecord(DailyRecordUIReqVO reqVO) {
|
||||
DailyRecordDto detail = dailyRecordMapper.getDailyRecord(reqVO);
|
||||
if (detail != null && !detail.isUpdated()) {
|
||||
try {
|
||||
SimpleDateFormat beforeSdf = new SimpleDateFormat("yyyyMMdd", Locale.KOREAN);
|
||||
SimpleDateFormat afterSdf = new SimpleDateFormat("yyyy-MM-dd", Locale.KOREAN);
|
||||
|
||||
Date formatDate = beforeSdf.parse(reqVO.getSearchMonth() + String.format("%02d", detail.getStartDay()));
|
||||
detail.setStartDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||
|
||||
formatDate = beforeSdf.parse(reqVO.getSearchMonth() + String.format("%02d", detail.getEndDay()));
|
||||
detail.setEndDate(LocalDate.parse(afterSdf.format(formatDate)));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.warn("[DateParse] target={}", detail.getStartDay(), e);
|
||||
}
|
||||
}
|
||||
return detail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createDailyRecord(CreateDailyRecordReqVO reqVO) {
|
||||
CreateDailyRecordCmd command = AuditUtil.create(
|
||||
new CreateDailyRecordCmd(
|
||||
null,
|
||||
reqVO.getRecordMonth(),
|
||||
reqVO.getDayGroupNo(),
|
||||
reqVO.getStartDate(),
|
||||
reqVO.getEndDate(),
|
||||
reqVO.getAllStatus(),
|
||||
reqVO.getIncomeStatus(),
|
||||
reqVO.getWorkStatus(),
|
||||
reqVO.getExpenseStatus(),
|
||||
reqVO.getPowerStatus(),
|
||||
reqVO.getForestryStatus(),
|
||||
reqVO.getFarmingStatus()));
|
||||
|
||||
Integer existCount = dailyRecordMapper.getDailyRecordExistCount(new DailyRecordUIReqVO(reqVO.getRecordMonth(), reqVO.getDayGroupNo()));
|
||||
if (existCount == 0) {
|
||||
dailyRecordMapper.createDailyRecord(command);
|
||||
|
||||
log.debug("[CreateDailyRecord] record={}", command);
|
||||
} else {
|
||||
log.warn("[DailyRecordCreate] existCount={}, recordMonth={}, dayGroupNo={}", existCount, reqVO.getRecordMonth(), reqVO.getDayGroupNo());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDailyRecordStatus(String recordMonth, Integer dayGroupNo, String targetType, String targetStatus) {
|
||||
UpdateDailyRecordStatusCmd command = AuditUtil.update(
|
||||
new UpdateDailyRecordStatusCmd(
|
||||
recordMonth,
|
||||
dayGroupNo,
|
||||
"ALL".equals(targetType) ? targetStatus : null,
|
||||
!"ALL".equals(targetType) ? targetType : null,
|
||||
!"ALL".equals(targetType) ? targetStatus : null
|
||||
)
|
||||
);
|
||||
|
||||
dailyRecordMapper.updateDailyRecordStatus(command);
|
||||
|
||||
// TODO : target 업데이트 후 데이터 등록이 완료된 건은 allStatus 값 변경해주기
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package app.module.front.usecase.daily.record.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||
import app.module.front.usecase.daily.calendar.service.RecordCalendarService;
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyTargetStatus;
|
||||
import app.module.front.usecase.daily.record.web.validator.CreateDailyRecordValidator;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/api/record/daily")
|
||||
public class DailyRecordController {
|
||||
private final RecordCalendarService recordCalendarService;
|
||||
private final DailyRecordService dailyRecordService;
|
||||
private final CreateDailyRecordValidator createDailyRecordValidator;
|
||||
|
||||
/**
|
||||
* 일계부 등록 처리
|
||||
*
|
||||
* @param searchMonth
|
||||
* @param groupNo
|
||||
* @param formVO
|
||||
* @param bindingResult
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}")
|
||||
ResponseEntity<?> create(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @Valid @RequestBody CreateDailyRecordReqVO formVO, BindingResult bindingResult) {
|
||||
|
||||
createDailyRecordValidator.validate(formVO, bindingResult);
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
DailyRecordDto detail = dailyRecordService.getDailyRecord(reqVO);
|
||||
formVO.setRecordMonth(reqVO.getSearchMonth());
|
||||
formVO.setDayGroupNo(reqVO.getGroupNo());
|
||||
formVO.setStartDate(detail.getStartDate());
|
||||
formVO.setEndDate(detail.getEndDate());
|
||||
log.debug("formVO: {}", formVO);
|
||||
|
||||
dailyRecordService.createDailyRecord(formVO);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
|
||||
@PostMapping(path = "/{searchMonth}/{groupNo}/today-none")
|
||||
ResponseEntity<?> todayNone(@PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo
|
||||
, @RequestParam(name = "target", required = true, defaultValue = "") String targetType
|
||||
, @RequestParam(name = "status", required = false, defaultValue = "N") String targetStatus) {
|
||||
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
log.debug("target: {}", targetType);
|
||||
log.debug("status: {}", targetStatus);
|
||||
|
||||
DailyRecordDto detail = dailyRecordService.getDailyRecord(reqVO);
|
||||
|
||||
// TODO : true / false 를 업데이트하는 것은 대상 타켓이 되는 것이라 판단하여 그냥 강제 업데이트할 것인가? valid 체크
|
||||
dailyRecordService.updateDailyRecordStatus(detail.getRecordMonth(), detail.getGroupNo(), targetType, "Y".equals(targetStatus) ? DailyTargetStatus.TODAY_NONE.name() : DailyTargetStatus.TARGET.name());
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package app.module.front.usecase.daily.record.web;
|
||||
|
||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||
import app.module.front.usecase.daily.calendar.service.RecordCalendarService;
|
||||
import app.module.front.usecase.daily.record.persistence.model.DailyRecordDto;
|
||||
import app.module.front.usecase.daily.record.service.DailyRecordService;
|
||||
import app.module.front.usecase.daily.record.web.model.CreateDailyRecordReqVO;
|
||||
import app.module.front.usecase.daily.record.web.model.DailyRecordUIReqVO;
|
||||
import app.module.front.usecase.daily.record.web.validator.CreateDailyRecordValidator;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping(path = "/record/daily")
|
||||
public class DailyRecordUIController {
|
||||
private final RecordCalendarService recordCalendarService;
|
||||
private final DailyRecordService dailyRecordService;
|
||||
private final CreateDailyRecordValidator createDailyRecordValidator;
|
||||
|
||||
/**
|
||||
* 일계부 등록 화면
|
||||
*
|
||||
* @param model
|
||||
* @param searchMonth 검색 월(yyyyMM)
|
||||
* @param groupNo 검색 그룹
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(path = "/{searchMonth}/{groupNo}")
|
||||
public String createForm(Model model, @PathVariable("searchMonth") String searchMonth, @PathVariable("groupNo") String groupNo) {
|
||||
|
||||
DailyRecordUIReqVO reqVO = new DailyRecordUIReqVO(searchMonth, groupNo);
|
||||
log.debug("reqVO: {}", reqVO);
|
||||
|
||||
DailyRecordDto dailyRecord = dailyRecordService.getDailyRecord(reqVO);
|
||||
if (dailyRecord == null) {
|
||||
throw new NoMatchingURIException("[Record] 잘못된 접근");
|
||||
}
|
||||
|
||||
model.addAttribute("reqVO", reqVO);
|
||||
model.addAttribute("dailyRecord", dailyRecord);
|
||||
|
||||
return "record/daily";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package app.module.front.usecase.daily.record.web.model;
|
||||
|
||||
import app.module.front.config.adapters.persistence.component.FrontAuditCommand;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class CreateDailyRecordReqVO {
|
||||
private Long id;
|
||||
private String recordMonth;
|
||||
private int dayGroupNo;
|
||||
private LocalDate startDate;
|
||||
private LocalDate endDate;
|
||||
private String todayNone;
|
||||
private DailyStatus allStatus;
|
||||
private DailyTargetStatus incomeStatus;
|
||||
private DailyTargetStatus workStatus;
|
||||
private DailyTargetStatus expenseStatus;
|
||||
private DailyTargetStatus powerStatus;
|
||||
private DailyTargetStatus forestryStatus;
|
||||
private DailyTargetStatus farmingStatus;
|
||||
|
||||
public void setTodayNone(String todayNone) {
|
||||
if ("Y".equals(todayNone)) {
|
||||
this.allStatus = DailyStatus.TODAY_NONE;
|
||||
} else {
|
||||
this.allStatus = DailyStatus.WAITING;
|
||||
|
||||
if (incomeStatus == null) {
|
||||
this.incomeStatus = DailyTargetStatus.NONE;
|
||||
}
|
||||
if (workStatus == null) {
|
||||
this.workStatus = DailyTargetStatus.NONE;
|
||||
}
|
||||
if (expenseStatus == null) {
|
||||
this.expenseStatus = DailyTargetStatus.NONE;
|
||||
}
|
||||
if (powerStatus == null) {
|
||||
this.powerStatus = DailyTargetStatus.NONE;
|
||||
}
|
||||
if (forestryStatus == null) {
|
||||
this.forestryStatus = DailyTargetStatus.NONE;
|
||||
}
|
||||
if (farmingStatus == null) {
|
||||
this.farmingStatus = DailyTargetStatus.NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.front.usecase.daily.record.web.model;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString(callSuper = true)
|
||||
public class DailyRecordUIReqVO extends DailyUIReqVO {
|
||||
public DailyRecordUIReqVO(String month, String no) {
|
||||
setSearchMonth(month);
|
||||
setGroupNo(Integer.parseInt(no));
|
||||
}
|
||||
|
||||
public DailyRecordUIReqVO(String month, Integer no) {
|
||||
setSearchMonth(month);
|
||||
setGroupNo(no);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.front.usecase.daily.record.web.model;
|
||||
|
||||
public enum DailyStatus {
|
||||
/**
|
||||
* 입력중
|
||||
*/
|
||||
WAITING,
|
||||
/**
|
||||
* 등록 없음
|
||||
*/
|
||||
TODAY_NONE,
|
||||
/**
|
||||
* 등록 완료
|
||||
*/
|
||||
DONE,
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package app.module.front.usecase.daily.record.web.model;
|
||||
|
||||
public enum DailyTargetStatus {
|
||||
/**
|
||||
* 등록 대상
|
||||
*/
|
||||
TARGET,
|
||||
/**
|
||||
* 금일 없음
|
||||
*/
|
||||
TODAY_NONE,
|
||||
/**
|
||||
* 등록 없음
|
||||
*/
|
||||
NONE,
|
||||
/**
|
||||
* 등록 완료
|
||||
*/
|
||||
DONE,
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package app.module.front.usecase.daily.record.web.model;
|
||||
|
||||
import app.module.front.config.application.util.AuthUtil;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class DailyUIReqVO {
|
||||
public DailyUIReqVO() {
|
||||
this.householdSeq = AuthUtil.getUserSeq();
|
||||
}
|
||||
|
||||
/**
|
||||
* 검색 월(yyyyMM)
|
||||
*/
|
||||
private String searchMonth;
|
||||
/**
|
||||
* 검색 그룸번호
|
||||
*/
|
||||
private Integer groupNo;
|
||||
/**
|
||||
* 임가 일련번호
|
||||
*/
|
||||
private Long householdSeq;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user