package com.oguerreiro.resilient.web.rest;

import java.net.URISyntaxException;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.oguerreiro.resilient.domain.ContentPage;
import com.oguerreiro.resilient.repository.ContentPageRepository;
import com.oguerreiro.resilient.service.ContentPageService;
import com.oguerreiro.resilient.service.dto.ContentPageDTO;

import jakarta.validation.Valid;

/**
 * REST controller for managing {@link com.oguerreiro.resilient.domain.ContentPage}.
 */
@RestController
@RequestMapping("/api/content-pages")
public class ContentPageResource extends AbstractResilientResource<ContentPage, ContentPageDTO, Long> {

  private static final String ENTITY_NAME = "contentPage";

  public ContentPageResource(ContentPageRepository contentPageRepository, ContentPageService contentPageService) {
    super(ContentPage.class, contentPageRepository, contentPageService);
  }

  /* Abstract methods impl*/
  @Override
  protected String getEntityName() {
    return ENTITY_NAME;
  }

  /* Override endpoints */
  /**
   * {@code DELETE  /content-pages/:id} : delete entity by the "id".
   * UNSUPPORTED. CANT DELETE CONTENTPAGE.
   */
  @Override
  @PreAuthorize("@resilientSecurity.canAccess()")
  @DeleteMapping("/{id}")
  public ResponseEntity<Void> delete(Long id) {
    log.debug("REST request to delete : {}", id);
    throw new UnsupportedOperationException();
  }

  /**
   * {@code POST  /content-pages} : Create a new entity.
   * UNSUPPORTED. CANT CREATE NEW CONTENTPAGE.
   */
  @Override
  @PreAuthorize("@resilientSecurity.canAccess()")
  @PostMapping("")
  public ResponseEntity<ContentPageDTO> create(@Valid ContentPageDTO domainDTO) throws URISyntaxException {
    log.debug("REST request to create : {}", domainDTO);
    throw new UnsupportedOperationException();
  }

  /* DashboardResource endpoints */
}
