[삭제] 미사용 파일 삭제 - AdminRole, AdminPrivilege, UserRole, Users, UserPrivilege
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.index.adapters.web;
|
||||
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import groovy.util.logging.Slf4j;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/settings/adminPrivilege")
|
||||
@Slf4j
|
||||
class PrivilegeIndexController {
|
||||
|
||||
@GetMapping
|
||||
String intro(Model model) {
|
||||
model.addAttribute("appType", AppType.ADMIN);
|
||||
return "privilege/privilegeList";
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.list.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.privileges.list.adapters.web.model.PrivilegeElementVO;
|
||||
import app.module.core.config.adapters.web.rest.response.RestResponse;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.usecase.privilege.list.ports.PrivilegeListPortIn;
|
||||
import app.module.core.usecase.privilege.list.ports.application.domain.PrivilegeElement;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class PrivilegeListRestController {
|
||||
|
||||
private final PrivilegeListPortIn<PrivilegeElement> listPortIn;
|
||||
|
||||
@GetMapping("/api/adminPrivilege/get/recursiveItems")
|
||||
ResponseEntity<?> operate() {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
RestResponse.<PrivilegeElementVO>builder()
|
||||
.items(
|
||||
listPortIn.connect(AppType.ADMIN).stream()
|
||||
.map(
|
||||
p ->
|
||||
new PrivilegeElementVO(
|
||||
p.getCreatedBy(),
|
||||
p.getCreatedAt(),
|
||||
p.getUpdatedBy(),
|
||||
p.getUpdatedAt(),
|
||||
p.getId(),
|
||||
p.getDescription(),
|
||||
p.getOrderNo()))
|
||||
.collect(Collectors.toList()))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.list.adapters.web.model;
|
||||
|
||||
import app.module.core.config.application.converter.CustomLocalDateTimeSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class PrivilegeElementVO {
|
||||
|
||||
private final String createdBy;
|
||||
|
||||
@JsonSerialize(using = CustomLocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
private final LocalDateTime createdAt;
|
||||
|
||||
private final String updatedBy;
|
||||
|
||||
@JsonSerialize(using = CustomLocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
private final LocalDateTime updatedAt;
|
||||
|
||||
private final String id;
|
||||
private final String description;
|
||||
private final Integer orderNo;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.remove.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.privileges.remove.adapters.web.model.RoleRemoveVO;
|
||||
import app.module.core.config.adapters.web.rest.response.RestResponse;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.privilege.remove.ports.PrivilegeRemovePortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class PrivilegeRemoveRestController {
|
||||
|
||||
private final PrivilegeRemovePortIn removePortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@PostMapping("/api/adminPrivilege/remove")
|
||||
ResponseEntity<?> remove(RoleRemoveVO formDto) {
|
||||
removePortIn.connect(formDto.getId());
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
RestResponse.builder()
|
||||
.message(messageUtil.getMessage("operation.common.remove.done"))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.remove.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RoleRemoveVO {
|
||||
|
||||
private String id;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.save.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.privileges.save.adapters.web.model.PrivilegeSaveBindingVO;
|
||||
import app.module.core.config.adapters.web.rest.response.RestResponse;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.config.application.exception.AlreadyExistsRoleException;
|
||||
import app.module.core.config.application.util.CoreUtil;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.privilege.save.ports.PrivilegeSavePortIn;
|
||||
import app.module.core.usecase.privilege.save.ports.application.domain.PrivilegeSaveCommand;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class PrivilegeSaveRestController {
|
||||
|
||||
private final CoreUtil coreUtil;
|
||||
private final MessageUtil messageUtil;
|
||||
private final PrivilegeSavePortIn savePortIn;
|
||||
|
||||
@PostMapping("/api/adminPrivilege/save")
|
||||
ResponseEntity<?> operate(@Valid PrivilegeSaveBindingVO bindingVO,
|
||||
BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
|
||||
PrivilegeSaveCommand saveInput =
|
||||
new PrivilegeSaveCommand(
|
||||
AppType.ADMIN, bindingVO.getId(), bindingVO.getDescription(), bindingVO.getOrderNo());
|
||||
|
||||
try {
|
||||
savePortIn.connect(saveInput);
|
||||
|
||||
// `create` 인 경우 save 과정에서 orderNo 가 생성된다.
|
||||
bindingVO.setOrderNo(saveInput.getOrderNo());
|
||||
|
||||
} catch (AlreadyExistsRoleException e) {
|
||||
bindingResult.rejectValue("id", "", e.getMessage());
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
RestResponse.builder()
|
||||
.item(bindingVO)
|
||||
.message(messageUtil.getMessage("operation.common.save.done"))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.save.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class PrivilegeSaveBindingVO {
|
||||
|
||||
private final String id;
|
||||
private final String description;
|
||||
private Integer orderNo;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.sort.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.privileges.sort.adapters.web.model.PrivilegeSortVO;
|
||||
import app.module.core.usecase.privilege.sort.ports.PrivilegeSortPortIn;
|
||||
import app.module.core.usecase.privilege.sort.ports.application.domain.PrivilegeSortCmd;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class PrivilegeSortRestController {
|
||||
|
||||
private final PrivilegeSortPortIn sortPortIn;
|
||||
|
||||
@PostMapping("/api/adminPrivilege/switchOrderNo")
|
||||
ResponseEntity<?> switchOrderNo(@RequestBody List<PrivilegeSortVO> sortVOs) {
|
||||
sortPortIn.connect(
|
||||
sortVOs.stream()
|
||||
.map(s -> new PrivilegeSortCmd(s.getId(), s.getOrderNo()))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(null);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.sort.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PrivilegeSortVO {
|
||||
|
||||
private String id;
|
||||
private Integer orderNo;
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.view.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.privileges.view.adapters.web.model.PrivilegeViewVO;
|
||||
import app.module.core.config.adapters.web.rest.response.RestResponse;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.privilege.view.ports.PrivilegeViewPortIn;
|
||||
import app.module.core.usecase.privilege.view.ports.application.domain.PrivilegeView;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class PrivilegeViewRestController {
|
||||
|
||||
private final MessageUtil messageUtil;
|
||||
private final PrivilegeViewPortIn privilegeViewPortIn;
|
||||
|
||||
@GetMapping("/api/adminPrivilege/get/{id}")
|
||||
ResponseEntity<?> view(@PathVariable String id) {
|
||||
PrivilegeView item =
|
||||
Optional.ofNullable(privilegeViewPortIn.connect(id))
|
||||
.orElseThrow(
|
||||
() ->
|
||||
new NoSuchElementException(
|
||||
messageUtil.getMessage("exception.noSuchElement", id, "ROLE ID")));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
RestResponse.builder()
|
||||
.item(
|
||||
new PrivilegeViewVO(
|
||||
item.getCreatedBy(),
|
||||
item.getCreatedAt(),
|
||||
item.getUpdatedBy(),
|
||||
item.getUpdatedAt(),
|
||||
item.getId(),
|
||||
item.getDescription(),
|
||||
item.getOrderNo()))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package app.module.admin.usecase.privileges.view.adapters.web.model;
|
||||
|
||||
import app.module.core.config.application.converter.CustomLocalDateTimeSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import java.time.LocalDateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class PrivilegeViewVO {
|
||||
|
||||
private final String createdBy;
|
||||
|
||||
@JsonSerialize(using = CustomLocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
private final LocalDateTime createdAt;
|
||||
|
||||
private final String updatedBy;
|
||||
|
||||
@JsonSerialize(using = CustomLocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
private final LocalDateTime updatedAt;
|
||||
|
||||
private final String id;
|
||||
private final String description;
|
||||
private final Integer orderNo;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package app.module.admin.usecase.role.index.adapters.web;
|
||||
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.usecase.privilege.list.ports.PrivilegeListPortIn;
|
||||
import app.module.core.usecase.privilege.list.ports.application.domain.PrivilegeElement;
|
||||
import groovy.util.logging.Slf4j;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
class RoleIndexUIController {
|
||||
|
||||
private final PrivilegeListPortIn<PrivilegeElement> privilegeListPortIn;
|
||||
|
||||
@GetMapping("/settings/adminRoles")
|
||||
String intro(Model model) {
|
||||
model.addAttribute("privileges", privilegeListPortIn.connect(AppType.ADMIN));
|
||||
return "adminRole/adminRoleList";
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package app.module.admin.usecase.role.list.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.role.view.adapters.web.model.RoleBindingVO;
|
||||
import app.module.core.config.adapters.web.rest.response.RestResponse;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.usecase.role.list.ports.RoleListPortIn;
|
||||
import app.module.core.usecase.role.list.ports.application.domain.PrivilegeElement;
|
||||
import app.module.core.usecase.role.list.ports.application.domain.RoleElement;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class RoleListRestController {
|
||||
|
||||
private final RoleListPortIn<RoleElement> roleListPortIn;
|
||||
|
||||
@GetMapping("/api/adminRole/get/recursiveItems")
|
||||
ResponseEntity<?> operate() {
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
RestResponse.<RoleBindingVO>builder()
|
||||
.items(
|
||||
roleListPortIn.connect(AppType.ADMIN).stream()
|
||||
.map(
|
||||
item ->
|
||||
new RoleBindingVO(
|
||||
item.getCreatedBy(),
|
||||
item.getCreatedAt(),
|
||||
item.getUpdatedBy(),
|
||||
item.getUpdatedAt(),
|
||||
item.getId(),
|
||||
item.getDescription(),
|
||||
item.getOrderNo(),
|
||||
CollectionUtils.emptyIfNull(item.getPrivileges()).stream()
|
||||
.map(PrivilegeElement::getId)
|
||||
.collect(Collectors.toList())))
|
||||
.collect(Collectors.toList()))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package app.module.admin.usecase.role.list.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class PrivilegeBindingVO {
|
||||
|
||||
private final String id;
|
||||
private final String description;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package app.module.admin.usecase.role.list.adapters.web.model;
|
||||
|
||||
import app.module.core.config.application.converter.CustomLocalDateTimeSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class RoleBindingVO {
|
||||
|
||||
private final String createdBy;
|
||||
|
||||
@JsonSerialize(using = CustomLocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
private final LocalDateTime createdAt;
|
||||
|
||||
private final String updatedBy;
|
||||
|
||||
@JsonSerialize(using = CustomLocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
private final LocalDateTime updatedAt;
|
||||
|
||||
private final String id;
|
||||
private final String description;
|
||||
private final Integer orderNo;
|
||||
private List<PrivilegeBindingVO> privileges;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package app.module.admin.usecase.role.removeRole.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.privileges.remove.adapters.web.model.RoleRemoveVO;
|
||||
import app.module.core.config.adapters.web.rest.response.RestResponse;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.role.remove.ports.RoleRemovePortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class RoleRemoveRestController {
|
||||
|
||||
private final RoleRemovePortIn roleRemovePortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@PostMapping("/api/adminRole/remove")
|
||||
ResponseEntity<?> remove(RoleRemoveVO formDto) {
|
||||
roleRemovePortIn.connect(formDto.getId());
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
RestResponse.builder()
|
||||
.message(messageUtil.getMessage("operation.common.remove.done"))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package app.module.admin.usecase.role.saveRole.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.role.saveRole.adapters.web.model.RoleSaveBindingVO;
|
||||
import app.module.core.config.adapters.web.rest.response.RestResponse;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.config.application.exception.AlreadyExistsRoleException;
|
||||
import app.module.core.config.application.util.CoreUtil;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.role.save.ports.RoleSavePortIn;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class RoleSaveRestController {
|
||||
|
||||
private final CoreUtil coreUtil;
|
||||
private final MessageUtil messageUtil;
|
||||
private final RoleSavePortIn roleSavePortIn;
|
||||
|
||||
@PostMapping("/api/adminRole/save")
|
||||
ResponseEntity<?> operate(@Valid RoleSaveBindingVO bindingVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
|
||||
try {
|
||||
roleSavePortIn.connect(
|
||||
AppType.ADMIN,
|
||||
bindingVO.getId(),
|
||||
bindingVO.getDescription(),
|
||||
bindingVO.getOrderNo(),
|
||||
bindingVO.getPrivilegeIds());
|
||||
|
||||
} catch (AlreadyExistsRoleException e) {
|
||||
bindingResult.rejectValue("id", "", e.getMessage());
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
RestResponse.builder()
|
||||
.item(bindingVO)
|
||||
.message(messageUtil.getMessage("operation.common.save.done"))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package app.module.admin.usecase.role.saveRole.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RoleSaveBindingVO {
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
@Pattern(regexp = "^(ROLE_).+", message = "{valid.adminRole.id.mustStartWith.role}")
|
||||
private String id;
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String description;
|
||||
|
||||
private Integer orderNo;
|
||||
private List<String> privilegeIds;
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package app.module.admin.usecase.role.sortRoles.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.role.sortRoles.adapters.web.model.RoleSortVO;
|
||||
import app.module.core.usecase.role.sort.ports.RoleSortPortIn;
|
||||
import app.module.core.usecase.role.sort.ports.application.domain.RoleSortCommand;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class RoleSortRestController {
|
||||
|
||||
private final RoleSortPortIn roleSortPortIn;
|
||||
|
||||
@PostMapping("/api/adminRole/switchOrderNo")
|
||||
ResponseEntity<?> switchOrderNo(@RequestBody List<RoleSortVO> sortVOs) {
|
||||
roleSortPortIn.connect(
|
||||
sortVOs.stream()
|
||||
.map(item -> new RoleSortCommand(item.getId(), item.getOrderNo()))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(null);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package app.module.admin.usecase.role.sortRoles.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RoleSortVO {
|
||||
|
||||
private String id;
|
||||
private Integer orderNo;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package app.module.admin.usecase.role.view.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.role.view.adapters.web.model.RoleBindingVO;
|
||||
import app.module.core.config.adapters.web.rest.response.RestResponse;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.role.view.ports.RoleViewPortIn;
|
||||
import app.module.core.usecase.role.view.ports.application.domain.RoleView;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class RoleViewRestController {
|
||||
|
||||
private final MessageUtil messageUtil;
|
||||
private final RoleViewPortIn roleViewPortIn;
|
||||
|
||||
@GetMapping("/api/adminRole/get/{role}")
|
||||
ResponseEntity<?> view(@PathVariable String role) {
|
||||
RoleView item =
|
||||
Optional.ofNullable(roleViewPortIn.connect(role))
|
||||
.orElseThrow(
|
||||
() ->
|
||||
new NoSuchElementException(
|
||||
messageUtil.getMessage("exception.noSuchElement", role, "ROLE ID")));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
RestResponse.builder()
|
||||
.item(
|
||||
new RoleBindingVO(
|
||||
item.getCreatedBy(),
|
||||
item.getCreatedAt(),
|
||||
item.getUpdatedBy(),
|
||||
item.getUpdatedAt(),
|
||||
item.getId(),
|
||||
item.getDescription(),
|
||||
item.getOrderNo(),
|
||||
item.getPrivilegeIds()))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package app.module.admin.usecase.role.view.adapters.web.model;
|
||||
|
||||
import app.module.core.config.application.converter.CustomLocalDateTimeSerializer;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class RoleBindingVO {
|
||||
|
||||
private final String createdBy;
|
||||
|
||||
@JsonSerialize(using = CustomLocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
private final LocalDateTime createdAt;
|
||||
|
||||
private final String updatedBy;
|
||||
|
||||
@JsonSerialize(using = CustomLocalDateTimeSerializer.class)
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
private final LocalDateTime updatedAt;
|
||||
|
||||
private String id;
|
||||
private String description;
|
||||
private Integer orderNo;
|
||||
private List<String> privilegeIds;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package app.module.admin.usecase.user.getUser.adapters.web;
|
||||
|
||||
import app.module.core.usecase.user.findUser.ports.FindUserPortIn;
|
||||
import app.module.core.usecase.user.findUser.ports.application.domain.FindUser;
|
||||
import app.module.core.usecase.user.findUser.ports.application.domain.FindUserCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetUserController {
|
||||
|
||||
private final FindUserPortIn findUserPortIn;
|
||||
|
||||
@GetMapping(path = "/api/settings/users/{id}")
|
||||
ResponseEntity<?> operate(@PathVariable String id) {
|
||||
FindUser findUser = findUserPortIn.operate(new FindUserCmd(id)).orElseThrow();
|
||||
|
||||
// 불필요한 정보는 제거
|
||||
findUser.setPassword(null);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(findUser);
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package app.module.admin.usecase.user.getUserUpdateUI.adapters.web;
|
||||
|
||||
import app.module.core.usecase.user.getRoles.ports.GetRolesPortIn;
|
||||
import app.module.core.usecase.user.getRoles.ports.application.domain.GetRolesCmd;
|
||||
import app.module.admin.usecase.user.getUserUpdateUI.adapters.web.model.GetUserUpdateUIReqVO;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetUserUpdateUIController {
|
||||
|
||||
private final GetRolesPortIn getRolesPortIn;
|
||||
|
||||
@GetMapping(path = "/settings/users/{id}")
|
||||
String operate(
|
||||
Model model,
|
||||
@PathVariable @ModelAttribute("id") String id,
|
||||
@ModelAttribute("reqVO") GetUserUpdateUIReqVO reqVO) {
|
||||
|
||||
model.addAttribute("roles", getRolesPortIn.operate(new GetRolesCmd(AppType.FRONT)));
|
||||
|
||||
return "settings/users/{id}";
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package app.module.admin.usecase.user.getUserUpdateUI.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetUserUpdateUIReqVO {
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package app.module.admin.usecase.user.getUsers.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.user.getUsers.adapters.web.model.GetUsersReqVO;
|
||||
import app.module.core.usecase.user.getUsers.ports.GetUsersPortIn;
|
||||
import app.module.core.usecase.user.getUsers.ports.application.domain.GetUsers;
|
||||
import app.module.core.usecase.user.getUsers.ports.application.domain.GetUsersCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.web.PageableDefault;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetUsersController {
|
||||
|
||||
private final GetUsersPortIn getUsersPortIn;
|
||||
|
||||
@GetMapping(path = "/api/settings/users")
|
||||
ResponseEntity<?> operate(@PageableDefault Pageable pageable, GetUsersReqVO reqVO) {
|
||||
Page<GetUsers> users =
|
||||
getUsersPortIn.operate(
|
||||
pageable,
|
||||
new GetUsersCmd(reqVO.getSearchField(), reqVO.getSearchValue(),
|
||||
reqVO.getSearchRole()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(users);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package app.module.admin.usecase.user.getUsers.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetUsersReqVO {
|
||||
|
||||
private final String searchField;
|
||||
private final String searchValue;
|
||||
private final String searchRole;
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package app.module.admin.usecase.user.getUsersUI.adapters.web;
|
||||
|
||||
import app.module.core.usecase.user.getRoles.ports.GetRolesPortIn;
|
||||
import app.module.core.usecase.user.getRoles.ports.application.domain.GetRolesCmd;
|
||||
import app.module.admin.usecase.user.getUsersUI.adapters.web.model.GetUsersUIReqVO;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetUsersUIController {
|
||||
|
||||
private final UICodeListPortIn uiCodeListPortIn;
|
||||
private final GetRolesPortIn getRolesPortIn;
|
||||
|
||||
@GetMapping(path = "/settings/users")
|
||||
String operate(Model model, @ModelAttribute("reqVO") GetUsersUIReqVO reqVO) {
|
||||
|
||||
model.addAttribute("pageRows", uiCodeListPortIn.connect("code.pageable.rows"));
|
||||
model.addAttribute("roles", getRolesPortIn.operate(new GetRolesCmd(AppType.FRONT)));
|
||||
|
||||
return "settings/users";
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package app.module.admin.usecase.user.getUsersUI.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.thymeleaf.util.StringUtils;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetUsersUIReqVO {
|
||||
|
||||
private final String searchField;
|
||||
private final String searchValue;
|
||||
private final String searchRole;
|
||||
private Integer page;
|
||||
private String sort;
|
||||
private Integer size;
|
||||
|
||||
public Integer getPage() {
|
||||
// 요청 페이지 넘버 - 초기값 `0`
|
||||
return page != null ? page : 0;
|
||||
}
|
||||
|
||||
public String getSort() {
|
||||
// 정렬 값 - 초기값 `createdAt 내림차순`
|
||||
return StringUtils.isEmpty(sort) ? "createdAt,DESC" : sort;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
// 페이지 당 아이템 수 - 초기값 `10`
|
||||
return size != null ? size : 10;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package app.module.admin.usecase.user.updateUser.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.user.updateUser.adapters.web.model.UpdateUserReqVO;
|
||||
import app.module.core.usecase.user.updateUserByAdmin.ports.UpdateUserPortIn;
|
||||
import app.module.core.usecase.user.updateUserByAdmin.ports.application.domain.UpdateUserCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class UpdateUserController {
|
||||
|
||||
private final UpdateUserPortIn updateUserPortIn;
|
||||
|
||||
@PatchMapping(path = "/api/settings/users/update")
|
||||
ResponseEntity<?> operate(@Valid UpdateUserReqVO reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
updateUserPortIn.operate(
|
||||
new UpdateUserCmd(
|
||||
reqVO.getId(),
|
||||
reqVO.getEmail(),
|
||||
reqVO.getNickname(),
|
||||
reqVO.getAccountDisabled(),
|
||||
reqVO.getLoginFailCnt(),
|
||||
reqVO.getAccountLocked(),
|
||||
reqVO.getRoles()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package app.module.admin.usecase.user.updateUser.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import java.util.Set;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class UpdateUserReqVO {
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private String id;
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
@Pattern(
|
||||
regexp =
|
||||
"^[\\w!#$%&’*+/=?`{|}~^-]+(?:\\.[\\w!#$%&’*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$",
|
||||
message = "{valid.common.email.wrong}")
|
||||
private String email;
|
||||
|
||||
// TODO : 닉네임은 프론트 쪽에만 사용되는 항목인지 체크하기(임시 주석처리)
|
||||
// @NotBlank(message = "{valid.common.required}")
|
||||
@Pattern(regexp = "^[가-힣a-zA-Z0-9_-]{2,10}$", message = "{valid.common.nickname.wrong}")
|
||||
private String nickname;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Boolean accountDisabled;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Integer loginFailCnt;
|
||||
|
||||
@NotNull(message = "{valid.common.required}")
|
||||
private Boolean accountLocked;
|
||||
|
||||
@NotEmpty(message = "{valid.common.required}")
|
||||
private Set<String> roles;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.getUserPrivilege.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userPrivilege.getUserPrivilege.adapters.web.model.GetUserPrivilegeResVO;
|
||||
import app.module.core.usecase.userPrivilege.getUserPrivilege.ports.GetUserPrivilegePortIn;
|
||||
import app.module.core.usecase.userPrivilege.getUserPrivilege.ports.application.domain.GetUserPrivilege;
|
||||
import app.module.core.usecase.userPrivilege.getUserPrivilege.ports.application.domain.GetUserPrivilegeCmd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetUserPrivilegeController {
|
||||
|
||||
private final GetUserPrivilegePortIn getUserPrivilegePortIn;
|
||||
|
||||
@GetMapping(path = "/api/userPrivileges/{id}")
|
||||
ResponseEntity<?> operate(@PathVariable String id) {
|
||||
GetUserPrivilege userPrivilege =
|
||||
getUserPrivilegePortIn.operate(new GetUserPrivilegeCmd(id)).orElse(null);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new GetUserPrivilegeResVO(userPrivilege));
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.getUserPrivilege.adapters.web.model;
|
||||
|
||||
import app.module.core.usecase.userPrivilege.getUserPrivilege.ports.application.domain.GetUserPrivilege;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetUserPrivilegeResVO {
|
||||
|
||||
private GetUserPrivilege userPrivilege;
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.getUserPrivileges.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userPrivilege.getUserPrivileges.adapters.web.model.GetUserPrivilegesResVO;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.usecase.userPrivilege.getUserPrivileges.ports.GetUserPrivilegesPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetUserPrivilegesController {
|
||||
|
||||
private final GetUserPrivilegesPortIn getUserPrivilegesPortIn;
|
||||
|
||||
@GetMapping(path = "/api/userPrivileges")
|
||||
ResponseEntity<?> operate() {
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new GetUserPrivilegesResVO(getUserPrivilegesPortIn.operate(AppType.FRONT)));
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.getUserPrivileges.adapters.web.model;
|
||||
|
||||
import app.module.core.usecase.userPrivilege.getUserPrivileges.ports.application.domain.GetUserPrivileges;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetUserPrivilegesResVO {
|
||||
|
||||
private List<GetUserPrivileges> userPrivileges;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.getUserPrivilegesUI.adapters.web;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetUserPrivilegeUIController {
|
||||
|
||||
@GetMapping(path = "/settings/userPrivilege")
|
||||
String operate() {
|
||||
return "settings/userPrivilege";
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.removeUserPrivilege.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userPrivilege.removeUserPrivilege.adapters.web.model.RemoveUserPrivilegeReqVO;
|
||||
import app.module.admin.usecase.userPrivilege.removeUserPrivilege.adapters.web.model.RemoveUserPrivilegeResVO;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.userPrivilege.removeUserPrivilege.ports.RemoveUserPrivilegePortIn;
|
||||
import app.module.core.usecase.userPrivilege.removeUserPrivilege.ports.application.domain.RemoveUserPrivilegeCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class RemoveUserPrivilegeController {
|
||||
|
||||
private final RemoveUserPrivilegePortIn removeUserPrivilegePortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@DeleteMapping(path = "/api/userPrivileges/remove")
|
||||
ResponseEntity<?> operate(@Valid RemoveUserPrivilegeReqVO reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
removeUserPrivilegePortIn.operate(new RemoveUserPrivilegeCmd(reqVO.getId()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new RemoveUserPrivilegeResVO(
|
||||
messageUtil.getMessage("operation.common.remove.done")));
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.removeUserPrivilege.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class RemoveUserPrivilegeReqVO {
|
||||
|
||||
private String id;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.removeUserPrivilege.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class RemoveUserPrivilegeResVO {
|
||||
|
||||
private String msg;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.saveUserPrivilege.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userPrivilege.saveUserPrivilege.adapters.web.model.SaveUserPrivilegeReqVO;
|
||||
import app.module.admin.usecase.userPrivilege.saveUserPrivilege.adapters.web.model.SaveUserPrivilegeResVO;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.userPrivilege.saveUserPrivilege.ports.SaveUserPrivilegePortIn;
|
||||
import app.module.core.usecase.userPrivilege.saveUserPrivilege.ports.application.domain.SaveUserPrivilege;
|
||||
import app.module.core.usecase.userPrivilege.saveUserPrivilege.ports.application.domain.SaveUserPrivilegeCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class SaveUserPrivilegeController {
|
||||
|
||||
private final SaveUserPrivilegePortIn saveUserPrivilegePortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@PostMapping(path = "/api/userPrivileges/save")
|
||||
ResponseEntity<?> operate(@Valid SaveUserPrivilegeReqVO reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
SaveUserPrivilege userPrivilege =
|
||||
saveUserPrivilegePortIn
|
||||
.operate(
|
||||
new SaveUserPrivilegeCmd(reqVO.getId(), reqVO.getDescription(),
|
||||
reqVO.getOrderNo()))
|
||||
.orElse(null);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(
|
||||
new SaveUserPrivilegeResVO(
|
||||
userPrivilege, messageUtil.getMessage("operation.common.save.done")));
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.saveUserPrivilege.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SaveUserPrivilegeReqVO {
|
||||
|
||||
private String id;
|
||||
private String description;
|
||||
private Integer orderNo;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.saveUserPrivilege.adapters.web.model;
|
||||
|
||||
import app.module.core.usecase.userPrivilege.saveUserPrivilege.ports.application.domain.SaveUserPrivilege;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SaveUserPrivilegeResVO {
|
||||
|
||||
private SaveUserPrivilege userPrivilege;
|
||||
private String msg;
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.sortUserPrivilege.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userPrivilege.sortUserPrivilege.adapters.web.model.SortUserPrivilegeReqVO;
|
||||
import app.module.admin.usecase.userPrivilege.sortUserPrivilege.adapters.web.model.SortUserPrivilegeResVO;
|
||||
import app.module.core.usecase.userPrivilege.sortUserPrivilege.ports.SortUserPrivilegePortIn;
|
||||
import app.module.core.usecase.userPrivilege.sortUserPrivilege.ports.application.domain.SortUserPrivilegeCmd;
|
||||
import app.module.core.usecase.userPrivilege.sortUserPrivilege.ports.application.domain.SortUserPrivilegeDTO;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class SortUserPrivilegeController {
|
||||
|
||||
private final SortUserPrivilegePortIn sortUserPrivilegePortIn;
|
||||
|
||||
@PatchMapping(path = "/api/userPrivileges/sort")
|
||||
ResponseEntity<?> operate(
|
||||
@Valid @RequestBody SortUserPrivilegeReqVO reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
sortUserPrivilegePortIn.operate(
|
||||
new SortUserPrivilegeCmd(
|
||||
reqVO.getSortUserPrivileges().stream()
|
||||
.map(vo -> new SortUserPrivilegeDTO(vo.getId(), vo.getOrderNo()))
|
||||
.collect(Collectors.toList())));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new SortUserPrivilegeResVO(true));
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.sortUserPrivilege.adapters.web.model;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SortUserPrivilegeReqVO {
|
||||
|
||||
private List<SortUserPrivilegeVO> sortUserPrivileges;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.sortUserPrivilege.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SortUserPrivilegeResVO {
|
||||
|
||||
private boolean sorted;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package app.module.admin.usecase.userPrivilege.sortUserPrivilege.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SortUserPrivilegeVO {
|
||||
|
||||
private String id;
|
||||
private Integer orderNo;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.GetUserRole.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userRole.SaveUserRole.adapters.web.model.model.GetUserRoleResVO;
|
||||
import app.module.core.usecase.userRole.getUserRole.ports.GetUserRolePortIn;
|
||||
import app.module.core.usecase.userRole.getUserRole.ports.application.domain.GetUserRole;
|
||||
import app.module.core.usecase.userRole.getUserRole.ports.application.domain.GetUserRoleCmd;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetUserRoleController {
|
||||
|
||||
private final GetUserRolePortIn getUserRolePortIn;
|
||||
|
||||
@GetMapping(path = "/api/userRoles/{id}")
|
||||
ResponseEntity<?> operate(@PathVariable String id) {
|
||||
Optional<GetUserRole> userRole = getUserRolePortIn.operate(new GetUserRoleCmd(id));
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new GetUserRoleResVO(userRole.orElse(null)));
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.GetUserRoles.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userRole.GetUserRoles.adapters.web.model.GetUserRolesResVO;
|
||||
import app.module.admin.usecase.userRole.GetUserRoles.adapters.web.model.GetUserRolesVO;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.usecase.userRole.getUserRoles.ports.GetUserRolesPortIn;
|
||||
import app.module.core.usecase.userRole.getUserRoles.ports.application.domain.GetUserPrivileges;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class GetUserRolesController {
|
||||
|
||||
private final GetUserRolesPortIn getUserRolesPortIn;
|
||||
|
||||
@GetMapping(path = "/api/userRoles")
|
||||
ResponseEntity<?> operate() {
|
||||
List<GetUserRolesVO> userRoles =
|
||||
getUserRolesPortIn.operate(AppType.FRONT).stream()
|
||||
.map(
|
||||
getUserRoles ->
|
||||
new GetUserRolesVO(
|
||||
getUserRoles.getId(),
|
||||
getUserRoles.getDescription(),
|
||||
getUserRoles.getOrderNo(),
|
||||
getUserRoles.getPrivileges().stream()
|
||||
.map(GetUserPrivileges::getId)
|
||||
.toList()))
|
||||
.toList();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new GetUserRolesResVO(userRoles));
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.GetUserRoles.adapters.web.model;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetUserRolesResVO {
|
||||
|
||||
private List<GetUserRolesVO> userRoles;
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.GetUserRoles.adapters.web.model;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
public class GetUserRolesVO {
|
||||
|
||||
private String id;
|
||||
private String description;
|
||||
private Integer orderNo;
|
||||
private List<String> privilegeIds;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.GetUserRolesUI.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userRole.GetUserRolesUI.adapters.web.model.GetUserRolesUIReqVO;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import app.module.core.usecase.userPrivilege.getUserPrivileges.ports.GetUserPrivilegesPortIn;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
|
||||
@Controller
|
||||
@RequiredArgsConstructor
|
||||
class GetUserRolesUIController {
|
||||
|
||||
private final GetUserPrivilegesPortIn getUserPrivilegesPortIn;
|
||||
|
||||
@GetMapping(path = "/settings/userRoles")
|
||||
String operate(Model model, @ModelAttribute("reqVO") GetUserRolesUIReqVO reqVO) {
|
||||
model.addAttribute("privileges", getUserPrivilegesPortIn.operate(AppType.FRONT));
|
||||
return "settings/userRoles";
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.GetUserRolesUI.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetUserRolesUIReqVO {
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.SaveUserRole.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userRole.SaveUserRole.adapters.web.model.SaveUserRoleReqVO;
|
||||
import app.module.admin.usecase.userRole.SaveUserRole.adapters.web.model.SaveUserRoleResVO;
|
||||
import app.module.core.config.application.util.CoreUtil;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.userRole.saveUserRole.ports.SaveUserRolePortIn;
|
||||
import app.module.core.usecase.userRole.saveUserRole.ports.application.domain.SaveUserRole;
|
||||
import app.module.core.usecase.userRole.saveUserRole.ports.application.domain.SaveUserRoleCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.Optional;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class SaveUserRoleController {
|
||||
|
||||
private final CoreUtil coreUtil;
|
||||
private final MessageUtil messageUtil;
|
||||
private final SaveUserRolePortIn saveUserRolePortIn;
|
||||
|
||||
@PostMapping(path = "/api/userRoles/save")
|
||||
ResponseEntity<?> operate(@Valid SaveUserRoleReqVO reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return coreUtil.getErrorInfo(bindingResult);
|
||||
}
|
||||
|
||||
Optional<SaveUserRole> role =
|
||||
saveUserRolePortIn.operate(
|
||||
new SaveUserRoleCmd(
|
||||
reqVO.getId(),
|
||||
reqVO.getDescription(),
|
||||
reqVO.getOrderNo(),
|
||||
reqVO.getPrivilegeIds()));
|
||||
|
||||
String id = role.map(SaveUserRole::getId).orElse(null);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new SaveUserRoleResVO(id, messageUtil.getMessage("operation.common.save.done")));
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.SaveUserRole.adapters.web.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SaveUserRoleReqVO {
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
@Pattern(regexp = "^(ROLE_).+", message = "{valid.adminRole.id.mustStartWith.role}")
|
||||
private String id;
|
||||
|
||||
@NotBlank(message = "{valid.common.required}")
|
||||
private String description;
|
||||
|
||||
private Integer orderNo;
|
||||
private List<String> privilegeIds;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.SaveUserRole.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SaveUserRoleResVO {
|
||||
|
||||
private String id;
|
||||
private String msg;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.SaveUserRole.adapters.web.model.model;
|
||||
|
||||
import app.module.core.usecase.userRole.getUserRole.ports.application.domain.GetUserRole;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class GetUserRoleResVO {
|
||||
|
||||
private GetUserRole userRole;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.removeUserRole.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userRole.removeUserRole.adapters.web.model.RemoveUserRoleReqVO;
|
||||
import app.module.admin.usecase.userRole.removeUserRole.adapters.web.model.RemoveUserRoleResVO;
|
||||
import app.module.core.config.application.util.MessageUtil;
|
||||
import app.module.core.usecase.userRole.removeUserRole.ports.RemoveUserRolePortIn;
|
||||
import app.module.core.usecase.userRole.removeUserRole.ports.application.domain.RemoveUserRoleCmd;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class RemoveUserRoleController {
|
||||
|
||||
private final RemoveUserRolePortIn removeUserRolePortIn;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
@DeleteMapping(path = "/api/userRole/remove")
|
||||
ResponseEntity<?> operate(@Valid RemoveUserRoleReqVO reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
removeUserRolePortIn.operate(new RemoveUserRoleCmd(reqVO.getId()));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new RemoveUserRoleResVO(messageUtil.getMessage("operation.common.remove.done")));
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.removeUserRole.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class RemoveUserRoleReqVO {
|
||||
|
||||
private String id;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.removeUserRole.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class RemoveUserRoleResVO {
|
||||
|
||||
private String msg;
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.sortUserRole.adapters.web;
|
||||
|
||||
import app.module.admin.usecase.userRole.sortUserRole.adapters.web.model.SortUserRoleReqVO;
|
||||
import app.module.admin.usecase.userRole.sortUserRole.adapters.web.model.SortUserRoleResVO;
|
||||
import app.module.core.usecase.userRole.sortUserRole.ports.SortUserRolePortIn;
|
||||
import app.module.core.usecase.userRole.sortUserRole.ports.application.domain.SortUserRoleCmd;
|
||||
import app.module.core.usecase.userRole.sortUserRole.ports.application.domain.SortUserRoleDTO;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
class SortUserRoleController {
|
||||
|
||||
private final SortUserRolePortIn sortUserRolePortIn;
|
||||
|
||||
@PatchMapping(path = "/api/userRoles/sort")
|
||||
ResponseEntity<?> operate(
|
||||
@Valid @RequestBody SortUserRoleReqVO reqVO, BindingResult bindingResult) {
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||
.body(bindingResult.getFieldErrors());
|
||||
}
|
||||
|
||||
sortUserRolePortIn.operate(
|
||||
new SortUserRoleCmd(
|
||||
reqVO.getSortUserRoles().stream()
|
||||
.map(
|
||||
sortUserRoleVO ->
|
||||
new SortUserRoleDTO(sortUserRoleVO.getId(),
|
||||
sortUserRoleVO.getOrderNo()))
|
||||
.collect(Collectors.toList())));
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new SortUserRoleResVO(true));
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.sortUserRole.adapters.web.model;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SortUserRoleReqVO {
|
||||
|
||||
private List<SortUserRoleVO> sortUserRoles;
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.sortUserRole.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SortUserRoleResVO {
|
||||
|
||||
private boolean sorted;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package app.module.admin.usecase.userRole.sortUserRole.adapters.web.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class SortUserRoleVO {
|
||||
|
||||
private String id;
|
||||
private Integer orderNo;
|
||||
}
|
||||
@@ -1,430 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<span style="color:red; background-color: black;font-size: 30px;"> ** 화면 깨짐 주의 **</span>
|
||||
<div class="row mb-1">
|
||||
<div class="col ps-0 pe-0">
|
||||
<a href="javascript:expand();" class="link-secondary">Expand</a>
|
||||
<a href="javascript:collapse();" class="link-secondary">Collapse</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-secondary float-end ms-1" onclick="searchNode();">
|
||||
<i
|
||||
class="bi bi-search"></i></button>
|
||||
<input class="form-control form-control-sm w-25 inline-block float-end" id="searchNode"
|
||||
type="text"
|
||||
placeholder="역할 검색">
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col fw-bold border rounded-3 overflow-auto lh-1" id="tree"></div>
|
||||
<div class="col fw-bold ms-4">
|
||||
|
||||
<form name="formDto" action="" method="post">
|
||||
<input type="hidden" name="orderNo" value="">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="id">역할 ID *</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="id" name="id" class="form-control"
|
||||
placeholder="ROLE_ 로 시작하는 역할 ID 입력"/>
|
||||
<div class="invalid-feedback fw-bold field-id"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="description">설명</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="description" name="description" class="form-control"
|
||||
placeholder="설명을 입력하세요"/>
|
||||
<div class="invalid-feedback fw-bold field-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="privilegeIds">권한</label>
|
||||
<div class="col-sm-9">
|
||||
<select class="form-select text-secondary" id="privilegeIds" name="privilegeIds"
|
||||
multiple style="height: 200px;">
|
||||
<option th:each="privilege : ${privileges}" th:value="${privilege.id}"
|
||||
class="fw-bold"
|
||||
th:text="${privilege.id + ' (' + privilege.description + ')'}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold field-privilegeIds"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 row">
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('up');">
|
||||
<i class="bi bi-arrow-up-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('down');">
|
||||
<i class="bi bi-arrow-down-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-primary mt-1" onclick="addChildNode();">역할 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-primary" onclick="goSave();">저장</button>
|
||||
<button type="button" class="btn btn-danger" onclick="goRemove();">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
|
||||
// 노드가 보여질 level 전연벽수 기본값 6
|
||||
let globalLevels = 6;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadTree();
|
||||
});
|
||||
|
||||
function loadTree(currentId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/adminRole/get/recursiveItems',
|
||||
cache: false,
|
||||
success: function (response) {
|
||||
let jsonData = response.items;
|
||||
$(jsonData).each(function (idx, oj) {
|
||||
oj['text'] = !oj.description ? oj.id : oj.id + ' (' + oj.description + ')';
|
||||
oj['value'] = oj.description;
|
||||
});
|
||||
renderTree({
|
||||
text: '관리자 역할',
|
||||
value: '',
|
||||
nodes: jsonData
|
||||
}, currentId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderTree(nodes, currentId) {
|
||||
const tree = $('#tree');
|
||||
tree.treeview({
|
||||
data: [nodes],
|
||||
color: "#428bca",
|
||||
expandIcon: 'bi bi-plus-square-fill',
|
||||
collapseIcon: 'bi bi-dash-square-fill',
|
||||
emptyIcon: 'bi bi-dot',
|
||||
showBorder: false,
|
||||
enableLinks: true,
|
||||
levels: globalLevels,
|
||||
});
|
||||
|
||||
tree.on('rendered', function () {
|
||||
if (currentId) {
|
||||
setTimeout(function () {
|
||||
const currentNode = tree.treeview('findNodes', ['^' + currentId + '$', 'id']);
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
currentNode[0].$el[0].scrollIntoView();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
tree.off('nodeSelected').on('nodeSelected', function (event, data) {
|
||||
const f = document.formDto;
|
||||
const currentNode = tree.treeview('getSelected')[0];
|
||||
|
||||
if (data.id === 'code.new.temp') {
|
||||
// 신규 노드일 경우 id는 'code.new.temp'
|
||||
|
||||
cleanFormFields();
|
||||
|
||||
$(f.id).removeAttr('readonly');
|
||||
|
||||
f.id.value = currentNode.text;
|
||||
f.description.value = currentNode.value ? currentNode.value : '';
|
||||
f.id.focus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentNode.id) {
|
||||
getInfo(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addChildNode() {
|
||||
const tree = $('#tree');
|
||||
const parentNode = tree.treeview('getNodes')[0];
|
||||
tree.treeview('addNode', [{text: 'NEW NODE - 저장 필요', id: 'code.new.temp'}, parentNode]);
|
||||
const currentNode = tree.treeview('findNodes', ['^code.new.temp$', 'id']);
|
||||
|
||||
setTimeout(function () {
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function refreshTree(currentId) {
|
||||
$('#tree').treeview('remove');
|
||||
cleanFormFields();
|
||||
loadTree(currentId);
|
||||
}
|
||||
|
||||
function getInfo(data) {
|
||||
const f = document.formDto;
|
||||
if (data.id === 'code.new.temp') {
|
||||
return;
|
||||
}
|
||||
cleanFormFields();
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/adminRole/get/' + data.id,
|
||||
cache: false,
|
||||
statusCode: {
|
||||
400: function (response) {
|
||||
alert(response.responseJSON.message);
|
||||
},
|
||||
200: function (response) {
|
||||
const item = response.item;
|
||||
f.id.value = item.id;
|
||||
f.description.value = item.description;
|
||||
f.orderNo.value = item.orderNo;
|
||||
|
||||
$('#privilegeIds').val(item.privilegeIds);
|
||||
|
||||
showAudit(item.id, item.createdBy, item.createdAt, item.updatedBy, item.updatedAt);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$(f.id).attr('readonly', 'readonly');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goSave() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert(/*[[#{operation.role.save.choose.first}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
const f = document.formDto;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminRole/save',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
refreshTree(response.item.id);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
const fieldErrors = response.responseJSON.fieldErrors;
|
||||
let form = document.formDto;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
$(form[error.field]).addClass('is-invalid');
|
||||
$('.field-' + error.field).text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
const f = document.formDto;
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert([[#{operation.uri.remove.choose.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = selectedNode[0];
|
||||
|
||||
if (confirm("'" + info.text + "' " + [[#{operation.uri.remove.ask(info.text)}]])) {
|
||||
if (!info.id) {
|
||||
// 신규생성 임시 노드인 경우
|
||||
tree.treeview('removeNode', [selectedNode]);
|
||||
alert([[#{operation.common.remove.done}]]);
|
||||
refreshTree();
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminRole/remove',
|
||||
data: {id: info.id},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
refreshTree();
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function cleanFormFields() {
|
||||
const f = document.formDto;
|
||||
f.id.value = '';
|
||||
f.orderNo.value = '';
|
||||
f.description.value = '';
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$('.audit-area').hide();
|
||||
$('#privilegeIds').val([]);
|
||||
}
|
||||
|
||||
function move(dir) {
|
||||
const curNode = $('#tree').treeview('getSelected');
|
||||
if (curNode.length === 0) {
|
||||
alert([[#{operation.uri.move.choose}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = curNode[0];
|
||||
if (info.id === 'code.new.temp') {
|
||||
alert([[#{operation.uri.move.save.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const curOrderNo = info.orderNo;
|
||||
const siblingsWithoutMe = $('#tree').treeview('getSiblings', curNode);
|
||||
const f = document.formDto;
|
||||
let updateList = [];
|
||||
let targetItem;
|
||||
switch (dir) {
|
||||
case 'up':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo < curOrderNo) {
|
||||
targetItem = item;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.before}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
case 'down':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo > curOrderNo) {
|
||||
targetItem = item;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.after}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
}
|
||||
|
||||
// 다음 tree 랜더링시 보여줄 level 설정
|
||||
globalLevels = info.nodeId.split('.').length - 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminRole/switchOrderNo',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify(updateList),
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function () {
|
||||
refreshTree(info.id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('collapseAll', {silent: true});
|
||||
}
|
||||
|
||||
function expand() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('expandAll', {silent: true, levels: 6});
|
||||
}
|
||||
|
||||
function searchNode() {
|
||||
let searchVal = $('#searchNode').val().trim();
|
||||
if (!searchVal) {
|
||||
return;
|
||||
}
|
||||
const tree = $('#tree');
|
||||
const searchNode = tree.treeview('search', [
|
||||
searchVal, {ignoreCase: true, revealResults: true}
|
||||
]);
|
||||
if (searchNode.length) {
|
||||
tree.treeview('selectNode', [searchNode[0], {silent: false}]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
<th:block layout:fragment="script">
|
||||
<script th:inline="javascript">
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const head = document.getElementsByTagName('head')[0];
|
||||
|
||||
const link1 = document.createElement('link');
|
||||
link1.rel = 'stylesheet';
|
||||
link1.href = /*[[@{/static/library/bootstrap/bootstrap.min.css}]]*/'';
|
||||
head.appendChild(link1);
|
||||
|
||||
const link2 = document.createElement('link');
|
||||
link2.rel = 'stylesheet';
|
||||
link2.href =/*[[@{/static/library/bootstrap/bootstrap-icons.css}]]*/'';
|
||||
head.appendChild(link2);
|
||||
|
||||
const link3 = document.createElement('link');
|
||||
link3.rel = 'stylesheet';
|
||||
link3.href =/*[[@{/static/library/bootstrap-treeview/bootstrap-treeview.min.css}]]*/'';
|
||||
head.appendChild(link2);
|
||||
|
||||
const link4 = document.createElement('script');
|
||||
link4.type = 'text/javascript';
|
||||
link4.src =/*[[@{/static/library/bootstrap-treeview/bootstrap-treeview.min.js}]]*/'';
|
||||
head.appendChild(link4);
|
||||
|
||||
});
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
||||
@@ -1,414 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
<span style="color:red; background-color: black;font-size: 30px;"> ** 화면 깨짐 주의 **</span>
|
||||
<div class="row mb-1">
|
||||
<div class="col ps-0 pe-0">
|
||||
<a href="javascript:expand();" class="link-secondary">Expand</a>
|
||||
<a href="javascript:collapse();" class="link-secondary">Collapse</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-secondary float-end ms-1" onclick="searchNode();">
|
||||
<i
|
||||
class="bi bi-search"></i></button>
|
||||
<input class="form-control form-control-sm w-25 inline-block float-end" id="searchNode"
|
||||
type="text"
|
||||
placeholder="권한 검색">
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col fw-bold border rounded-3 overflow-auto lh-1" id="tree"></div>
|
||||
<div class="col fw-bold ms-4">
|
||||
|
||||
<form name="formDto" action="" method="post">
|
||||
<input type="hidden" name="orderNo" value="">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="id">권한 ID *</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="id" name="id" class="form-control" placeholder="공백없이 권한 ID 입력"/>
|
||||
<div class="invalid-feedback fw-bold field-id"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=" row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="description">설명</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="description" name="description" class="form-control"
|
||||
placeholder="설명을 입력하세요"/>
|
||||
<div class="invalid-feedback fw-bold field-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 row">
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('up');">
|
||||
<i class="bi bi-arrow-up-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('down');">
|
||||
<i class="bi bi-arrow-down-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-primary mt-1" onclick="addChildNode();">권한 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-primary" onclick="goSave();">저장</button>
|
||||
<button type="button" class="btn btn-danger" onclick="goRemove();">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
|
||||
// 노드가 보여질 level 전연벽수 기본값 6
|
||||
let globalLevels = 6;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadTree();
|
||||
});
|
||||
|
||||
function loadTree(currentId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/adminPrivilege/get/recursiveItems',
|
||||
cache: false,
|
||||
success: function (response) {
|
||||
let jsonData = response.items;
|
||||
$(jsonData).each(function (idx, oj) {
|
||||
oj['text'] = !oj.description ? oj.id : oj.id + ' (' + oj.description + ')';
|
||||
oj['value'] = oj.description;
|
||||
});
|
||||
renderTree({
|
||||
text: '관리자 권한',
|
||||
value: '',
|
||||
nodes: jsonData
|
||||
}, currentId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderTree(nodes, currentId) {
|
||||
const tree = $('#tree');
|
||||
tree.treeview({
|
||||
data: [nodes],
|
||||
color: "#428bca",
|
||||
expandIcon: 'bi bi-plus-square-fill',
|
||||
collapseIcon: 'bi bi-dash-square-fill',
|
||||
emptyIcon: 'bi bi-dot',
|
||||
showBorder: false,
|
||||
enableLinks: true,
|
||||
levels: globalLevels,
|
||||
});
|
||||
|
||||
tree.on('rendered', function () {
|
||||
if (currentId) {
|
||||
setTimeout(function () {
|
||||
const currentNode = tree.treeview('findNodes', ['^' + currentId + '$', 'id']);
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
currentNode[0].$el[0].scrollIntoView();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
tree.off('nodeSelected').on('nodeSelected', function (event, data) {
|
||||
const f = document.formDto;
|
||||
const currentNode = tree.treeview('getSelected')[0];
|
||||
|
||||
if (data.id === 'code.new.temp') {
|
||||
// 신규 노드일 경우 id는 'code.new.temp'
|
||||
|
||||
cleanFormFields();
|
||||
|
||||
$(f.id).removeAttr('readonly');
|
||||
|
||||
f.id.value = currentNode.text;
|
||||
f.description.value = currentNode.value ? currentNode.value : '';
|
||||
f.id.focus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentNode.id) {
|
||||
getInfo(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addChildNode() {
|
||||
const tree = $('#tree');
|
||||
const parentNode = tree.treeview('getNodes')[0];
|
||||
tree.treeview('addNode', [{text: 'NEW NODE - 저장 필요', id: 'code.new.temp'}, parentNode]);
|
||||
const currentNode = tree.treeview('findNodes', ['^code.new.temp$', 'id']);
|
||||
|
||||
setTimeout(function () {
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function refreshTree(currentId) {
|
||||
$('#tree').treeview('remove');
|
||||
cleanFormFields();
|
||||
loadTree(currentId);
|
||||
}
|
||||
|
||||
function getInfo(data) {
|
||||
const f = document.formDto;
|
||||
if (data.id === 'code.new.temp') {
|
||||
return;
|
||||
}
|
||||
cleanFormFields();
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/adminPrivilege/get/' + data.id,
|
||||
cache: false,
|
||||
statusCode: {
|
||||
400: function (response) {
|
||||
alert(response.responseJSON.message);
|
||||
},
|
||||
200: function (response) {
|
||||
const item = response.item;
|
||||
f.id.value = item.id;
|
||||
f.description.value = item.description;
|
||||
f.orderNo.value = item.orderNo;
|
||||
|
||||
showAudit(item.id, item.createdBy, item.createdAt, item.updatedBy, item.updatedAt);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$(f.id).attr('readonly', 'readonly');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goSave() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert(/*[[#{operation.adminRole.save.choose.first}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
const f = document.formDto;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminPrivilege/save',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
refreshTree(response.item.id);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
const fieldErrors = response.responseJSON.fieldErrors;
|
||||
let form = document.formDto;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
$(form[error.field]).addClass('is-invalid');
|
||||
$('.field-' + error.field).text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
const f = document.formDto;
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert([[#{operation.uri.remove.choose.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = selectedNode[0];
|
||||
|
||||
if (confirm("'" + info.text + "' " + [[#{operation.uri.remove.ask(info.text)}]])) {
|
||||
if (!info.id) {
|
||||
// 신규생성 임시 노드인 경우
|
||||
tree.treeview('removeNode', [selectedNode]);
|
||||
alert([[#{operation.common.remove.done}]]);
|
||||
refreshTree();
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminPrivilege/remove',
|
||||
data: {id: info.id},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.message);
|
||||
refreshTree();
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function cleanFormFields() {
|
||||
const f = document.formDto;
|
||||
f.id.value = '';
|
||||
f.orderNo.value = '';
|
||||
f.description.value = '';
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$('.audit-area').hide();
|
||||
}
|
||||
|
||||
function move(dir) {
|
||||
const curNode = $('#tree').treeview('getSelected');
|
||||
if (curNode.length === 0) {
|
||||
alert([[#{operation.uri.move.choose}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = curNode[0];
|
||||
if (info.id === 'code.new.temp') {
|
||||
alert([[#{operation.uri.move.save.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const curOrderNo = info.orderNo;
|
||||
const siblingsWithoutMe = $('#tree').treeview('getSiblings', curNode);
|
||||
const f = document.formDto;
|
||||
let updateList = [];
|
||||
let targetItem;
|
||||
switch (dir) {
|
||||
case 'up':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo < curOrderNo) {
|
||||
targetItem = item;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.before}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
case 'down':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo > curOrderNo) {
|
||||
targetItem = item;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.after}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
}
|
||||
|
||||
// 다음 tree 랜더링시 보여줄 level 설정
|
||||
globalLevels = info.nodeId.split('.').length - 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/adminPrivilege/switchOrderNo',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify(updateList),
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (data) {
|
||||
refreshTree(info.id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('collapseAll', {silent: true});
|
||||
}
|
||||
|
||||
function expand() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('expandAll', {silent: true, levels: 6});
|
||||
}
|
||||
|
||||
function searchNode() {
|
||||
let searchVal = $('#searchNode').val().trim();
|
||||
if (!searchVal) {
|
||||
return;
|
||||
}
|
||||
const tree = $('#tree');
|
||||
const searchNode = tree.treeview('search', [
|
||||
searchVal, {ignoreCase: true, revealResults: true}
|
||||
]);
|
||||
if (searchNode.length) {
|
||||
tree.treeview('selectNode', [searchNode[0], {silent: false}]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
<th:block layout:fragment="script">
|
||||
<script th:inline="javascript">
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
const head = document.getElementsByTagName('head')[0];
|
||||
|
||||
const link1 = document.createElement('link');
|
||||
link1.rel = 'stylesheet';
|
||||
link1.href = /*[[@{/static/library/bootstrap/bootstrap.min.css}]]*/'';
|
||||
head.appendChild(link1);
|
||||
|
||||
const link2 = document.createElement('link');
|
||||
link2.rel = 'stylesheet';
|
||||
link2.href =/*[[@{/static/library/bootstrap/bootstrap-icons.css}]]*/'';
|
||||
head.appendChild(link2);
|
||||
|
||||
const link3 = document.createElement('link');
|
||||
link3.rel = 'stylesheet';
|
||||
link3.href =/*[[@{/static/library/bootstrap-treeview/bootstrap-treeview.min.css}]]*/'';
|
||||
head.appendChild(link2);
|
||||
|
||||
const link4 = document.createElement('script');
|
||||
link4.type = 'text/javascript';
|
||||
link4.src =/*[[@{/static/library/bootstrap-treeview/bootstrap-treeview.min.js}]]*/'';
|
||||
head.appendChild(link4);
|
||||
|
||||
});
|
||||
</script>
|
||||
</th:block>
|
||||
</html>
|
||||
@@ -1,388 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<div class="row mb-1">
|
||||
<div class="col ps-0 pe-0">
|
||||
<a href="javascript:expand();" class="link-secondary">Expand</a>
|
||||
<a href="javascript:collapse();" class="link-secondary">Collapse</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-secondary float-end ms-1" onclick="searchNode();">
|
||||
<i
|
||||
class="bi bi-search"></i></button>
|
||||
<input class="form-control form-control-sm w-25 inline-block float-end" id="searchNode"
|
||||
type="text"
|
||||
placeholder="권한 검색">
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col fw-bold border rounded-3 overflow-auto lh-1" id="tree"></div>
|
||||
<div class="col fw-bold ms-4">
|
||||
|
||||
<form name="formDto" action="" method="post">
|
||||
<input type="hidden" name="orderNo" value="">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="id">권한 ID *</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="id" name="id" class="form-control" placeholder="공백없이 권한 ID 입력"/>
|
||||
<div class="invalid-feedback fw-bold field-id"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=" row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="description">설명</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="description" name="description" class="form-control"
|
||||
placeholder="설명을 입력하세요"/>
|
||||
<div class="invalid-feedback fw-bold field-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 row">
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('up');">
|
||||
<i class="bi bi-arrow-up-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('down');">
|
||||
<i class="bi bi-arrow-down-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-primary mt-1" onclick="addChildNode();">권한 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-primary" onclick="goSave();">저장</button>
|
||||
<button type="button" class="btn btn-danger" onclick="goRemove();">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
|
||||
// 노드가 보여질 level 전연벽수 기본값 6
|
||||
let globalLevels = 6;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadTree();
|
||||
});
|
||||
|
||||
function loadTree(currentId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/userPrivileges',
|
||||
cache: false,
|
||||
success: function (response) {
|
||||
let jsonData = response.userPrivileges;
|
||||
$(jsonData).each(function (idx, oj) {
|
||||
oj['text'] = !oj.description ? oj.id : oj.id + ' (' + oj.description + ')';
|
||||
oj['value'] = oj.description;
|
||||
});
|
||||
renderTree({
|
||||
text: '사용자 권한',
|
||||
value: '',
|
||||
nodes: jsonData
|
||||
}, currentId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderTree(nodes, currentId) {
|
||||
const tree = $('#tree');
|
||||
tree.treeview({
|
||||
data: [nodes],
|
||||
color: "#428bca",
|
||||
expandIcon: 'bi bi-plus-square-fill',
|
||||
collapseIcon: 'bi bi-dash-square-fill',
|
||||
emptyIcon: 'bi bi-dot',
|
||||
showBorder: false,
|
||||
enableLinks: true,
|
||||
levels: globalLevels,
|
||||
});
|
||||
|
||||
tree.on('rendered', function () {
|
||||
if (currentId) {
|
||||
setTimeout(function () {
|
||||
const currentNode = tree.treeview('findNodes', ['^' + currentId + '$', 'id']);
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
currentNode[0].$el[0].scrollIntoView();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
tree.off('nodeSelected').on('nodeSelected', function (event, data) {
|
||||
const f = document.formDto;
|
||||
const currentNode = tree.treeview('getSelected')[0];
|
||||
|
||||
if (data.id === 'code.new.temp') {
|
||||
// 신규 노드일 경우 id는 'code.new.temp'
|
||||
|
||||
cleanFormFields();
|
||||
|
||||
$(f.id).removeAttr('readonly');
|
||||
|
||||
f.id.value = currentNode.text;
|
||||
f.description.value = currentNode.value ? currentNode.value : '';
|
||||
f.id.focus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentNode.id) {
|
||||
getInfo(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addChildNode() {
|
||||
const tree = $('#tree');
|
||||
const parentNode = tree.treeview('getNodes')[0];
|
||||
tree.treeview('addNode', [{text: 'NEW NODE - 저장 필요', id: 'code.new.temp'}, parentNode]);
|
||||
const currentNode = tree.treeview('findNodes', ['^code.new.temp$', 'id']);
|
||||
|
||||
setTimeout(function () {
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function refreshTree(currentId) {
|
||||
$('#tree').treeview('remove');
|
||||
cleanFormFields();
|
||||
loadTree(currentId);
|
||||
}
|
||||
|
||||
function getInfo(data) {
|
||||
const f = document.formDto;
|
||||
if (data.id === 'code.new.temp') {
|
||||
return;
|
||||
}
|
||||
cleanFormFields();
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/userPrivileges/' + data.id,
|
||||
cache: false,
|
||||
statusCode: {
|
||||
400: function (response) {
|
||||
alert(response.responseJSON.message);
|
||||
},
|
||||
200: function (response) {
|
||||
const item = response.userPrivilege;
|
||||
f.id.value = item.id;
|
||||
f.description.value = item.description;
|
||||
f.orderNo.value = item.orderNo;
|
||||
|
||||
showAudit(item.id, item.createdBy, item.createdAt, item.updatedBy, item.updatedAt);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$(f.id).attr('readonly', 'readonly');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goSave() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert(/*[[#{operation.adminRole.save.choose.first}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
const f = document.formDto;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/userPrivileges/save',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.msg);
|
||||
refreshTree(response.userPrivilege.id);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
const fieldErrors = response.responseJSON.fieldErrors;
|
||||
let form = document.formDto;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
$(form[error.field]).addClass('is-invalid');
|
||||
$('.field-' + error.field).text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
const f = document.formDto;
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert([[#{operation.uri.remove.choose.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = selectedNode[0];
|
||||
|
||||
if (confirm("'" + info.text + "' " + [[#{operation.uri.remove.ask(info.text)}]])) {
|
||||
if (!info.id) {
|
||||
// 신규생성 임시 노드인 경우
|
||||
tree.treeview('removeNode', [selectedNode]);
|
||||
alert([[#{operation.common.remove.done}]]);
|
||||
refreshTree();
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: '/api/userPrivileges/remove',
|
||||
data: {id: info.id},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.msg);
|
||||
refreshTree();
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function cleanFormFields() {
|
||||
const f = document.formDto;
|
||||
f.id.value = '';
|
||||
f.orderNo.value = '';
|
||||
f.description.value = '';
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$('.audit-area').hide();
|
||||
}
|
||||
|
||||
function move(dir) {
|
||||
const curNode = $('#tree').treeview('getSelected');
|
||||
if (curNode.length === 0) {
|
||||
alert([[#{operation.uri.move.choose}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = curNode[0];
|
||||
if (info.id === 'code.new.temp') {
|
||||
alert([[#{operation.uri.move.save.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const curOrderNo = info.orderNo;
|
||||
const siblingsWithoutMe = $('#tree').treeview('getSiblings', curNode);
|
||||
const f = document.formDto;
|
||||
let updateList = [];
|
||||
let targetItem;
|
||||
switch (dir) {
|
||||
case 'up':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo < curOrderNo) {
|
||||
targetItem = item;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.before}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
case 'down':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo > curOrderNo) {
|
||||
targetItem = item;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.after}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
}
|
||||
|
||||
// 다음 tree 랜더링시 보여줄 level 설정
|
||||
globalLevels = info.nodeId.split('.').length - 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'PATCH',
|
||||
url: '/api/userPrivileges/sort',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify({
|
||||
sortUserPrivileges: updateList
|
||||
}),
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (data) {
|
||||
refreshTree(info.id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('collapseAll', {silent: true});
|
||||
}
|
||||
|
||||
function expand() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('expandAll', {silent: true, levels: 6});
|
||||
}
|
||||
|
||||
function searchNode() {
|
||||
let searchVal = $('#searchNode').val().trim();
|
||||
if (!searchVal) {
|
||||
return;
|
||||
}
|
||||
const tree = $('#tree');
|
||||
const searchNode = tree.treeview('search', [
|
||||
searchVal, {ignoreCase: true, revealResults: true}
|
||||
]);
|
||||
if (searchNode.length) {
|
||||
tree.treeview('selectNode', [searchNode[0], {silent: false}]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,404 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
||||
layout:decorate="~{layout/layout}">
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<div class="row mb-1">
|
||||
<div class="col ps-0 pe-0">
|
||||
<a href="javascript:expand();" class="link-secondary">Expand</a>
|
||||
<a href="javascript:collapse();" class="link-secondary">Collapse</a>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-secondary float-end ms-1" onclick="searchNode();">
|
||||
<i
|
||||
class="bi bi-search"></i></button>
|
||||
<input class="form-control form-control-sm w-25 inline-block float-end" id="searchNode"
|
||||
type="text"
|
||||
placeholder="역할 검색">
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col fw-bold border rounded-3 overflow-auto lh-1" id="tree"></div>
|
||||
<div class="col fw-bold ms-4">
|
||||
|
||||
<form name="formDto" action="" method="post">
|
||||
<input type="hidden" name="orderNo" value="">
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="id">역할 ID *</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="id" name="id" class="form-control"
|
||||
placeholder="ROLE_ 로 시작하는 역할 ID 입력"/>
|
||||
<div class="invalid-feedback fw-bold field-id"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="description">설명</label>
|
||||
<div class="col-sm-9">
|
||||
<input type="text" id="description" name="description" class="form-control"
|
||||
placeholder="설명을 입력하세요"/>
|
||||
<div class="invalid-feedback fw-bold field-description"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-3 col-form-label" for="privilegeIds">권한</label>
|
||||
<div class="col-sm-9">
|
||||
<select class="form-select text-secondary" id="privilegeIds" name="privilegeIds"
|
||||
multiple style="height: 200px;">
|
||||
<option th:each="privilege : ${privileges}" th:value="${privilege.id}"
|
||||
class="fw-bold"
|
||||
th:text="${privilege.id + ' (' + privilege.description + ')'}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold field-privilegeIds"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-2 row">
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('up');">
|
||||
<i class="bi bi-arrow-up-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary mt-1" onclick="move('down');">
|
||||
<i class="bi bi-arrow-down-circle-fill"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-primary mt-1" onclick="addChildNode();">역할 추가
|
||||
</button>
|
||||
</div>
|
||||
<div class="col text-end">
|
||||
<button type="button" class="btn btn-primary" onclick="goSave();">저장</button>
|
||||
<button type="button" class="btn btn-danger" onclick="goRemove();">삭제</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
|
||||
// 노드가 보여질 level 전연벽수 기본값 6
|
||||
let globalLevels = 6;
|
||||
|
||||
$(document).ready(function () {
|
||||
loadTree();
|
||||
});
|
||||
|
||||
function loadTree(currentId) {
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/userRoles',
|
||||
cache: false,
|
||||
success: function (response) {
|
||||
let jsonData = response.userRoles;
|
||||
$(jsonData).each(function (idx, oj) {
|
||||
oj['text'] = !oj.description ? oj.id : oj.id + ' (' + oj.description + ')';
|
||||
oj['value'] = oj.description;
|
||||
});
|
||||
renderTree({
|
||||
text: '사용자 역할',
|
||||
value: '',
|
||||
nodes: jsonData
|
||||
}, currentId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renderTree(nodes, currentId) {
|
||||
const tree = $('#tree');
|
||||
tree.treeview({
|
||||
data: [nodes],
|
||||
color: "#428bca",
|
||||
expandIcon: 'bi bi-plus-square-fill',
|
||||
collapseIcon: 'bi bi-dash-square-fill',
|
||||
emptyIcon: 'bi bi-dot',
|
||||
showBorder: false,
|
||||
enableLinks: true,
|
||||
levels: globalLevels,
|
||||
});
|
||||
|
||||
tree.on('rendered', function () {
|
||||
if (currentId) {
|
||||
setTimeout(function () {
|
||||
const currentNode = tree.treeview('findNodes', ['^' + currentId + '$', 'id']);
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
currentNode[0].$el[0].scrollIntoView();
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
|
||||
tree.off('nodeSelected').on('nodeSelected', function (event, data) {
|
||||
const f = document.formDto;
|
||||
const currentNode = tree.treeview('getSelected')[0];
|
||||
|
||||
if (data.id === 'code.new.temp') {
|
||||
// 신규 노드일 경우 id는 'code.new.temp'
|
||||
|
||||
cleanFormFields();
|
||||
|
||||
$(f.id).removeAttr('readonly');
|
||||
|
||||
f.id.value = currentNode.text;
|
||||
f.description.value = currentNode.value ? currentNode.value : '';
|
||||
f.id.focus();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentNode.id) {
|
||||
getInfo(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addChildNode() {
|
||||
const tree = $('#tree');
|
||||
const parentNode = tree.treeview('getNodes')[0];
|
||||
tree.treeview('addNode', [{text: 'NEW NODE - 저장 필요', id: 'code.new.temp'}, parentNode]);
|
||||
const currentNode = tree.treeview('findNodes', ['^code.new.temp$', 'id']);
|
||||
|
||||
setTimeout(function () {
|
||||
tree.treeview('selectNode', [currentNode, {silent: false}]);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
function refreshTree(currentId) {
|
||||
$('#tree').treeview('remove');
|
||||
cleanFormFields();
|
||||
loadTree(currentId);
|
||||
}
|
||||
|
||||
function getInfo(data) {
|
||||
const f = document.formDto;
|
||||
if (data.id === 'code.new.temp') {
|
||||
return;
|
||||
}
|
||||
cleanFormFields();
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/api/userRoles/' + data.id,
|
||||
cache: false,
|
||||
statusCode: {
|
||||
400: function (response) {
|
||||
alert(response.responseJSON.message);
|
||||
},
|
||||
200: function (response) {
|
||||
const item = response.userRole;
|
||||
f.id.value = item.id;
|
||||
f.description.value = item.description;
|
||||
f.orderNo.value = item.orderNo;
|
||||
|
||||
$('#privilegeIds').val(item.privileges);
|
||||
|
||||
showAudit(item.id, item.createdBy, item.createdAt, item.updatedBy, item.updatedAt);
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
$(f.id).attr('readonly', 'readonly');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goSave() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert(/*[[#{operation.adminRole.save.choose.first}]]*/);
|
||||
return;
|
||||
}
|
||||
|
||||
const f = document.formDto;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/api/userRoles/save',
|
||||
data: obj,
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.msg);
|
||||
refreshTree(response.id);
|
||||
},
|
||||
statusCode: {
|
||||
// error
|
||||
400: function (response) {
|
||||
const resJson = response.responseJSON;
|
||||
alert(resJson.message);
|
||||
},
|
||||
// validation fail
|
||||
422: function (response) {
|
||||
const fieldErrors = response.responseJSON.fieldErrors;
|
||||
let form = document.formDto;
|
||||
$(fieldErrors).each(function (idx, error) {
|
||||
$(form[error.field]).addClass('is-invalid');
|
||||
$('.field-' + error.field).text(error.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function goRemove() {
|
||||
const tree = $('#tree');
|
||||
const selectedNode = tree.treeview('getSelected');
|
||||
const f = document.formDto;
|
||||
|
||||
if (selectedNode.length === 0) {
|
||||
alert([[#{operation.uri.remove.choose.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = selectedNode[0];
|
||||
|
||||
if (confirm("'" + info.text + "' " + [[#{operation.uri.remove.ask(info.text)}]])) {
|
||||
if (!info.id) {
|
||||
// 신규생성 임시 노드인 경우
|
||||
tree.treeview('removeNode', [selectedNode]);
|
||||
alert([[#{operation.common.remove.done}]]);
|
||||
refreshTree();
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'DELETE',
|
||||
url: '/api/userRole/remove',
|
||||
data: {id: info.id},
|
||||
beforeSend: function (xhr) {
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function (response) {
|
||||
alert(response.msg);
|
||||
refreshTree();
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function cleanFormFields() {
|
||||
const f = document.formDto;
|
||||
f.id.value = '';
|
||||
f.orderNo.value = '';
|
||||
f.description.value = '';
|
||||
|
||||
$(f).find('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$('.audit-area').hide();
|
||||
$('#privilegeIds').val([]);
|
||||
}
|
||||
|
||||
function move(dir) {
|
||||
const curNode = $('#tree').treeview('getSelected');
|
||||
if (curNode.length === 0) {
|
||||
alert([[#{operation.uri.move.choose}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const info = curNode[0];
|
||||
if (info.id === 'code.new.temp') {
|
||||
alert([[#{operation.uri.move.save.first}]]);
|
||||
return;
|
||||
}
|
||||
|
||||
const curOrderNo = info.orderNo;
|
||||
const siblingsWithoutMe = $('#tree').treeview('getSiblings', curNode);
|
||||
const f = document.formDto;
|
||||
let updateList = [];
|
||||
let targetItem;
|
||||
switch (dir) {
|
||||
case 'up':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo < curOrderNo) {
|
||||
targetItem = item;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.before}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
case 'down':
|
||||
$(siblingsWithoutMe).each(function (idx, item) {
|
||||
if (item.orderNo > curOrderNo) {
|
||||
targetItem = item;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (!targetItem) {
|
||||
alert([[#{operation.uri.move.cannot.after}]]);
|
||||
return;
|
||||
}
|
||||
updateList.push({id: info.id, orderNo: targetItem.orderNo});
|
||||
updateList.push({id: targetItem.id, orderNo: info.orderNo});
|
||||
break;
|
||||
}
|
||||
|
||||
// 다음 tree 랜더링시 보여줄 level 설정
|
||||
globalLevels = info.nodeId.split('.').length - 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'PATCH',
|
||||
url: '/api/userRoles/sort',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
data: JSON.stringify({
|
||||
sortUserRoles: updateList
|
||||
}),
|
||||
beforeSend: function (xhr) {
|
||||
// csrf 토큰
|
||||
xhr.setRequestHeader(
|
||||
$("meta[name='_csrf_header']").attr("content"),
|
||||
$("meta[name='_csrf']").attr("content"));
|
||||
},
|
||||
success: function () {
|
||||
refreshTree(info.id);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('collapseAll', {silent: true});
|
||||
}
|
||||
|
||||
function expand() {
|
||||
const tree = $('#tree');
|
||||
tree.treeview('expandAll', {silent: true, levels: 6});
|
||||
}
|
||||
|
||||
function searchNode() {
|
||||
let searchVal = $('#searchNode').val().trim();
|
||||
if (!searchVal) {
|
||||
return;
|
||||
}
|
||||
const tree = $('#tree');
|
||||
const searchNode = tree.treeview('search', [
|
||||
searchVal, {ignoreCase: true, revealResults: true}
|
||||
]);
|
||||
if (searchNode.length) {
|
||||
tree.treeview('selectNode', [searchNode[0], {silent: false}]);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,216 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<form method="post" name="reqForm" th:action="@{/settings/users}" th:object="${reqVO}">
|
||||
|
||||
<!-- hidden parameters -->
|
||||
<input name="sort" th:field="*{sort}" type="hidden"/>
|
||||
<input name="page" th:field="*{page}" type="hidden"/>
|
||||
|
||||
<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 id="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="size"
|
||||
onchange="goSearch()"
|
||||
th:field="*{size}">
|
||||
<option
|
||||
th:each="item : ${pageRows}"
|
||||
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"><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="nickname" href="#">닉네임</a></th>
|
||||
<th scope="col"><a class="order-able" data-sort-field="signUpType" href="#">가입유형</a></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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="listTBody">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="row paging"></div>
|
||||
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script>
|
||||
const getUsers = (pageNo) => {
|
||||
const f = document.reqForm;
|
||||
f.page.value = pageNo;
|
||||
|
||||
let dataOj = $(f).serializeObject();
|
||||
|
||||
$.ajax({
|
||||
method: 'GET',
|
||||
url: '/api/settings/users',
|
||||
data: dataOj,
|
||||
success(response) {
|
||||
console.log(response);
|
||||
|
||||
$('#totalElements').text(response.totalElements);
|
||||
|
||||
// List 구성하기
|
||||
const tbody = $('#listTBody');
|
||||
tbody.empty();
|
||||
|
||||
$(response.content).each((idx, ct) => {
|
||||
tbody.append(
|
||||
`
|
||||
<tr data-id="${ct.id}">
|
||||
<th scope="row">
|
||||
${idx + (pageNo * f.size.value) + 1}
|
||||
</th>
|
||||
<td><a href="javascript:goUpdate('${ct.id}')">${ct.id}</a></td>
|
||||
<td>
|
||||
${ct.roles.map(r => r.id).join(', ')}
|
||||
</td>
|
||||
<td>${ct.nickname}</td>
|
||||
<td>${ct.signUpType}</td>
|
||||
<td>${ct.email}</td>
|
||||
<td>${ct.accountDisabled ? 'N' : 'Y'}</td>
|
||||
<td>${ct.accountLocked ? 'Y' : 'N'}</td>
|
||||
<td>${uiUtil.isoStrToReadable(ct.createdAt)}</td>
|
||||
</tr>
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
if (!$(response.content).length) {
|
||||
tbody.append(`
|
||||
<tr>
|
||||
<td colspan="9" class="text-center text-muted">게시물이 존재하지 않습니다.</td>
|
||||
</tr>
|
||||
`);
|
||||
}
|
||||
|
||||
// Pagination 구성하기
|
||||
const paging = $('.paging');
|
||||
paging.empty();
|
||||
paging.append(
|
||||
uiUtil.getPagingUI(pageNo, f.size.value, response.totalPages,
|
||||
(movePageNo) => {
|
||||
f.page.value = movePageNo;
|
||||
goSearch();
|
||||
}));
|
||||
|
||||
// 리스트 상단 정렬 notation 및 갱신 기능 적용
|
||||
uiUtil.addSortNotation(f.sort.value, (targetPage, targetSort) => {
|
||||
f.page.value = targetPage;
|
||||
f.sort.value = targetSort;
|
||||
goSearch();
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 최초 리스트 로드
|
||||
getUsers(0);
|
||||
</script>
|
||||
|
||||
<script th:inline="javascript">
|
||||
// 검색
|
||||
function goSearch() {
|
||||
const f = document.reqForm;
|
||||
f.method = 'GET';
|
||||
f.submit();
|
||||
}
|
||||
|
||||
// 초기화
|
||||
function goInit() {
|
||||
const f = document.reqForm;
|
||||
f.searchField.value = '';
|
||||
f.searchValue.value = '';
|
||||
f.searchRole.value = '';
|
||||
}
|
||||
|
||||
// 수정페이지 이동
|
||||
function goUpdate(id) {
|
||||
location.href = '/settings/users/' + id;
|
||||
}
|
||||
|
||||
// 체크박스 선택/해제
|
||||
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.reqForm;
|
||||
f.action = '/settings/admins/delete';
|
||||
f.method = 'post';
|
||||
f.submit();
|
||||
}
|
||||
}
|
||||
|
||||
function goExcel() {
|
||||
const f = document.reqForm;
|
||||
f.action = '/settings/admins/excel';
|
||||
f.sort.value = convertToPageableSortValue(f.sort.value);
|
||||
f.method = 'post';
|
||||
f.submit();
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -1,165 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html layout:decorate="~{layout/layout}" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<section layout:fragment="content">
|
||||
|
||||
<form class="fw-bold"
|
||||
method="post"
|
||||
name="reqForm"
|
||||
th:action="@{/settings/users/update}">
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<!-- audit area -->
|
||||
<div th:replace="common/components :: auditArea"></div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="id">ID *</label>
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control" id="id" name="id" readonly="readonly"
|
||||
th:value="${id}"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="email">Email *</label>
|
||||
<div class="input-group w-50">
|
||||
<input class="form-control" id="email" name="email" type="email"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="roleIds">권한 *</label>
|
||||
<div class="input-group w-50">
|
||||
<select class="form-control" multiple name="roles">
|
||||
<option th:each="role : ${roles}" th:text="${role.id}"
|
||||
th:value="${role.id}"></option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 활성화 -->
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="inlineRadio1">비활성화 여부 *</label>
|
||||
<div class="input-group w-25">
|
||||
<select class="form-select" name="accountDisabled">
|
||||
<option value="true">비활성화</option>
|
||||
<option value="false">활성화</option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 계정잠김 -->
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="accountLocked1">계정잠김 여부 *</label>
|
||||
<div class="input-group w-25">
|
||||
<select class="form-select" name="accountLocked">
|
||||
<option value="true">Locked</option>
|
||||
<option value="false">Unlocked</option>
|
||||
</select>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<label class="form-label" for="loginFailCnt">로그인 실패 회수</label>
|
||||
<div class="input-group w-25">
|
||||
<input class="form-control" id="loginFailCnt" name="loginFailCnt" type="text"/>
|
||||
<div class="invalid-feedback fw-bold">
|
||||
에러 메세지
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<button class="btn btn-outline-secondary" onclick="goPrev();" title="이전 화면으로 이동">
|
||||
<i class="bi bi-arrow-left"></i>
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary" onclick="gotoList();" title="목록 화면으로 이동">
|
||||
<i class="bi bi-justify"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button class="btn btn-primary float-end" onclick="updateUser();" type="button">
|
||||
<i class="bi bi-save2"></i> 저장
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section layout:fragment="script">
|
||||
<script>
|
||||
const getUser = () => {
|
||||
const f = document.reqForm;
|
||||
|
||||
$.ajax({
|
||||
'method': 'GET',
|
||||
'url': '/api/settings/users/' + f.id.value,
|
||||
success(res) {
|
||||
console.log(res);
|
||||
|
||||
showAudit(res.id, res.createdBy, uiUtil.isoStrToReadable(res.createdAt)
|
||||
, res.updatedBy, uiUtil.isoStrToReadable(res.updatedAt));
|
||||
|
||||
f.email.value = res.email;
|
||||
f.roles.value = res.roles.map((el) => el.id);
|
||||
f.accountDisabled.value = res.accountDisabled;
|
||||
f.accountLocked.value = res.accountLocked;
|
||||
f.loginFailCnt.value = res.loginFailCnt;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 상세정보 얻기
|
||||
getUser();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
const updateUser = () => {
|
||||
const f = document.reqForm;
|
||||
const obj = $(f).serializeObject();
|
||||
|
||||
// 기존 에러 메세지 초기화
|
||||
$('.is-invalid').removeClass('is-invalid');
|
||||
|
||||
$.ajax({
|
||||
'method': 'PATCH',
|
||||
'url': '/api/settings/users/update',
|
||||
'data': obj,
|
||||
success(res) {
|
||||
if (confirm(`'${res.id}' 정보가 수정되었습니다.\n이전 화면으로 이동하시겠습니까?`)) {
|
||||
history.back();
|
||||
}
|
||||
},
|
||||
statusCode: {
|
||||
'422': (res) => {
|
||||
$(res.responseJSON).each((idx, oj) => {
|
||||
let target = $(f).find('[name=' + oj.field + ']');
|
||||
target.addClass('is-invalid');
|
||||
|
||||
target.parent().find('.invalid-feedback').text(oj.defaultMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</section>
|
||||
|
||||
</html>
|
||||
@@ -45,12 +45,6 @@ public class InitUriAdminData implements ApplicationRunner {
|
||||
final String ADMIN_SETTINGS_ADMIN_ROLE = "uri.admin.settings.adminRoles";
|
||||
final String ADMIN_SETTINGS_ADMIN_PRIVILEGE = "uri.admin.settings.adminPrivilege";
|
||||
|
||||
final String ADMIN_SETTINGS_USER_GROUP = "uri.admin.settings.user.group";
|
||||
final String ADMIN_SETTINGS_USER = "uri.admin.settings.user";
|
||||
final String ADMIN_SETTINGS_USER_UPDATE = "uri.admin.settings.user.update";
|
||||
final String ADMIN_SETTINGS_USER_ROLE = "uri.admin.settings.user.role";
|
||||
final String ADMIN_SETTINGS_USER_PRIVILEGE = "uri.admin.settings.user.privilege";
|
||||
|
||||
final String ADMIN_SETTINGS_URI_ADMIN = "uri.admin.settings.uri.admin";
|
||||
final String ADMIN_SETTINGS_URI_FRONT = "uri.admin.settings.uri.front";
|
||||
final String ADMIN_SETTINGS_CODE = "uri.admin.settings.uicode";
|
||||
@@ -308,15 +302,6 @@ public class InitUriAdminData implements ApplicationRunner {
|
||||
|
||||
|
||||
// 관리자 시작
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS,
|
||||
ADMIN_SETTINGS_ADMIN_GROUP,
|
||||
"관리자 & 역할",
|
||||
"/settings/adminGroup",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS_ADMIN_GROUP,
|
||||
@@ -362,71 +347,6 @@ public class InitUriAdminData implements ApplicationRunner {
|
||||
false,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS_ADMIN_GROUP,
|
||||
ADMIN_SETTINGS_ADMIN_ROLE,
|
||||
"관리자 역할",
|
||||
"/settings/adminRoles",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS_ADMIN_GROUP,
|
||||
ADMIN_SETTINGS_ADMIN_PRIVILEGE,
|
||||
"관리자 권한",
|
||||
"/settings/adminPrivilege",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
// 사용자 & 역할 - 시작
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS,
|
||||
ADMIN_SETTINGS_USER_GROUP,
|
||||
"사용자 & 역할",
|
||||
"/settings/userGroup",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS_USER_GROUP,
|
||||
ADMIN_SETTINGS_USER,
|
||||
"사용자 목록",
|
||||
"/settings/users",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS_USER,
|
||||
ADMIN_SETTINGS_USER_UPDATE,
|
||||
"사용자 수정",
|
||||
"/settings/users/{{pathVar}}",
|
||||
false,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS_USER_GROUP,
|
||||
ADMIN_SETTINGS_USER_ROLE,
|
||||
"사용자 역할",
|
||||
"/settings/userRoles",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS_USER_GROUP,
|
||||
ADMIN_SETTINGS_USER_PRIVILEGE,
|
||||
"사용자 권한",
|
||||
"/settings/userPrivilege",
|
||||
true,
|
||||
Set.of("ROLE_ADMIN"));
|
||||
// 사용자 & 역할 - 끝
|
||||
|
||||
appendURI(
|
||||
AppType.ADMIN,
|
||||
ADMIN_SETTINGS,
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.repository;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.Privilege;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface FrontUserPrivilegeRepo {
|
||||
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.repository;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface FrontUserRepo {
|
||||
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.repository;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.Role;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
@Mapper
|
||||
public interface FrontUserRoleRepo {
|
||||
|
||||
List<Role> findByAppType(AppType appType, Sort sort);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package app.module.core.config.adapters.persistence.repository;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.Privilege;
|
||||
import app.module.core.config.application.enums.AppType;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
@Mapper
|
||||
public interface PrivilegeRepo {
|
||||
List<Privilege> findByAppType(AppType appType, Sort sort);
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package app.module.core.usecase.user.createUser.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.entity.FrontUser;
|
||||
import app.module.core.config.adapters.persistence.entity.FrontUserHasRole;
|
||||
import app.module.core.config.adapters.persistence.entity.Role;
|
||||
import app.module.core.config.adapters.persistence.repository.FrontUserRepo;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.usecase.user.createUser.adapters.persistence.model.SaveFrontUserHasRoleParam;
|
||||
import app.module.core.usecase.user.createUser.ports.CreateUserPortOut;
|
||||
@@ -13,7 +10,7 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package app.module.core.usecase.user.getUsers.adapters.persistence;
|
||||
|
||||
import app.module.core.config.adapters.persistence.repository.FrontUserRepo;
|
||||
import app.module.core.usecase.user.getUsers.adapters.persistence.model.GetUsersDto;
|
||||
import app.module.core.usecase.user.getUsers.ports.GetUsersPortOut;
|
||||
import app.module.core.usecase.user.getUsers.ports.application.domain.GetUsers;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?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.privilege.list.adapters.persistence.PrivilegeListMapper">
|
||||
|
||||
<select id="findByAppType"
|
||||
resultType="app.module.core.usecase.privilege.list.adapters.persistence.model.PrivilegeListDto">
|
||||
/* findByAppType : 역할 목록 조회 */
|
||||
SELECT
|
||||
id,
|
||||
description,
|
||||
app_type,
|
||||
order_no,
|
||||
created_by,
|
||||
created_at,
|
||||
updated_by,
|
||||
updated_at
|
||||
FROM privilege
|
||||
WHERE app_type = #{appType}
|
||||
AND is_deleted = false
|
||||
ORDER BY order_no ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,13 +0,0 @@
|
||||
<?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.privilege.save.adapters.persistence.PrivilegeNextOrderNoMapper">
|
||||
|
||||
<select id="findMaxOrderNo" resultType="java.lang.Integer">
|
||||
/* findMaxOrderNo : 권한 정렬순서 max 값 조회 */
|
||||
SELECT max(order_no)
|
||||
FROM privilege p
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?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.privilege.remove.adapters.persistence.PrivilegeRemoveMapper">
|
||||
<update id="deleteById">
|
||||
UPDATE privilege
|
||||
SET <include refid="common.fields.DeleteBaseSet" />
|
||||
WHERE
|
||||
id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deleteRoleHasPrivilegesByPrivilegeId">
|
||||
UPDATE role_has_privilege
|
||||
SET <include refid="common.fields.DeleteBaseSet" />
|
||||
WHERE
|
||||
privilege_id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?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.privilege.save.adapters.persistence.PrivilegeSaveMapper">
|
||||
|
||||
<insert id="insertPrivilege">
|
||||
/* insertPrivilege : 권한 저장 */
|
||||
INSERT INTO privilege (id,
|
||||
description,
|
||||
app_type,
|
||||
order_no,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>)
|
||||
VALUES (#{id},
|
||||
#{description},
|
||||
#{appType},
|
||||
#{orderNo},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>)
|
||||
</insert>
|
||||
|
||||
<update id="updatePrivilege">
|
||||
/* updatePrivilege : 권한 정보 수정 */
|
||||
UPDATE privilege
|
||||
SET description = #{description},
|
||||
order_no = #{orderNo},
|
||||
<include refid="common.fields.UpdateBaseSet"/>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?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.privilege.sort.adapters.persistence.PrivilegeSortMapper">
|
||||
|
||||
<update id="updateOrderNo">
|
||||
/* updateOrderNo : 권한 정렬 수정 */
|
||||
UPDATE privilege
|
||||
SET order_no = #{orderNo},
|
||||
<include refid="common.fields.UpdateBaseSet" />
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -1,20 +0,0 @@
|
||||
<?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.privilege.view.adapters.persistence.PrivilegeViewMapper">
|
||||
|
||||
<select id="findById"
|
||||
resultType="app.module.core.usecase.privilege.view.ports.application.domain.PrivilegeView">
|
||||
SELECT
|
||||
p.created_by,
|
||||
p.created_at,
|
||||
p.updated_by,
|
||||
p.updated_at,
|
||||
p.id,
|
||||
p.description,
|
||||
p.order_no
|
||||
FROM privilege p
|
||||
WHERE p.id = #{id}
|
||||
AND p.is_deleted = false
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -1,12 +0,0 @@
|
||||
<?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.role.save.adapters.persistence.RoleNextOrderNoMapper">
|
||||
|
||||
<select id="getMaxOrderNo" resultType="java.lang.Integer">
|
||||
/* selectLastOrderNo : 역할 정렬순서 max 값 조회 */
|
||||
SELECT max(order_no)
|
||||
FROM role r
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?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.role.remove.adapters.persistence.RoleRemoveMapper">
|
||||
|
||||
<update id="deleteById">
|
||||
/* deleteById : 역할 삭제 */
|
||||
UPDATE role
|
||||
SET <include refid="common.fields.DeleteBaseSet" />
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deleteAdminHasRoleByRoleId">
|
||||
/* deleteAdminHasRoleByRoleId : 관리자의 역할 매핑 정보 삭제 */
|
||||
UPDATE admin_has_role
|
||||
SET <include refid="common.fields.DeleteBaseSet" />
|
||||
WHERE role_id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deleteRoleHasPrivilegesByRoleId">
|
||||
/* deleteRoleHasPrivilegesByRoleId : 역할 권한 매핑 정보 삭제 */
|
||||
UPDATE role_has_privilege
|
||||
SET <include refid="common.fields.DeleteBaseSet" />
|
||||
WHERE role_id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1,52 +0,0 @@
|
||||
<?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.role.save.adapters.persistence.RoleSaveMapper">
|
||||
|
||||
<insert id="insertRole">
|
||||
/* insertRole : 역할 저장 */
|
||||
INSERT INTO role (id,
|
||||
description,
|
||||
app_type,
|
||||
order_no,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>)
|
||||
VALUES (#{id},
|
||||
#{description},
|
||||
#{appType},
|
||||
#{orderNo},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>)
|
||||
</insert>
|
||||
|
||||
<update id="updateRole">
|
||||
/* updateRole : 역할 정보 수정 */
|
||||
UPDATE role
|
||||
SET description = #{description},
|
||||
order_no = #{orderNo},
|
||||
<include refid="common.fields.UpdateBaseSet"/>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<insert id="insertRoleHasPrivileges">
|
||||
/* insertRoleHasPrivileges : 역할 권한 매핑 정보 저장 */
|
||||
INSERT INTO role_has_privilege ( id,
|
||||
role_id,
|
||||
privilege_id,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>)
|
||||
VALUES
|
||||
<foreach collection="privilegeIds" item="pid" separator=",">
|
||||
(
|
||||
nextval('role_has_privilege_seq'),
|
||||
#{roleId},
|
||||
#{pid},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="deleteAllRoleHasPrivileges">
|
||||
/* deleteAllRoleHasPrivileges : 역할 권한 매핑 정보 삭제 */
|
||||
UPDATE role_has_privilege
|
||||
SET <include refid="common.fields.DeleteBaseSet"/>
|
||||
WHERE role_id = #{roleId}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?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.role.sort.adapters.persistence.RoleSortMapper">
|
||||
|
||||
<update id="updateOrderNo">
|
||||
/* updateOrderNo : 역할 정렬 수정 */
|
||||
UPDATE role
|
||||
SET order_no = #{orderNo},
|
||||
<include refid="common.fields.UpdateBaseSet" />
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -1,27 +0,0 @@
|
||||
<?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.role.view.adapters.persistence.RoleViewMapper">
|
||||
|
||||
<select id="findRoleById" resultType="app.module.core.usecase.role.view.adapters.persistence.model.RoleViewDto">
|
||||
SELECT
|
||||
r.id,
|
||||
r.description,
|
||||
r.order_no,
|
||||
r.created_by,
|
||||
r.created_at,
|
||||
r.updated_by,
|
||||
r.updated_at
|
||||
FROM role r
|
||||
WHERE r.id = #{roleId}
|
||||
AND r.is_deleted = false
|
||||
</select>
|
||||
|
||||
<select id="findPrivilegeIdsByRoleId" resultType="string">
|
||||
SELECT privilege_id
|
||||
FROM role_has_privilege
|
||||
WHERE role_id = #{roleId}
|
||||
AND is_deleted = false
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,49 +0,0 @@
|
||||
<?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.user.createUser.adapters.persistence.CreateUserMapper">
|
||||
|
||||
<insert id="insertFrontUser">
|
||||
/* insertFrontUser : 사용자 등록 */
|
||||
INSERT INTO front_user ( id,
|
||||
password,
|
||||
email,
|
||||
nickname,
|
||||
sign_up_type,
|
||||
password_updated_at,
|
||||
account_disabled,
|
||||
login_fail_cnt,
|
||||
account_locked,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>)
|
||||
VALUES (#{id},
|
||||
#{password},
|
||||
#{email},
|
||||
#{nickname},
|
||||
#{signUpType},
|
||||
#{passwordUpdatedAt},
|
||||
#{accountDisabled},
|
||||
#{loginFailCnt},
|
||||
#{accountLocked},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>)
|
||||
</insert>
|
||||
|
||||
<insert id="insertFrontUserHasRoles">
|
||||
/* insertFrontUserHasRoles : 사용자 역할 매핑 정보 저장 */
|
||||
INSERT INTO front_user_has_role (
|
||||
id,
|
||||
user_id,
|
||||
role_id,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="roleIds" item="roleId" separator=",">
|
||||
(
|
||||
nextval('front_user_has_role_seq'),
|
||||
#{userId},
|
||||
#{roleId},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -1,70 +0,0 @@
|
||||
<?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.user.findUser.adapters.persistence.FindUserMapper">
|
||||
|
||||
<select id="findUserById"
|
||||
parameterType="string"
|
||||
resultType="app.module.core.usecase.user.findUser.adapters.persistence.model.FindUserDto">
|
||||
SELECT
|
||||
u.id,
|
||||
u.password,
|
||||
u.email,
|
||||
u.nickname,
|
||||
u.sign_up_type,
|
||||
u.password_updated_at,
|
||||
u.account_disabled,
|
||||
u.login_fail_cnt,
|
||||
u.account_locked,
|
||||
u.created_at,
|
||||
u.created_by,
|
||||
u.updated_at,
|
||||
u.updated_by
|
||||
FROM front_user u
|
||||
WHERE u.id = #{id}
|
||||
AND u.is_deleted = FALSE
|
||||
</select>
|
||||
|
||||
<!-- 사용자 역할 + 권한 JOIN -->
|
||||
<resultMap id="CoreRoleWithPrivilegesMap" type="app.module.core.config.adapters.web.security.domain.CoreRole">
|
||||
<id property="id" column="role_id"/>
|
||||
<result property="description" column="role_description"/>
|
||||
|
||||
<collection property="privileges" ofType="app.module.core.config.adapters.web.security.domain.CorePrivilege">
|
||||
<id property="id" column="privilege_id"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="findRolesWithPrivilegesByUserId" resultMap="CoreRoleWithPrivilegesMap">
|
||||
SELECT
|
||||
r.id AS role_id,
|
||||
r.description AS role_description,
|
||||
p.id AS privilege_id
|
||||
FROM front_user_has_role fur
|
||||
JOIN role r ON fur.role_id = r.id
|
||||
AND r.is_deleted = FALSE
|
||||
AND fur.is_deleted = FALSE
|
||||
LEFT JOIN role_has_privilege rhp ON r.id = rhp.role_id AND rhp.is_deleted = FALSE
|
||||
LEFT JOIN privilege p ON rhp.privilege_id = p.id AND p.is_deleted = FALSE
|
||||
WHERE fur.front_user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="findProfileImageByUserId"
|
||||
parameterType="string"
|
||||
resultType="app.module.core.usecase.user.findUser.ports.application.domain.FindProfileImages">
|
||||
SELECT
|
||||
f.id,
|
||||
f.type,
|
||||
f.path,
|
||||
f.name,
|
||||
f.origin_name,
|
||||
f.file_length
|
||||
FROM front_user_has_upload_file ufmap
|
||||
JOIN upload_file f ON ufmap.upload_files_id = f.id
|
||||
WHERE ufmap.front_user_id = #{userId}
|
||||
AND f.type = #{fileUploadType}
|
||||
AND f.is_deleted = FALSE
|
||||
LIMIT 1 /* .findFirst() */
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,21 +0,0 @@
|
||||
<?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.user.getRoles.adapters.persistence.GetRolesMapper">
|
||||
|
||||
<select id="findByAppType" resultType="app.module.core.usecase.user.getRoles.ports.application.domain.GetRoles">
|
||||
SELECT
|
||||
id,
|
||||
description,
|
||||
order_no,
|
||||
created_at,
|
||||
created_by,
|
||||
updated_at,
|
||||
updated_by
|
||||
FROM role
|
||||
WHERE is_deleted = false
|
||||
AND app_type = #{appType}
|
||||
ORDER BY order_no ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,78 +0,0 @@
|
||||
<?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.user.getUsers.adapters.persistence.GetUsersMapper">
|
||||
|
||||
<select id="getUsers" resultType="app.module.core.usecase.user.getUsers.adapters.persistence.model.GetUsersDto">
|
||||
SELECT
|
||||
fu.id,
|
||||
fu.email,
|
||||
fu.nickname,
|
||||
fu.sign_up_type,
|
||||
fu.password_updated_at,
|
||||
fu.account_disabled,
|
||||
fu.login_fail_cnt,
|
||||
fu.account_locked,
|
||||
fu.created_at,
|
||||
fu.created_by,
|
||||
fu.updated_at,
|
||||
fu.updated_by,
|
||||
COUNT(*) OVER() AS total
|
||||
FROM front_user fu
|
||||
WHERE fu.is_deleted = FALSE
|
||||
|
||||
<if test="pageable.sort != null and !pageable.sort.isEmpty()">
|
||||
ORDER BY
|
||||
<foreach collection="pageable.sort" item="order" separator=",">
|
||||
<choose>
|
||||
<when test="order.property eq 'id'">fu.id</when>
|
||||
<when test="order.property eq 'email'">fu.email</when>
|
||||
<when test="order.property eq 'accountDisabled'">fu.account_disabled</when>
|
||||
<when test="order.property eq 'accountLocked'">fu.account_locked</when>
|
||||
<when test="order.property eq 'createdAt'">fu.created_at</when>
|
||||
<when test="order.property eq 'updatedAt'">fu.updated_at</when>
|
||||
<otherwise>fu.created_at</otherwise>
|
||||
</choose>
|
||||
<choose>
|
||||
<when test="order.direction.toString() eq 'DESC'"> DESC</when>
|
||||
<otherwise> ASC</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
</if>
|
||||
|
||||
OFFSET #{pageable.offset} ROWS FETCH NEXT #{pageable.pageSize} ROWS ONLY
|
||||
</select>
|
||||
|
||||
<resultMap id="GetUsersRoleMap" type="app.module.core.usecase.user.getUsers.ports.application.domain.GetUsersRole">
|
||||
<id property="id" column="role_id" />
|
||||
<result property="userId" column="user_id"/>
|
||||
<result property="description" column="role_description" />
|
||||
|
||||
<collection property="privileges" ofType="app.module.core.usecase.user.getUsers.ports.application.domain.GetUsersPrivilege">
|
||||
<id property="id" column="privilege_id" />
|
||||
<result property="description" column="privilege_description" />
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="findRolesWithPrivilegesByUserIds" resultMap="GetUsersRoleMap">
|
||||
SELECT
|
||||
r.id AS role_id,
|
||||
fur.front_user_id AS user_id,
|
||||
r.description AS role_description,
|
||||
p.id AS privilege_id,
|
||||
p.description AS privilege_description
|
||||
FROM front_user_has_role fur
|
||||
JOIN role r ON fur.role_id = r.id AND r.is_deleted = FALSE
|
||||
LEFT JOIN role_has_privilege rhp ON r.id = rhp.role_id AND rhp.is_deleted = FALSE
|
||||
LEFT JOIN privilege p ON rhp.privilege_id = p.id AND p.is_deleted = FALSE
|
||||
<where>
|
||||
<if test="ids != null and ids.size() > 0">
|
||||
fur.front_user_id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,45 +0,0 @@
|
||||
<?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.user.updateFrontUser.adapters.persistence.UpdateFrontUserMapper">
|
||||
|
||||
<update id="updateFrontUser">
|
||||
/* updateFrontUser : 사용자 정보 수정 */
|
||||
UPDATE front_user
|
||||
SET
|
||||
password = #{password},
|
||||
email = #{email},
|
||||
nickname = #{nickname},
|
||||
sign_up_type = #{signUpType},
|
||||
password_updated_at = #{passwordUpdatedAt},
|
||||
account_disabled = #{accountDisabled},
|
||||
login_fail_cnt = #{loginFailCnt},
|
||||
account_locked = #{accountLocked},
|
||||
<include refid="common.fields.UpdateBaseSet"/>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deleteFrontUserHasUploadFiles">
|
||||
UPDATE front_user_has_upload_file
|
||||
SET <include refid="common.fields.DeleteBaseSet" />
|
||||
WHERE front_user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<insert id="insertFrontUserHasUploadFiles">
|
||||
INSERT INTO front_user_has_upload_file (
|
||||
front_user_id,
|
||||
upload_files_id,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="fileIds" item="fileId" separator=",">
|
||||
(
|
||||
#{userId},
|
||||
#{fileId},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -1,46 +0,0 @@
|
||||
<?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.user.updateUserByAdmin.adapters.persistence.UpdateUserMapper">
|
||||
|
||||
<update id="updateFrontUser">
|
||||
UPDATE front_user
|
||||
SET
|
||||
email = #{email},
|
||||
<if test="nickname != null">
|
||||
nickname = #{nickname},
|
||||
</if>
|
||||
account_disabled = #{accountDisabled},
|
||||
login_fail_cnt = #{loginFailCnt},
|
||||
account_locked = #{accountLocked},
|
||||
<include refid="common.fields.UpdateBaseSet"/>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deleteFrontUserHasRoles">
|
||||
UPDATE front_user_has_role
|
||||
SET <include refid="common.fields.DeleteBaseSet" />
|
||||
WHERE front_user_id = #{userId}
|
||||
</update>
|
||||
|
||||
<insert id="insertFrontUserHasRoles">
|
||||
INSERT INTO front_user_has_role
|
||||
(
|
||||
id,
|
||||
front_user_id,
|
||||
role_id,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/>
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="roleIds" item="roleId" separator=",">
|
||||
(
|
||||
nextval('front_user_has_role_seq'),
|
||||
#{userId},
|
||||
#{roleId},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/>
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@@ -1,22 +0,0 @@
|
||||
<?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.userPrivilege.getUserPrivilege.adapters.persistence.GetUserPrivilegeMapper">
|
||||
|
||||
<select id="findById"
|
||||
resultType="app.module.core.usecase.userPrivilege.getUserPrivilege.ports.application.domain.GetUserPrivilege">
|
||||
SELECT
|
||||
id,
|
||||
description,
|
||||
order_no,
|
||||
created_at,
|
||||
created_by,
|
||||
updated_at,
|
||||
updated_by
|
||||
FROM privilege
|
||||
WHERE id = #{id}
|
||||
AND is_deleted = false
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,19 +0,0 @@
|
||||
<?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.userPrivilege.getUserPrivileges.adapters.persistence.GetUserPrivilegesMapper">
|
||||
|
||||
<select id="findAllByAppType"
|
||||
resultType="app.module.core.usecase.userPrivilege.getUserPrivileges.ports.application.domain.GetUserPrivileges">
|
||||
SELECT
|
||||
id,
|
||||
description,
|
||||
order_no
|
||||
FROM privilege
|
||||
WHERE app_type = #{appType}
|
||||
AND is_deleted = false
|
||||
ORDER BY order_no ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,14 +0,0 @@
|
||||
<?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.userPrivilege.removeUserPrivilege.adapters.persistence.RemoveUserPrivilegeMapper">
|
||||
|
||||
<update id="deleteUserPrivilege">
|
||||
/* deleteUserPrivilege : 사용자 권한 삭제 */
|
||||
UPDATE privilege
|
||||
SET <include refid="common.fields.DeleteBaseSet" />
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -1,36 +0,0 @@
|
||||
<?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.userPrivilege.saveUserPrivilege.adapters.persistence.SaveUserPrivilegeMapper">
|
||||
|
||||
<select id="getMaxOrderNo" resultType="int">
|
||||
SELECT MAX(order_no)
|
||||
FROM privilege
|
||||
WHERE app_type = #{appType}
|
||||
AND is_deleted = false
|
||||
</select>
|
||||
|
||||
<insert id="insertPrivilege">
|
||||
INSERT INTO privilege ( id,
|
||||
description,
|
||||
app_type,
|
||||
order_no,
|
||||
<include refid="common.fields.CreateUpdateBaseColumns"/> )
|
||||
VALUES ( #{id},
|
||||
#{description},
|
||||
#{appType},
|
||||
#{orderNo},
|
||||
<include refid="common.fields.CreateUpdateBaseValues"/> )
|
||||
</insert>
|
||||
|
||||
<update id="updatePrivilege">
|
||||
UPDATE privilege
|
||||
SET description = #{description},
|
||||
app_type = #{appType},
|
||||
order_no = #{orderNo},
|
||||
<include refid="common.fields.UpdateBaseSet"/>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?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.userPrivilege.sortUserPrivilege.adapters.persistence.SortUserPrivilegeMapper">
|
||||
|
||||
<update id="updateOrderNo">
|
||||
/* updateOrderNo : 권한 정렬 수정 */
|
||||
UPDATE privilege
|
||||
SET order_no = #{orderNo},
|
||||
<include refid="common.fields.UpdateBaseSet" />
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -1,37 +0,0 @@
|
||||
<?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.userRole.getUserRoles.adapters.persistence.GetUserRolesMapper">
|
||||
|
||||
<!-- 역할 목록 조회 -->
|
||||
<select id="findRolesByAppType" resultType="app.module.core.usecase.userRole.getUserRoles.adapters.persistence.model.GetUserRolesDto">
|
||||
SELECT
|
||||
r.id,
|
||||
r.description,
|
||||
r.order_no
|
||||
FROM role r
|
||||
WHERE r.app_type = #{appType}
|
||||
AND r.is_deleted = false
|
||||
ORDER BY r.order_no ASC
|
||||
</select>
|
||||
|
||||
<!-- 권한 목록 (역할 ID 기준) -->
|
||||
<select id="findPrivilegesByRoleIds" resultType="app.module.core.usecase.userRole.getUserRoles.adapters.persistence.model.GetUserPrivilegesDto">
|
||||
SELECT
|
||||
rhp.role_id,
|
||||
p.id,
|
||||
p.description,
|
||||
p.order_no
|
||||
FROM role_has_privilege rhp
|
||||
JOIN privilege p ON rhp.privilege_id = p.id
|
||||
WHERE rhp.role_id IN
|
||||
<foreach collection="roleIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND rhp.is_deleted = false
|
||||
AND p.is_deleted = false
|
||||
ORDER BY rhp.role_id, p.order_no ASC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,25 +0,0 @@
|
||||
<?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.userRole.removeUserRole.adapters.persistence.RemoveUserRoleMapper">
|
||||
|
||||
<update id="deleteRole">
|
||||
UPDATE role
|
||||
SET <include refid="common.fields.DeleteBaseSet"/>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deleteRoleHasPrivilege">
|
||||
UPDATE role_has_privilege
|
||||
SET <include refid="common.fields.DeleteBaseSet"/>
|
||||
WHERE role_id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="deleteFrontUserHasRole">
|
||||
UPDATE front_user_has_role
|
||||
SET <include refid="common.fields.DeleteBaseSet"/>
|
||||
WHERE role_id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user