package com.qqchen.deploy.backend.deploy.api;

import com.qqchen.deploy.backend.deploy.dto.ServerCategoryDTO;
import com.qqchen.deploy.backend.deploy.entity.ServerCategory;
import com.qqchen.deploy.backend.deploy.query.ServerCategoryQuery;
import com.qqchen.deploy.backend.deploy.service.IServerCategoryService;
import com.qqchen.deploy.backend.framework.api.Response;
import com.qqchen.deploy.backend.framework.controller.BaseController;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
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;
import java.util.concurrent.CompletableFuture;

/**
 * 服务器分类 Controller
 */
@Slf4j
@RestController
@RequestMapping("/api/v1/server-category")
@Tag(name = "服务器分类管理", description = "服务器分类管理相关接口")
public class ServerCategoryApiController
    extends BaseController<ServerCategory, ServerCategoryDTO, Long, ServerCategoryQuery> {

    @Resource
    private IServerCategoryService serverCategoryService;

    @Override
    public Response<ServerCategoryDTO> create(@Validated @RequestBody ServerCategoryDTO dto) {
        return super.create(dto);
    }

    @Override
    public Response<ServerCategoryDTO> update(@PathVariable Long id, @Validated @RequestBody ServerCategoryDTO dto) {
        return super.update(id, dto);
    }

    @Override
    public Response<Void> delete(@PathVariable Long id) {
        return super.delete(id);
    }

    @Override
    public Response<ServerCategoryDTO> findById(@PathVariable Long id) {
        return super.findById(id);
    }

    @Override
    public Response<List<ServerCategoryDTO>> findAll() {
        return super.findAll();
    }

    @Override
    public Response<Page<ServerCategoryDTO>> page(ServerCategoryQuery query) {
        return super.page(query);
    }

    @Override
    public Response<List<ServerCategoryDTO>> findAll(ServerCategoryQuery query) {
        return super.findAll(query);
    }

    @Override
    public CompletableFuture<Response<Void>> batchProcess(List<ServerCategoryDTO> dtos) {
        return super.batchProcess(dtos);
    }

    @Override
    protected void exportData(HttpServletResponse response, List<ServerCategoryDTO> data) {
        log.info("导出服务器分类数据，数据量：{}", data.size());
    }
}

