package com.zioinfo.signage.controller;

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

@RestController
@RequestMapping("/api/store-groups")
@RequiredArgsConstructor
public class StoreGroupController {
    private final StoreGroupService service;

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

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

    @PostMapping
    public ApiResponse<StoreGroupVo> create(@RequestBody StoreGroupVo v) {
        return ApiResponse.ok("매장그룹 생성 완료", service.create(v));
    }

    @PutMapping("/{id}")
    public ApiResponse<StoreGroupVo> update(@PathVariable Long id, @RequestBody StoreGroupVo v) {
        return ApiResponse.ok("매장그룹 수정 완료", service.update(id, v));
    }

    @DeleteMapping("/{id}")
    public ApiResponse<Void> delete(@PathVariable Long id) {
        service.delete(id);
        return ApiResponse.ok("매장그룹 삭제 완료", null);
    }
}
