관리자 목록 수정
This commit is contained in:
@@ -58,7 +58,7 @@ public class RoleUpdateAspect {
|
||||
|
||||
if (beforeAdmin.isPresent()) {
|
||||
List<String> beforeRoles =
|
||||
beforeAdmin.get().getRoles().stream().map(CoreRole::getId).toList();
|
||||
beforeAdmin.stream().map(r -> r.getRole().getId()).toList();
|
||||
if (beforeRoles.size() != currentRoles.size()
|
||||
|| currentRoles.stream().anyMatch(item -> !beforeRoles.contains(item))) {
|
||||
createLog = true;
|
||||
|
||||
@@ -44,14 +44,14 @@ public class AdminDetailsService implements UserDetailsService {
|
||||
adminUser.getSeq(),
|
||||
adminUser.getId(),
|
||||
adminUser.getPassword(),
|
||||
adminUser.getRoles().stream().map(CoreRole::getId).findFirst().orElse(null),
|
||||
adminUser.getRole().getId(),
|
||||
adminUser.getRegionMainCode(),
|
||||
adminUser.getLastLoginIp(),
|
||||
!accountDisabled,
|
||||
true,
|
||||
isCredentialsNonExpired(adminUser.getPasswordUpdatedAt()),
|
||||
!accountLocked,
|
||||
getAuthorities(adminUser.getRoles()),
|
||||
getAuthorities(Stream.of(adminUser.getRole()).toList()),
|
||||
passwordValidPeriodDays - getDaysPassedFrom(adminUser.getPasswordUpdatedAt()));
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ public class AdminCreatePostController {
|
||||
savePortIn.apiConnect(bindingVO.getSeq(),
|
||||
bindingVO.getId(),
|
||||
bindingVO.getPassword(),
|
||||
bindingVO.getName(),
|
||||
"010-"+bindingVO.getPhone1()+"-"+bindingVO.getPhone2(),
|
||||
bindingVO.getRegionMainCode(),
|
||||
"ROLE_RESEARCHER".equals(bindingVO.getRoleId())?bindingVO.getName():null,
|
||||
"ROLE_RESEARCHER".equals(bindingVO.getRoleId())?"010-"+bindingVO.getPhone1()+"-"+bindingVO.getPhone2():null,
|
||||
!"ROLE_ADMIN".equals(bindingVO.getRoleId())?bindingVO.getRegionMainCode():null,
|
||||
bindingVO.getAccountDisabled(),
|
||||
bindingVO.getRoleId()));
|
||||
}
|
||||
|
||||
@@ -46,19 +46,16 @@ class AdminUpdateGetController {
|
||||
|
||||
AdminUpdateBindingVO bindingVO =
|
||||
new AdminUpdateBindingVO(
|
||||
output.getCreatedBy(),
|
||||
output.getCreatedAt(),
|
||||
output.getUpdatedBy(),
|
||||
output.getUpdatedAt(),
|
||||
output.getSeq(),
|
||||
output.getId(),
|
||||
null,
|
||||
output.getName(),
|
||||
output.getPhone(),
|
||||
output.getPhone().split("-")[1],
|
||||
output.getPhone().split("-")[2],
|
||||
output.getRegionMainCode(),
|
||||
output.getPasswordUpdatedAt(),
|
||||
output.getAccountDisabled(),
|
||||
output.getRoles().stream().map(CoreRole::getId).collect(Collectors.toList()));
|
||||
output.getRole().getId());
|
||||
|
||||
model.addAttribute("bindingVO", bindingVO);
|
||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
||||
|
||||
@@ -9,16 +9,20 @@ 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.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.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Controller
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class AdminUpdatePostController {
|
||||
|
||||
@@ -28,34 +32,24 @@ class AdminUpdatePostController {
|
||||
private final SaveAdminPortIn saveAdminPortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@PostMapping(path = "/settings/admins/update/{id}")
|
||||
String operate(
|
||||
Model model,
|
||||
RedirectAttributes redirectAttributes,
|
||||
@Valid @ModelAttribute("bindingVO") AdminUpdateBindingVO bindingVO,
|
||||
BindingResult bindingResult) {
|
||||
@PostMapping(path = "/api/settings/admin/update")
|
||||
ResponseEntity<?> operate( @RequestBody AdminUpdateBindingVO bindingVO, BindingResult bindingResult) {
|
||||
|
||||
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";
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY.value())
|
||||
.body(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
||||
}
|
||||
|
||||
saveAdminPortIn.apiConnect(
|
||||
bindingVO.getSeq(),
|
||||
bindingVO.getId(),
|
||||
bindingVO.getUpdatePassword(),
|
||||
bindingVO.getName(),
|
||||
bindingVO.getPhone(),
|
||||
bindingVO.getRegionMainCode(),
|
||||
bindingVO.getAccountDisabled(),
|
||||
bindingVO.getRoleIds().stream().collect(Collectors.joining()));
|
||||
|
||||
redirectAttributes.addFlashAttribute(
|
||||
"operationMessage",
|
||||
messageUtil.getMessage("operation.settings.admin.updated", bindingVO.getId()));
|
||||
|
||||
return "redirect:/settings/admins";
|
||||
return ResponseEntity.status(HttpStatus.OK).body(
|
||||
saveAdminPortIn.apiConnect(
|
||||
bindingVO.getSeq(),
|
||||
bindingVO.getId(),
|
||||
bindingVO.getUpdatePassword(),
|
||||
"ROLE_RESEARCHER".equals(bindingVO.getRoleId())?bindingVO.getName():null,
|
||||
"ROLE_RESEARCHER".equals(bindingVO.getRoleId())?"010-"+bindingVO.getPhone1()+"-"+bindingVO.getPhone2():null,
|
||||
!"ROLE_ADMIN".equals(bindingVO.getRoleId())? bindingVO.getRegionMainCode():null,
|
||||
bindingVO.getAccountDisabled(),
|
||||
bindingVO.getRoleId()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,16 @@
|
||||
package app.module.admin.usecase.admin.saveAdmin.adapters.web.model;
|
||||
|
||||
import app.module.core.config.application.component.AuditOutput;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class AdminUpdateBindingVO implements AuditOutput {
|
||||
|
||||
private final String createdBy;
|
||||
|
||||
private final LocalDateTime createdAt;
|
||||
|
||||
private final String updatedBy;
|
||||
|
||||
private final LocalDateTime updatedAt;
|
||||
@NoArgsConstructor
|
||||
public class AdminUpdateBindingVO{
|
||||
|
||||
private Long seq;
|
||||
private String id;
|
||||
@@ -33,12 +23,13 @@ public class AdminUpdateBindingVO implements AuditOutput {
|
||||
message = "{valid.common.email.wrong}")
|
||||
private String email;*/
|
||||
private String name;
|
||||
private String phone;
|
||||
private String phone1;
|
||||
private String phone2;
|
||||
private String regionMainCode;
|
||||
|
||||
private LocalDateTime passwordUpdatedAt;
|
||||
private Boolean accountDisabled;
|
||||
/* private Integer loginFailCnt;
|
||||
private Boolean accountLocked;*/
|
||||
private List<String> roleIds;
|
||||
private String roleId;
|
||||
}
|
||||
|
||||
@@ -4,12 +4,14 @@ import app.module.admin.usecase.admin.saveAdmin.adapters.web.model.AdminUpdateBi
|
||||
import java.util.Optional;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.Errors;
|
||||
import org.springframework.validation.ValidationUtils;
|
||||
import org.springframework.validation.Validator;
|
||||
|
||||
@Component
|
||||
public class AdminUpdateValidator implements Validator {
|
||||
|
||||
private final String PASSWORD_REGEX = "^((?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%_\\-])\\S{6,15})$";
|
||||
// 비밀번호: 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상
|
||||
private final String PASSWORD_REGEX = "^(?=.*[0-9])(?=.*[!@#$%_\\-]).{5}$";
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> clazz) {
|
||||
@@ -20,23 +22,38 @@ public class AdminUpdateValidator implements Validator {
|
||||
public void validate(Object target, Errors errors) {
|
||||
AdminUpdateBindingVO vo = (AdminUpdateBindingVO) target;
|
||||
|
||||
Optional.ofNullable(vo.getRoleIds())
|
||||
.filter(ids -> ids.size() < 1)
|
||||
.ifPresent(
|
||||
ids ->
|
||||
errors.rejectValue(
|
||||
"roleIds", "valid.common.required.size.min", new Object[]{1}, ""));
|
||||
if (vo.getRoleId() == null || vo.getRoleId().isEmpty()) {
|
||||
errors.rejectValue("roleId", "error.roleId", "권한을 선택해주세요.");
|
||||
}
|
||||
|
||||
Optional.ofNullable(vo.getUpdatePassword())
|
||||
.filter(s -> !s.trim().isEmpty() && !s.matches(PASSWORD_REGEX))
|
||||
.ifPresent(s -> errors.rejectValue("updatePassword", "valid.common.password.wrong"));
|
||||
.filter(password -> !password.trim().isEmpty() && !password.matches(PASSWORD_REGEX))
|
||||
.ifPresent(password -> errors.rejectValue("updatePassword", "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.getName().length() > 4) {
|
||||
errors.rejectValue("name", "error.name", "이름은 4자리까지 입력가능합니다.");
|
||||
}
|
||||
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","실사지역을 선택해주세요.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class HomeController {
|
||||
.ifPresent(
|
||||
loginUser -> {
|
||||
model.addAttribute("loginUser", loginUser);
|
||||
model.addAttribute("loginUserRoles", loginUser.getRoles());
|
||||
model.addAttribute("loginUserRoles", loginUser.getRole());
|
||||
});
|
||||
|
||||
return "home";
|
||||
|
||||
@@ -235,19 +235,18 @@
|
||||
ajaxUtil._ajaxMethod(
|
||||
'/api/settings/admin/create',
|
||||
JSON.stringify(dataOj),
|
||||
function(response) { // 성공
|
||||
alert("등록이 완료되었습니다.");
|
||||
location.href = '/settings/admins';
|
||||
function(response) {
|
||||
},
|
||||
function (code, rstData) {
|
||||
if(code == 422) alert(rstData.responseText);
|
||||
if(code == 200 ){
|
||||
if(code === 422) alert(rstData.responseText);
|
||||
if(code === 200 ){
|
||||
alert("등록이 완료되었습니다.");
|
||||
location.href = '/settings/admins';
|
||||
}
|
||||
},
|
||||
'post',
|
||||
'json'
|
||||
'json',
|
||||
{ handle422Type: 'alert' }
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -96,13 +96,12 @@
|
||||
<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="#">아이디</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="id" href="#">이름</a></th>
|
||||
<th class="text-secondary" scope="col">권한</th></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="id" href="#">실사</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="createdAt" href="#">생성일</a>
|
||||
</th>
|
||||
<th scope="col">아이디</th>
|
||||
<th scope="col">이름</th>
|
||||
<th scope="col">권한</th>
|
||||
<th scope="col">실사</th>
|
||||
<th scope="col">계정사용여부</th>
|
||||
<th scope="col">생성일</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -166,12 +165,9 @@
|
||||
f.searchDisabled.value = '';
|
||||
}
|
||||
|
||||
// 수정페이지 이동
|
||||
|
||||
function goUpdate(adminId) {
|
||||
const f = document.adminParamForm;
|
||||
f.action = '/settings/admins/update/' + adminId;
|
||||
f.method = 'get';
|
||||
f.submit();
|
||||
location.href = '/settings/admins/update/' + adminId; // 쿼리 파라미터 없이 이동
|
||||
}
|
||||
|
||||
// 체크박스 선택/해제
|
||||
|
||||
@@ -6,28 +6,34 @@
|
||||
<form
|
||||
method="post"
|
||||
th:action="${'/settings/admins/update/' + bindingVO.id}"
|
||||
th:object="${bindingVO}">
|
||||
th:object="${bindingVO}"
|
||||
name="adminUpdateForm"
|
||||
onsubmit="event.preventDefault(); updateAdmin(); return false;">
|
||||
<div class="content-inner">
|
||||
<input type="hidden" name="seq" th:field="*{seq}"/>
|
||||
|
||||
<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="component-select">
|
||||
<select class="select-list" id="roleIds"
|
||||
th:classappend="${#fields.hasErrors('roleIds')} ? 'is-invalid'"
|
||||
th:field="*{roleIds}"
|
||||
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="d-flex">
|
||||
<div class="component-input">
|
||||
<div class="component-select">
|
||||
<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="*{roleId}"
|
||||
th:if="${#fields.hasErrors('roleId')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -40,24 +46,25 @@
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<th><label for="password">비밀번호<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
|
||||
<th><label for="updatePassword">비밀번호<i class="ico-required-mark" role="img" aria-label="필수">*</i></label></th>
|
||||
<td>
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input id="password" placeholder="암호를 변경하고 싶다면 입력하세요"
|
||||
<input id="updatePassword" 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 class="invalid-feedback fw-bold" th:errors="*{updatePassword}"
|
||||
th:if="${#fields.hasErrors('updatePassword')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
<span>총 5자 / 숫자 + 특수문자 1개 이상 (!,@,#,$,%,_,-)</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="researcherArea"
|
||||
th:classappend="${#lists.isEmpty(bindingVO.roleIds) or #lists.contains(bindingVO.roleIds, 'ROLE_LOCAL_INSPECTOR')} ? 'd-none'">
|
||||
th:classappend="${#lists.isEmpty(bindingVO.roleId) or #lists.contains(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">
|
||||
@@ -83,25 +90,28 @@
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input type="number" id="phone1" name="phone1" placeholder=""
|
||||
th:value="${bindingVO.phone != null ? bindingVO.phone.substring(4, 8) : ''}">
|
||||
th:value="${bindingVO.phone1 != null ? bindingVO.phone1 : ''}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold"
|
||||
th:if="${#fields.hasErrors('phone1')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input type="number" id="phone2" name="phone2" placeholder=""
|
||||
th:value="${bindingVO.phone != null ? bindingVO.phone.substring(9, 13) : ''}">
|
||||
th:value="${bindingVO.phone2 != null ? bindingVO.phone2 : ''}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold"
|
||||
th:if="${#fields.hasErrors('phone2')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold"
|
||||
th:if="${#fields.hasErrors('phone')}">
|
||||
에러 메세지
|
||||
</div>
|
||||
<input type="hidden" name="phone" id="phone" th:field="*{phone}"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="regionMainCodeArea"
|
||||
th:classappend="${#lists.isEmpty(bindingVO.roleIds) or #lists.contains(bindingVO.roleIds, 'ROLE_ADMIN')} ? 'd-none'">
|
||||
th:classappend="${#lists.isEmpty(bindingVO.roleId) or #lists.contains(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">
|
||||
@@ -128,16 +138,16 @@
|
||||
<label for="inlineRadio1" class="radio-inner">
|
||||
<input id="inlineRadio1" th:field="*{accountDisabled}" type="radio" value="true">
|
||||
<span class="radio-item">
|
||||
<span class="radio-txt">미사용</span>
|
||||
</span>
|
||||
<span class="radio-txt">미사용</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="component-input">
|
||||
<label for="inlineRadio2" class="radio-inner">
|
||||
<input id="inlineRadio2" th:field="*{accountDisabled}" type="radio" value="false">
|
||||
<span class="radio-item">
|
||||
<span class="radio-txt">사용</span>
|
||||
</span>
|
||||
<span class="radio-txt">사용</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="invalid-feedback fw-bold" th:errors="*{accountDisabled}"
|
||||
@@ -148,6 +158,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- <div th:replace="common/components :: auditArea"></div>-->
|
||||
|
||||
<div class="component-btns bottom-btn-group">
|
||||
@@ -155,12 +166,13 @@
|
||||
<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="updateAdmin();">
|
||||
<span class="btn-txt">저장</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- 이전 목록페이지의 검색 및 정렬조건 폼 -->
|
||||
@@ -185,18 +197,14 @@
|
||||
}
|
||||
|
||||
$(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")}]]);
|
||||
|
||||
// 초기 로드 시 roleIds에 따라 regionMainCodeArea 표시/숨김
|
||||
const roleSelect = document.getElementById('roleIds');
|
||||
// 초기 로드 시 roleId에 따라 regionMainCodeArea 표시/숨김
|
||||
const roleSelect = document.getElementById('roleId');
|
||||
if (roleSelect) {
|
||||
onRoleChange(roleSelect);
|
||||
}
|
||||
|
||||
$('form').on('submit', function() {
|
||||
/* $('form').on('submit', function() {
|
||||
const phone1 = $('#phone1').val();
|
||||
const phone2 = $('#phone2').val();
|
||||
if (phone1 && phone2) {
|
||||
@@ -204,7 +212,7 @@
|
||||
} else {
|
||||
$('#phone').val('');
|
||||
}
|
||||
});
|
||||
});*/
|
||||
|
||||
});
|
||||
|
||||
@@ -215,6 +223,29 @@
|
||||
$('.researcherArea').toggle(idResearcher);
|
||||
};
|
||||
|
||||
const updateAdmin = () => {
|
||||
|
||||
const f = document.adminUpdateForm;
|
||||
let dataOj = $(f).serializeObject();
|
||||
|
||||
ajaxUtil._ajaxMethod(
|
||||
'/api/settings/admin/update',
|
||||
JSON.stringify(dataOj),
|
||||
function(response) {
|
||||
},
|
||||
function (code, rstData) {
|
||||
if(code === 422) alert(rstData.responseText);
|
||||
if(code === 200 ){
|
||||
alert("수정이 완료되었습니다.");
|
||||
location.href = '/settings/admins';
|
||||
}
|
||||
},
|
||||
'post',
|
||||
'json',
|
||||
{ handle422Type: 'alert' }
|
||||
);
|
||||
}
|
||||
|
||||
</script>
|
||||
</th:block>
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class AdminViewDao implements AdminViewPortOut {
|
||||
@Transactional
|
||||
public Optional<AdminView> connect(String id) {
|
||||
return mapper.findById(id).map(admin -> {
|
||||
admin.setRoles(mapper.findRoleHasPrivilegesByAdminId(admin.getSeq()));
|
||||
admin.setRole(mapper.findRoleHasPrivilegesByAdminId(admin.getSeq()));
|
||||
return admin;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface AdminViewMapper {
|
||||
Optional<AdminView> findById(String id);
|
||||
List<CoreRole> findRoleHasPrivilegesByAdminId(Long id);
|
||||
CoreRole findRoleHasPrivilegesByAdminId(Long id);
|
||||
}
|
||||
|
||||
@@ -29,5 +29,5 @@ public class AdminView implements Serializable {
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
private String updatedBy;
|
||||
private List<CoreRole> roles;
|
||||
private CoreRole role;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user