package com.yimeng.okr.controller;

import com.yimeng.okr.dto.ApiResult;
import com.yimeng.okr.dto.WorkspaceOverviewDto;
import com.yimeng.okr.security.SecurityUtils;
import com.yimeng.okr.service.WorkspaceService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/workspace")
@RequiredArgsConstructor
public class WorkspaceController {

    private final WorkspaceService workspaceService;

    @GetMapping("/overview")
    public ApiResult<WorkspaceOverviewDto> overview(@RequestParam(required = false) Long periodId) {
        Long userId = SecurityUtils.getCurrentUserId();
        return ApiResult.success(workspaceService.getOverview(userId, periodId));
    }
}
