package com.inkasso.factoring.common.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.inkasso.factoring.common.dao.SystemSerialNumMapper;
import com.inkasso.factoring.common.entity.SystemSerialNum;
import com.inkasso.factoring.common.service.SystemSerialNumService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class SystemSerialNumServiceImpl extends ServiceImpl<SystemSerialNumMapper,SystemSerialNum> implements SystemSerialNumService {

    @Autowired
    private SystemSerialNumMapper sysSerialNumMapper;

    @Override
    public SystemSerialNum add(SystemSerialNum sysSerialNum) {
        sysSerialNumMapper.insert(sysSerialNum);
        return get(sysSerialNum.getId());
    }

    @Override
    public SystemSerialNum update(SystemSerialNum sysSerialNum) {
        if (null != sysSerialNum && null != sysSerialNum.getId()) {
            sysSerialNumMapper.updateById(sysSerialNum);
        }
        return get(sysSerialNum.getId());
    }

    @Override
    public SystemSerialNum get(Long id) {
        return sysSerialNumMapper.selectById(id);
    }

    @Override
    public SystemSerialNum getByName(String name) {
        return sysSerialNumMapper.getByName(name);
    }
}
