package com.iformall.service.impl;

import java.util.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.domain.po.WxTags;
import com.iformall.mapper.WxTagsMapper;
import com.iformall.service.WxTagsService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iformall.common.IdWorker;

@Service
public class WxTagsServiceImpl implements WxTagsService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxTagsMapper wxTagsMapper;


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

    @Override
    public WxTags getById(Long id) {
        return wxTagsMapper.selectByPrimaryKey(id);
    }

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

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

    @Override
    public List<WxTags> findList(WxTags wxTags) {
        return wxTagsMapper.findList(wxTags);
    }
}
