package com.example.demo.controller;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import com.example.demo.dto.UserDto;
import com.example.demo.service.UserService;

@RestController
@RequestMapping("/api/admin")
public class AdminController {

	private final UserService userService;

	public AdminController(UserService userService) {
		this.userService = userService;
	}

	@PostMapping("/users/{id}/ban")
	public ResponseEntity<UserDto> banUser(@PathVariable Integer id) {
		return new ResponseEntity<>(userService.banUser(id), HttpStatus.OK);
	}

	@PostMapping("/users/{id}/unban")
	public ResponseEntity<UserDto> unbanUser(@PathVariable Integer id) {
		return new ResponseEntity<>(userService.unbanUser(id), HttpStatus.OK);
	}

	@PostMapping("/users/{id}/make-admin")
	public ResponseEntity<UserDto> makeAdmin(@PathVariable Integer id) {
		return new ResponseEntity<>(userService.makeAdmin(id), HttpStatus.OK);
	}

	@PostMapping("/users/{id}/make-user")
	public ResponseEntity<UserDto> makeUser(@PathVariable Integer id) {
		return new ResponseEntity<>(userService.makeUser(id), HttpStatus.OK);
	}
}
