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

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jpsoft.shinestar.modules.base.dao.RechargeRecordWaterDAO;
import com.jpsoft.shinestar.modules.base.entity.RechargeRecordWater;
import com.jpsoft.shinestar.modules.base.service.RechargeRecordWaterService;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Transactional
@Component(value="rechargeRecordWaterService")
public class RechargeRecordWaterServiceImpl implements RechargeRecordWaterService {
	@Resource(name="rechargeRecordWaterDAO")
	private RechargeRecordWaterDAO rechargeRecordWaterDAO;

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

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

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

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

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

	@Override
	public RechargeRecordWater getBySerialNum(String erialNum){
		return rechargeRecordWaterDAO.getBySerialNum(erialNum);
	}

	@Override
	public List<RechargeRecordWater> list() {
		// TODO Auto-generated method stub
		return rechargeRecordWaterDAO.list();
	}
		
	@Override
	public Page<RechargeRecordWater> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,List<Sort> sortList) {
		Page<RechargeRecordWater> page = PageHelper.startPage(pageNumber,pageSize).doSelectPage(()->{
			rechargeRecordWaterDAO.search(searchParams,sortList);
		});

		return page;
	}

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

		return page;
	}
}