package com.jasamedika.medifirst2000.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

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

import com.jasamedika.medifirst2000.dao.RIS_UserDao;
import com.jasamedika.medifirst2000.entities.RIS_Order;
import com.jasamedika.medifirst2000.entities.RIS_User;
import com.jasamedika.medifirst2000.service.RIS_UserService;
import com.jasamedika.medifirst2000.util.CommonUtil;

@Service("RIS_UserService")
public class RIS_UserServiceImpl implements RIS_UserService{

	@Autowired
	private RIS_UserDao rIS_UserDao;
	
	@Override
	public Map<String, Object> save(RIS_User vo){
		Map<String, Object> result = new HashMap<>();
		if(CommonUtil.isNotNullOrEmpty(vo)) {
			RIS_User model = rIS_UserDao.save(vo);
			result.put("id", model.getUSER_KEY());
		}
		return result;
	}
	
	@Override
	public void delete(RIS_User vo) {
		if(CommonUtil.isNotNullOrEmpty(vo)) {
			rIS_UserDao.delete(vo.getUSER_KEY());
		}
	}
	
	@Override
	public RIS_User getOne(RIS_User vo) {
		RIS_User result = new RIS_User();
		if(CommonUtil.isNotNullOrEmpty(vo.getUSER_KEY())) {
			result = rIS_UserDao.findOne(vo.getUSER_KEY());
		}
		return result;
	}
	
	@Override
	public List<RIS_User> getAll(){
		List<RIS_User> result = new ArrayList<>();
		result = (List<RIS_User>) rIS_UserDao.findAll();
		return result;
	}
}
