package com.zioinfo.signage.controller;

import com.zioinfo.signage.common.ApiResponse;
import com.zioinfo.signage.domain.SignImageVo;
import com.zioinfo.signage.service.SignImageService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/sign-images")
@RequiredArgsConstructor
public class SignImageController {
    private final SignImageService service;

    @GetMapping
    public ApiResponse<List<SignImageVo>> list(
            @RequestParam(required = false) String tenantCode,
            @RequestParam(required = false) String status,
            @RequestParam(required = false) String keyword) {
        return ApiResponse.ok(service.list(tenantCode, status, keyword));
    }

    @GetMapping("/{id}")
    public ApiResponse<SignImageVo> get(@PathVariable Long id) {
        return ApiResponse.ok(service.get(id));
    }

    @PostMapping
    public ApiResponse<SignImageVo> create(@RequestBody SignImageVo v) {
        return ApiResponse.ok("간판 이미지 생성 완료", service.create(v));
    }

    @PutMapping("/{id}")
    public ApiResponse<SignImageVo> update(@PathVariable Long id, @RequestBody SignImageVo v) {
        return ApiResponse.ok("간판 이미지 수정 완료", service.update(id, v));
    }

    @DeleteMapping("/{id}")
    public ApiResponse<Void> delete(@PathVariable Long id) {
        service.delete(id);
        return ApiResponse.ok("간판 이미지 삭제 완료", null);
    }
}
