package com.arms.api.report.rolling3m.assignee.controller;

import com.arms.api.report.rolling3m.assignee.model.dto.Rolling3mDTO;
import com.arms.api.report.rolling3m.assignee.model.vo.AssigneeInfo;
import com.arms.api.report.rolling3m.assignee.service.AssigneeService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.http.ResponseEntity;
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;

import java.util.List;

@RestController
@RequestMapping("/assignees/rolling3m")
@AllArgsConstructor
@Slf4j
public class Rolling3mAssigneeController {

    private final AssigneeService assigneeService;

    @PostMapping
    public ResponseEntity<List<AssigneeInfo>> rolling3mAssigneeList(@RequestBody Rolling3mDTO rolling3mDTO) {

        if (rolling3mDTO.getPdServiceId() == null || ObjectUtils.isEmpty(rolling3mDTO.getPdServiceVersions())) {
            log.warn("Rolling3mReportController :: selectRolling3mAssigneeList | 제품/서비스 아이디 또는 버전 정보가 없습니다.");
            return ResponseEntity.badRequest().build();
        }
        return ResponseEntity.ok(assigneeService.selectRolling3mAssigneeList(rolling3mDTO));
    }
}
