package com.iformall.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.WxTagsType;
import com.iformall.mapper.WxTagsTypeMapper;
import com.iformall.service.WxTagsTypeService;
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 WxTagsTypeServiceImpl implements WxTagsTypeService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
	
	@Autowired
    WxTagsTypeMapper wxTagsTypeMapper;


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

    @Override
    public WxTagsType getById(Long id) {
        return wxTagsTypeMapper.selectById(id);
    }

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

    @Override
    public void deleteById(Long id) {
        wxTagsTypeMapper.deleteById(id);
    }
    @Override
    public List<WxTagsType> findList(WxTagsType wxTagsType) {
        return wxTagsTypeMapper.findList(wxTagsType);
    }

}
