package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.MallUserAction;
import com.iformall.mapper.MallUserActionMapper;
import com.iformall.service.MallUserActionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

@Service
public class MallUserActionServiceImpl implements MallUserActionService {
	
	@Autowired
    MallUserActionMapper mallUserActionMapper;

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

    @Override
    public MallUserAction getById(Long id) {
        return mallUserActionMapper.selectByPrimaryKey(id);
    }

    @Override
    public void saveOrUpdate(MallUserAction record) {
        if (record.getId() == null) {
            //record.setId(UUID.randomUUID().toString().replaceAll("-", ""));
            final IdWorker idWorker = IdWorker.get();
        	record.setId(idWorker.nextId());
            mallUserActionMapper.insertSelective(record);
        } else {
            mallUserActionMapper.updateByPrimaryKeySelective(record);
        }
    }

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