package com.jpsoft.shinestar.modules.base.service.impl;

import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.jpsoft.shinestar.modules.base.dao.IconTypeDAO;
import com.jpsoft.shinestar.modules.base.entity.IconType;
import com.jpsoft.shinestar.modules.base.service.IconTypeService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="iconTypeService")
public class IconTypeServiceImpl implements IconTypeService {
	@Resource(name="iconTypeDAO")
	private IconTypeDAO iconTypeDAO;

	@Override
	public IconType get(String id) {
		// TODO Auto-generated method stub
		return iconTypeDAO.get(id);
	}

	@Override
	public int insert(IconType model) {
		// TODO Auto-generated method stub
		//model.setId(UUID.randomUUID().toString());
		
		return iconTypeDAO.insert(model);
	}

	@Override
	public int update(IconType model) {
		// TODO Auto-generated method stub
		return iconTypeDAO.update(model);		
	}

	@Override
	public int delete(String id) {
		// TODO Auto-generated method stub
		return iconTypeDAO.delete(id);
	}

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = iconTypeDAO.exist(id);
		
		return count > 0 ? true : false;
	}
	
	@Override
	public List<IconType> list() {
		// TODO Auto-generated method stub
		return iconTypeDAO.list();
	}
		
	@Override
	public Page<IconType> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
        Page<IconType> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
            iconTypeDAO.search(searchParams,sortList);
        });
        
        return page;
	}
}