package com.iformall.service.impl;

import java.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.PosActionLog;
import com.iformall.mapper.PosActionLogMapper;
import com.iformall.service.PosActionLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

@Service
public class PosActionLogServiceImpl implements PosActionLogService {
	
	@Autowired
    PosActionLogMapper posActionLogMapper;


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

    @Override
    public PosActionLog getById(Long id) {
        return posActionLogMapper.selectById(id);
    }

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

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