Merge branch 'dev' into deploy-dev-admin
This commit is contained in:
@@ -16,11 +16,6 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<artifactId>aws</artifactId>
|
|
||||||
<groupId>app.module</groupId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<groupId>app.module</groupId>
|
<groupId>app.module</groupId>
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
|
|||||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
|
@EnableScheduling
|
||||||
@ComponentScan(basePackages = "app.module")
|
@ComponentScan(basePackages = "app.module")
|
||||||
public class AdminApplication extends SpringBootServletInitializer {
|
public class AdminApplication extends SpringBootServletInitializer {
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package app.module.admin.config.adapters.web.interceptor;
|
package app.module.admin.config.adapters.web.interceptor;
|
||||||
|
|
||||||
|
import app.module.admin.config.application.util.AdminUtil;
|
||||||
import app.module.core.config.adapters.web.interceptor.model.URITopTierVO;
|
import app.module.core.config.adapters.web.interceptor.model.URITopTierVO;
|
||||||
import app.module.core.config.application.enums.AppType;
|
import app.module.core.config.application.enums.AppType;
|
||||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||||
@@ -28,6 +29,8 @@ public class AdminURIInterceptor implements HandlerInterceptor {
|
|||||||
private final URICurrentMatchingPortIn uriCurrentMatchingPortIn;
|
private final URICurrentMatchingPortIn uriCurrentMatchingPortIn;
|
||||||
private final URIAncestryPortIn uriAncestryPortIn;
|
private final URIAncestryPortIn uriAncestryPortIn;
|
||||||
private final URITopTierPortIn topTierPortIn;
|
private final URITopTierPortIn topTierPortIn;
|
||||||
|
@Value("${spring.profiles.active}")
|
||||||
|
private String activeProfiles;
|
||||||
|
|
||||||
@Value("${app.aws.s3.domain:null}")
|
@Value("${app.aws.s3.domain:null}")
|
||||||
private String cloudFrontDomain;
|
private String cloudFrontDomain;
|
||||||
@@ -71,16 +74,19 @@ public class AdminURIInterceptor implements HandlerInterceptor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 활성 프로파일 가져오기 TODO 2차 오픈시 삭제 예정
|
||||||
|
modelAndView.addObject("activeProfile", activeProfiles);
|
||||||
|
|
||||||
|
String roleId = AdminUtil.getLoginUserRole();
|
||||||
if (!CommonUtil.isAjaxRequest(request)) {
|
if (!CommonUtil.isAjaxRequest(request)) {
|
||||||
URITopTier topTierOutput = topTierPortIn.connect(AppType.ADMIN);
|
URITopTier topTierOutput = topTierPortIn.connectRoleId(AppType.ADMIN,roleId);
|
||||||
modelAndView.addObject("topNode", recursiveMapping(topTierOutput));
|
modelAndView.addObject("topNode", recursiveMapping(topTierOutput));
|
||||||
|
|
||||||
if (modelAndView.getModelMap().getAttribute("currentURI") == null) {
|
if (modelAndView.getModelMap().getAttribute("currentURI") == null) {
|
||||||
modelAndView.addObject("currentURI", request.getAttribute("currentURI"));
|
modelAndView.addObject("currentURI", request.getAttribute("currentURI"));
|
||||||
}
|
}
|
||||||
|
|
||||||
modelAndView.addObject(
|
modelAndView.addObject("menuHierarchy", uriAncestryPortIn.connect(AppType.ADMIN, request.getRequestURI()));
|
||||||
"menuHierarchy", uriAncestryPortIn.connect(AppType.ADMIN, request.getRequestURI()));
|
|
||||||
|
|
||||||
if (cloudFrontDomain != null && bucketFolder != null) {
|
if (cloudFrontDomain != null && bucketFolder != null) {
|
||||||
modelAndView.addObject("S3URL", "https://" + cloudFrontDomain + bucketFolder);
|
modelAndView.addObject("S3URL", "https://" + cloudFrontDomain + bucketFolder);
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package app.module.admin.config.application.enums;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public enum ManagementType {
|
||||||
|
VISIT("방문조사"),
|
||||||
|
CALL("전화상담"),
|
||||||
|
ETC("기타");
|
||||||
|
private final String desc;
|
||||||
|
}
|
||||||
@@ -65,17 +65,18 @@ public class AdminAuthSuccessEvent {
|
|||||||
"security.password.change.notify", adminUser.getRemainPasswordDays()));
|
"security.password.change.notify", adminUser.getRemainPasswordDays()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 로그인 활성화 기록 생성
|
// 로그인 이력 쌓기
|
||||||
// loggedInUserSavePortIn.connect(
|
loggedInUserSavePortIn.connect(
|
||||||
// LoggedInUserSaveCmd.builder()
|
LoggedInUserSaveCmd.builder()
|
||||||
// .loggedInUserId(
|
.loggedInUserId(
|
||||||
// LoggedInUserIdSaveCmd.builder()
|
LoggedInUserIdSaveCmd.builder()
|
||||||
// .appType(AppType.ADMIN)
|
.appType(AppType.ADMIN)
|
||||||
// .id(authentication.getName())
|
.id(authentication.getName())
|
||||||
// .build())
|
.build())
|
||||||
// .clientIP(CommonUtil.getClientIP(request))
|
.clientIP(CommonUtil.getClientIP(request))
|
||||||
// .lastLoggedInAt(LocalDateTime.now())
|
.lastLoggedInAt(LocalDateTime.now())
|
||||||
// .build());
|
.build());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventListener
|
@EventListener
|
||||||
|
|||||||
@@ -41,8 +41,12 @@ public class AdminDetailsService implements UserDetailsService {
|
|||||||
boolean accountDisabled = Optional.ofNullable(adminUser.getAccountDisabled()).orElse(false);
|
boolean accountDisabled = Optional.ofNullable(adminUser.getAccountDisabled()).orElse(false);
|
||||||
|
|
||||||
return new AdminUser(
|
return new AdminUser(
|
||||||
|
adminUser.getSeq(),
|
||||||
adminUser.getId(),
|
adminUser.getId(),
|
||||||
adminUser.getPassword(),
|
adminUser.getPassword(),
|
||||||
|
adminUser.getRoles().stream().map(CoreRole::getId).findFirst().orElse(null),
|
||||||
|
adminUser.getRegionMainCode(),
|
||||||
|
adminUser.getLastLoginIp(),
|
||||||
!accountDisabled,
|
!accountDisabled,
|
||||||
true,
|
true,
|
||||||
isCredentialsNonExpired(adminUser.getPasswordUpdatedAt()),
|
isCredentialsNonExpired(adminUser.getPasswordUpdatedAt()),
|
||||||
|
|||||||
@@ -7,12 +7,19 @@ import org.springframework.security.core.userdetails.User;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class AdminUser extends User {
|
public class AdminUser extends User {
|
||||||
|
private Long seq;
|
||||||
|
private String roleId;
|
||||||
|
private String regionMainCode;
|
||||||
|
private String lastLoginIp;
|
||||||
private long remainPasswordDays;
|
private long remainPasswordDays;
|
||||||
|
|
||||||
public AdminUser(
|
public AdminUser(
|
||||||
|
Long seq,
|
||||||
String username,
|
String username,
|
||||||
String password,
|
String password,
|
||||||
|
String roleId,
|
||||||
|
String regionMainCode,
|
||||||
|
String lastLoginIp,
|
||||||
boolean enabled,
|
boolean enabled,
|
||||||
boolean accountNonExpired,
|
boolean accountNonExpired,
|
||||||
boolean credentialsNonExpired,
|
boolean credentialsNonExpired,
|
||||||
@@ -27,6 +34,10 @@ public class AdminUser extends User {
|
|||||||
credentialsNonExpired,
|
credentialsNonExpired,
|
||||||
accountNonLocked,
|
accountNonLocked,
|
||||||
authorities);
|
authorities);
|
||||||
|
this.seq = seq;
|
||||||
|
this.roleId = roleId;
|
||||||
|
this.regionMainCode = regionMainCode;
|
||||||
|
this.lastLoginIp = lastLoginIp;
|
||||||
this.remainPasswordDays = remainPasswordDays;
|
this.remainPasswordDays = remainPasswordDays;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package app.module.admin.config.application.util;
|
package app.module.admin.config.application.util;
|
||||||
|
|
||||||
|
import app.module.admin.config.application.security.AdminUser;
|
||||||
import app.module.core.config.adapters.web.interceptor.model.URITopTierVO;
|
import app.module.core.config.adapters.web.interceptor.model.URITopTierVO;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -19,4 +23,44 @@ public class AdminUtil {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getLoginUserRole() {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
if (authentication == null || !(authentication.getPrincipal() instanceof AdminUser)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminUser user = (AdminUser) authentication.getPrincipal();
|
||||||
|
return user.getRoleId().isEmpty() ? null : user.getRoleId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Long getLoginUserSeq() {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
if (authentication == null || !(authentication.getPrincipal() instanceof AdminUser)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminUser user = (AdminUser) authentication.getPrincipal();
|
||||||
|
return user.getSeq();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLoginUserRegionMainCode() {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
if (authentication == null || !(authentication.getPrincipal() instanceof AdminUser)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminUser user = (AdminUser) authentication.getPrincipal();
|
||||||
|
return user.getRegionMainCode().isEmpty() ? null : user.getRegionMainCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLoginUserLastIp() {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
if (authentication == null || !(authentication.getPrincipal() instanceof AdminUser)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminUser user = (AdminUser) authentication.getPrincipal();
|
||||||
|
return user.getLastLoginIp();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package app.module.admin.config.application.util.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class EnumDto {
|
||||||
|
private String id;
|
||||||
|
private String codeText;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package app.module.admin.usecase.admin.checkAdminId.adapters.web;
|
||||||
|
|
||||||
|
import app.module.core.usecase.admin.checkAdminId.ports.CheckAdminIdPortIn;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class AdminIdDuplicateCheckPostController {
|
||||||
|
|
||||||
|
private final CheckAdminIdPortIn checkAdminIdPortIn;
|
||||||
|
|
||||||
|
@GetMapping("/api/settings/admin/idCheck")
|
||||||
|
ResponseEntity<?> updateMappingHousehold(@RequestParam String id ) {
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(checkAdminIdPortIn.connect(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,7 +45,9 @@ class AdminExcelController {
|
|||||||
new GetAdminsCmd(
|
new GetAdminsCmd(
|
||||||
adminListFilterVO.getSearchField(),
|
adminListFilterVO.getSearchField(),
|
||||||
adminListFilterVO.getSearchValue(),
|
adminListFilterVO.getSearchValue(),
|
||||||
adminListFilterVO.getSearchRole()));
|
adminListFilterVO.getSearchRole(),
|
||||||
|
adminListFilterVO.getSearchArea(),
|
||||||
|
adminListFilterVO.getSearchDisabled()));
|
||||||
|
|
||||||
if (CollectionUtils.isNotEmpty(listOutput.getContent())) {
|
if (CollectionUtils.isNotEmpty(listOutput.getContent())) {
|
||||||
// Header
|
// Header
|
||||||
|
|||||||
@@ -37,11 +37,14 @@ class AdminListController {
|
|||||||
new GetAdminsCmd(
|
new GetAdminsCmd(
|
||||||
adminListFilterVO.getSearchField(),
|
adminListFilterVO.getSearchField(),
|
||||||
adminListFilterVO.getSearchValue(),
|
adminListFilterVO.getSearchValue(),
|
||||||
adminListFilterVO.getSearchRole()));
|
adminListFilterVO.getSearchRole(),
|
||||||
|
adminListFilterVO.getSearchArea(),
|
||||||
|
adminListFilterVO.getSearchDisabled()));
|
||||||
|
|
||||||
model.addAttribute("listOutput", listOutput);
|
model.addAttribute("listOutput", listOutput);
|
||||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
||||||
model.addAttribute("pageRows", uiCodeListPortIn.connect("code.pageable.rows"));
|
model.addAttribute("pageRows", uiCodeListPortIn.connect("code.pageable.rows"));
|
||||||
|
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
||||||
|
|
||||||
return "admin/adminList";
|
return "admin/adminList";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,4 +12,6 @@ public class AdminListFilterVO {
|
|||||||
private String searchField;
|
private String searchField;
|
||||||
private String searchValue;
|
private String searchValue;
|
||||||
private String searchRole;
|
private String searchRole;
|
||||||
|
private String searchArea;
|
||||||
|
private String searchDisabled;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,10 @@ public class AdminCreateGetController {
|
|||||||
private final UICodeListPortIn uiCodeListPortIn;
|
private final UICodeListPortIn uiCodeListPortIn;
|
||||||
|
|
||||||
@GetMapping(path = "/settings/admins/create")
|
@GetMapping(path = "/settings/admins/create")
|
||||||
String operate(Model model, @ModelAttribute("bindingVO") AdminCreateBindingVO bindingVO) {
|
String operate(Model model) {
|
||||||
|
|
||||||
|
AdminCreateBindingVO bindingVO = new AdminCreateBindingVO();
|
||||||
|
model.addAttribute("bindingVO", bindingVO);
|
||||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
||||||
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
||||||
|
|
||||||
|
|||||||
@@ -9,51 +9,42 @@ import app.module.core.usecase.role.list.ports.RoleListPortIn;
|
|||||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.validation.BindingResult;
|
import org.springframework.validation.BindingResult;
|
||||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
import org.springframework.validation.ObjectError;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
@Controller
|
@Slf4j
|
||||||
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AdminCreatePostController {
|
public class AdminCreatePostController {
|
||||||
|
|
||||||
private final RoleListPortIn roleListPortIn;
|
|
||||||
private final MessageUtil messageUtil;
|
|
||||||
private final SaveAdminPortIn savePortIn;
|
private final SaveAdminPortIn savePortIn;
|
||||||
private final UICodeListPortIn uiCodeListPortIn;
|
|
||||||
private final AdminCreateValidator adminCreateValidator;
|
private final AdminCreateValidator adminCreateValidator;
|
||||||
|
|
||||||
@PostMapping(path = "/settings/admins/create")
|
@PostMapping(path = "/api/settings/admin/create")
|
||||||
String operate(
|
ResponseEntity<?> operate(@RequestBody AdminCreateBindingVO bindingVO, BindingResult bindingResult ) {
|
||||||
RedirectAttributes redirectAttributes,
|
|
||||||
Model model,
|
|
||||||
@Valid @ModelAttribute("bindingVO") AdminCreateBindingVO bindingVO,
|
|
||||||
BindingResult bindingResult) {
|
|
||||||
|
|
||||||
adminCreateValidator.validate(bindingVO, bindingResult);
|
adminCreateValidator.validate(bindingVO, bindingResult);
|
||||||
|
|
||||||
if (bindingResult.hasErrors()) {
|
if (bindingResult.hasErrors()) {
|
||||||
model.addAttribute("roles", roleListPortIn.connect(AppType.ADMIN));
|
|
||||||
model.addAttribute("regionMainCode", uiCodeListPortIn.connect("code.region.main"));
|
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||||
return "admin/adminCreateForm";
|
.body(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
savePortIn.connect(
|
return ResponseEntity.status(HttpStatus.OK).body(
|
||||||
bindingVO.getSeq(),
|
savePortIn.apiConnect(bindingVO.getSeq(),
|
||||||
bindingVO.getId(),
|
bindingVO.getId(),
|
||||||
bindingVO.getPassword(),
|
bindingVO.getPassword(),
|
||||||
bindingVO.getEmail(),
|
bindingVO.getName(),
|
||||||
bindingVO.getRegionMainCode(),
|
"010-"+bindingVO.getPhone1()+"-"+bindingVO.getPhone2(),
|
||||||
bindingVO.getAccountDisabled(),
|
bindingVO.getRegionMainCode(),
|
||||||
bindingVO.getAccountLocked(),
|
bindingVO.getAccountDisabled(),
|
||||||
bindingVO.getRoleIds());
|
bindingVO.getRoleId()));
|
||||||
|
|
||||||
redirectAttributes.addFlashAttribute(
|
|
||||||
"operationMessage",
|
|
||||||
messageUtil.getMessage("operation.settings.admin.created", bindingVO.getId()));
|
|
||||||
|
|
||||||
return "redirect:/settings/admins";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,12 +53,11 @@ class AdminUpdateGetController {
|
|||||||
output.getSeq(),
|
output.getSeq(),
|
||||||
output.getId(),
|
output.getId(),
|
||||||
null,
|
null,
|
||||||
output.getEmail(),
|
output.getName(),
|
||||||
|
output.getPhone(),
|
||||||
output.getRegionMainCode(),
|
output.getRegionMainCode(),
|
||||||
output.getPasswordUpdatedAt(),
|
output.getPasswordUpdatedAt(),
|
||||||
output.getAccountDisabled(),
|
output.getAccountDisabled(),
|
||||||
output.getLoginFailCnt(),
|
|
||||||
output.getAccountLocked(),
|
|
||||||
output.getRoles().stream().map(CoreRole::getId).collect(Collectors.toList()));
|
output.getRoles().stream().map(CoreRole::getId).collect(Collectors.toList()));
|
||||||
|
|
||||||
model.addAttribute("bindingVO", bindingVO);
|
model.addAttribute("bindingVO", bindingVO);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.ModelAttribute;
|
|||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
class AdminUpdatePostController {
|
class AdminUpdatePostController {
|
||||||
@@ -40,15 +42,15 @@ class AdminUpdatePostController {
|
|||||||
return "admin/adminUpdateForm";
|
return "admin/adminUpdateForm";
|
||||||
}
|
}
|
||||||
|
|
||||||
saveAdminPortIn.connect(
|
saveAdminPortIn.apiConnect(
|
||||||
bindingVO.getSeq(),
|
bindingVO.getSeq(),
|
||||||
bindingVO.getId(),
|
bindingVO.getId(),
|
||||||
bindingVO.getUpdatePassword(),
|
bindingVO.getUpdatePassword(),
|
||||||
bindingVO.getEmail(),
|
bindingVO.getName(),
|
||||||
|
bindingVO.getPhone(),
|
||||||
bindingVO.getRegionMainCode(),
|
bindingVO.getRegionMainCode(),
|
||||||
bindingVO.getAccountDisabled(),
|
bindingVO.getAccountDisabled(),
|
||||||
bindingVO.getAccountLocked(),
|
bindingVO.getRoleIds().stream().collect(Collectors.joining()));
|
||||||
bindingVO.getRoleIds());
|
|
||||||
|
|
||||||
redirectAttributes.addFlashAttribute(
|
redirectAttributes.addFlashAttribute(
|
||||||
"operationMessage",
|
"operationMessage",
|
||||||
|
|||||||
@@ -1,29 +1,31 @@
|
|||||||
package app.module.admin.usecase.admin.saveAdmin.adapters.web.model;
|
package app.module.admin.usecase.admin.saveAdmin.adapters.web.model;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.Pattern;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
public class AdminCreateBindingVO {
|
public class AdminCreateBindingVO {
|
||||||
private Long seq;
|
private Long seq;
|
||||||
private String id;
|
private String id;
|
||||||
private String password;
|
private String password;
|
||||||
|
private String name;
|
||||||
@NotBlank(message = "{valid.common.required}")
|
private String phone1;
|
||||||
|
private String phone2;
|
||||||
|
private String regionMainCode;
|
||||||
|
/* @NotBlank(message = "{valid.common.required}")
|
||||||
@Pattern(
|
@Pattern(
|
||||||
regexp =
|
regexp =
|
||||||
"^[\\w!#$%&’*+/=?`{|}~^-]+(?:\\.[\\w!#$%&’*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$",
|
"^[\\w!#$%&’*+/=?`{|}~^-]+(?:\\.[\\w!#$%&’*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$",
|
||||||
message = "{valid.common.email.wrong}")
|
message = "{valid.common.email.wrong}")
|
||||||
private String email;
|
private String email;*/
|
||||||
|
|
||||||
private Boolean accountDisabled;
|
private Boolean accountDisabled;
|
||||||
private Boolean accountLocked;
|
/* private Boolean accountLocked;*/
|
||||||
private List<String> roleIds;
|
private String roleId;
|
||||||
private String regionMainCode;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,17 +26,19 @@ public class AdminUpdateBindingVO implements AuditOutput {
|
|||||||
private String id;
|
private String id;
|
||||||
private String updatePassword;
|
private String updatePassword;
|
||||||
|
|
||||||
@NotBlank(message = "{valid.common.required}")
|
/* @NotBlank(message = "{valid.common.required}")
|
||||||
@Pattern(
|
@Pattern(
|
||||||
regexp =
|
regexp =
|
||||||
"^[\\w!#$%&’*+/=?`{|}~^-]+(?:\\.[\\w!#$%&’*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$",
|
"^[\\w!#$%&’*+/=?`{|}~^-]+(?:\\.[\\w!#$%&’*+/=?`{|}~^-]+)*@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,6}$",
|
||||||
message = "{valid.common.email.wrong}")
|
message = "{valid.common.email.wrong}")
|
||||||
private String email;
|
private String email;*/
|
||||||
|
private String name;
|
||||||
|
private String phone;
|
||||||
private String regionMainCode;
|
private String regionMainCode;
|
||||||
|
|
||||||
private LocalDateTime passwordUpdatedAt;
|
private LocalDateTime passwordUpdatedAt;
|
||||||
private Boolean accountDisabled;
|
private Boolean accountDisabled;
|
||||||
private Integer loginFailCnt;
|
/* private Integer loginFailCnt;
|
||||||
private Boolean accountLocked;
|
private Boolean accountLocked;*/
|
||||||
private List<String> roleIds;
|
private List<String> roleIds;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import org.springframework.validation.Validator;
|
|||||||
@Component
|
@Component
|
||||||
public class AdminCreateValidator implements Validator {
|
public class AdminCreateValidator implements Validator {
|
||||||
|
|
||||||
private final String PASSWORD_REGEX = "^((?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%_\\-])\\S{6,15})$";
|
// 아이디: 4~15자, 영문/숫자/한글/특수문자(_,-) 허용
|
||||||
|
private final String ID_REGEX = "^[a-zA-Z0-9가-힣_-]{4,15}$";
|
||||||
|
// 비밀번호: 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상
|
||||||
|
private final String PASSWORD_REGEX = "^(?=.*[0-9])(?=.*[!@#$%_\\-]).{5}$";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supports(Class<?> clazz) {
|
public boolean supports(Class<?> clazz) {
|
||||||
@@ -21,25 +24,50 @@ public class AdminCreateValidator implements Validator {
|
|||||||
public void validate(Object target, Errors errors) {
|
public void validate(Object target, Errors errors) {
|
||||||
AdminCreateBindingVO vo = (AdminCreateBindingVO) target;
|
AdminCreateBindingVO vo = (AdminCreateBindingVO) target;
|
||||||
|
|
||||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "valid.common.required");
|
if (vo.getRoleId() == null || vo.getRoleId().isEmpty()) {
|
||||||
|
errors.rejectValue("roleId", "error.roleId", "권한을 선택해주세요.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vo.getAccountDisabled() == null ) {
|
||||||
|
errors.rejectValue("accountDisabled", "error.accountDisabled", "사용여부를 선택해주세요.");
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "id", "valid.common.required","아이디는 필수입력값입니다.");
|
||||||
|
Optional.ofNullable(vo.getId())
|
||||||
|
.filter(id -> !id.matches(ID_REGEX))
|
||||||
|
.ifPresent(id -> errors.rejectValue("id", "valid.common.id.wrong","아이디를 4~15자, 영문/숫자/한글/특수문자(_,-) 입니다."));
|
||||||
|
|
||||||
|
// 비밀번호 유효성 검사
|
||||||
|
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "password", "valid.common.required","비밀번호는 필수입력값입니다.");
|
||||||
|
|
||||||
Optional.ofNullable(vo.getPassword())
|
Optional.ofNullable(vo.getPassword())
|
||||||
.filter(password -> !password.matches(PASSWORD_REGEX))
|
.filter(password -> !password.matches(PASSWORD_REGEX))
|
||||||
.ifPresent(password -> errors.rejectValue("password", "valid.common.password.wrong"));
|
.ifPresent(password -> errors.rejectValue("password", "valid.common.password.wrong","비밀번호는 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상입니다."));
|
||||||
|
|
||||||
Optional.ofNullable(vo.getRoleIds())
|
|
||||||
.filter(ids -> ids.size() < 1)
|
|
||||||
.ifPresent(
|
|
||||||
ids ->
|
|
||||||
errors.rejectValue(
|
|
||||||
"roleIds", "valid.common.required.size.min", new Object[]{1}, ""));
|
|
||||||
|
|
||||||
|
if (vo.getRoleId() != null && "ROLE_RESEARCHER".equals(vo.getRoleId())) {
|
||||||
|
if (vo.getName() == null || vo.getName().isBlank()) {
|
||||||
|
errors.rejectValue("name", "error.name", "이름을 입력해주세요.");
|
||||||
|
}
|
||||||
|
if (vo.getName().length() > 4) {
|
||||||
|
errors.rejectValue("name", "error.name", "이름은 4자리까지 입력가능합니다.");
|
||||||
|
}
|
||||||
|
if (vo.getPhone1() == null || vo.getPhone1().isBlank()) {
|
||||||
|
errors.rejectValue("phone1", "error.phone1", "전화번호 앞자리를 입력해주세요.");
|
||||||
|
} else if (!vo.getPhone1().matches("^\\d{4}$")) {
|
||||||
|
errors.rejectValue("phone1", "error.phone1", "전화번호 앞자리는 4자리 숫자여야 합니다.");
|
||||||
|
}
|
||||||
|
if (vo.getPhone2() == null || vo.getPhone2().isBlank()) {
|
||||||
|
errors.rejectValue("phone2", "error.phone2", "전화번호 뒷자리를 입력해주세요.");
|
||||||
|
} else if (!vo.getPhone2().matches("^\\d{4}$")) {
|
||||||
|
errors.rejectValue("phone2", "error.phone2", "전화번호 뒷자리는 4자리 숫자여야 합니다.");
|
||||||
|
}
|
||||||
|
}
|
||||||
// ROLE_ADMIN이 아닌 경우 regionMainCode null체크
|
// ROLE_ADMIN이 아닌 경우 regionMainCode null체크
|
||||||
Optional.ofNullable(vo.getRoleIds())
|
Optional.ofNullable(vo.getRoleId())
|
||||||
.filter(ids -> ids.stream().noneMatch(role -> role.equals("ROLE_ADMIN")))
|
.filter(id -> !id.equals("ROLE_ADMIN"))
|
||||||
.ifPresent(nonAdmins -> {
|
.ifPresent(nonAdmins -> {
|
||||||
if (vo.getRegionMainCode() == null || vo.getRegionMainCode().isBlank()) {
|
if (vo.getRegionMainCode() == null || vo.getRegionMainCode().isBlank()) {
|
||||||
errors.rejectValue("regionMainCode", "valid.common.required");
|
errors.rejectValue("regionMainCode", "valid.common.required","실사지역은 필수입력값입니다.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model.CreateNoticeDto;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model.CreateNoticeHasUploadFilesParam;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.CreateNoticePortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CreateNoticeDao implements CreateNoticePortOut {
|
||||||
|
|
||||||
|
private final CreateNoticeMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Optional<CreateNotice> operate(CreateNoticeCmd command) {
|
||||||
|
|
||||||
|
|
||||||
|
CreateNoticeDto dto =
|
||||||
|
new CreateNoticeDto(
|
||||||
|
null,
|
||||||
|
command.getTitle(),
|
||||||
|
command.getContent(),
|
||||||
|
command.getVisible(),
|
||||||
|
command.getStartDate(),
|
||||||
|
command.getEndDate(),
|
||||||
|
command.getFileMappingId(),
|
||||||
|
command.getCreatedAt(),
|
||||||
|
command.getCreatedBy(),
|
||||||
|
command.getUpdatedAt(),
|
||||||
|
command.getUpdatedBy());
|
||||||
|
|
||||||
|
mapper.createNotice(dto);
|
||||||
|
|
||||||
|
if (dto.getFileMappingId() != null && !dto.getFileMappingId().isEmpty()) {
|
||||||
|
mapper.createNoticeHasUploadFile(new CreateNoticeHasUploadFilesParam(
|
||||||
|
dto.getId(),
|
||||||
|
dto.getFileMappingId().stream()
|
||||||
|
.map(Long::parseLong)
|
||||||
|
.collect(Collectors.toList()),
|
||||||
|
dto.getCreatedAt(),
|
||||||
|
dto.getCreatedBy(),
|
||||||
|
dto.getUpdatedAt(),
|
||||||
|
dto.getUpdatedBy()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Optional.of(new CreateNotice(dto.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model.CreateNoticeDto;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model.CreateNoticeHasUploadFilesParam;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CreateNoticeMapper {
|
||||||
|
void createNotice(CreateNoticeDto dto);
|
||||||
|
void createNoticeHasUploadFile(CreateNoticeHasUploadFilesParam param);
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CreateNoticeDto {
|
||||||
|
private Long id;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private Boolean visible;
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
private LocalDateTime endDate;
|
||||||
|
private List<String> fileMappingId;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String createdBy;
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
private String updatedBy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.adapters.persistence.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CreateNoticeHasUploadFilesParam {
|
||||||
|
private Long id;
|
||||||
|
private List<Long> fileMappingIds;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String createdBy;
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
private String updatedBy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.adapters.web;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.adapters.web.model.CreateNoticeReqVO;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.CreateNoticePortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CreateNoticeController {
|
||||||
|
|
||||||
|
private final CreateNoticePortIn createNoticePortIn;
|
||||||
|
@PostMapping(path = "/api/communication/notices/create")
|
||||||
|
ResponseEntity<?> operate(@RequestBody @Valid CreateNoticeReqVO reqVO, BindingResult bindingResult) {
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||||
|
.body(bindingResult.getFieldErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateNotice article =
|
||||||
|
createNoticePortIn
|
||||||
|
.operate(
|
||||||
|
new CreateNoticeCmd(
|
||||||
|
reqVO.getTitle(),
|
||||||
|
reqVO.getContent(),
|
||||||
|
reqVO.getVisible(),
|
||||||
|
reqVO.getStartDate(),
|
||||||
|
reqVO.getEndDate(),
|
||||||
|
reqVO.getFileMappingId()))
|
||||||
|
.orElseThrow();
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(article);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.adapters.web;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.adapters.web.model.CreateNoticeReqVO;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.adapters.web.model.CreateNoticeUIReqVO;
|
||||||
|
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 CreateNoticeUIController {
|
||||||
|
|
||||||
|
@GetMapping(path = "/communication/notices/create")
|
||||||
|
String operate(
|
||||||
|
Model model,
|
||||||
|
@ModelAttribute("reqVO") CreateNoticeUIReqVO reqVO) {
|
||||||
|
|
||||||
|
return "communication/notice/create";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.adapters.web.model;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.*;
|
||||||
|
import org.apache.commons.text.StringEscapeUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CreateNoticeReqVO {
|
||||||
|
@NotBlank(message = "{valid.common.required}")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@NotBlank(message = "{valid.common.required}")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@NotNull(message = "{valid.common.required}")
|
||||||
|
private Boolean visible;
|
||||||
|
|
||||||
|
@NotNull(message = "{valid.common.required}")
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
|
||||||
|
@NotNull(message = "{valid.common.required}")
|
||||||
|
private LocalDateTime endDate;
|
||||||
|
|
||||||
|
private List<String> fileMappingId;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return StringEscapeUtils.escapeHtml4(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return StringEscapeUtils.escapeHtml4(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.adapters.web.model;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.apache.commons.text.StringEscapeUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CreateNoticeUIReqVO {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface CreateNoticePortIn {
|
||||||
|
|
||||||
|
Optional<CreateNotice> operate(CreateNoticeCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface CreateNoticePortOut {
|
||||||
|
|
||||||
|
Optional<CreateNotice> operate(CreateNoticeCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.ports.application;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.CreateNoticePortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.CreateNoticePortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.createNotice.ports.application.domain.CreateNoticeCmd;
|
||||||
|
import app.module.core.config.application.annotation.CreateCommand;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CreateNoticeService implements CreateNoticePortIn {
|
||||||
|
|
||||||
|
private final CreateNoticePortOut portOut;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CreateCommand
|
||||||
|
public Optional<CreateNotice> operate(CreateNoticeCmd command) {
|
||||||
|
return portOut.operate(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CreateNotice {
|
||||||
|
private Long id;
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.createNotice.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CreateNoticeCmd extends AuditCommand {
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private Boolean visible;
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
private LocalDateTime endDate;
|
||||||
|
private List<String> fileMappingId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNotice.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile;
|
||||||
|
import app.module.core.usecase.file.url.application.port.in.FileUrlPortIn;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class GetNoticeDao implements GetNoticePortOut {
|
||||||
|
|
||||||
|
private final GetNoticeMapper mapper;
|
||||||
|
private final FileUrlPortIn fileUrlPortIn;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Optional<GetNotice> operate(GetNoticeCmd command) {
|
||||||
|
GetNotice secArticle = mapper.getNotice(command);
|
||||||
|
|
||||||
|
List<GetNoticeUploadFile> setArticleUploadFile =
|
||||||
|
mapper.getUploadFiles(command.getId());
|
||||||
|
|
||||||
|
secArticle.setUploadFiles(
|
||||||
|
setArticleUploadFile.stream()
|
||||||
|
.map(
|
||||||
|
uploadFile -> {
|
||||||
|
// 참조 URL 전달
|
||||||
|
uploadFile.setReferURL(
|
||||||
|
fileUrlPortIn.getInline(
|
||||||
|
uploadFile.getType().getFileStorageType(),
|
||||||
|
uploadFile.getPath(),
|
||||||
|
uploadFile.getName()));
|
||||||
|
// attachment URL 전달
|
||||||
|
uploadFile.setAttachmentURL(
|
||||||
|
fileUrlPortIn.getAttachment(
|
||||||
|
uploadFile.getType().getFileStorageType(), uploadFile.getId()));
|
||||||
|
|
||||||
|
return uploadFile;
|
||||||
|
})
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
|
||||||
|
return Optional.of(secArticle);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNotice.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeUploadFile;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface GetNoticeMapper {
|
||||||
|
|
||||||
|
GetNotice getNotice(GetNoticeCmd command);
|
||||||
|
|
||||||
|
List<GetNoticeUploadFile> getUploadFiles(Long id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNotice.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||||
|
import app.module.core.usecase.article.getArticle.ports.application.domain.GetArticleCmd;
|
||||||
|
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 GetNoticeController {
|
||||||
|
private final GetNoticePortIn getNoticePortIn;
|
||||||
|
|
||||||
|
@GetMapping(path = "/api/communication/notices/{id}")
|
||||||
|
ResponseEntity<?> operate(@PathVariable Long id) {
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(getNoticePortIn.operate(new GetNoticeCmd(id)).orElseThrow());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNotice.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface GetNoticePortIn {
|
||||||
|
|
||||||
|
Optional<GetNotice> operate(GetNoticeCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNotice.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public interface GetNoticePortOut {
|
||||||
|
|
||||||
|
Optional<GetNotice> operate(GetNoticeCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNotice.ports.application;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.GetNoticePortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNotice;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNotice.ports.application.domain.GetNoticeCmd;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class GetNoticeService implements GetNoticePortIn {
|
||||||
|
|
||||||
|
private final GetNoticePortOut portOut;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<GetNotice> operate(GetNoticeCmd command) {
|
||||||
|
return portOut.operate(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNotice.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class GetNotice {
|
||||||
|
private Long id;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private Boolean visible;
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
private LocalDateTime endDate;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String createdBy;
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
private String updatedBy;
|
||||||
|
private List<GetNoticeUploadFile> uploadFiles;
|
||||||
|
public boolean getNewDate() {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
return now.toLocalDate().isEqual(createdAt.toLocalDate());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package app.module.api.frontUsecases.auth.frontLogin.adapters.web.model;
|
package app.module.admin.usecase.communication.notice.getNotice.ports.application.domain;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@@ -9,7 +9,6 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
public class FrontLoginResVO {
|
public class GetNoticeCmd {
|
||||||
|
private Long id;
|
||||||
private String jwtToken;
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNotice.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.core.config.application.enums.FileUploadType;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DTO for {@link app.module.core.config.adapters.persistence.entity.UploadFile}
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class GetNoticeUploadFile implements Serializable {
|
||||||
|
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String createdBy;
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
private String updatedBy;
|
||||||
|
private Long id;
|
||||||
|
private FileUploadType type;
|
||||||
|
private String path;
|
||||||
|
private String name;
|
||||||
|
private String originName;
|
||||||
|
private Long fileLength;
|
||||||
|
private String referURL;
|
||||||
|
private String attachmentURL;
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package app.module.admin.usecase.communication.notice.getNoticeUI;
|
|
||||||
|
|
||||||
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 app.module.admin.usecase.communication.notice.getNoticeUI.model.GetNoticesReqVO;
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
class GetNoticesUIController {
|
|
||||||
|
|
||||||
@GetMapping(path = "/communication/notices")
|
|
||||||
String operate(
|
|
||||||
Model model,
|
|
||||||
@ModelAttribute("reqVO") GetNoticesReqVO reqVO) {
|
|
||||||
|
|
||||||
return "communication/notices";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence.model.GetNoticesDto;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticeFiles;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||||
|
import app.module.core.config.application.enums.FileUploadType;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.commons.collections4.ListUtils;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class GetNoticesDao implements GetNoticesPortOut {
|
||||||
|
|
||||||
|
private final GetNoticesMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Page<GetNotices> operate(Pageable pageable, GetNoticesCmd command) {
|
||||||
|
// 게시물 목록 얻기
|
||||||
|
List<GetNoticesDto> contents =
|
||||||
|
ListUtils.emptyIfNull(mapper.getNotices(pageable, command));
|
||||||
|
|
||||||
|
// 대표 이미지 목록 얻기
|
||||||
|
List<GetNoticeFiles> uploadFiles =
|
||||||
|
contents.isEmpty()
|
||||||
|
? Collections.emptyList()
|
||||||
|
: ListUtils.emptyIfNull(
|
||||||
|
mapper.getUploadFiles(
|
||||||
|
contents.stream().map(GetNoticesDto::getId)
|
||||||
|
.collect(Collectors.toList()),
|
||||||
|
FileUploadType.NOTICE));
|
||||||
|
|
||||||
|
return new PageImpl<>(
|
||||||
|
contents.stream()
|
||||||
|
.map(
|
||||||
|
article ->
|
||||||
|
new GetNotices(
|
||||||
|
article.getId(),
|
||||||
|
article.getUpdatedBy(),
|
||||||
|
article.getUpdatedAt(),
|
||||||
|
article.getCreatedBy(),
|
||||||
|
article.getCreatedAt(),
|
||||||
|
article.getTitle(),
|
||||||
|
article.getContent(),
|
||||||
|
article.getVisible(),
|
||||||
|
article.getStartDate(),
|
||||||
|
article.getEndDate(),
|
||||||
|
uploadFiles.stream()
|
||||||
|
.filter(file -> file.getNoticeId().equals(article.getId()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null)))
|
||||||
|
.collect(Collectors.toList()),
|
||||||
|
pageable,
|
||||||
|
contents.isEmpty() ? 0 : contents.get(0).getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public List<GetNotices> operateList(GetNoticesCmd command) {
|
||||||
|
/*// 검색조건 초기화
|
||||||
|
Specification<Article> spec = (root, query, criteriaBuilder) -> null;
|
||||||
|
|
||||||
|
// 검색어 - like 검색
|
||||||
|
if (!StringUtils.isEmpty(command.getSearchField())) {
|
||||||
|
spec =
|
||||||
|
spec.and(
|
||||||
|
(root, query, builder) ->
|
||||||
|
builder.like(
|
||||||
|
root.get(command.getSearchField()),
|
||||||
|
"%" + command.getSearchValue() + "%"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 공개여부 검색
|
||||||
|
if (!StringUtils.isEmpty(command.getSearchOpen())) {
|
||||||
|
spec =
|
||||||
|
spec.and(
|
||||||
|
((root, query, criteriaBuilder) ->
|
||||||
|
criteriaBuilder.equal(
|
||||||
|
root.get("visible"), Boolean.valueOf(command.getSearchOpen()))));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Article> result = getArticlesRepo.findAll(spec);
|
||||||
|
|
||||||
|
return result.stream()
|
||||||
|
.map(
|
||||||
|
article ->
|
||||||
|
new GetArticles(
|
||||||
|
article.getId(),
|
||||||
|
article.getUpdatedBy(),
|
||||||
|
article.getUpdatedAt(),
|
||||||
|
article.getTitle(),
|
||||||
|
article.getContent(),
|
||||||
|
article.getVisible(),
|
||||||
|
article.getStartDate(),
|
||||||
|
article.getEndDate(),
|
||||||
|
article.getOrderNo(),
|
||||||
|
article.getUploadFiles().stream()
|
||||||
|
// 목록에 보여줄 대표이미지만 담는다
|
||||||
|
.filter(
|
||||||
|
uploadFile -> uploadFile.getType()
|
||||||
|
.equals(FileUploadType.EXAMPLE_REP))
|
||||||
|
.map(
|
||||||
|
uploadFile ->
|
||||||
|
new GetArticleFiles(
|
||||||
|
uploadFile.getId(),
|
||||||
|
uploadFile.getType(),
|
||||||
|
uploadFile.getPath(),
|
||||||
|
uploadFile.getName(),
|
||||||
|
uploadFile.getOriginName(),
|
||||||
|
uploadFile.getFileLength()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null)))
|
||||||
|
.collect(Collectors.toList());*/
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence.model.GetNoticesDto;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticeFiles;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||||
|
import app.module.core.config.application.enums.FileUploadType;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface GetNoticesMapper {
|
||||||
|
List<GetNoticesDto> getNotices(
|
||||||
|
@Param("pageable") Pageable pageable, @Param("cmd") GetNoticesCmd cmd);
|
||||||
|
List<GetNoticeFiles> getUploadFiles(
|
||||||
|
@Param("ids") List<Long> ids, @Param("fileUploadType") FileUploadType fileUploadType);
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.persistence.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class GetNoticesDto {
|
||||||
|
private Long id;
|
||||||
|
private String updatedBy;
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
private String createdBy;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private Boolean visible;
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
private LocalDateTime endDate;
|
||||||
|
private Long total;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web.model.GetNoticesReqVO;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||||
|
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.web.PageableDefault;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class GetNoticesController {
|
||||||
|
|
||||||
|
private final GetNoticesPortIn getNoticesPortIn;
|
||||||
|
private final UICodeListPortIn uiCodeListPortIn;
|
||||||
|
|
||||||
|
@GetMapping(path = "/api/communication/notices")
|
||||||
|
ResponseEntity<?> operate(
|
||||||
|
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC, page = 0, size = 10) Pageable pageable,
|
||||||
|
GetNoticesReqVO reqVO) {
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(getNoticesPortIn.operate(pageable, new GetNoticesCmd(
|
||||||
|
reqVO.getSearchField(),
|
||||||
|
reqVO.getSearchValue(),
|
||||||
|
reqVO.getSearchOpen()
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.config.application.util.AdminUtil;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web.model.GetNoticesReqVO;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||||
|
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.web.PageableDefault;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class GetNoticesUIController {
|
||||||
|
|
||||||
|
private final GetNoticesPortIn getNoticesPortIn;
|
||||||
|
private final UICodeListPortIn uiCodeListPortIn;
|
||||||
|
|
||||||
|
@GetMapping(path = "/communication/notices")
|
||||||
|
String operate(Model model, @PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC, page = 0, size = 10) Pageable pageable
|
||||||
|
, GetNoticesReqVO reqVO) {
|
||||||
|
|
||||||
|
Page<GetNotices> notices =
|
||||||
|
getNoticesPortIn.operate(
|
||||||
|
pageable,
|
||||||
|
new GetNoticesCmd(
|
||||||
|
reqVO.getSearchField(), reqVO.getSearchValue(), reqVO.getSearchOpen()));
|
||||||
|
|
||||||
|
model.addAttribute("reqVO", reqVO);
|
||||||
|
model.addAttribute("notices", notices);
|
||||||
|
|
||||||
|
model.addAttribute("userRole", AdminUtil.getLoginUserRole());
|
||||||
|
model.addAttribute("pageRows", uiCodeListPortIn.connect("code.pageable.rows"));
|
||||||
|
|
||||||
|
return "communication/notice/notices";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.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 GetNoticesReqVO {
|
||||||
|
|
||||||
|
private String searchField;
|
||||||
|
private String searchValue;
|
||||||
|
private String searchOpen;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer page;
|
||||||
|
private String sort;
|
||||||
|
private Integer size;
|
||||||
|
|
||||||
|
public Integer getPage() {
|
||||||
|
// 요청 페이지 넘버 - 초기값 `0`
|
||||||
|
return page != null ? page : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSort() {
|
||||||
|
// 정렬 값 - 초기값 `orderNo 내림차순`
|
||||||
|
return StringUtils.isEmpty(sort) ? "createdAt,DESC" : sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSize() {
|
||||||
|
// 페이지 당 아이템 수 - 초기값 `10`
|
||||||
|
return size != null ? size : 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.ports;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface GetNoticesPortIn {
|
||||||
|
|
||||||
|
Page<GetNotices> operate(Pageable pageable, GetNoticesCmd command);
|
||||||
|
|
||||||
|
List<GetNotices> operateList(GetNoticesCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.ports;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface GetNoticesPortOut {
|
||||||
|
|
||||||
|
Page<GetNotices> operate(Pageable pageable, GetNoticesCmd command);
|
||||||
|
|
||||||
|
List<GetNotices> operateList(GetNoticesCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.ports.application;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class GetNoticesService implements GetNoticesPortIn {
|
||||||
|
|
||||||
|
private final GetNoticesPortOut portOut;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<GetNotices> operate(Pageable pageable, GetNoticesCmd command) {
|
||||||
|
return portOut.operate(pageable, command);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<GetNotices> operateList(GetNoticesCmd command) {
|
||||||
|
return portOut.operateList(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.core.config.application.enums.FileUploadType;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class GetNoticeFiles {
|
||||||
|
private Long noticeId;
|
||||||
|
private Long id;
|
||||||
|
private FileUploadType type;
|
||||||
|
private String path;
|
||||||
|
private String name;
|
||||||
|
private String originName;
|
||||||
|
private Long fileLength;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class GetNotices {
|
||||||
|
private Long id;
|
||||||
|
private String updatedBy;
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
private String createdBy;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private Boolean visible;
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
private LocalDateTime endDate;
|
||||||
|
private GetNoticeFiles uploadFile;
|
||||||
|
|
||||||
|
public boolean getNewDate() {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
return now.toLocalDate().isEqual(createdAt.toLocalDate());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class GetNoticesCmd {
|
||||||
|
|
||||||
|
private String searchField;
|
||||||
|
private String searchValue;
|
||||||
|
private String searchOpen;
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.removeNotices.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.adapters.persistence.model.RemoveNoticesParam;
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.ports.RemoveNoticesPortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||||
|
import app.module.core.config.application.util.CommonUtil;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class RemoveNoticesDao implements RemoveNoticesPortOut {
|
||||||
|
|
||||||
|
private final RemoveNoticesMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operate(RemoveNoticesCmd command) {
|
||||||
|
String loginUser = CommonUtil.getLoginUsername();;
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
|
||||||
|
mapper.deleteNoticeHasFiles(
|
||||||
|
new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser));
|
||||||
|
mapper.deleteNotices(
|
||||||
|
new RemoveNoticesParam(command.getRemoveIds(), now, loginUser, now, loginUser));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.removeNotices.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.adapters.persistence.model.RemoveNoticesParam;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface RemoveNoticesMapper {
|
||||||
|
void deleteNotices(RemoveNoticesParam param);
|
||||||
|
void deleteNoticeHasFiles(RemoveNoticesParam param);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.removeNotices.adapters.persistence.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RemoveNoticesParam {
|
||||||
|
private Set<Long> removeIds;
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
private String updatedBy;
|
||||||
|
private LocalDateTime deletedAt;
|
||||||
|
private String deletedBy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.removeNotices.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.adapters.web.model.RemoveNoticesReqVO;
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.ports.RemoveNoticesPortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||||
|
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 RemoveNoticesController {
|
||||||
|
private final RemoveNoticesPortIn removeNoticesPortIn;
|
||||||
|
|
||||||
|
@DeleteMapping(path = "/api/communication/notices/remove")
|
||||||
|
ResponseEntity<?> operate(@Valid RemoveNoticesReqVO reqVO, BindingResult bindingResult) {
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||||
|
.body(bindingResult.getFieldErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
removeNoticesPortIn.operate(new RemoveNoticesCmd(reqVO.getSelectIds()));
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.removeNotices.adapters.web.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class RemoveNoticesReqVO {
|
||||||
|
private Set<Long> selectIds;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.removeNotices.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||||
|
|
||||||
|
public interface RemoveNoticesPortIn {
|
||||||
|
void operate(RemoveNoticesCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.removeNotices.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||||
|
|
||||||
|
public interface RemoveNoticesPortOut {
|
||||||
|
void operate(RemoveNoticesCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.removeNotices.ports.application;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.ports.RemoveNoticesPortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.ports.RemoveNoticesPortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain.RemoveNoticesCmd;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class RemoveNoticesService implements RemoveNoticesPortIn {
|
||||||
|
|
||||||
|
private final RemoveNoticesPortOut portOut;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operate(RemoveNoticesCmd command) {
|
||||||
|
portOut.operate(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.removeNotices.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class RemoveNoticesCmd {
|
||||||
|
private Set<Long> removeIds;
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||||
|
import app.module.core.config.adapters.persistence.entity.NoticeHasUploadFile;
|
||||||
|
import app.module.core.config.application.util.CommonUtil;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class UpdateNoticeDao implements UpdateNoticePortOut {
|
||||||
|
|
||||||
|
private final UpdateNoticeMapper mapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operate(UpdateNoticeCmd command) {
|
||||||
|
mapper.updateNotice(
|
||||||
|
|
||||||
|
new UpdateNoticeDto(
|
||||||
|
command.getId(),
|
||||||
|
command.getTitle(),
|
||||||
|
command.getContent(),
|
||||||
|
command.getVisible(),
|
||||||
|
command.getStartDate(),
|
||||||
|
command.getEndDate(),
|
||||||
|
command.getFileMappingId(),
|
||||||
|
LocalDateTime.now(),
|
||||||
|
CommonUtil.getLoginUsername()
|
||||||
|
));
|
||||||
|
|
||||||
|
// 첨부파일 초기화
|
||||||
|
mapper.deleteFileUploads(new NoticeHasUploadFile(command.getId()));
|
||||||
|
|
||||||
|
// 첨부파일 있을 시, 등록
|
||||||
|
if (command.getFileMappingId() != null && !command.getFileMappingId().isEmpty()) {
|
||||||
|
mapper.createFileUploads(new CreateUploadFileParam(
|
||||||
|
command.getId(),
|
||||||
|
command.getFileMappingId().stream()
|
||||||
|
.map(Long::parseLong)
|
||||||
|
.toList(),
|
||||||
|
LocalDateTime.now(),
|
||||||
|
CommonUtil.getLoginUsername(),
|
||||||
|
LocalDateTime.now(),
|
||||||
|
CommonUtil.getLoginUsername()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.CreateUploadFileParam;
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model.UpdateNoticeDto;
|
||||||
|
import app.module.core.config.adapters.persistence.entity.ArticleHasUploadFile;
|
||||||
|
import app.module.core.config.adapters.persistence.entity.NoticeHasUploadFile;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface UpdateNoticeMapper {
|
||||||
|
void updateNotice(UpdateNoticeDto dto);
|
||||||
|
void deleteFileUploads(NoticeHasUploadFile noticeHasUploadFile);
|
||||||
|
void createFileUploads(CreateUploadFileParam param);
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CreateUploadFileParam {
|
||||||
|
private Long id;
|
||||||
|
private List<Long> fileMappingId;
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
private String createdBy;
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
private String updatedBy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.adapters.persistence.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UpdateNoticeDto {
|
||||||
|
private Long id;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private Boolean visible;
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
private LocalDateTime endDate;
|
||||||
|
private List<String> fileMappingId;
|
||||||
|
private LocalDateTime updatedAt;
|
||||||
|
private String updatedBy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.adapters.web.model.UpdateNoticeReqVO;
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||||
|
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.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class UpdateNoticeController {
|
||||||
|
private final UpdateNoticePortIn updateNoticePortIn;
|
||||||
|
|
||||||
|
@PutMapping(path = "/api/communication/notices/update")
|
||||||
|
ResponseEntity<?> operate(@RequestBody @Valid UpdateNoticeReqVO reqVO, BindingResult bindingResult) {
|
||||||
|
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||||
|
.body(bindingResult.getFieldErrors());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateNoticePortIn.operate(
|
||||||
|
new UpdateNoticeCmd(
|
||||||
|
reqVO.getId(),
|
||||||
|
reqVO.getTitle(),
|
||||||
|
reqVO.getContent(),
|
||||||
|
reqVO.getVisible(),
|
||||||
|
reqVO.getStartDate(),
|
||||||
|
reqVO.getEndDate(),
|
||||||
|
reqVO.getFileMappingId()
|
||||||
|
));
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(reqVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.config.application.util.AdminUtil;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.adapters.web.model.GetNoticesReqVO;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.GetNoticesPortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNotices;
|
||||||
|
import app.module.admin.usecase.communication.notice.getNoticesUI.ports.application.domain.GetNoticesCmd;
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn;
|
||||||
|
import app.module.core.usecase.uicode.list.ports.UICodeListPortIn;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.web.PageableDefault;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class UpdateNoticeUIController {
|
||||||
|
|
||||||
|
private final UpdateNoticePortIn updateNoticePortIn;
|
||||||
|
private final UICodeListPortIn uiCodeListPortIn;
|
||||||
|
|
||||||
|
@GetMapping(path = "/communication/notices/{id}")
|
||||||
|
String operate(Model model
|
||||||
|
, @PathVariable @ModelAttribute("id") Long id) {
|
||||||
|
|
||||||
|
|
||||||
|
return "communication/notice/{id}";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.adapters.web.model;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.*;
|
||||||
|
import org.apache.commons.text.StringEscapeUtils;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class UpdateNoticeReqVO {
|
||||||
|
@NotNull(message = "{valid.common.required}")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@NotBlank(message = "{valid.common.required}")
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
@NotBlank(message = "{valid.common.required}")
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
@NotNull(message = "{valid.common.required}")
|
||||||
|
private Boolean visible;
|
||||||
|
|
||||||
|
|
||||||
|
@NotNull(message = "{valid.common.required}")
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
|
||||||
|
@NotNull(message = "{valid.common.required}")
|
||||||
|
private LocalDateTime endDate;
|
||||||
|
|
||||||
|
private List<String> fileMappingId;
|
||||||
|
|
||||||
|
private LocalDateTime createdAt;
|
||||||
|
|
||||||
|
private String createdBy;
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return StringEscapeUtils.escapeHtml4(title);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return StringEscapeUtils.escapeHtml4(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||||
|
|
||||||
|
public interface UpdateNoticePortIn {
|
||||||
|
|
||||||
|
void operate(UpdateNoticeCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.ports;
|
||||||
|
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||||
|
|
||||||
|
public interface UpdateNoticePortOut {
|
||||||
|
|
||||||
|
void operate(UpdateNoticeCmd command);
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.ports.application;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortIn;
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.UpdateNoticePortOut;
|
||||||
|
import app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain.UpdateNoticeCmd;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class UpdateNoticeService implements UpdateNoticePortIn {
|
||||||
|
|
||||||
|
private final UpdateNoticePortOut portOut;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operate(UpdateNoticeCmd command) {
|
||||||
|
portOut.operate(command);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package app.module.admin.usecase.communication.notice.updateNotice.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class UpdateNoticeCmd {
|
||||||
|
private Long id;
|
||||||
|
private String title;
|
||||||
|
private String content;
|
||||||
|
private Boolean visible;
|
||||||
|
private LocalDateTime startDate;
|
||||||
|
private LocalDateTime endDate;
|
||||||
|
private List<String> fileMappingId;
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package app.module.admin.usecase.household.checkHouseholdNum.adapters.persistence;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNumCmd;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.CheckHouseholdNumPortOut;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CheckHouseholdNumDao implements CheckHouseholdNumPortOut {
|
||||||
|
private final CheckHouseholdNumMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<CheckHouseholdNum> operate(CheckHouseholdNumCmd cmd) {
|
||||||
|
return mapper.checkHouseholdNum(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package app.module.admin.usecase.household.checkHouseholdNum.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNumCmd;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CheckHouseholdNumMapper {
|
||||||
|
Optional<CheckHouseholdNum> checkHouseholdNum(CheckHouseholdNumCmd cmd);
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package app.module.admin.usecase.household.checkHouseholdNum.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.adapters.web.model.CheckHouseholdNumReqVO;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.CheckHouseholdNumPortIn;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNumCmd;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
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.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CheckHouseholdNumController {
|
||||||
|
private final CheckHouseholdNumPortIn portIn;
|
||||||
|
|
||||||
|
@GetMapping(path = "/api/households/check")
|
||||||
|
ResponseEntity<CheckHouseholdNum> operate(
|
||||||
|
@Valid CheckHouseholdNumReqVO reqVO) {
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(portIn.operate(new CheckHouseholdNumCmd(reqVO.getHouseholdNum())).orElse(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package app.module.admin.usecase.household.checkHouseholdNum.adapters.web.model;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CheckHouseholdNumReqVO {
|
||||||
|
@NotEmpty
|
||||||
|
private String householdNum;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package app.module.front.usecase.user.updateUserUI.adapters.web.model;
|
package app.module.admin.usecase.household.checkHouseholdNum.adapters.web.model;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@@ -9,6 +9,5 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
public class UpdateUserUIReqVO {
|
public class CheckHouseholdNumResVO {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package app.module.admin.usecase.household.checkHouseholdNum.ports;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNumCmd;
|
||||||
|
|
||||||
|
public interface CheckHouseholdNumPortIn {
|
||||||
|
Optional<CheckHouseholdNum> operate(CheckHouseholdNumCmd cmd);
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package app.module.admin.usecase.household.checkHouseholdNum.ports;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNumCmd;
|
||||||
|
|
||||||
|
public interface CheckHouseholdNumPortOut {
|
||||||
|
Optional<CheckHouseholdNum> operate(CheckHouseholdNumCmd cmd);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package app.module.admin.usecase.household.checkHouseholdNum.ports.application;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNumCmd;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.CheckHouseholdNumPortIn;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.CheckHouseholdNumPortOut;
|
||||||
|
import java.util.Optional;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CheckHouseholdNumService implements CheckHouseholdNumPortIn {
|
||||||
|
private final CheckHouseholdNumPortOut portOut;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<CheckHouseholdNum> operate(CheckHouseholdNumCmd cmd) {
|
||||||
|
return portOut.operate(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CheckHouseholdNum {
|
||||||
|
private Boolean isDuplicated; // 사용여부
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CheckHouseholdNumCmd {
|
||||||
|
private String householdNum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateResearcherHasHouseholdCmd;
|
||||||
|
import app.module.core.config.application.annotation.CreateCommand;
|
||||||
|
import app.module.core.config.application.util.AuditUtil;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdHasRoleCmd;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdOutCmd;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.CreateHouseholdPortOut;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CreateHouseholdDao implements CreateHouseholdPortOut {
|
||||||
|
private final CreateHouseholdMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
@CreateCommand
|
||||||
|
public void operate(CreateHouseholdOutCmd outCmd) {
|
||||||
|
// 임가 등록
|
||||||
|
mapper.createHousehold(outCmd);
|
||||||
|
|
||||||
|
// 임가 역할 등록
|
||||||
|
if(outCmd.getRoleIds() != null && !outCmd.getRoleIds().isEmpty()) {
|
||||||
|
mapper.createHouseholdHasRole(
|
||||||
|
AuditUtil.create(new CreateHouseholdHasRoleCmd(outCmd.getSeq(), outCmd.getRoleIds())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 임가 담당 조사원 등록
|
||||||
|
if(outCmd.getResearcherSeq() != null) {
|
||||||
|
mapper.createResearcherHasHousehold(
|
||||||
|
AuditUtil.create(new CreateResearcherHasHouseholdCmd(outCmd.getSeq(), outCmd.getResearcherSeq())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.adapters.persistence;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdHasRoleCmd;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdOutCmd;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateResearcherHasHouseholdCmd;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CreateHouseholdMapper {
|
||||||
|
void createHousehold(CreateHouseholdOutCmd outCmd);
|
||||||
|
void createHouseholdHasRole(CreateHouseholdHasRoleCmd cmd);
|
||||||
|
void createResearcherHasHousehold(CreateResearcherHasHouseholdCmd cmd);
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.createHousehold.adapters.web.model.CreateHouseholdResVO;
|
||||||
|
import app.module.core.config.application.util.MessageUtil;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.CreateHouseholdPortIn;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdInCmd;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
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;
|
||||||
|
import org.springframework.validation.BindingResult;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.adapters.web.model.CreateHouseholdReqVO;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.adapters.web.validator.CreateHouseholdValidator;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CreateHouseholdController {
|
||||||
|
private final CreateHouseholdValidator validator;
|
||||||
|
private final CreateHouseholdPortIn createHouseholdPortIn;
|
||||||
|
|
||||||
|
@PostMapping(path = "/api/households/create")
|
||||||
|
ResponseEntity<?> operate(
|
||||||
|
@Valid @RequestBody CreateHouseholdReqVO reqVO, BindingResult bindingResult) {
|
||||||
|
validator.validate(reqVO, bindingResult);
|
||||||
|
|
||||||
|
if (bindingResult.hasErrors()) {
|
||||||
|
return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY)
|
||||||
|
.body(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
createHouseholdPortIn.operate(
|
||||||
|
new CreateHouseholdInCmd(
|
||||||
|
reqVO.getHouseholdNum(),
|
||||||
|
reqVO.getOwnerName(),
|
||||||
|
reqVO.getOwnerAge(),
|
||||||
|
reqVO.getTel1(),
|
||||||
|
reqVO.getTel2(),
|
||||||
|
reqVO.getTel3(),
|
||||||
|
reqVO.getPhone1(),
|
||||||
|
reqVO.getPhone2(),
|
||||||
|
reqVO.getPhone3(),
|
||||||
|
reqVO.getRegionMainCode(),
|
||||||
|
reqVO.getRegionSubCode(),
|
||||||
|
reqVO.getRegionDetailCode(),
|
||||||
|
reqVO.getAddress(),
|
||||||
|
reqVO.getIndustryLargeCode(),
|
||||||
|
reqVO.getIndustryMiddleCode(),
|
||||||
|
reqVO.getIndustrySubMiddle(),
|
||||||
|
reqVO.getIndustryDetail(),
|
||||||
|
reqVO.getResearcherSeq(),
|
||||||
|
reqVO.getIsPanel(),
|
||||||
|
reqVO.getMemo()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new CreateHouseholdResVO(reqVO.getHouseholdNum()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.adapters.web.model;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CreateHouseholdReqVO {
|
||||||
|
private String householdNum;
|
||||||
|
private String ownerName;
|
||||||
|
private Integer ownerAge;
|
||||||
|
private String tel1;
|
||||||
|
private String tel2;
|
||||||
|
private String tel3;
|
||||||
|
private String phone1;
|
||||||
|
private String phone2;
|
||||||
|
private String phone3;
|
||||||
|
private String regionMainCode;
|
||||||
|
private String regionSubCode;
|
||||||
|
private String regionDetailCode;
|
||||||
|
private String address;
|
||||||
|
private String industryLargeCode;
|
||||||
|
private String industryMiddleCode;
|
||||||
|
private String industrySubMiddle;
|
||||||
|
private String industryDetail;
|
||||||
|
private Long researcherSeq;
|
||||||
|
private Boolean isPanel;
|
||||||
|
private String memo;
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.adapters.web.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CreateHouseholdResVO {
|
||||||
|
private String householdNum;
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.adapters.web.validator;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.createHousehold.adapters.web.model.CreateHouseholdReqVO;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import org.springframework.validation.Errors;
|
||||||
|
import org.springframework.validation.Validator;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class CreateHouseholdValidator implements Validator {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Class<?> clazz) {
|
||||||
|
return CreateHouseholdReqVO.class.equals(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void validate(Object target, Errors errors) {
|
||||||
|
CreateHouseholdReqVO vo = (CreateHouseholdReqVO) target;
|
||||||
|
|
||||||
|
// 1. 임가번호
|
||||||
|
if (!StringUtils.hasText(vo.getHouseholdNum())) {
|
||||||
|
errors.reject("householdNum", "임가번호는 필수 입력 항목입니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringUtils.hasText(vo.getHouseholdNum()) && vo.getHouseholdNum().length() < 5) {
|
||||||
|
errors.reject("householdNum", "임가번호는 5자리 숫자로 입력해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 경영주명
|
||||||
|
if (!StringUtils.hasText(vo.getOwnerName())) {
|
||||||
|
errors.reject("ownerName", "경영주명을 입력해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (vo.getOwnerName().length() > 10) {
|
||||||
|
errors.reject("ownerName", "경영주명은 최대 10자까지 입력 가능합니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 연령
|
||||||
|
if (vo.getOwnerAge() == null) {
|
||||||
|
errors.reject("ownerAge", "연령을 입력해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (vo.getOwnerAge().toString().length() > 3) {
|
||||||
|
errors.reject("ownerAge", "연령은 최대 3자리 숫자까지 입력 가능합니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 가구 연락처
|
||||||
|
// TODO : 필수입력값 맞는지 체크
|
||||||
|
// if (!StringUtils.hasText(vo.getTel1()) || !StringUtils.hasText(vo.getTel2()) || !StringUtils.hasText(vo.getTel3())) {
|
||||||
|
// errors.reject("tel", "가구 연락처를 모두 입력해주세요.");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (vo.getTel2().length() > 4 || vo.getTel3().length() > 4) {
|
||||||
|
// errors.reject("tel", "가구 연락처는 각 4자리까지 입력 가능합니다.");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
if (StringUtils.hasText(vo.getTel2()) || StringUtils.hasText(vo.getTel3())) {
|
||||||
|
if ((vo.getTel2() != null && vo.getTel2().length() > 4) ||
|
||||||
|
(vo.getTel3() != null && vo.getTel3().length() > 4)) {
|
||||||
|
errors.reject("tel", "가구 연락처는 각 4자리까지 입력 가능합니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 휴대폰 번호
|
||||||
|
if (!StringUtils.hasText(vo.getPhone1()) || !StringUtils.hasText(vo.getPhone2()) || !StringUtils.hasText(vo.getPhone3())) {
|
||||||
|
errors.reject("phone", "휴대폰 번호를 모두 입력해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (vo.getPhone2().length() > 4 || vo.getPhone3().length() > 4) {
|
||||||
|
errors.reject("phone", "휴대폰 번호는 각 4자리까지 입력 가능합니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 지역 코드
|
||||||
|
if (!StringUtils.hasText(vo.getRegionMainCode())) {
|
||||||
|
errors.reject("regionMainCode", "실사를 선택해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!StringUtils.hasText(vo.getRegionSubCode())) {
|
||||||
|
errors.reject("regionSubCode", "지역을 선택해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!StringUtils.hasText(vo.getRegionDetailCode())) {
|
||||||
|
errors.reject("regionDetailCode", "세부지역을 선택해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. 주소
|
||||||
|
if (!StringUtils.hasText(vo.getAddress())) {
|
||||||
|
errors.reject("address", "주소를 입력해주세요.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringUtils.hasText(vo.getAddress()) && vo.getAddress().length() > 50) {
|
||||||
|
errors.reject("address", "주소는 최대 50자까지 입력 가능합니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8. 업종 중분류2
|
||||||
|
if (StringUtils.hasText(vo.getIndustrySubMiddle()) && vo.getIndustrySubMiddle().length() > 20) {
|
||||||
|
errors.reject("industrySubMiddle", "업종 중분류는 최대 20자까지 입력 가능합니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 9. 업종 세부품목
|
||||||
|
if (StringUtils.hasText(vo.getIndustryDetail()) && vo.getIndustryDetail().length() > 20) {
|
||||||
|
errors.reject("industryDetail", "업종 세부품목은 최대 20자까지 입력 가능합니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.ports;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdInCmd;
|
||||||
|
|
||||||
|
public interface CreateHouseholdPortIn {
|
||||||
|
void operate(CreateHouseholdInCmd inCmd);
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.ports;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdOutCmd;
|
||||||
|
|
||||||
|
public interface CreateHouseholdPortOut {
|
||||||
|
void operate(CreateHouseholdOutCmd outCmd);
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.ports.application;
|
||||||
|
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.CheckHouseholdNumPortIn;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNum;
|
||||||
|
import app.module.admin.usecase.household.checkHouseholdNum.ports.application.domain.CheckHouseholdNumCmd;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.CreateHouseholdPortIn;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.CreateHouseholdPortOut;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdInCmd;
|
||||||
|
import app.module.admin.usecase.household.createHousehold.ports.application.domain.CreateHouseholdOutCmd;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CreateHouseholdService implements CreateHouseholdPortIn {
|
||||||
|
|
||||||
|
private final CreateHouseholdPortOut portOut;
|
||||||
|
private final BCryptPasswordEncoder passwordEncoder;
|
||||||
|
private final CheckHouseholdNumPortIn checkHouseholdNumPortIn;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operate(CreateHouseholdInCmd inCmd) {
|
||||||
|
|
||||||
|
// 임가번호 중복체크
|
||||||
|
if (!inCmd.getHouseholdNum().isEmpty()) {
|
||||||
|
checkHouseholdNumPortIn
|
||||||
|
.operate(new CheckHouseholdNumCmd(inCmd.getHouseholdNum()))
|
||||||
|
.filter(CheckHouseholdNum::getIsDuplicated)
|
||||||
|
.ifPresent(result -> {
|
||||||
|
throw new IllegalArgumentException("입력하신 번호는 중복입니다. 다른 임가번호를 입력해주세요.");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
portOut.operate(new CreateHouseholdOutCmd(
|
||||||
|
null,
|
||||||
|
inCmd.getHouseholdNum(),
|
||||||
|
inCmd.getOwnerName(),
|
||||||
|
inCmd.getOwnerAge(),
|
||||||
|
(!StringUtils.hasText(inCmd.getTel2()) || !StringUtils.hasText(inCmd.getTel3()))
|
||||||
|
? null
|
||||||
|
: inCmd.getTel1() + "-" + inCmd.getTel2() + "-" + inCmd.getTel3(),
|
||||||
|
inCmd.getPhone1() + "-" + inCmd.getPhone2() + "-" + inCmd.getPhone3(),
|
||||||
|
passwordEncoder.encode(inCmd.getPhone3()), // 비밀번호 핸드폰 뒤 네자리
|
||||||
|
inCmd.getRegionMainCode(),
|
||||||
|
inCmd.getRegionSubCode(),
|
||||||
|
inCmd.getRegionDetailCode(),
|
||||||
|
inCmd.getAddress(),
|
||||||
|
inCmd.getIndustryLargeCode(),
|
||||||
|
inCmd.getIndustryMiddleCode(),
|
||||||
|
inCmd.getIndustrySubMiddle(),
|
||||||
|
inCmd.getIndustryDetail(),
|
||||||
|
inCmd.getResearcherSeq(),
|
||||||
|
inCmd.getIsPanel(),
|
||||||
|
inCmd.getMemo(),
|
||||||
|
List.of("ROLE_GENERAL")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package app.module.core.usecase.household.createHousehold.ports.application.domain;
|
package app.module.admin.usecase.household.createHousehold.ports.application.domain;
|
||||||
|
|
||||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.ports.application.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CreateHouseholdInCmd {
|
||||||
|
private String householdNum;
|
||||||
|
private String ownerName;
|
||||||
|
private Integer ownerAge;
|
||||||
|
private String tel1;
|
||||||
|
private String tel2;
|
||||||
|
private String tel3;
|
||||||
|
private String phone1;
|
||||||
|
private String phone2;
|
||||||
|
private String phone3;
|
||||||
|
private String regionMainCode;
|
||||||
|
private String regionSubCode;
|
||||||
|
private String regionDetailCode;
|
||||||
|
private String address;
|
||||||
|
private String industryLargeCode;
|
||||||
|
private String industryMiddleCode;
|
||||||
|
private String industrySubMiddle;
|
||||||
|
private String industryDetail;
|
||||||
|
private Long researcherSeq;
|
||||||
|
private Boolean isPanel;
|
||||||
|
private String memo;
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package app.module.core.usecase.household.createHousehold.ports.application.domain;
|
package app.module.admin.usecase.household.createHousehold.ports.application.domain;
|
||||||
|
|
||||||
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -23,13 +23,12 @@ public class CreateHouseholdOutCmd extends AuditCommand {
|
|||||||
private String regionSubCode;
|
private String regionSubCode;
|
||||||
private String regionDetailCode;
|
private String regionDetailCode;
|
||||||
private String address;
|
private String address;
|
||||||
private Integer industryLargeCode;
|
private String industryLargeCode;
|
||||||
private Integer industryMiddleCode;
|
private String industryMiddleCode;
|
||||||
private Integer industrySubMiddle;
|
private String industrySubMiddle;
|
||||||
private Integer industryDetail;
|
private String industryDetail;
|
||||||
private Integer employmentCode;
|
private Long researcherSeq;
|
||||||
private Boolean isPanel;
|
private Boolean isPanel;
|
||||||
private String memo;
|
private String memo;
|
||||||
private String dropReason;
|
|
||||||
private List<String> roleIds;
|
private List<String> roleIds;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package app.module.admin.usecase.household.createHousehold.ports.application.domain;
|
||||||
|
|
||||||
|
import app.module.core.config.adapters.persistence.component.AuditCommand;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
public class CreateResearcherHasHouseholdCmd extends AuditCommand {
|
||||||
|
private Long householdSeq;
|
||||||
|
private Long researcherSeq;
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package app.module.admin.usecase.household.createHouseholdUI.adapters.web;
|
||||||
|
|
||||||
|
import app.module.admin.config.application.util.AdminUtil;
|
||||||
|
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;
|
||||||
|
import app.module.admin.usecase.household.createHouseholdUI.adapters.web.model.CreateHouseholdUIReqVO;
|
||||||
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
class CreateHouseholdUIController {
|
||||||
|
|
||||||
|
private final UICodeListPortIn uiCodeListPortIn;
|
||||||
|
|
||||||
|
@GetMapping(path = "/households/create")
|
||||||
|
String operate(Model model, @ModelAttribute("reqVO") CreateHouseholdUIReqVO reqVO,
|
||||||
|
RedirectAttributes redirectAttributes) {
|
||||||
|
|
||||||
|
// 임가 등록 페이지는 관리자만 접근 가능
|
||||||
|
if (!AdminUtil.getLoginUserRole().equals("ROLE_ADMIN")) {
|
||||||
|
redirectAttributes.addFlashAttribute("alertMessage", "접근 권한이 없습니다.");
|
||||||
|
return "redirect:/households";
|
||||||
|
}
|
||||||
|
|
||||||
|
// 실사
|
||||||
|
model.addAttribute("regionMainList", uiCodeListPortIn.connect("code.region.main"));
|
||||||
|
// 지역
|
||||||
|
model.addAttribute("regionSubList", uiCodeListPortIn.connect("code.region.sub"));
|
||||||
|
// 세부지역
|
||||||
|
model.addAttribute("regionDetailList", uiCodeListPortIn.connect("code.region.detail"));
|
||||||
|
// 업종 대분류
|
||||||
|
model.addAttribute("industryLargeList", uiCodeListPortIn.connect("code.industry.large"));
|
||||||
|
// 업종 중분류1
|
||||||
|
model.addAttribute("industryMiddleList", uiCodeListPortIn.connect("code.industry.middle"));
|
||||||
|
|
||||||
|
return "households/create";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package app.module.admin.usecase.researcher.getResearchersUI.model;
|
package app.module.admin.usecase.household.createHouseholdUI.adapters.web.model;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@@ -9,5 +9,5 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode
|
@EqualsAndHashCode
|
||||||
public class GetResearchersUIReqVO {
|
public class CreateHouseholdUIReqVO {
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user