Merge branch 'susu' into dev
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
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.application.enums.AppType;
|
||||
import app.module.core.config.application.exception.NoMatchingURIException;
|
||||
@@ -76,16 +77,16 @@ public class AdminURIInterceptor implements HandlerInterceptor {
|
||||
// 활성 프로파일 가져오기 TODO 2차 오픈시 삭제 예정
|
||||
modelAndView.addObject("activeProfile", activeProfiles);
|
||||
|
||||
String roleId = AdminUtil.getLoginUserRole();
|
||||
if (!CommonUtil.isAjaxRequest(request)) {
|
||||
URITopTier topTierOutput = topTierPortIn.connect(AppType.ADMIN);
|
||||
URITopTier topTierOutput = topTierPortIn.connectRoleId(AppType.ADMIN,roleId);
|
||||
modelAndView.addObject("topNode", recursiveMapping(topTierOutput));
|
||||
|
||||
if (modelAndView.getModelMap().getAttribute("currentURI") == null) {
|
||||
modelAndView.addObject("currentURI", request.getAttribute("currentURI"));
|
||||
}
|
||||
|
||||
modelAndView.addObject(
|
||||
"menuHierarchy", uriAncestryPortIn.connect(AppType.ADMIN, request.getRequestURI()));
|
||||
modelAndView.addObject("menuHierarchy", uriAncestryPortIn.connect(AppType.ADMIN, request.getRequestURI()));
|
||||
|
||||
if (cloudFrontDomain != null && bucketFolder != null) {
|
||||
modelAndView.addObject("S3URL", "https://" + cloudFrontDomain + bucketFolder);
|
||||
|
||||
@@ -65,17 +65,18 @@ public class AdminAuthSuccessEvent {
|
||||
"security.password.change.notify", adminUser.getRemainPasswordDays()));
|
||||
}
|
||||
|
||||
// 로그인 활성화 기록 생성
|
||||
// loggedInUserSavePortIn.connect(
|
||||
// LoggedInUserSaveCmd.builder()
|
||||
// .loggedInUserId(
|
||||
// LoggedInUserIdSaveCmd.builder()
|
||||
// .appType(AppType.ADMIN)
|
||||
// .id(authentication.getName())
|
||||
// .build())
|
||||
// .clientIP(CommonUtil.getClientIP(request))
|
||||
// .lastLoggedInAt(LocalDateTime.now())
|
||||
// .build());
|
||||
// 로그인 이력 쌓기
|
||||
loggedInUserSavePortIn.connect(
|
||||
LoggedInUserSaveCmd.builder()
|
||||
.loggedInUserId(
|
||||
LoggedInUserIdSaveCmd.builder()
|
||||
.appType(AppType.ADMIN)
|
||||
.id(authentication.getName())
|
||||
.build())
|
||||
.clientIP(CommonUtil.getClientIP(request))
|
||||
.lastLoggedInAt(LocalDateTime.now())
|
||||
.build());
|
||||
|
||||
}
|
||||
|
||||
@EventListener
|
||||
|
||||
@@ -46,6 +46,7 @@ public class AdminDetailsService implements UserDetailsService {
|
||||
adminUser.getPassword(),
|
||||
adminUser.getRoles().stream().map(CoreRole::getId).findFirst().orElse(null),
|
||||
adminUser.getRegionMainCode(),
|
||||
adminUser.getLastLoginIp(),
|
||||
!accountDisabled,
|
||||
true,
|
||||
isCredentialsNonExpired(adminUser.getPasswordUpdatedAt()),
|
||||
|
||||
@@ -10,6 +10,7 @@ public class AdminUser extends User {
|
||||
private Long seq;
|
||||
private String roleId;
|
||||
private String regionMainCode;
|
||||
private String lastLoginIp;
|
||||
private long remainPasswordDays;
|
||||
|
||||
public AdminUser(
|
||||
@@ -18,6 +19,7 @@ public class AdminUser extends User {
|
||||
String password,
|
||||
String roleId,
|
||||
String regionMainCode,
|
||||
String lastLoginIp,
|
||||
boolean enabled,
|
||||
boolean accountNonExpired,
|
||||
boolean credentialsNonExpired,
|
||||
@@ -35,6 +37,7 @@ public class AdminUser extends User {
|
||||
this.seq = seq;
|
||||
this.roleId = roleId;
|
||||
this.regionMainCode = regionMainCode;
|
||||
this.lastLoginIp = lastLoginIp;
|
||||
this.remainPasswordDays = remainPasswordDays;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,4 +53,14 @@ public class AdminUtil {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,15 @@
|
||||
<insert id="insert" parameterType="app.module.core.config.adapters.persistence.entity.LoggedInUser">
|
||||
INSERT INTO logged_in_user
|
||||
(
|
||||
app_type,
|
||||
id,
|
||||
app_type,
|
||||
login_id,
|
||||
clientip,
|
||||
last_logged_in_at
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
nextval('logged_in_user_seq'),
|
||||
#{appType},
|
||||
#{id},
|
||||
#{clientIP},
|
||||
@@ -27,7 +29,7 @@
|
||||
clientip = #{clientIP},
|
||||
last_logged_in_at = #{lastLoggedInAt}
|
||||
WHERE app_type = #{appType}
|
||||
AND id = #{id}
|
||||
AND login_id = #{id}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -105,7 +105,7 @@
|
||||
|
||||
<!-- 자식 children 가 있는 경우 -->
|
||||
<th:block th:if="${#lists.size(menu.children) > 0}">
|
||||
<a th:href="${menu.uri}" th:text="${#messages.msg(menu.id)}">메뉴명</a>
|
||||
<a href="#" th:text="${#messages.msg(menu.id)}" >메뉴명</a>
|
||||
<th:block th:insert="~{this :: subMenuFrag}"
|
||||
th:with="subMenus = ${menu.children}, addSubMenuClass = false">
|
||||
</th:block>
|
||||
@@ -133,7 +133,7 @@
|
||||
</ul>
|
||||
<div class="header-right">
|
||||
<p class="user"><strong sec:authentication="name">로그인 사용자명</strong>님 안녕하세요</p>
|
||||
<span class="user-ip">111.11.111.111</span>
|
||||
<span class="user-ip" th:text="${@adminUtil.getLoginUserLastIp}">111.11.111.111</span>
|
||||
<button class="btn-logout" onclick="location.href='/logout'">로그아웃</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="component-btns bottom-btn-group">
|
||||
<div class="component-btns bottom-btn-group" th:unless="${activeProfile != 'local'}">
|
||||
<div class="btns-row align-right">
|
||||
<button type="button" class="btn">
|
||||
<span class="btn-txt">정보수정</span>
|
||||
|
||||
@@ -20,7 +20,18 @@
|
||||
<tr>
|
||||
<th>방문일</th>
|
||||
<td>
|
||||
<input id="visitDate" class="flatpickr" name="visitDate" type="text" placeholder="방문일을 선택하세요"/>
|
||||
<div class="component-datepicker">
|
||||
<div class="component-input">
|
||||
<div class="input-field">
|
||||
<input type="text" class="datepicker-btn-trigger" name="visitDate" id="visitDate" aria-label="방문일"
|
||||
placeholder="방문일을 입력해주세요" />
|
||||
<span class="input-field-btn datepicker-state">
|
||||
<span class="hide-txt">달력</span>
|
||||
<i class="ico-calendar ico-normal" aria-hidden="true"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<th>관리분야</th>
|
||||
<td>
|
||||
@@ -87,7 +98,7 @@
|
||||
|
||||
const showHouseholdModal2 = (seq) => {
|
||||
document.querySelector(".modal02").ui.open();
|
||||
initFlatpickr();
|
||||
//initFlatpickr();
|
||||
|
||||
ajaxUtil._ajaxMethod(
|
||||
'/api/researcher/visitHousehold/'+seq,
|
||||
|
||||
@@ -24,6 +24,7 @@ public class AdminView implements Serializable {
|
||||
private Boolean accountDisabled;
|
||||
private Integer loginFailCnt;
|
||||
private Boolean accountLocked;
|
||||
private String lastLoginIp;
|
||||
private LocalDateTime createdAt;
|
||||
private String createdBy;
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@@ -9,5 +9,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
@Mapper
|
||||
public interface URIMapper {
|
||||
URITopTier findTopTierByAppType(@Param("appType") AppType appType);
|
||||
URITopTier findTopTierByAppTypeByRoleId(@Param("appType") AppType appType,@Param("roleId") String roleId);
|
||||
List<URITopTier> findChildrenByParentId(@Param("parentId") String parentId);
|
||||
List<URITopTier> findChildrenByParentIdByRoleId(@Param("parentId") String parentId,@Param("roleId") String roleId);
|
||||
}
|
||||
|
||||
@@ -25,12 +25,33 @@ public class URITopTierDao implements URITopTierPortOut {
|
||||
|
||||
return recursiveMapping(top);
|
||||
}
|
||||
@Override
|
||||
@Transactional
|
||||
public URITopTier connectRoleId(AppType appType, String roleId) {
|
||||
URITopTier top = uriMapper.findTopTierByAppTypeByRoleId(appType,roleId);
|
||||
if (top == null) {
|
||||
throw new RuntimeException("There is no top tier item of " + appType);
|
||||
}
|
||||
|
||||
return recursiveMapping(top,roleId);
|
||||
}
|
||||
|
||||
private URITopTier recursiveMapping(URITopTier current) {
|
||||
List<URITopTier> children = uriMapper.findChildrenByParentId(current.getId());
|
||||
current.setChildren(children.stream()
|
||||
.map(this::recursiveMapping)
|
||||
.map(this::recursiveMapping)
|
||||
.collect(Collectors.toList()));
|
||||
return current;
|
||||
}
|
||||
|
||||
private URITopTier recursiveMapping(URITopTier current,String roleId) {
|
||||
List<URITopTier> children = uriMapper.findChildrenByParentIdByRoleId(current.getId(),roleId);
|
||||
current.setChildren(children.stream()
|
||||
.map(uri -> recursiveMapping(uri,roleId))
|
||||
.collect(Collectors.toList()));
|
||||
return current;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -5,4 +5,5 @@ import app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier;
|
||||
|
||||
public interface URITopTierPortIn {
|
||||
URITopTier connect(AppType appType);
|
||||
URITopTier connectRoleId(AppType appType, String roleId);
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ import app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier;
|
||||
public interface URITopTierPortOut {
|
||||
|
||||
URITopTier connect(AppType appType);
|
||||
URITopTier connectRoleId(AppType appType,String roleId);
|
||||
}
|
||||
|
||||
@@ -19,4 +19,10 @@ public class URITopTierService implements URITopTierPortIn {
|
||||
public URITopTier connect(AppType appType) {
|
||||
return topTierPortOut.connect(appType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public URITopTier connectRoleId(AppType appType, String roleId) {
|
||||
return topTierPortOut.connectRoleId(appType,roleId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,12 +18,17 @@
|
||||
a.account_disabled,
|
||||
a.login_fail_cnt,
|
||||
a.account_locked,
|
||||
liu.clientip as last_login_ip,
|
||||
a.created_at,
|
||||
a.created_by,
|
||||
a.updated_at,
|
||||
a.updated_by
|
||||
FROM admin a
|
||||
WHERE id = #{id}
|
||||
LEFT JOIN ( SELECT clientip,login_id
|
||||
FROM logged_in_user liu
|
||||
ORDER BY last_logged_in_at desc
|
||||
LIMIT 1 ) liu on liu.login_id = a.id
|
||||
WHERE a.id = #{id}
|
||||
AND a.is_deleted = false
|
||||
</select>
|
||||
|
||||
|
||||
@@ -2,32 +2,65 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="app.module.core.usecase.uri.toptier.adapters.persistence.URIMapper">
|
||||
<select id="findTopTierByAppType" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
SELECT
|
||||
u.id,
|
||||
u.app_type,
|
||||
u.text,
|
||||
u.uri,
|
||||
u.show_on_navi,
|
||||
u.order_no
|
||||
FROM uri u
|
||||
WHERE u.app_type = #{appType}
|
||||
AND u.parent_id IS NULL
|
||||
AND u.is_deleted = false
|
||||
</select>
|
||||
|
||||
<select id="findTopTierByAppType" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
<select id="findChildrenByParentId" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
SELECT
|
||||
u.id,
|
||||
u.app_type,
|
||||
u.text,
|
||||
u.uri,
|
||||
u.show_on_navi,
|
||||
u.order_no
|
||||
FROM uri u
|
||||
WHERE u.parent_id = #{parentId}
|
||||
AND u.is_deleted = false
|
||||
ORDER BY u.order_no ASC
|
||||
</select>
|
||||
|
||||
<select id="findTopTierByAppTypeByRoleId" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
SELECT
|
||||
id,
|
||||
app_type,
|
||||
text,
|
||||
uri,
|
||||
show_on_navi,
|
||||
order_no
|
||||
FROM uri
|
||||
WHERE app_type = #{appType}
|
||||
AND parent_id IS NULL
|
||||
AND is_deleted = false
|
||||
u.id,
|
||||
u.app_type,
|
||||
u.text,
|
||||
u.uri,
|
||||
u.show_on_navi,
|
||||
u.order_no
|
||||
FROM uri u
|
||||
JOIN uri_has_role uhr ON u.id = uhr.uri_id and uhr.is_deleted = false
|
||||
WHERE u.app_type = #{appType}
|
||||
AND u.parent_id IS NULL
|
||||
AND u.is_deleted = false
|
||||
AND uhr.role_id = #{roleId}
|
||||
AND u.show_on_navi = true
|
||||
</select>
|
||||
|
||||
<select id="findChildrenByParentId" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
<select id="findChildrenByParentIdByRoleId" resultType="app.module.core.usecase.uri.toptier.ports.application.domain.URITopTier">
|
||||
SELECT
|
||||
id,
|
||||
app_type,
|
||||
text,
|
||||
uri,
|
||||
show_on_navi,
|
||||
order_no
|
||||
FROM uri
|
||||
WHERE parent_id = #{parentId}
|
||||
AND is_deleted = false
|
||||
ORDER BY order_no ASC
|
||||
u.id,
|
||||
u.app_type,
|
||||
u.text,
|
||||
u.uri,
|
||||
u.show_on_navi,
|
||||
u.order_no
|
||||
FROM uri u
|
||||
JOIN uri_has_role uhr ON u.id = uhr.uri_id and uhr.is_deleted = false
|
||||
WHERE u.parent_id = #{parentId}
|
||||
AND u.is_deleted = false
|
||||
AND uhr.role_id = #{roleId}
|
||||
AND u.show_on_navi = true
|
||||
ORDER BY u.order_no ASC
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -831,23 +831,26 @@ COMMENT ON COLUMN operation_log.is_deleted IS '삭제여부';
|
||||
|
||||
-- ============================================
|
||||
-- TABLE : logged_in_user
|
||||
-- DESC : 로그인 사용자 정보 테이블
|
||||
-- DESC : 로그인 사용자 이력 테이블
|
||||
-- ============================================
|
||||
CREATE SEQUENCE logged_in_user_seq START WITH 1 INCREMENT BY 1 CACHE 1 NO CYCLE;
|
||||
CREATE TABLE logged_in_user (
|
||||
id bigint DEFAULT nextval('logged_in_user_seq') NOT NULL, -- 로그 ID (PK)
|
||||
app_type varchar(255) NOT NULL, -- 앱 타입 (FRONT / ADMIN)
|
||||
id varchar(255) NOT NULL, -- 로그인 아이디
|
||||
login_id varchar(255) NOT NULL, -- 로그인 아이디
|
||||
last_logged_in_at timestamp(6), -- 마지막 로그인 날짜
|
||||
clientip varchar(255), -- 접속 아이피
|
||||
|
||||
CONSTRAINT logged_in_user_pkey PRIMARY KEY (app_type, id),
|
||||
CONSTRAINT logged_in_user_pkey PRIMARY KEY (id),
|
||||
CONSTRAINT logged_in_user_app_type_check
|
||||
CHECK (app_type::text = ANY (ARRAY['FRONT', 'ADMIN']))
|
||||
);
|
||||
|
||||
COMMENT ON TABLE logged_in_user IS '로그인사용자정보테이블';
|
||||
COMMENT ON TABLE logged_in_user IS '로그인사용자이력테이블';
|
||||
|
||||
COMMENT ON COLUMN logged_in_user.id IS '로그 ID';
|
||||
COMMENT ON COLUMN logged_in_user.app_type IS '앱 타입';
|
||||
COMMENT ON COLUMN logged_in_user.id IS '로그인 아이디';
|
||||
COMMENT ON COLUMN logged_in_user.login_id IS '로그인 아이디';
|
||||
COMMENT ON COLUMN logged_in_user.last_logged_in_at IS '마지막 로그인 날짜';
|
||||
COMMENT ON COLUMN logged_in_user.clientip IS '접속 아이피';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user