package com.devjob.job.controller;

import com.devjob.common.dto.ApiResponse;
import com.devjob.job.dto.CompanyCreateRequest;
import com.devjob.job.dto.CompanyResponse;
import com.devjob.job.service.CompanyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "회사")
@RestController
@RequestMapping("/api/companies")
@RequiredArgsConstructor
public class CompanyController {

    private final CompanyService companyService;

    @Operation(summary = "회사 등록")
    @PostMapping
    public ResponseEntity<ApiResponse<CompanyResponse>> create(@RequestBody @Valid CompanyCreateRequest req) {
        return ResponseEntity.status(HttpStatus.CREATED).body(ApiResponse.ok(companyService.create(req)));
    }

    @Operation(summary = "회사 단건 조회")
    @GetMapping("/{id}")
    public ApiResponse<CompanyResponse> getOne(@PathVariable Long id) {
        return ApiResponse.ok(companyService.findById(id));
    }
}
