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.define.entity.RelationDefine;
import com.persagy.dmp.rwd.define.dao.RelationDefineMapper;
import com.persagy.dmp.rwd.define.service.IRelationDefineService;
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 RelationDefineServiceImpl implements IRelationDefineService {

    @Resource
    private RelationDefineMapper dao;

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

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

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

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

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

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