package com.ssj.service.sys.train.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ssj.bean.sys.train.bean.TrainUser;
import com.ssj.dao.sys.train.dao.TrainQueryDao;
import com.ssj.dao.sys.train.dao.TrainUserDao;
import com.ssj.framework.core.common.service.BaseServiceImpl;
import com.ssj.service.sys.train.service.TrainUserService;

@Service
@Transactional
public class TrainUserServiceImpl extends BaseServiceImpl<TrainUser, String> implements TrainUserService {

    @Autowired
    private TrainUserDao trainUserDao;
    
    @Autowired
    private TrainQueryDao trainQueryDao;

    @Override
	public PagingAndSortingRepository<TrainUser, String> getDao() {
		return trainUserDao;
	}

	@Override
	public Page<Map<String, Object>> findTrainUserBySysPage(Map<String, Object> params, Pageable pageable) {
		return trainQueryDao.findTrainUserBySysPage(params, pageable);
	}

	@Override
	public TrainUser getTrainUserByMobile(String mobile) {
		return trainUserDao.getTrainUserByMobile(mobile);
	}

	
	@Override
	public TrainUser login(String mobile,String password) {
		TrainUser trainUser=this.getTrainUserByMobile(mobile);
		if(trainUser!=null) {
			if(trainUser.getPassword().equals(password)) {
				return trainUser;
			}
		}
		return null;
	}
    
    
	

}
