package com.ssm.service.impl.business;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.ssm.mapper.business.SmsUserMapper;
import com.ssm.model.business.SmsUser;
import com.ssm.service.business.SmsUserService;
import com.ssm.util.page.BeanUtil;
import com.ssm.util.page.PagedResult;

@Service
public class SmsUserServiceImpl implements SmsUserService {
	@Autowired
	private SmsUserMapper smsUserMapper;

	@Override
	public PagedResult<SmsUser> selectSmsUser(SmsUser smsUser, Integer pageNo,
			Integer pageSize) {
		pageNo = pageNo == null ? 1 : pageNo;
		pageSize = pageSize == null ? 500 : pageSize;
		PageHelper.startPage(pageNo, pageSize);
		List<SmsUser> list = smsUserMapper.selectSmsUser(smsUser);
		PagedResult<SmsUser> pageResult = BeanUtil.toPagedResult(list);
		return pageResult;
	}

	@Override
	public int insertSelective(SmsUser smsUser) {
		return smsUserMapper.insertSelective(smsUser);
	}

	@Override
	public int deleteByPrimaryKey(Integer smsUserId) {
		return smsUserMapper.deleteByPrimaryKey(smsUserId);
	}

	@Override
	public SmsUser selectSmsUserByUserId(Integer userId) {
		return smsUserMapper.selectByPrimaryKey(userId);
	}

	@Override
	public int updateSmsUserSave(SmsUser smsUser) {
		
		return smsUserMapper.updateByPrimaryKeySelective(smsUser);
	}

	@Override
	public int selectSmsUserCountByPhoen(String phoen) {
		
		return smsUserMapper.selectSmsUserCountByPhoen(phoen);
	}


}
