Merge branch 'susu' into dev
This commit is contained in:
@@ -89,6 +89,25 @@ public class CommonUtil {
|
||||
return username;
|
||||
}
|
||||
|
||||
public static String getLoginUserRole() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null) {
|
||||
return null;
|
||||
}
|
||||
Object principal = authentication.getPrincipal();
|
||||
if (principal instanceof UserDetails) {
|
||||
UserDetails userDetails = (UserDetails) principal;
|
||||
if (!userDetails.getAuthorities().isEmpty()) {
|
||||
return userDetails.getAuthorities().stream()
|
||||
.map(auth -> auth.getAuthority())
|
||||
.filter(authority -> authority != null && authority.startsWith("ROLE_"))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static HttpServletRequest getRequest() {
|
||||
HttpServletRequest request = null;
|
||||
if (RequestContextHolder.getRequestAttributes() != null) {
|
||||
|
||||
@@ -30,7 +30,7 @@ public final class CommonConstants {
|
||||
* 관리자 비밀번호 생성 규칙
|
||||
* [정책] 비밀번호: 5자, 숫자 + 특수문자(!@#$%_-) 1개 이상
|
||||
*/
|
||||
public static final String ADMIN_PASSWORD_REGEX = "^[a-zA-Z0-9가-힣_-]{4,15}$";
|
||||
public static final String ADMIN_PASSWORD_REGEX = "^(?=.*[0-9])(?=.*[!@#$%_-])[a-zA-Z0-9가-힣!@#$%_-]{5,15}$";
|
||||
|
||||
/**
|
||||
* 관리자 비밀번호 유효성 실패 메시지
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.util.AuditUtil;
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.usecase.admin.checkAdminId.persistence.CheckAdminIdMapper;
|
||||
import app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence.model.ExcelAdminCreateVO;
|
||||
import app.module.core.usecase.admin.excelSaveAdmin.adapters.persistence.model.ExcelResultVO;
|
||||
@@ -12,6 +13,7 @@ import app.module.core.usecase.uicode.list.adapters.persistence.UICodeListMapper
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -24,6 +26,8 @@ import java.util.List;
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeProfiles;
|
||||
|
||||
private final CheckAdminIdMapper checkAdminIdMapper;
|
||||
private final SaveAdminMapper saveAdminMapper;
|
||||
@@ -37,7 +41,7 @@ class ExcelSaveAdminIdDao implements ExcelSaveAdminPortOut {
|
||||
Workbook workbook = WorkbookFactory.create(file.getInputStream());
|
||||
Sheet sheet = workbook.getSheetAt(0);
|
||||
Integer success = 0;
|
||||
List<UICodeElement> uiCodeElementList = uiCodeListMapper.findByParentId("code.region.main");
|
||||
List<UICodeElement> uiCodeElementList = uiCodeListMapper.findByParentId("code.region.main", CommonUtil.getLoginUserRole(),activeProfiles);
|
||||
// 첫 번째 행은 헤더로 간주하고 스킵
|
||||
for (int i = 1; i <= sheet.getLastRowNum(); i++) {
|
||||
Row row = sheet.getRow(i);
|
||||
|
||||
@@ -1,20 +1,27 @@
|
||||
package app.module.core.usecase.uicode.list.adapters.persistence;
|
||||
|
||||
import app.module.core.config.application.util.CommonUtil;
|
||||
import app.module.core.usecase.uicode.list.ports.UICodeListPortOut;
|
||||
import app.module.core.usecase.uicode.list.ports.application.domain.UICodeElement;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
@RequiredArgsConstructor
|
||||
class UICodeListDao implements UICodeListPortOut {
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeProfiles;
|
||||
|
||||
private final UICodeListMapper uiCodeListMapper;
|
||||
|
||||
@Override
|
||||
public List<UICodeElement> connect(String parentId) {
|
||||
return uiCodeListMapper.findByParentId(parentId);
|
||||
return uiCodeListMapper.findByParentId(parentId,CommonUtil.getLoginUserRole(),activeProfiles);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UICodeListMapper {
|
||||
List<UICodeElement> findByParentId(@Param("parentId") String parentId);
|
||||
List<UICodeElement> findByParentId(@Param("parentId") String parentId,@Param("role")String role,@Param("activeProfiles")String activeProfiles);
|
||||
List<UICodeElement> findByLikeId(@Param("id") String id);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
FROM uicode
|
||||
WHERE parent_id = #{parentId}
|
||||
AND is_deleted = false
|
||||
AND in_use = true
|
||||
<if test="( activeProfiles == 'prod' and role != 'ROLE_ADMIN' ) or (role != 'ROLE_ADMIN')">
|
||||
AND in_use = true
|
||||
</if>
|
||||
ORDER BY order_no ASC
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user