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

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.persagy.dmp.common.constant.ValidEnum;
import com.persagy.dmp.rwd.define.dao.GraphDefineMapper;
import com.persagy.dmp.rwd.define.service.IGraphDefineService;
import com.persagy.dmp.define.entity.GraphDefine;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 图定义 实现类
 * @author Charlie Yu
 * @date 2021-06-25
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class GraphDefineServiceImpl implements IGraphDefineService {

    @Resource
    private GraphDefineMapper dao;

    @Override
    public List<GraphDefine> queryByCondition(Wrapper<GraphDefine> queryWrapper) {
        return dao.selectList(queryWrapper);
    }

    @Override
    public Integer queryCount(Wrapper<GraphDefine> queryWrapper) {
        return dao.selectCount(queryWrapper);
    }

    @Override
    public Page queryByCondition(Page page, Wrapper<GraphDefine> queryWrapper) {
        return dao.selectPage(page, queryWrapper);
    }

    @Override
    public GraphDefine insert(GraphDefine vo) {
        dao.insert(vo);
        return vo;
    }

    @Override
    public GraphDefine update(GraphDefine vo) {
        dao.updateById(vo);
        return vo;
    }

    @Override
    public void delete(String id) {
        GraphDefine vo = dao.selectById(id);
        vo.setValid(ValidEnum.FALSE.getType());
        dao.updateById(vo);
    }
}
