관리자 등록 ,목록 수정
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package app.module.admin.usecase.admin.checkAdminId.adapters.web;
|
||||
|
||||
import app.module.core.usecase.admin.checkAdminId.ports.CheckAdminIdPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class AdminIdDuplicateCheckPostController {
|
||||
|
||||
private final CheckAdminIdPortIn checkAdminIdPortIn;
|
||||
|
||||
@GetMapping("/api/settings/admin/idCheck")
|
||||
ResponseEntity<?> updateMappingHousehold(@RequestParam String id ) {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(checkAdminIdPortIn.connect(id));
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ class AdminListController {
|
||||
model.addAttribute("listOutput", listOutput);
|
||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
||||
model.addAttribute("pageRows", uiCodeListPortIn.connect("code.pageable.rows"));
|
||||
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
||||
|
||||
return "admin/adminList";
|
||||
}
|
||||
|
||||
@@ -18,8 +18,10 @@ public class AdminCreateGetController {
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
|
||||
@GetMapping(path = "/settings/admins/create")
|
||||
String operate(Model model, @ModelAttribute("bindingVO") AdminCreateBindingVO bindingVO) {
|
||||
String operate(Model model) {
|
||||
|
||||
AdminCreateBindingVO bindingVO = new AdminCreateBindingVO();
|
||||
model.addAttribute("bindingVO", bindingVO);
|
||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
||||
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
||||
|
||||
|
||||
@@ -9,49 +9,44 @@ 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 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.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.validation.ObjectError;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
@Controller
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
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")
|
||||
String operate(
|
||||
RedirectAttributes redirectAttributes,
|
||||
Model model,
|
||||
@Valid @ModelAttribute("bindingVO") AdminCreateBindingVO bindingVO,
|
||||
BindingResult bindingResult) {
|
||||
|
||||
@PostMapping(path = "/api/settings/admin/create")
|
||||
ResponseEntity<?> operate(@RequestBody AdminCreateBindingVO bindingVO, BindingResult bindingResult ) {
|
||||
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";
|
||||
|
||||
log.info("############Binding errors: {}", bindingResult.getAllErrors());
|
||||
log.info("Binding 메세지 errors: {}", bindingResult.getAllErrors().get(0).getDefaultMessage());
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
||||
}
|
||||
|
||||
savePortIn.connect(
|
||||
bindingVO.getSeq(),
|
||||
bindingVO.getId(),
|
||||
bindingVO.getPassword(),
|
||||
bindingVO.getRegionMainCode(),
|
||||
bindingVO.getAccountDisabled(),
|
||||
bindingVO.getRoleIds());
|
||||
|
||||
redirectAttributes.addFlashAttribute(
|
||||
"operationMessage",
|
||||
messageUtil.getMessage("operation.settings.admin.created", bindingVO.getId()));
|
||||
|
||||
return "redirect:/settings/admins";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(
|
||||
savePortIn.apiConnect(bindingVO.getSeq(),
|
||||
bindingVO.getId(),
|
||||
bindingVO.getPassword(),
|
||||
bindingVO.getName(),
|
||||
"010"+bindingVO.getPhone1()+bindingVO.getPhone2(),
|
||||
bindingVO.getRegionMainCode(),
|
||||
bindingVO.getAccountDisabled(),
|
||||
bindingVO.getRoleId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ class AdminUpdateGetController {
|
||||
output.getSeq(),
|
||||
output.getId(),
|
||||
null,
|
||||
output.getName(),
|
||||
output.getPhone(),
|
||||
output.getRegionMainCode(),
|
||||
output.getPasswordUpdatedAt(),
|
||||
output.getAccountDisabled(),
|
||||
|
||||
@@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class AdminUpdatePostController {
|
||||
@@ -40,13 +42,15 @@ class AdminUpdatePostController {
|
||||
return "admin/adminUpdateForm";
|
||||
}
|
||||
|
||||
saveAdminPortIn.connect(
|
||||
saveAdminPortIn.apiConnect(
|
||||
bindingVO.getSeq(),
|
||||
bindingVO.getId(),
|
||||
bindingVO.getUpdatePassword(),
|
||||
bindingVO.getName(),
|
||||
bindingVO.getPhone(),
|
||||
bindingVO.getRegionMainCode(),
|
||||
bindingVO.getAccountDisabled(),
|
||||
bindingVO.getRoleIds());
|
||||
bindingVO.getRoleIds().stream().collect(Collectors.joining()));
|
||||
|
||||
redirectAttributes.addFlashAttribute(
|
||||
"operationMessage",
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
package app.module.admin.usecase.admin.saveAdmin.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AdminCreateBindingVO {
|
||||
private Long seq;
|
||||
private String id;
|
||||
private String password;
|
||||
|
||||
private String name;
|
||||
private String phone1;
|
||||
private String phone2;
|
||||
private String regionMainCode;
|
||||
/* @NotBlank(message = "{valid.common.required}")
|
||||
@Pattern(
|
||||
regexp =
|
||||
@@ -24,6 +27,5 @@ public class AdminCreateBindingVO {
|
||||
|
||||
private Boolean accountDisabled;
|
||||
/* private Boolean accountLocked;*/
|
||||
private List<String> roleIds;
|
||||
private String regionMainCode;
|
||||
private String roleId;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@ 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 name;
|
||||
private String phone;
|
||||
private String regionMainCode;
|
||||
|
||||
private LocalDateTime passwordUpdatedAt;
|
||||
|
||||
@@ -10,7 +10,10 @@ import org.springframework.validation.Validator;
|
||||
@Component
|
||||
public class AdminCreateValidator implements Validator {
|
||||
|
||||
private final String PASSWORD_REGEX = "^((?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%_\\-])\\S{6,15})$";
|
||||
// 아이디: 4~15자, 영문/숫자/한글/특수문자(_,-) 허용
|
||||
private final String ID_REGEX = "^[a-zA-Z0-9가-힣_-]{4,15}$";
|
||||
// 비밀번호: 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상
|
||||
private final String PASSWORD_REGEX = "^(?=.*[0-9])(?=.*[!@#$%_\\-]).{5}$";
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
@@ -21,25 +24,47 @@ public class AdminCreateValidator implements Validator {
|
||||
public void validate(Object target, Errors errors) {
|
||||
AdminCreateBindingVO vo = (AdminCreateBindingVO) target;
|
||||
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "valid.common.required");
|
||||
if (vo.getRoleId() == null || vo.getRoleId().isEmpty()) {
|
||||
errors.rejectValue("roleId", "error.roleId", "권한을 선택해주세요.");
|
||||
}
|
||||
|
||||
if (vo.getAccountDisabled() == null ) {
|
||||
errors.rejectValue("accountDisabled", "error.accountDisabled", "사용여부를 선택해주세요.");
|
||||
}
|
||||
|
||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "id", "valid.common.required","아이디는 필수입력값입니다.");
|
||||
Optional.ofNullable(vo.getId())
|
||||
.filter(id -> !id.matches(ID_REGEX))
|
||||
.ifPresent(id -> errors.rejectValue("id", "valid.common.id.wrong","아이디를 4~15자, 영문/숫자/한글/특수문자(_,-) 입니다."));
|
||||
|
||||
// 비밀번호 유효성 검사
|
||||
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"));
|
||||
|
||||
Optional.ofNullable(vo.getRoleIds())
|
||||
.filter(ids -> ids.size() < 1)
|
||||
.ifPresent(
|
||||
ids ->
|
||||
errors.rejectValue(
|
||||
"roleIds", "valid.common.required.size.min", new Object[]{1}, ""));
|
||||
.ifPresent(password -> errors.rejectValue("password", "valid.common.password.wrong","비밀번호는 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상입니다."));
|
||||
|
||||
if (vo.getRoleId() != null && "ROLE_RESEARCHER".equals(vo.getRoleId())) {
|
||||
if (vo.getName() == null || vo.getName().isBlank()) {
|
||||
errors.rejectValue("name", "error.name", "이름을 입력해주세요.");
|
||||
}
|
||||
if (vo.getPhone1() == null || vo.getPhone1().isBlank()) {
|
||||
errors.rejectValue("phone1", "error.phone1", "전화번호 앞자리를 입력해주세요.");
|
||||
} else if (!vo.getPhone1().matches("^\\d{4}$")) {
|
||||
errors.rejectValue("phone1", "error.phone1", "전화번호 앞자리는 4자리 숫자여야 합니다.");
|
||||
}
|
||||
if (vo.getPhone2() == null || vo.getPhone2().isBlank()) {
|
||||
errors.rejectValue("phone2", "error.phone2", "전화번호 뒷자리를 입력해주세요.");
|
||||
} else if (!vo.getPhone2().matches("^\\d{4}$")) {
|
||||
errors.rejectValue("phone2", "error.phone2", "전화번호 뒷자리는 4자리 숫자여야 합니다.");
|
||||
}
|
||||
}
|
||||
// ROLE_ADMIN이 아닌 경우 regionMainCode null체크
|
||||
Optional.ofNullable(vo.getRoleIds())
|
||||
.filter(ids -> ids.stream().noneMatch(role -> role.equals("ROLE_ADMIN")))
|
||||
Optional.ofNullable(vo.getRoleId())
|
||||
.filter(id -> !id.equals("ROLE_ADMIN"))
|
||||
.ifPresent(nonAdmins -> {
|
||||
if (vo.getRegionMainCode() == null || vo.getRegionMainCode().isBlank()) {
|
||||
errors.rejectValue("regionMainCode", "valid.common.required");
|
||||
errors.rejectValue("regionMainCode", "valid.common.required","실사지역은 필수입력값입니다.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,27 +7,28 @@
|
||||
<form
|
||||
method="post"
|
||||
th:action="@{/settings/admins/create}"
|
||||
th:object="${bindingVO}">
|
||||
th:object="${bindingVO}"
|
||||
name="adminCreateForm">
|
||||
|
||||
<table class="type-form">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th><label for="roleIds">권한<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
|
||||
<th><label for="roleId">권한<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
|
||||
<td>
|
||||
<div class="d-flex">
|
||||
<div class="component-input">
|
||||
<div class="component-select">
|
||||
<select class="select-list" id="roleIds"
|
||||
th:classappend="${#fields.hasErrors('roleIds')} ? 'is-invalid'"
|
||||
th:field="*{roleIds}"
|
||||
<select class="select-list" id="roleId"
|
||||
th:classappend="${#fields.hasErrors('roleId')} ? 'is-invalid'"
|
||||
th:field="*{roleId}"
|
||||
onchange="onRoleChange(this);">
|
||||
<option value="">선택</option>
|
||||
<option th:each="role : ${roles}" th:text="${role.description}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleIds}"
|
||||
th:if="${#fields.hasErrors('roleIds')}">
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{roleId}"
|
||||
th:if="${#fields.hasErrors('roleId')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
@@ -40,13 +41,18 @@
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input id="id"
|
||||
name="id"
|
||||
th:classappend="${#fields.hasErrors('id')} ? 'is-invalid'"
|
||||
th:field="*{id}"/>
|
||||
<button type="button" class="btn btn-primary" onclick="adminIdCheckDuplicate();">
|
||||
<span class="btn-txt">중복확인</span>
|
||||
</button>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{id}"
|
||||
th:if="${#fields.hasErrors('id')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<span>4~15자 / 영문,숫자,한글 가능/ 특수문자 _,- 사용가능</span>
|
||||
</div>
|
||||
</td>
|
||||
<th><label for="password">Password<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
|
||||
@@ -61,11 +67,51 @@
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<span>총 5자 / 숫자 + 특수문자 1개 이상 (!,@,#,$,%,_,-)</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="researcherArea"
|
||||
th:classappend="${bindingVO.roleId == 'ROLE_LOCAL_INSPECTOR'} ? 'd-none'">
|
||||
<th><label for="name">이름<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input id="name" type="text" name="name"
|
||||
th:classappend="${#fields.hasErrors('name')} ? 'is-invalid'"
|
||||
th:field="*{name}"/>
|
||||
<div class="invalid-feedback fw-bold"
|
||||
th:if="${#fields.hasErrors('name')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<th><label for="name">전화번호<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
|
||||
<td>
|
||||
010-
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input id="phone1" name="phone1" type="number" maxlength="4" th:field="*{phone1}"
|
||||
th:classappend="${#fields.hasErrors('name')} ? 'is-invalid'"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input id="phone2" name="phone2" type="number" maxlength="4" th:field="*{phone2}"
|
||||
th:classappend="${#fields.hasErrors('name')} ? 'is-invalid'"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold"
|
||||
th:if="${#fields.hasErrors('phone1')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="regionMainCodeArea"
|
||||
th:classappend="${#lists.isEmpty(bindingVO.roleIds) or #lists.contains(bindingVO.roleIds, 'ROLE_ADMIN')} ? 'd-none'">
|
||||
th:classappend="${bindingVO.roleId != 'ROLE_ADMIN'} ? 'd-none'">
|
||||
<th><label for="regionMainCode">실사<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
|
||||
<td>
|
||||
<div class="component-select">
|
||||
@@ -118,7 +164,7 @@
|
||||
<button type="button" class="btn btn-secondary" onclick="gotoList();return false;">
|
||||
<span class="btn-txt">목록으로 이동</span>
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<button type="button" class="btn btn-primary" onclick="createAdmin();">
|
||||
<span class="btn-txt">저장</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -137,14 +183,69 @@
|
||||
}
|
||||
|
||||
$(document).ready(() => {
|
||||
const roleSelect = document.getElementById('roleIds');
|
||||
const roleSelect = document.getElementById('roleId');
|
||||
onRoleChange(roleSelect);
|
||||
|
||||
});
|
||||
const onRoleChange = (el) => {
|
||||
const selectedValues = Array.from(el.selectedOptions).map(option => option.value);
|
||||
const isAdmin = !selectedValues.length || selectedValues.includes('ROLE_ADMIN');
|
||||
const idResearcher = !selectedValues.length || selectedValues.includes('ROLE_RESEARCHER');
|
||||
$('.regionMainCodeArea').toggle(!isAdmin);
|
||||
$('.researcherArea').toggle(idResearcher);
|
||||
};
|
||||
|
||||
let checkDuplicate = false;
|
||||
|
||||
const adminIdCheckDuplicate = () => {
|
||||
const f = document.adminCreateForm;
|
||||
if (!f.id.value) {
|
||||
alert("아이디를 입력해주세요.");
|
||||
return;
|
||||
}
|
||||
ajaxUtil._ajaxMethod(
|
||||
'/api/settings/admin/idCheck',
|
||||
{ id : f.id.value },
|
||||
function(response) { // 성공
|
||||
const message = response > 0
|
||||
? "이미 사용하고 있는 아이디 입니다. 아이디를 입력해주세요."
|
||||
: "사용 가능한 아이디입니다.";
|
||||
alert(message);
|
||||
checkDuplicate = response <= 0;
|
||||
},
|
||||
function (code, rstData) {
|
||||
console.log("error : ", code);
|
||||
if(code == 400) alert("아이디를 입력해주세요.");
|
||||
},
|
||||
'get',
|
||||
'json'
|
||||
);
|
||||
}
|
||||
const createAdmin = () => {
|
||||
if (!checkDuplicate) {
|
||||
alert("아이디 중복 확인을 해주세요.");
|
||||
return false;
|
||||
}
|
||||
|
||||
const f = document.adminCreateForm;
|
||||
let dataOj = $(f).serializeObject();
|
||||
|
||||
ajaxUtil._ajaxMethod(
|
||||
'/api/settings/admin/create',
|
||||
JSON.stringify(dataOj),
|
||||
function(response) { // 성공
|
||||
alert("등록이 완료되었습니다.");
|
||||
location.href = '/settings/admins';
|
||||
},
|
||||
function (code, rstData) {
|
||||
if(code == 422) alert(rstData.responseText);
|
||||
if(code == 400) alert(rstData.responseJSON.message);
|
||||
},
|
||||
'post',
|
||||
'json',
|
||||
{ handle422Type: 'alert' }
|
||||
);
|
||||
}
|
||||
</script>
|
||||
</th:block>
|
||||
|
||||
|
||||
@@ -17,14 +17,26 @@
|
||||
<div class="form-area">
|
||||
<div class="input-group">
|
||||
<div class="input-label">
|
||||
<p class="label-txt"><label for="searchField">검색필드</label></p>
|
||||
<p class="label-txt">권한</p>
|
||||
</div>
|
||||
<div class="component-select">
|
||||
<select class="select-list" id="searchRole" th:field="*{searchRole}">
|
||||
<option selected value="">전체</option>
|
||||
<option th:each="role : ${roles}" th:text="${role.description}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<div class="input-label">
|
||||
<p class="label-txt"><label for="searchField">정보</label></p>
|
||||
</div>
|
||||
<div class="d-flex">
|
||||
<div class="component-select">
|
||||
<select class="select-list" id="searchField" th:field="*{searchField}">
|
||||
<option selected value="">선택</option>
|
||||
<option selected value="">전체</option>
|
||||
<option value="id">ID</option>
|
||||
<option value="email">Email</option>
|
||||
<option value="name">이름</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="component-input">
|
||||
@@ -38,13 +50,25 @@
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<div class="input-label">
|
||||
<p class="label-txt">권한</p>
|
||||
<p class="label-txt">실사</p>
|
||||
</div>
|
||||
<div class="component-select">
|
||||
<select class="select-list" id="searchRole" th:field="*{searchRole}">
|
||||
<select class="select-list" id="searchArea" th:field="*{searchRole}">
|
||||
<option selected value="">전체</option>
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></option>
|
||||
<option th:each="region : ${regionMainCode}" th:text="${region.codeText}"
|
||||
th:value="${region.id}"></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<div class="input-label">
|
||||
<p class="label-txt">계정사용여부</p>
|
||||
</div>
|
||||
<div class="component-select">
|
||||
<select class="select-list" id="searchDisabled" th:field="*{searchRole}">
|
||||
<option selected value="">전체</option>
|
||||
<option value="false">사용</option>
|
||||
<option value="true">미사용</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,7 +32,11 @@
|
||||
<tr>
|
||||
<th>내용</th>
|
||||
<td>
|
||||
<textarea id="content" name="content" rows="5" cols="50"></textarea>
|
||||
<div class="component-input">
|
||||
<div class="input-textarea-field">
|
||||
<textarea id="content" name="content" class="textarea" placeholder=""></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -43,13 +43,13 @@ class AdminAuthFailHandlerTest {
|
||||
|
||||
@BeforeAll
|
||||
public void beforeAll() {
|
||||
saveAdminPortIn.connect(
|
||||
/* saveAdminPortIn.connect(
|
||||
1L,
|
||||
testUsername,
|
||||
"test.1@#$",
|
||||
null,
|
||||
false,
|
||||
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));
|
||||
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));*/
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -38,13 +38,13 @@ class AdminDetailsServiceTest {
|
||||
|
||||
@BeforeAll
|
||||
public void beforeAll() {
|
||||
saveAdminPortIn.connect(
|
||||
/* saveAdminPortIn.connect(
|
||||
1L,
|
||||
username,
|
||||
password,
|
||||
null,
|
||||
false,
|
||||
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));
|
||||
Arrays.asList("ROLE_SUPER", "ROLE_STAFF"));*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ class AdminCreateUpdateDaoTest {
|
||||
@DisplayName("operate - AdminCreateDao")
|
||||
void operate() {
|
||||
|
||||
saveAdminPortIn.connect(
|
||||
/* saveAdminPortIn.connect(
|
||||
1L,
|
||||
"admin_for_createDao_test",
|
||||
"test.1@#$",
|
||||
@@ -60,6 +60,6 @@ class AdminCreateUpdateDaoTest {
|
||||
assertEquals(
|
||||
1,
|
||||
adminViewPortIn.connect("admin_for_createDao_test").orElseThrow().getRoles().size(),
|
||||
"기존 권한들을 (내부적으로) 삭제하고 새로이 추가 등록되기에 withRoles 의 size 는 1이다.");
|
||||
"기존 권한들을 (내부적으로) 삭제하고 새로이 추가 등록되기에 withRoles 의 size 는 1이다.");*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ valid.common.required.size.min={0} \uAC1C \uC774\uC0C1 \uD56D\uBAA9\uC774 \uD544
|
||||
valid.common.required.remove.item=\uC0AD\uC81C\uD560 \uC544\uC774\uD15C\uC774 \uC5C6\uC2B5\uB2C8\uB2E4.
|
||||
valid.common.email.wrong=\uC774\uBA54\uC77C \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.
|
||||
valid.common.nickname.wrong=\uB2C9\uB124\uC784(2-10\uAE00\uC790)\uC740 \uD55C\uAE00,\uC601\uC5B4 \uB300\uC18C\uBB38\uC790, -, _ \uB9CC \uC785\uB825\uD560 \uC218 \uC788\uC2B5\uB2C8\uB2E4.
|
||||
valid.common.password.wrong=6\uC790 \uC774\uC0C1 15\uC790 \uC774\uD558 \uB300,\uC18C,\uD2B9\uC218\uBB38\uC790\uAC00 \uD3EC\uD568 \uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4.
|
||||
valid.common.password.wrong=\uCD1D 5\uC790 / \uC22B\uC790 + \uD2B9\uC218\uBB38\uC790 1\uAC1C \uC774\uC0C1 (!,@,#,$,%,_,-)\uD3EC\uD568\uB418\uC5B4\uC57C \uD569\uB2C8\uB2E4.
|
||||
valid.common.already.exists=\uC774\uBBF8 \uB4F1\uB85D\uB41C {0} \uC785\uB2C8\uB2E4.
|
||||
valid.common.endWith.not=\uB9C8\uC9C0\uB9C9\uC774 "{0}"\uC73C\uB85C \uB05D\uB098\uC11C\uB294 \uC548\uB429\uB2C8\uB2E4.
|
||||
valid.common.date.invalid=\uAC8C\uC2DC\uC77C\uC744 \uD655\uC778\uD574 \uC8FC\uC138\uC694.
|
||||
|
||||
@@ -27,7 +27,7 @@ public class InitAdminData implements ApplicationRunner {
|
||||
return;
|
||||
}
|
||||
|
||||
// 관리자
|
||||
/* // 관리자
|
||||
saveAdminPortIn.connect(
|
||||
null,
|
||||
"test-admin",
|
||||
@@ -52,6 +52,6 @@ public class InitAdminData implements ApplicationRunner {
|
||||
"researcher1@#$",
|
||||
"code.region.main.1",
|
||||
false,
|
||||
List.of("ROLE_RESEARCHER"));
|
||||
List.of("ROLE_RESEARCHER"));*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package app.module.core.usecase.admin.checkAdminId.persistence;
|
||||
|
||||
import app.module.core.usecase.admin.checkAdminId.ports.CheckAdminIdPortOut;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
class CheckAdminIdDao implements CheckAdminIdPortOut {
|
||||
|
||||
private final CheckAdminIdMapper mapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer connect(String id) {
|
||||
return mapper.checkAdminId(id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package app.module.core.usecase.admin.checkAdminId.persistence;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CheckAdminIdMapper {
|
||||
Integer checkAdminId(String id);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package app.module.core.usecase.admin.checkAdminId.persistence.model;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class DeleteAdminHasRoleParam extends AuditCommand {
|
||||
private Long adminSeq;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package app.module.core.usecase.admin.checkAdminId.persistence.model;
|
||||
|
||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class SaveAdminHasRoleParam extends AuditCommand {
|
||||
private Long adminSeq;
|
||||
private List<String> roleIds;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package app.module.core.usecase.admin.checkAdminId.ports;
|
||||
|
||||
|
||||
public interface CheckAdminIdPortIn {
|
||||
|
||||
Integer connect(String id);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package app.module.core.usecase.admin.checkAdminId.ports;
|
||||
|
||||
public interface CheckAdminIdPortOut {
|
||||
Integer connect(String id);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package app.module.core.usecase.admin.checkAdminId.ports.application;
|
||||
|
||||
import app.module.core.usecase.admin.checkAdminId.ports.CheckAdminIdPortIn;
|
||||
import app.module.core.usecase.admin.checkAdminId.ports.CheckAdminIdPortOut;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CheckAdminIdService implements CheckAdminIdPortIn {
|
||||
|
||||
private final CheckAdminIdPortOut checkAdminIdPortOut;
|
||||
@Override
|
||||
public Integer connect(String id) {
|
||||
return checkAdminIdPortOut.connect(id);
|
||||
}
|
||||
}
|
||||
@@ -28,17 +28,17 @@ class SaveAdminDao implements SaveAdminPortOut {
|
||||
mapper.deleteAdminRolesByAdminId(
|
||||
AuditUtil.delete(new DeleteAdminHasRoleParam(cmd.getSeq())));
|
||||
|
||||
if (CollectionUtils.isNotEmpty(cmd.getRoleIds())) {
|
||||
if (!cmd.getRoleId().isEmpty()) {
|
||||
mapper.insertAdminHasRoles(
|
||||
AuditUtil.create(new SaveAdminHasRoleParam(cmd.getSeq(), cmd.getRoleIds())));
|
||||
AuditUtil.create(new SaveAdminHasRoleParam(cmd.getSeq(), cmd.getRoleId())));
|
||||
}
|
||||
} else {
|
||||
// create
|
||||
mapper.insertAdmin(AuditUtil.create(cmd));
|
||||
|
||||
if (CollectionUtils.isNotEmpty(cmd.getRoleIds())) {
|
||||
if (!cmd.getRoleId().isEmpty()) {
|
||||
mapper.insertAdminHasRoles(
|
||||
AuditUtil.create(new SaveAdminHasRoleParam(cmd.getSeq(), cmd.getRoleIds())));
|
||||
AuditUtil.create(new SaveAdminHasRoleParam(cmd.getSeq(), cmd.getRoleId())));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,5 +12,5 @@ import lombok.Setter;
|
||||
@AllArgsConstructor
|
||||
public class SaveAdminHasRoleParam extends AuditCommand {
|
||||
private Long adminSeq;
|
||||
private List<String> roleIds;
|
||||
private String roleId;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
package app.module.core.usecase.admin.saveAdmin.ports;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SaveAdminPortIn {
|
||||
|
||||
String connect(
|
||||
Long seq,
|
||||
String id,
|
||||
String password,
|
||||
String regionMainCode,
|
||||
Boolean accountDisabled,
|
||||
List<String> roleIds);
|
||||
String apiConnect(
|
||||
Long seq,
|
||||
String id,
|
||||
String password,
|
||||
String name,
|
||||
String phone,
|
||||
String regionMainCode,
|
||||
Boolean accountDisabled,
|
||||
String roleId);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import app.module.core.usecase.admin.saveAdmin.ports.application.domain.SaveAdmi
|
||||
import app.module.core.usecase.admin.view.ports.AdminViewPortIn;
|
||||
import app.module.core.usecase.admin.view.ports.application.domain.AdminView;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -20,14 +19,10 @@ public class SaveAdminService implements SaveAdminPortIn {
|
||||
private final BCryptPasswordEncoder passwordEncoder;
|
||||
private final AdminViewPortIn adminViewPortIn;
|
||||
|
||||
|
||||
@Override
|
||||
public String connect(
|
||||
Long seq,
|
||||
String id,
|
||||
String password,
|
||||
String regionMainCode,
|
||||
Boolean accountDisabled,
|
||||
List<String> roleIds) {
|
||||
public String apiConnect(Long seq, String id, String password, String name, String phone, String regionMainCode, Boolean accountDisabled, String roleId) {
|
||||
|
||||
|
||||
LocalDateTime passwordUpdatedAt;
|
||||
Integer loginFailCnt;
|
||||
@@ -51,15 +46,19 @@ public class SaveAdminService implements SaveAdminPortIn {
|
||||
}
|
||||
|
||||
return saveAdminPortOut.connect(
|
||||
new SaveAdminCmd(
|
||||
seq,
|
||||
id,
|
||||
password,
|
||||
passwordUpdatedAt,
|
||||
regionMainCode,
|
||||
accountDisabled,
|
||||
loginFailCnt,
|
||||
roleIds
|
||||
));
|
||||
new SaveAdminCmd(
|
||||
seq,
|
||||
id,
|
||||
password,
|
||||
passwordUpdatedAt,
|
||||
name,
|
||||
phone,
|
||||
regionMainCode,
|
||||
accountDisabled,
|
||||
loginFailCnt,
|
||||
roleId
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,9 +16,11 @@ public class SaveAdminCmd extends AuditCommand {
|
||||
private String encodedPassword;
|
||||
private LocalDateTime passwordUpdatedAt;
|
||||
/* private String email;*/
|
||||
private String name;
|
||||
private String phone;
|
||||
private String regionMainCode;
|
||||
private Boolean accountDisabled;
|
||||
private Integer loginFailCnt;
|
||||
/* private Boolean accountLocked;*/
|
||||
private List<String> roleIds;
|
||||
private String roleId;
|
||||
}
|
||||
|
||||
13
core/src/main/resources/mappers/admin/CheckAdminIdMapper.xml
Normal file
13
core/src/main/resources/mappers/admin/CheckAdminIdMapper.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?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.core.usecase.admin.checkAdminId.persistence.CheckAdminIdMapper">
|
||||
|
||||
<select id="checkAdminId" >
|
||||
select count(*)
|
||||
from admin
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -12,6 +12,8 @@
|
||||
INSERT INTO admin (seq,
|
||||
id,
|
||||
password,
|
||||
name,
|
||||
phone,
|
||||
region_main_code,
|
||||
password_updated_at,
|
||||
account_disabled,
|
||||
@@ -20,6 +22,8 @@
|
||||
VALUES (#{seq},
|
||||
#{id},
|
||||
#{encodedPassword},
|
||||
#{name},
|
||||
#{phone},
|
||||
#{regionMainCode},
|
||||
#{passwordUpdatedAt},
|
||||
#{accountDisabled},
|
||||
@@ -32,6 +36,8 @@
|
||||
UPDATE admin
|
||||
SET
|
||||
password = #{encodedPassword},
|
||||
name = #{name},
|
||||
phone = #{phone},
|
||||
region_main_code = #{regionMainCode},
|
||||
password_updated_at = #{passwordUpdatedAt},
|
||||
account_disabled = #{accountDisabled},
|
||||
@@ -48,14 +54,12 @@
|
||||
role_id,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
) VALUES
|
||||
<foreach collection="roleIds" item="roleId" separator=",">
|
||||
(
|
||||
nextval('admin_has_role_seq'),
|
||||
#{adminSeq},
|
||||
#{roleId},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="deleteAdminRolesByAdminId">
|
||||
|
||||
Reference in New Issue
Block a user