-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/in27sung/stock-mate.git
into main_16 Conflicts: stockMate/src/main/java/com/stockm8/controller/HomeController.java stockMate/src/main/webapp/WEB-INF/views/dashboard.jsp stockMate/src/main/webapp/WEB-INF/views/main.jsp
- Loading branch information
Showing
44 changed files
with
1,685 additions
and
1,402 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
stockMate/src/main/java/com/stockm8/controller/ManagerController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.stockm8.controller; | ||
|
||
public class ManagerController { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
stockMate/src/main/java/com/stockm8/controller/api/AdminApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.stockm8.controller.api; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
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.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.SessionAttribute; | ||
|
||
import com.stockm8.domain.dto.UpdateUserStatusDTO; | ||
import com.stockm8.service.UserService; | ||
|
||
@RestController | ||
@RequestMapping("/api/admin") | ||
public class AdminApiController { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(AdminApiController.class); | ||
|
||
@Inject | ||
private UserService userService; | ||
|
||
@PostMapping("/approve") | ||
public ResponseEntity<Map<String, Object>> adminApprove( | ||
@RequestBody UpdateUserStatusDTO updateUserStatusDTO, | ||
@SessionAttribute(value = "userId", required = false) Long sessionUserId) { | ||
|
||
Map<String, Object> response = new HashMap<>(); | ||
|
||
// 세션 값 확인 | ||
if (sessionUserId == null) { | ||
logger.error("Session userId is missing"); | ||
response.put("success", false); | ||
response.put("message", "세션 정보가 없습니다. 다시 로그인해주세요."); | ||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).body(response); | ||
} | ||
|
||
// 세션에서 userId를 DTO에 설정 | ||
updateUserStatusDTO.setUserId(sessionUserId); | ||
|
||
// 입력값 검증 | ||
if (updateUserStatusDTO.getApprovedUserId() == null || updateUserStatusDTO.getUserStatus() == null) { | ||
logger.error("Invalid input: approvedUserId or userStatus is null - DTO: {}", updateUserStatusDTO); | ||
response.put("success", false); | ||
response.put("message", "유효하지 않은 데이터입니다."); | ||
return ResponseEntity.badRequest().body(response); | ||
} | ||
|
||
// 디버깅용 로그 | ||
// logger.info("adminApprove() 호출 - approvedUserId: {}, userStatus: {}, userId: {}", | ||
// updateUserStatusDTO.getApprovedUserId(), | ||
// updateUserStatusDTO.getUserStatus(), | ||
// updateUserStatusDTO.getUserId()); | ||
|
||
try { | ||
// 사용자 상태 변경 | ||
userService.updateUserStatus(updateUserStatusDTO); | ||
|
||
// 성공 응답 | ||
response.put("success", true); | ||
response.put("message", "상태가 성공적으로 업데이트되었습니다."); | ||
return ResponseEntity.ok(response); | ||
} catch (Exception e) { | ||
// 예외 처리 | ||
logger.error("사용자 상태 업데이트 실패", e); | ||
response.put("success", false); | ||
response.put("message", "상태 업데이트 실패. 관리자에게 문의해주세요."); | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response); | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
stockMate/src/main/java/com/stockm8/controller/api/ManagerApiController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.stockm8.controller.api; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
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.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.bind.annotation.SessionAttribute; | ||
|
||
import com.stockm8.domain.dto.UpdateUserStatusDTO; | ||
import com.stockm8.service.UserService; | ||
|
||
@RestController | ||
@RequestMapping("/api/manager") | ||
public class ManagerApiController { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(ManagerApiController.class); | ||
|
||
@Autowired | ||
private UserService userService; | ||
|
||
@PostMapping("/approve") | ||
public ResponseEntity<Map<String, Object>> approveStaff( | ||
@RequestBody UpdateUserStatusDTO updateUserStatusDTO, | ||
@SessionAttribute("userId") Long sessionUserId) { | ||
|
||
Map<String, Object> response = new HashMap<>(); | ||
|
||
// 세션에서 Manager ID를 DTO에 설정 | ||
updateUserStatusDTO.setUserId(sessionUserId); | ||
|
||
// 입력값 검증 | ||
if (updateUserStatusDTO.getApprovedUserId() == null || updateUserStatusDTO.getUserStatus() == null) { | ||
response.put("success", false); | ||
response.put("message", "유효하지 않은 데이터입니다."); | ||
return ResponseEntity.badRequest().body(response); | ||
} | ||
|
||
// 직원 승인 처리 | ||
userService.updateUserStatus(updateUserStatusDTO);; | ||
|
||
response.put("success", true); | ||
response.put("message", "직원이 성공적으로 승인되었습니다."); | ||
return ResponseEntity.ok(response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
stockMate/src/main/java/com/stockm8/domain/dto/UpdateUserStatusDTO.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.stockm8.domain.dto; | ||
|
||
import com.stockm8.domain.enums.UserStatus; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class UpdateUserStatusDTO { | ||
|
||
private Long approvedUserId; // 승인받는 사용자 ID | ||
|
||
private UserStatus userStatus; // Enum으로 상태값 처리 | ||
|
||
private Long userId; // 승인 작업을 수행하는 관리자 ID | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.