package com.aip.gateway.api.service.impl;

import com.aip.gateway.api.aip.model.AipLabel;
import com.aip.gateway.api.aip.model.AipTemplate;
import com.aip.gateway.api.dao.mapper.BaseDbMapper;
import com.aip.gateway.api.model.response.GeneralResponse;
import com.aip.gateway.api.repository.AipFileRepository;
import com.aip.gateway.api.service.IApiAipService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Slf4j
@RequiredArgsConstructor
@Service
public class ApiAipService implements IApiAipService {

    protected final AipFileRepository aipFile;

    @Override
    public GeneralResponse downloadAipInfo() {
        return aipFile.downloadAipInfo();
    }

    @Override
    public List<AipLabel> getLabels() {
        List<AipLabel> result = this.aipFile.getManager().getSensitivityLabels();
//        if (result == null) {
//            return new ArrayList<>();
//        }
        return result;
    }

    @Override
    public List<AipLabel> getPolicies() {
        List<AipLabel> result = this.aipFile.getManager().getPolicySensitivityLabels();
//        if (result == null) {
//            return new ArrayList<>();
//        }
        return result;
    }

    @Override
    public List<AipTemplate> getProtections() {
        List<AipTemplate> result = this.aipFile.getManager().getTemplates();
        if (result == null) {
            return new ArrayList<>();
        }
        return result;
    }

}
