/*
 * Copyright (c) 2010-2013 meituan.com
 * All rights reserved.
 * 
 */
package com.tosla.controller;

import com.tosla.domain.User;
import com.tosla.service.UserService;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * TODO 在这里编写类的功能描述
 *
 * @author yuexiaojun
 * @version 1.0
 * @created 2014-08-12
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping(value = "/all",method = RequestMethod.GET,produces= MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public Object getAllUsers() {
        List<User> userList = new ArrayList<User>();
        User user1 = new User();
        user1.setId(1);
        user1.setAddTime(new Date());
        user1.setName("拉风少年");
        user1.setPassword("123456");

        User user2 = new User();
        user2.setId(2);
        user2.setAddTime(new Date());
        user2.setName("千字");
        user2.setPassword("123456");

        userList.add(user1);
        userList.add(user2);
        userService.printName();
        return userList;
    }
}
@@ -255,24 +255,85 @@
 Controller;%0A
+import org.springframework.web.bind.annotation.PathVariable;%0A
 import org.s
@@ -383,16 +383,16 @@
 apping;%0A
-
 import o
@@ -562,63 +562,9 @@
 til.
-ArrayList;%0Aimport java.util.Date;%0Aimport java.util.List
+*
 ;%0A%0A/
@@ -774,16 +774,56 @@
 rvice;%0A%0A
+    private Map%3CInteger,User%3E userMap;%0A%0A
     @Req
@@ -1438,24 +1438,24 @@
 rintName();%0A
-
         retu
@@ -1472,10 +1472,835 @@
 t;%0A    %7D
+%0A%0A    @RequestMapping(value = %22/%7Bid%7D%22,method = RequestMethod.GET,produces= MediaType.APPLICATION_JSON_VALUE)%0A    @ResponseBody%0A    public Object getUser(@PathVariable String id) %7B%0A%0A%0A        List%3CUser%3E userList = new ArrayList%3CUser%3E();%0A        User user1 = new User();%0A        user1.setId(1);%0A        user1.setAddTime(new Date());%0A        user1.setName(%22%E6%8B%89%E9%A3%8E%E5%B0%91%E5%B9%B4%22);%0A        user1.setPassword(%22123456%22);%0A%0A        User user2 = new User();%0A        user2.setId(2);%0A        user2.setAddTime(new Date());%0A        user2.setName(%22%E5%8D%83%E5%AD%97%22);%0A        user2.setPassword(%22123456%22);%0A%0A        userList.add(user1);%0A        userList.add(user2);%0A        userService.printName();%0A%0A        userMap = new HashMap%3CInteger, User%3E();%0A        userMap.put(user1.getId(), user1);%0A        userMap.put(user2.getId(), user2);%0A%0A        return userMap.get(id);%0A    %7D
 %0A%7D

add user by id