package com.iformall.service.sys.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.MallSaleType;
import com.iformall.mapper.MallSaleTypeMapper;
import com.iformall.service.sys.MallSaleTypeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MallSaleTypeServiceImpl implements MallSaleTypeService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    MallSaleTypeMapper mallSaleTypeMapper;

    @Override
    public PageInfo<MallSaleType> listAsPage(MallSaleType record, Integer pageIndex, Integer pageSize) {
        return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> mallSaleTypeMapper.findList(record));
    }

    @Override
    public List<MallSaleType> getList(MallSaleType record) {
        return mallSaleTypeMapper.findList(record);
    }

    @Override
    public MallSaleType getById(Long id) {
        return mallSaleTypeMapper.selectById(id);
    }

    @Override
    public void saveOrUpdate(MallSaleType record) {
        if (record.getId() == null) {
            final IdWorker idWorker = IdWorker.get();
            record.setId(idWorker.nextId());
            mallSaleTypeMapper.insert(record);
        } else {
            mallSaleTypeMapper.updateById(record);
        }
    }

    @Override
    public void deleteById(Long id) {
        mallSaleTypeMapper.deleteById(id);
    }
    
}
