package com.gescc.hedwig.service;

import javax.naming.spi.DirStateFactory.Result;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gescc.hedwig.dao.UserDao;
import com.gescc.hedwig.view.ResultView;
import com.gescc.hedwig.vo.User;

/**
* UserService
* 
* @author geine
* @date 2016.12.22
* @version a
*/
@Service("userService")
public class UserServiceImpl implements UserService{
	
	private static Logger LOG = LoggerFactory.getLogger(UserServiceImpl.class);

	@Autowired
	private UserDao dao;
	
	@Override
	public ResultView createUser(User user) {
		// TODO Auto-generated method stub
		try{
			if(dao.insertUser(user)) {
				
				return new ResultView("200", "Success");
			} else {
				return new ResultView("500", "Internal Server Error");
			}
		} catch (Throwable e) {
			try {
				e.printStackTrace();
				return new ResultView("500", "Internal Server Error");
			}
			catch (Throwable e1) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return new ResultView("500", "Internal Server Error");
			}
		}
	}

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

	@Override
	public ResultView doLogin(User user) {
		// TODO Auto-generated method stub
		try{
			User saveUser = dao.selectUser(user.getEmail());

			if (saveUser.getPassword().equals(user.getPassword())){
				return new ResultView("200", "success");
			} else {
				return new ResultView("501", "password incorrect");
			}
		}catch(Exception e){
			return new ResultView("501", "password incorrect");
		}
	}

	@Override
	public ResultView updateUser(User user) {
		// TODO Auto-generated method stub
		return null;
	}

}

@@ -355,16 +355,59 @@
 vo.User;
+%0Aimport com.gescc.hedwig.util.PasswordUtil;
 %0A%0A/**%0A* 
@@ -665,16 +665,66 @@
  dao;%0A%09%0A
+%09@Autowired%0A%09private PasswordUtil passwordUtil;%0A%09%0A
 %09@Overri
@@ -1519,16 +1519,19 @@
 ail());%0A
+%09%09%09
 %0A%09%09%09if (
@@ -1560,16 +1560,44 @@
 .equals(
+passwordUtil.encodePassword(
 user.get
@@ -1608,16 +1608,17 @@
 word()))
+)
 %7B%0A%09%09%09%09re

Update UserServiceImpl