package com.ozs.mdm.service.impl;

import com.ozs.mdm.dto.MdmInfoDataSourceInterfaceProjectDTO;
import com.ozs.mdm.mapper.InterfaceDataProjectMapper;
import com.ozs.mdm.service.InterfaceProjectService;
import com.ozs.mdm.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InterfaceProjectServiceImpl implements InterfaceProjectService {
    @Autowired
    private InterfaceDataProjectMapper interfaceDataProjectMapper;

    @Override
    public R<List<MdmInfoDataSourceInterfaceProjectDTO>> listInterfaceProject(String projectName,  String sort, String order,
                                                                           Integer page, Integer pageSize) throws Exception {

        R<MdmInfoDataSourceInterfaceProjectDTO> r = new R<>();
        r.pageStart(sort, order, page, pageSize);
        List<MdmInfoDataSourceInterfaceProjectDTO> resultList =  this.interfaceDataProjectMapper.listInterfaceProject(projectName);
        return r.page(resultList);
    }

    @Override
    public void addInterfaceProject(MdmInfoDataSourceInterfaceProjectDTO mdmInfoDataSourceInterfaceProjectDTO) {
        this.interfaceDataProjectMapper.addInterfaceProject(mdmInfoDataSourceInterfaceProjectDTO);
    }

    @Override
    public void updateInterfaceProjectById(MdmInfoDataSourceInterfaceProjectDTO mdmInfoDataSourceInterfaceProjectDTO) {
        this.interfaceDataProjectMapper.updateInterfaceProjectById(mdmInfoDataSourceInterfaceProjectDTO);
    }

    @Override
    public void deleteInterfaceProject(String projectId) {
        this.interfaceDataProjectMapper.deleteInterfaceProject(projectId);
    }

    @Override
    public MdmInfoDataSourceInterfaceProjectDTO getInterfaceProjectById(String projectId) {
        return interfaceDataProjectMapper.getInterfaceProjectById(projectId);
    }
}
