73 lines
2.7 KiB
Java
73 lines
2.7 KiB
Java
|
|
package com.dog.dognation.admin;
|
||
|
|
|
||
|
|
import com.dog.dognation.admin.dto.MemberAdminResponse;
|
||
|
|
import com.dog.dognation.admin.dto.RoleUpdateRequest;
|
||
|
|
import com.dog.dognation.admin.dto.StatusUpdateRequest;
|
||
|
|
import com.dog.dognation.admin.dto.TierUpdateRequest;
|
||
|
|
import com.dog.dognation.auth.SessionUser;
|
||
|
|
import com.dog.dognation.auth.web.AuthInterceptor;
|
||
|
|
import jakarta.validation.Valid;
|
||
|
|
import org.springframework.http.ResponseEntity;
|
||
|
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
||
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
||
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RequestAttribute;
|
||
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
||
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 관리자용 회원 관리 API. (/api/admin/members — AdminInterceptor 로 ADMIN 만 접근)
|
||
|
|
* 관리자 페이지는 웹 전용.
|
||
|
|
*/
|
||
|
|
@RestController
|
||
|
|
@RequestMapping("/api/admin/members")
|
||
|
|
public class MemberAdminController {
|
||
|
|
|
||
|
|
private final MemberAdminService memberAdminService;
|
||
|
|
|
||
|
|
public MemberAdminController(MemberAdminService memberAdminService) {
|
||
|
|
this.memberAdminService = memberAdminService;
|
||
|
|
}
|
||
|
|
|
||
|
|
@GetMapping
|
||
|
|
public List<MemberAdminResponse> list() {
|
||
|
|
return memberAdminService.list();
|
||
|
|
}
|
||
|
|
|
||
|
|
@PutMapping("/{id}/status")
|
||
|
|
public MemberAdminResponse updateStatus(
|
||
|
|
@PathVariable Long id,
|
||
|
|
@Valid @RequestBody StatusUpdateRequest req,
|
||
|
|
@RequestAttribute(AuthInterceptor.CURRENT_MEMBER) SessionUser current) {
|
||
|
|
return memberAdminService.updateStatus(id, req.status(), current.id());
|
||
|
|
}
|
||
|
|
|
||
|
|
@PutMapping("/{id}/tier")
|
||
|
|
public MemberAdminResponse updateTier(
|
||
|
|
@PathVariable Long id,
|
||
|
|
@Valid @RequestBody TierUpdateRequest req,
|
||
|
|
@RequestAttribute(AuthInterceptor.CURRENT_MEMBER) SessionUser current) {
|
||
|
|
return memberAdminService.updateTier(id, req.tier(), current.id());
|
||
|
|
}
|
||
|
|
|
||
|
|
@PutMapping("/{id}/role")
|
||
|
|
public MemberAdminResponse updateRole(
|
||
|
|
@PathVariable Long id,
|
||
|
|
@Valid @RequestBody RoleUpdateRequest req,
|
||
|
|
@RequestAttribute(AuthInterceptor.CURRENT_MEMBER) SessionUser current) {
|
||
|
|
return memberAdminService.updateRole(id, req.role(), current.id());
|
||
|
|
}
|
||
|
|
|
||
|
|
@DeleteMapping("/{id}")
|
||
|
|
public ResponseEntity<Void> delete(
|
||
|
|
@PathVariable Long id,
|
||
|
|
@RequestAttribute(AuthInterceptor.CURRENT_MEMBER) SessionUser current) {
|
||
|
|
memberAdminService.delete(id, current.id());
|
||
|
|
return ResponseEntity.noContent().build();
|
||
|
|
}
|
||
|
|
}
|