Admin 권한

This commit is contained in:
dyhj625 2025-03-17 12:06:33 +09:00
parent 778ffb5edf
commit e9f4cb2fc5
4 changed files with 28 additions and 47 deletions

View File

@ -39,24 +39,32 @@ public class AdminController {
private final NetmemberService netmemberService;
/**
* 사원 리스트
* @return 사원 리스트
*/
@Member
@ParameterCheck
@GetMapping("/users")
public ApiResponse<List<MapDto>> getAllUsers() {
List<MapDto> response = netmemberService.getallUserList();
public ApiResponse<List<MapDto>> selectallUserList() {
List<MapDto> response = netmemberService.selectallUserList();
return ApiResponse.ok(response);
}
/**
* 관리자 권한 수정
* @ReqMap map 요청 파라미터 (MEMBERROL, MEMBERSEQ)
* @return 결과 메시지
*/
@Member
@ParameterCheck
@PutMapping("/role")
public ApiResponse<String> updateUserRole(@ReqMap MapDto map) {
// 요청 데이터에서 id와 role 추출
Long id = Long.valueOf(map.get("id").toString());
String role = map.get("role").toString();
// 역할 변환
String newRole = role.equalsIgnoreCase("ADMIN") ? "ROLE_ADMIN" : "ROLE_USER";
String newRole = role.equalsIgnoreCase("ADMIN") ? "ROLE_ADMIN" : "ROLE_MEMBER";
// 권한 업데이트 서비스 호출
netmemberService.updateUserRole(id, newRole);
return ApiResponse.ok("관리자 권한이 변경되었습니다.");

View File

@ -229,7 +229,7 @@ public class BoardController {
/**
* 댓글 조회
* @ReqMap map 수정 데이터 (LOCBRDSEQ)
* @ReqMap map 수정 데이터 (LOCBRDSEQ, page)
* @return 댓글
*/
@Member
@ -245,7 +245,7 @@ public class BoardController {
/**
* 대댓글 조회
* @ReqMap map 수정 데이터 (LOCBRDSEQ)
* @ReqMap map 수정 데이터 (LOCCMTPNT)
* @return 대댓글
*/
@Member
@ -383,7 +383,7 @@ public class BoardController {
* @return 카테고리 리스트
*/
@GetMapping("/categories")
public ApiResponse<List<MapDto>> getCategories() {
public ApiResponse<List<MapDto>> SelectCategories() {
List<MapDto> categories = commoncodService.selectCategoryList();
return ApiResponse.ok(categories);
}

View File

@ -229,23 +229,21 @@ public class localbordService {
return boardMapper.selectCountCommentReactions(boardId);
}
private String procFirstImageUrl(String jsonContent) {
public static String procFirstImageUrl(String jsonContent) {
try {
// JSON 유효성 검사
if (!procIsValidJson(jsonContent)) {
throw new IllegalArgumentException("Invalid JSON content: " + jsonContent);
}
ObjectMapper objectMapper = new ObjectMapper();
JsonNode rootNode = objectMapper.readTree(jsonContent);
// JSON 배열 순회
for (JsonNode node : rootNode) {
// "ops" 배열 가져오기
JsonNode opsNode = rootNode.get("ops");
if (opsNode != null && opsNode.isArray()) {
for (JsonNode node : opsNode) {
JsonNode insertNode = node.get("insert");
if (insertNode != null && insertNode.has("image")) {
return insertNode.get("image").asText(); // 번째 이미지 URL 반환
}
}
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Failed to extract first image URL: " + e.getMessage(), e);

View File

@ -65,30 +65,6 @@
)
</insert>
<!-- 멀티 첨부파일 저장 -->
<insert id="insertAttachments" parameterType="map">
INSERT INTO commonfil (
CMNBRDSEQ,
CMNFLENAM,
CMNFLEORG,
CMNFLEPAT,
CMNFLEEXT,
CMNFLESIZ,
CMNFLEREG,
CMNFLERDT
) VALUES
<foreach collection="list" item="item" index="index" open="(" separator="),(" close=")">
#{LOCBRDSEQ},
#{item.saveFileName},
#{item.originalFileName},
#{item.filePath},
#{item.extension},
#{item.fileSize},
#{CMNFLEREG},
NOW()
</foreach>
</insert>
<!-- 게시물 상세정보 조회 -->
<select id="selectBoardDetail" resultType="io.company.localhost.common.dto.MapDto">
SELECT
@ -162,7 +138,7 @@
<select id="selectComments" resultType="io.company.localhost.common.dto.MapDto">
SELECT
c.LOCCMTSEQ,c.LOCBRDSEQ,c.LOCCMTPNT,c.LOCCMTRPY,
c.LOCCMTUDT,c.LOCCMTPWD,c.LOCCMTRDT,c.LOCCMTPNT,
c.LOCCMTUDT,c.LOCCMTPWD,c.LOCCMTRDT,
m.MEMBERNAM AS author,
m.MEMBERSEQ AS authorId
FROM localcomt c
@ -177,8 +153,7 @@
c.LOCCMTSEQ,c.LOCBRDSEQ,c.LOCCMTPNT,c.LOCCMTRPY,
c.LOCCMTUDT,c.LOCCMTPWD,c.LOCCMTRDT,c.LOCCMTPNT,
m.MEMBERNAM AS author,
m.MEMBERSEQ AS authorId,
m.MEMBERPRF as profileImg
m.MEMBERSEQ AS authorId
FROM localcomt c
LEFT JOIN netmember m ON c.MEMBERSEQ = m.MEMBERSEQ
WHERE LOCCMTPNT = #{LOCCMTPNT} and LOCCMTPNT != 1