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.IconInfoDAO;
import com.jpsoft.shinestar.modules.base.entity.IconInfo;
import com.jpsoft.shinestar.modules.base.service.IconInfoService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="iconInfoService")
public class IconInfoServiceImpl implements IconInfoService {
	@Resource(name="iconInfoDAO")
	private IconInfoDAO iconInfoDAO;

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

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

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

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

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = iconInfoDAO.exist(id);
		
		return count > 0 ? true : false;
	}
	
	@Override
	public List<IconInfo> list() {
		// TODO Auto-generated method stub
		return iconInfoDAO.list();
	}

	@Override
	public Page<IconInfo> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
        Page<IconInfo> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
            iconInfoDAO.search(searchParams,sortList);
        });
        
        return page;
	}
}