package com.gescc.hedwig.mapper;

import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gescc.hedwig.dao.UserDao;
import com.gescc.hedwig.vo.User;
import com.gescc.hedwig.vo.UserList;

/**
* UserFileMapper
* 
* @author geine
* @date 2016.12.22
* @version a
*/
@Repository
public class UserFileMapper implements UserDao {
	
	private ObjectMapper mapper = new ObjectMapper();
	//이부분 property로 제거 요망 - genie
	private URL url = UserFileMapper.class.getResource("/data/user.json");
	private Logger LOG = LoggerFactory.getLogger(UserFileMapper.class);
	
	@Override
	public Boolean insertUser(User user) throws Throwable {
		// TODO Auto-generated method stub
		LOG.error(url.toString());
		UserList.getInstance().getMap().put(user.getEmail(), user);
		File file = new File(url.toURI());
		//수없이 쓸거아니니까 읽었다가 다시쓰자 그게 더 빠를것같다 	
		PrintWriter out = new PrintWriter(new FileWriter(file, false));
		mapper.writeValue(out, UserList.getInstance().getMap());
		return true;
	}

	@Override
	public Boolean deleteUser(String userEmail) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public User selectUser(String userEmail) {
		// TODO Auto-generated method stub
		User user = (User) UserList.getInstance().getMap().get(userEmail);
		return user;
	}

	@Override
	public List<User> selectAllUser() {
		// TODO Auto-generated method stub
		return null;
	}
}

@@ -241,16 +241,79 @@
 actory;%0A
+import org.springframework.beans.factory.annotation.Autowired;%0A
 import o
@@ -354,16 +354,16 @@
 sitory;%0A
-
 %0Aimport 
@@ -498,16 +498,59 @@
 serDao;%0A
+import com.gescc.hedwig.util.PasswordUtil;%0A
 import c
@@ -750,16 +750,66 @@
 Dao %7B%0A%09%0A
+%09@Autowired%0A%09private PasswordUtil passwordUtil;%0A%09%0A
 %09private
@@ -1130,16 +1130,16 @@
 od stub%0A
-
 %09%09LOG.er
@@ -1159,16 +1159,85 @@
 ing());%0A
+%09%09user.setPassword(passwordUtil.encodePassword(user.getPassword()));%0A
 %09%09UserLi

Update UserFileMapper