사용자 상태 관리 기능 추가.

master
강석 최 2021-12-06 17:37:46 +09:00
parent c7f3f45ae3
commit f25aaa3c69
8 changed files with 21 additions and 8 deletions

View File

@ -41,6 +41,8 @@ public class UserInfo extends BaseModel implements UserDetails{
private String userRole; private String userRole;
@Column(name = "CREATE_DATE", updatable = false) @Column(name = "CREATE_DATE", updatable = false)
private LocalDateTime createDate; private LocalDateTime createDate;
@Column(name = "USER_STATUS")
private String userStatus;
@Transient @Transient
private String positionName; private String positionName;
@ -78,6 +80,6 @@ public class UserInfo extends BaseModel implements UserDetails{
@Override @Override
public boolean isEnabled() { public boolean isEnabled() {
return true; return userStatus.equals("T");
} }
} }

View File

@ -4,7 +4,6 @@ import com.dbnt.kcgfilemanager.mapper.UserInfoMapper;
import com.dbnt.kcgfilemanager.model.UserInfo; import com.dbnt.kcgfilemanager.model.UserInfo;
import com.dbnt.kcgfilemanager.repository.UserInfoRepository; import com.dbnt.kcgfilemanager.repository.UserInfoRepository;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.core.userdetails.UsernameNotFoundException;
@ -13,7 +12,6 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Optional;
@Service @Service
@RequiredArgsConstructor @RequiredArgsConstructor
@ -37,6 +35,7 @@ public class UserInfoService implements UserDetailsService {
targetUserInfo.setPosition(userInfo.getPosition()); targetUserInfo.setPosition(userInfo.getPosition());
targetUserInfo.setDepartment(userInfo.getDepartment()); targetUserInfo.setDepartment(userInfo.getDepartment());
targetUserInfo.setUserRole(userInfo.getUserRole()); targetUserInfo.setUserRole(userInfo.getUserRole());
targetUserInfo.setUserStatus(userInfo.getUserStatus());
return targetUserInfo.getUserId(); return targetUserInfo.getUserId();
} }

View File

@ -13,7 +13,8 @@
A.DEPARTMENT AS department, A.DEPARTMENT AS department,
C.VALUE AS departmentName, C.VALUE AS departmentName,
A.USER_ROLE AS userRole, A.USER_ROLE AS userRole,
A.CREATE_DATE AS createDate A.CREATE_DATE AS createDate,
A.USER_STATUS AS userStatus
FROM USER_INFO A FROM USER_INFO A
INNER JOIN COMMON_CODE B INNER JOIN COMMON_CODE B
ON A.POSITION = B.CODE_SQ ON A.POSITION = B.CODE_SQ

View File

@ -77,7 +77,7 @@ $(document).on('click', '#updateBtn', function (){
contentType: false, contentType: false,
success : function(data) { success : function(data) {
alert("저장되었습니다.") alert("저장되었습니다.")
$(".userInfoCheckBox:checked").click(); $("#searchBtn").click();
}, },
error : function(xhr, status) { error : function(xhr, status) {

View File

@ -56,6 +56,15 @@
</select> </select>
</div> </div>
</div> </div>
<div class="mb-3 row">
<label for="userStatus" class="col-sm-4 col-form-label">사용여부</label>
<div class="col-sm-6">
<select class="form-select" id="userStatus" name="userStatus">
<option value="T" th:selected="${userInfo.userStatus=='T'}">활성화</option>
<option value="F" th:selected="${userInfo.userStatus=='F'}">비활성화</option>
</select>
</div>
</div>
<div class="mb-3 row"> <div class="mb-3 row">
<div class="col-sm-4"></div> <div class="col-sm-4"></div>
<div class="col-sm-auto form-check ms-3"> <div class="col-sm-auto form-check ms-3">

View File

@ -73,6 +73,7 @@
<th>부서</th> <th>부서</th>
<th>직급</th> <th>직급</th>
<th>생성일</th> <th>생성일</th>
<th>상태</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -85,6 +86,7 @@
<td th:text="${userInfo.positionName}"></td> <td th:text="${userInfo.positionName}"></td>
<td th:text="${userInfo.departmentName}"></td> <td th:text="${userInfo.departmentName}"></td>
<td th:text="${#temporals.format(userInfo.createDate, 'yyyy-MM-dd')}"></td> <td th:text="${#temporals.format(userInfo.createDate, 'yyyy-MM-dd')}"></td>
<td th:text="${#strings.contains(userInfo.userStatus,'T')?'활성화':'비활성화'}"></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -11,7 +11,7 @@
<!-- Spring Security가 적용되면 POST 방식으로 보내는 모든 데이터는 csrf 토큰 값이 필요 --> <!-- Spring Security가 적용되면 POST 방식으로 보내는 모든 데이터는 csrf 토큰 값이 필요 -->
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/> <input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/> <input type="hidden" th:name="${_csrf.parameterName}" th:value="${_csrf.token}"/>
<p th:if="${loginError}" class="error">Wrong user or password</p> <p th:if="${loginError}" class="error text-danger">로그인에 실패하였습니다.</p>
<!-- 로그인 시 아이디의 name 애트리뷰트 값은 username --> <!-- 로그인 시 아이디의 name 애트리뷰트 값은 username -->
<!-- 파라미터명을 변경하고 싶을 경우 config class formlogin()에서 .usernameParameter("") 명시 --> <!-- 파라미터명을 변경하고 싶을 경우 config class formlogin()에서 .usernameParameter("") 명시 -->

View File

@ -4,8 +4,8 @@
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{layout/layout}"> layout:decorate="~{layout/layout}">
<div layout:fragment="content"> <div layout:fragment="content" class="p-5">
<h1>This is denied Page.</h1> <h1>권한 부족으로 접근이 거부되었습니다.</h1>
<hr /> <hr />
</div> </div>
</html> </html>