package com.persagy.dmp.rwd.migrate.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.persagy.dmp.rwd.migrate.dao.SyncDataMapper;
import com.persagy.dmp.rwd.migrate.entity.SyncData;
import com.persagy.dmp.rwd.migrate.service.ISyncDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author lvxianyun
 * @title: SyncDataServiceImpl
 * @projectName digital-twin
 * @description: 数据迁移日志入库
 * @date 2021/12/20 15:42
 */

@Slf4j
@Transactional(rollbackFor = Exception.class)
@Service
public class SyncDataServiceImpl extends ServiceImpl<SyncDataMapper, SyncData> implements ISyncDataService {
    @Autowired
    private SyncDataMapper syncDataMapper;


    /**
     * 添加迁移日志
     * @param voList 待修改数据
     * @return
     */
    @Override
    public List<SyncData> save(List<SyncData> voList) throws Exception {
        //修改采集信息点
        syncDataMapper.save(voList);
        return voList;
    }

    /**
     * 按条件查询
     *
     * @param queryWrapper 查询条件
     * @return 返回结果
     */
    @Override
    public List<SyncData> queryByCondition(Wrapper<SyncData> queryWrapper) {
        return syncDataMapper.selectList(queryWrapper);
    }

    /**
     * 分页条件查询
     *
     * @param page         分页条件
     * @param queryWrapper 查询条件
     * @return 分页结果
     */
    @Override
    public Page queryByCondition(Page page, Wrapper<SyncData> queryWrapper) {
        return syncDataMapper.selectPage(page, queryWrapper);
    }
}
