package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PosMallConfig;
import com.iformall.mapper.PosMallConfigMapper;
import com.iformall.service.PosMallConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

@Service
public class PosMallConfigServiceImpl implements PosMallConfigService {
	
	@Autowired
    PosMallConfigMapper posMallConfigMapper;


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

    @Override
    public PosMallConfig getById(Long id) {
        return posMallConfigMapper.selectById(id);
    }

    @Override
    public PosMallConfig getByTenantId(String id) {
        PosMallConfig config =  posMallConfigMapper.getByTenantId(id);
        return config;
    }

    @Override
    public void saveOrUpdate(PosMallConfig record) {
        if (record.getId() == null) {
            //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
            posMallConfigMapper.insert(record);
        } else {
            posMallConfigMapper.updateById(record);
        }
    }

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