Merge branch 'main' of
http://192.168.0.251:3000/localnet/localhost-back.git into main
This commit is contained in:
commit
558e732f62
@ -36,6 +36,7 @@ public class MapBasedUrlRoleMapper implements UrlRoleMapper{
|
|||||||
urlRoleMappings.put("/api/worddict/**", PERMIT_ALL);
|
urlRoleMappings.put("/api/worddict/**", PERMIT_ALL);
|
||||||
urlRoleMappings.put("/api/quilleditor/**", PERMIT_ALL);
|
urlRoleMappings.put("/api/quilleditor/**", PERMIT_ALL);
|
||||||
urlRoleMappings.put("/api/commuters/**", PERMIT_ALL);
|
urlRoleMappings.put("/api/commuters/**", PERMIT_ALL);
|
||||||
|
urlRoleMappings.put("/api/admin/**", PERMIT_ALL);
|
||||||
return new HashMap<>(urlRoleMappings);
|
return new HashMap<>(urlRoleMappings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
/************************************************************
|
||||||
|
*
|
||||||
|
* @packageName : io.company.localhost.controller.api
|
||||||
|
* @fileName : AdminController.java
|
||||||
|
* @author : 서지희
|
||||||
|
* @date : 25.03.14
|
||||||
|
* @description : 게시판
|
||||||
|
*
|
||||||
|
* ===========================================================
|
||||||
|
* DATE AUTHOR NOTE
|
||||||
|
* -----------------------------------------------------------
|
||||||
|
* 25.03.14 서지희 최초 생성
|
||||||
|
*
|
||||||
|
*************************************************************/
|
||||||
|
package io.company.localhost.controller.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import io.company.localhost.common.annotation.Member;
|
||||||
|
import io.company.localhost.common.annotation.ParameterCheck;
|
||||||
|
import io.company.localhost.common.annotation.ReqMap;
|
||||||
|
import io.company.localhost.common.dto.ApiResponse;
|
||||||
|
import io.company.localhost.common.dto.MapDto;
|
||||||
|
import io.company.localhost.service.NetmemberService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/admin")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class AdminController {
|
||||||
|
|
||||||
|
private final NetmemberService netmemberService;
|
||||||
|
|
||||||
|
@Member
|
||||||
|
@ParameterCheck
|
||||||
|
@GetMapping("/users")
|
||||||
|
public ApiResponse<List<MapDto>> getAllUsers() {
|
||||||
|
List<MapDto> response = netmemberService.getallUserList();
|
||||||
|
return ApiResponse.ok(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@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";
|
||||||
|
|
||||||
|
// 권한 업데이트 서비스 호출
|
||||||
|
netmemberService.updateUserRole(id, newRole);
|
||||||
|
|
||||||
|
return ApiResponse.ok("관리자 권한이 변경되었습니다.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -44,4 +44,6 @@ public interface NetmemberMapper {
|
|||||||
|
|
||||||
List<MapDto> selectallUserList();
|
List<MapDto> selectallUserList();
|
||||||
|
|
||||||
|
void updateUserRole(Long id, String role);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -123,6 +123,16 @@ public class NetmemberService {
|
|||||||
return memberMapper.selectallUserList();
|
return memberMapper.selectallUserList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 사원 권한 업데이트
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void updateUserRole(Long id, String newRole) {
|
||||||
|
memberMapper.updateUserRole(id, newRole);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 로그인 토큰
|
* 로그인 토큰
|
||||||
*
|
*
|
||||||
|
|||||||
@ -152,4 +152,8 @@
|
|||||||
m.MEMBERLEA ="N"
|
m.MEMBERLEA ="N"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<update id="updateUserRole">
|
||||||
|
UPDATE netmember SET MEMBERROL = #{role} WHERE MEMBERSEQ = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user