package com.test.test.service.impl;

import java.util.List;

import com.test.common.utils.DateUtils;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import com.test.test.mapper.TestDatasourceMapper;
import com.test.test.domain.TestDatasource;
import com.test.test.service.ITestDatasourceService;

/**
 * 数据源Service业务层处理
 */
@Service
public class TestDatasourceServiceImpl implements ITestDatasourceService {
    @Resource
    private TestDatasourceMapper testDatasourceMapper;

    /**
     * 查询数据源
     *
     * @param id 数据源主键
     * @return 数据源
     */
    @Override
    public TestDatasource selectTestDatasourceById(Long id) {
        return testDatasourceMapper.selectTestDatasourceById(id);
    }

    /**
     * 查询数据源列表
     */
    @Override
    public List<TestDatasource> selectTestDatasourceList() {
        return testDatasourceMapper.selectTestDatasourceList();
    }

    /**
     * 新增数据源
     */
    @Override
    public TestDatasource insertTestDatasource(TestDatasource testDatasource) {
        testDatasource.setCreateTime(DateUtils.getNowDate());
        testDatasourceMapper.insertTestDatasource(testDatasource);
        return testDatasource;
    }

    /**
     * 修改数据源
     */
    @Override
    public int updateTestDatasource(TestDatasource testDatasource) {
        testDatasource.setUpdateTime(DateUtils.getNowDate());
        return testDatasourceMapper.updateTestDatasource(testDatasource);
    }

    /**
     * 批量删除数据源
     */
    @Override
    public int deleteTestDatasourceByIds(Long[] ids) {
        return testDatasourceMapper.deleteTestDatasourceByIds(ids);
    }

    /**
     * 删除数据源信息
     */
    @Override
    public int deleteTestDatasourceById(Long id) {
        return testDatasourceMapper.deleteTestDatasourceById(id);
    }
}
