package com.gescc.hedwig.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.gescc.hedwig.service.UserService;
import com.gescc.hedwig.view.ResultView;
import com.gescc.hedwig.vo.User;

/**
* UserController
* 
* @author geine
* @date 2016.12.22
* @version a
*/

@Controller
@RequestMapping("/users")
public class UserController {

	private Logger LOG = LoggerFactory.getLogger(UserController.class);
	
	@Autowired
	private UserService userService;
	
	@ResponseBody
	@RequestMapping(method = RequestMethod.POST, consumes = "application/json")
	public ResultView createUser(HttpServletRequest req, HttpServletResponse res, @RequestBody User user) throws Exception{
		
		LOG.info("craete user : " + user.toString());
		try {
			return userService.createUser(user);
		} catch (Exception e) {
			throw e;
		}
	}
	
	@ResponseBody
	@RequestMapping(value = "/login", method = RequestMethod.POST, consumes = "application/json")
	public ResultView doLogin(HttpServletRequest req, HttpServletResponse res, @RequestBody User user) throws Exception{
		
		LOG.info("login user : " + user.toString());
		try {
			return userService.doLogin(user);
		} catch (Exception e) {
			throw e;
		}
	}
}

@@ -31,16 +31,55 @@
 oller;%0A%0A
+import javax.annotation.PostConstruct;%0A
 import j
@@ -284,16 +284,75 @@
 owired;%0A
+import org.springframework.beans.factory.annotation.Value;%0A
 import o
@@ -982,51 +982,555 @@
 %09%0A%09@
-Autowired%0A%09private UserService userService;
+Value(%22$%7BdefaultEmail%7D%22)%0A%09private String defaultEmail;%0A%09%0A%09@Value(%22$%7BdefaultPassword%7D%22)%0A%09private String defaultPassword;%0A%09%0A%09@Value(%22$%7BdefaultPhonenumber%7D%22)%0A%09private String defaultPhoneNumber;%0A%09%0A%09@Autowired%0A%09private UserService userService;%0A%09%0A%09@PostConstruct%0A%09public ResultView createDefaultUser() throws Exception %7B%0A%09%09try %7B%0A%09%09%09User user = new User();%0A%09%09%09user.setEmail(defaultEmail);%0A%09%09%09user.setPassword(defaultPassword);%0A%09%09%09user.setPhoneNumber(defaultPhoneNumber);%0A%09%09%09return userService.createUser(user);%0A%09%09%7D catch(Exception e) %7B%0A%09%09%09throw e;%0A%09%09%7D%0A%09%7D
 %0A%09%0A%09

Add createDefaultUser