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

@Transactional
@Component(value="activityInfoService")
public class ActivityInfoServiceImpl implements ActivityInfoService {
	@Resource(name="activityInfoDAO")
	private ActivityInfoDAO activityInfoDAO;

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

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

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

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

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