Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main/java/kr/co/lupintech/service/LeaveService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import kr.co.lupintech.core.annotation.MyErrorLog;
import kr.co.lupintech.core.annotation.MyLog;
import kr.co.lupintech.core.exception.Exception401;
import kr.co.lupintech.core.factory.AlarmFactory;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -57,7 +58,11 @@ public class LeaveService {
User userPS = userRepository.findById(userId).orElseThrow(
() -> new Exception500("로그인 된 유저가 DB에 존재하지 않음")
);
// 2. 당직인 경우
// 2. 탈퇴한 회원인지 확인
if(userPS.getStatus().equals(false)){
throw new Exception401("탈퇴한 회원입니다");
}
// 3. 당직인 경우
if(applyInDTO.getType().equals(LeaveType.DUTY)){
if(!applyInDTO.getStartDate().equals(applyInDTO.getEndDate())){
throw new Exception400("startDate, endDate", "startDate와 endDate가 같아야 합니다.");
Expand Down Expand Up @@ -101,7 +106,7 @@ public class LeaveService {

return new LeaveResponse.ApplyOutDTO(leavePS, userPS);
}
// 3. 연차인 경우
// 4. 연차인 경우
// 1) 사용할 연차 일수 계산하기: 평일만 계산 + 공휴일 계산 by 공공 API
Integer usingDays = -1;
try{
Expand Down Expand Up @@ -170,6 +175,9 @@ public class LeaveService {
User userPS = userRepository.findById(userId).orElseThrow(
() -> new Exception500("로그인 된 유저가 DB에 존재하지 않음")
);
if(userPS.getStatus().equals(false)){
throw new Exception401("탈퇴한 회원입니다");
}

if(leavePS.getStatus().equals(LeaveStatus.APPROVAL)){
throw new Exception400("id", "이미 승인된 신청입니다.");
Expand Down
35 changes: 26 additions & 9 deletions src/main/java/kr/co/lupintech/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public class UserService {
Authentication authentication = authenticationManager.authenticate(usernamePasswordAuthenticationToken);
MyUserDetails myUserDetails = (MyUserDetails) authentication.getPrincipal();

if(myUserDetails.getUser().getStatus().equals(false)){
throw new Exception401("탈퇴한 회원입니다");
}

String accessjwt = MyJwtProvider.createAccess(myUserDetails.getUser());
Pair<String, RefreshTokenEntity> rtInfo = MyJwtProvider.createRefresh(myUserDetails.getUser());

Expand All @@ -97,6 +101,9 @@ public class UserService {
User userPS = userRepository.findById(id).orElseThrow(
() -> new Exception400("id", "해당 유저를 찾을 수 없습니다")
);
if(userPS.getStatus().equals(false)){
throw new Exception401("탈퇴한 회원입니다");
}
return new UserResponse.DetailOutDTO(userPS);
}

Expand All @@ -112,18 +119,20 @@ public class UserService {
public UserResponse.ModifiedOutDTO 개인정보수정(UserRequest.ModifiedInDTO modifiedInDTO, MultipartFile profile, Long id) {
// 1. 아이디로 회원 조회
User user = userRepository.findById(id).orElseThrow(() -> new Exception400("id", "해당 유저가 존재하지 않습니다"));

// 2. 수정사항 없는 경우
// 2. 탈퇴한 회원인 경우
if(user.getStatus().equals(false)){
throw new Exception401("탈퇴한 회원입니다");
}
// 3. 수정사항 없는 경우
if ((profile == null || profile.isEmpty()) &&
(modifiedInDTO.getProfileToDelete() == null || modifiedInDTO.getProfileToDelete().isEmpty()) &&
(user.getEmail().equals(modifiedInDTO.getEmail())) &&
(user.getUsername().equals(modifiedInDTO.getUsername())) &&
(modifiedInDTO.getNewPassword() == null || modifiedInDTO.getNewPassword().isEmpty())){
throw new Exception400("profile, profileToDelete, email, username, newPassword", "수정사항이 없습니다.");
}

boolean isProfileReset = false;
// 3. 프로필 사진 등록 시
// 4. 프로필 사진 등록 시
if (profile != null && !profile.isEmpty()) {
// 서버에 사진 저장
try {
Expand All @@ -134,7 +143,7 @@ public class UserService {
throw new Exception500("프로필사진 변경 실패 : " + e.getMessage());
}
}
// 4. 프로필 사진 삭제 시
// 5. 프로필 사진 삭제 시
if (modifiedInDTO.getProfileToDelete() != null && !modifiedInDTO.getProfileToDelete().equals("https://lupinbucket.s3.ap-northeast-2.amazonaws.com/person.png")) {
try{
s3Service.delete(modifiedInDTO.getProfileToDelete());
Expand All @@ -144,22 +153,22 @@ public class UserService {
throw new Exception500("프로필사진 삭제 실패 : " + e.getMessage());
}
}
// 5. 이메일 주소 변경 시
// 6. 이메일 주소 변경 시
if (user.getEmail() != modifiedInDTO.getEmail()) {
user.changeEmail(modifiedInDTO.getEmail());
}
// 6. 사원명 변경 시
// 7. 사원명 변경 시
if (user.getUsername() != modifiedInDTO.getUsername()) {
user.changeUsername(modifiedInDTO.getUsername());
}
// 7. 비밀번호 변경 시
// 8. 비밀번호 변경 시
boolean isPasswordReset = false;
if (modifiedInDTO.getNewPassword() != null && !modifiedInDTO.getNewPassword().isEmpty()) {
String encodePassword = passwordEncoder.encode(modifiedInDTO.getNewPassword());
user.changePassword(encodePassword);
isPasswordReset = true;
}
// 8. ModifiedOutDTO 생성
// 9. ModifiedOutDTO 생성
return new UserResponse.ModifiedOutDTO(user, isPasswordReset, isProfileReset);
}

Expand All @@ -169,6 +178,10 @@ public class UserService {
public void 연차수정(Long id, UserRequest.AnnualInDTO annualInDTO) {
User userPS = userRepository.findByStatusAndId(true, id)
.orElseThrow(()->new Exception400("id", "해당 유저가 존재하지 않습니다."));
// 탈퇴한 회원인 경우
if(userPS.getStatus().equals(false)){
throw new Exception401("탈퇴한 회원입니다");
}
// 정보 수정
userPS.setRemainDays(annualInDTO.getRemainDays());
}
Expand Down Expand Up @@ -202,6 +215,10 @@ public class UserService {
public void 권한수정(Long id, UserRequest.MasterInDTO masterInDTO) {
User userPS = userRepository.findByStatusAndId(true, id)
.orElseThrow(()->new Exception400("id", "해당 유저가 존재하지 않습니다."));
// 탈퇴한 회원이면 권한 수정 불가
if(userPS.getStatus().equals(false)){
throw new Exception401("탈퇴한 회원입니다");
}
// 정보 수정
userPS.setRole(masterInDTO.getRole());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/docs/admin-api-docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ <h5 id="_curl_9">Curl</h5>
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-05-14 15:20:25 +0900
Last updated 2023-05-14 16:36:56 +0900
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/github.min.css">
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/static/docs/alarm-api-docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ <h5 id="_response_example">Response Example</h5>
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Content-Length: 297
Content-Length: 299

{
"status" : 200,
Expand All @@ -496,7 +496,7 @@ <h5 id="_response_example">Response Example</h5>
"endDate" : "2023-05-19",
"usingDays" : 3,
"status" : "APPROVAL",
"createdAt" : "2023-05-14T15:41:24.4657"
"createdAt" : "2023-05-14T22:51:43.869004"
} ]
}</code></pre>
</div>
Expand Down Expand Up @@ -561,7 +561,7 @@ <h5 id="_curl_2">Curl</h5>
<div id="footer">
<div id="footer-text">
Version 0.0.1-SNAPSHOT<br>
Last updated 2023-05-12 22:44:06 +0900
Last updated 2023-05-14 16:36:56 +0900
</div>
</div>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.15.6/styles/github.min.css">
Expand Down
Loading