package com.zioinfo.signage.controller;

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

@RestController
@RequestMapping("/api/ad-schedules")
@RequiredArgsConstructor
public class AdScheduleController {
    private final AdScheduleService service;

    @GetMapping
    public ApiResponse<List<AdScheduleVo>> 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<AdScheduleVo> get(@PathVariable Long id) {
        return ApiResponse.ok(service.get(id));
    }

    @PostMapping
    public ApiResponse<AdScheduleVo> create(@RequestBody AdScheduleVo v) {
        return ApiResponse.ok("광고 스케줄 생성 완료", service.create(v));
    }

    @PutMapping("/{id}")
    public ApiResponse<AdScheduleVo> update(@PathVariable Long id, @RequestBody AdScheduleVo v) {
        return ApiResponse.ok("광고 스케줄 수정 완료", service.update(id, v));
    }

    @DeleteMapping("/{id}")
    public ApiResponse<Void> delete(@PathVariable Long id) {
        service.delete(id);
        return ApiResponse.ok("광고 스케줄 삭제 완료", null);
    }
}
