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

@Transactional
@Component(value="returnInfoService")
public class ReturnInfoServiceImpl implements ReturnInfoService {
	@Resource(name="returnInfoDAO")
	private ReturnInfoDAO returnInfoDAO;

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

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

		return returnInfoDAO.insert(model);
	}

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

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

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = returnInfoDAO.exist(id);

		return count > 0 ? true : false;
	}

	@Override
	public List<ReturnInfo> list() {
		// TODO Auto-generated method stub
		return returnInfoDAO.list();
	}

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

        return page;
	}

	@Override
	public ReturnInfo findByOpenId(String openId) {
		return returnInfoDAO.findByOpenId(openId);
	}

	@Override
	public ReturnInfo findByIdCardOrPhone(String idCard, String phone) {
		return returnInfoDAO.findByIdCardOrPhone(idCard,phone);
	}
}