package xyz.acmer.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xyz.acmer.dao.IUserDao;
import xyz.acmer.entity.user.User;
import xyz.acmer.service.IUserService;
import xyz.acmer.util.EncryptHelper;

/**
 * Created by hypo on 16-2-19.
 */
@Service
public class UserServiceImpl implements IUserService {

    @Autowired
    private IUserDao dao;

    public User addNewUser(String username, String nickname, String email, String password){

        User newUser = new User(username, nickname, email, EncryptHelper.getPassword(password));
        dao.save(newUser);

        return newUser;
    }
}

@@ -440,91 +440,612 @@
 lic 
-User addNewUser(String username, String nickname, String email, String password)%7B%0A%0A
+Boolean login(String email, String password)%7B%0A%0A        if(password == null %7C%7C email == null %7C%7C password.length() == 0)%7B%0A            return false;%0A        %7D%0A%0A        User user = dao.getUserByEmail(email);%0A%0A        if (user == null %7C%7C user.getPassword() == null)%7B%0A            return false;%0A        %7D%0A%0A        password = EncryptHelper.getPassword(password);%0A%0A        return password.equals(user.getPassword());%0A    %7D%0A%0A    public User addNewUser(String username, String nickname, String email, String password)%7B%0A%0A        if(dao.getUserByEmail(email) == null && dao.getUserByUsername(username) == null)%7B%0A%0A    
     
@@ -1145,16 +1145,20 @@
         
+    
 dao.save
@@ -1173,24 +1173,28 @@
 );%0A%0A        
+ 
+   
 return newUs
@@ -1197,16 +1197,48 @@
 ewUser;%0A
+        %7D%0A%0A        return null;%0A
     %7D%0A%7D%0A

add user service