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 com.jpsoft.shinestar.modules.base.dao.CanteenOutsourcerBalanceDAO;
import com.jpsoft.shinestar.modules.base.entity.CanteenOutsourcerBalance;
import com.jpsoft.shinestar.modules.base.service.CanteenOutsourcerBalanceService;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="canteenOutsourcerBalanceService")
public class CanteenOutsourcerBalanceServiceImpl implements CanteenOutsourcerBalanceService {
	@Resource(name="canteenOutsourcerBalanceDAO")
	private CanteenOutsourcerBalanceDAO canteenOutsourcerBalanceDAO;

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

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

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

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

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

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