package com.gyee.frame.service.impl.ticket;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gyee.frame.common.exception.TicketException;
import com.gyee.frame.model.ticket.Ibsidgen;
import com.gyee.frame.mapper.ticket.IbsidgenMapper;
import com.gyee.frame.service.ticket.IbsidgenService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chenmh
 * @since 2020-08-13
 */
@Service
public class IbsidgenServiceImpl extends ServiceImpl<IbsidgenMapper, Ibsidgen> implements IbsidgenService {


    @Override
    public Ibsidgen selectId(String table) {
        QueryWrapper<Ibsidgen> wrapper = new QueryWrapper<>();
        wrapper.eq("TABLENAME", table);

        Ibsidgen ibsidgen = baseMapper.selectOne(wrapper);

        return ibsidgen;
    }

    @Transactional
    @Override
    public void updateGen(Ibsidgen gen, double id) {
        gen.setIdvalue(id);
        int result = baseMapper.updateById(gen);

        if (result== 0)
            throw new TicketException("数据更新失败");
    }
}
