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

@Transactional
@Component(value="sceneInfoService")
public class SceneInfoServiceImpl implements SceneInfoService {
	@Resource(name="sceneInfoDAO")
	private SceneInfoDAO sceneInfoDAO;

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

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

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

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

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