package com.boman.web.core.service.ip;

import com.boman.domain.IpColumns;
import com.boman.domain.IpTimes;
import com.boman.web.core.mapper.IpColumnsMapper;
import com.boman.web.core.mapper.IpTimesMapper;
import com.boman.web.core.utils.AuthUtils;
import org.springframework.stereotype.Service;

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

/**
 * @author shiqian
 * @date 2022年01月24日 11:15
 **/
@Service
public class IpColumnsServiceImpl implements IpColumnsService {

    @Resource
    private IpColumnsMapper mapper;

    @Override
    public List<IpColumns> list(IpColumns ipColumns) {
        return mapper.list(ipColumns);
    }

    @Override
    public IpColumns getById(Long id) {
        return mapper.getById(id);
    }

    @Override
    public int saveOrUpdate(IpColumns ipColumns) {
        String userName = AuthUtils.getLoginUser().getSysUser().getUserName();
        Long id = ipColumns.getId();
        ipColumns.setUpdateBy(userName);

        if (null == id) {
            ipColumns.setCreateBy(userName);
            return mapper.save(ipColumns);
        }

        return mapper.update(ipColumns);
    }

    @Override
    public int delete(Long id) {
        return mapper.delete(id);
    }
}
