package com.nicefish.web.controller;

import com.nicefish.model.User;
import com.nicefish.service.UserService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * Created by kimmking on 17/6/26.
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    UserService userService;

    /*@RequestMapping("/login")
    public User login(@RequestParam String userName,@RequestParam String password) {
        return userService.findByUserNameAndPassword(userName,password);
    }*/
    @ApiOperation(value = "login", nickname = "login",response = User.class)
    @ApiResponses({
            @ApiResponse(code = 404, response = String.class, message = "user not found"),
            @ApiResponse(code = 500, response = String.class, message = "Internal server error")
    })
    @RequestMapping(path="/id/{id}",method = RequestMethod.GET)
    public User login(@PathVariable("id") String userId) {
        return userService.findByUserId(userId);
    }

    /*@RequestMapping("/register")
    public User register(@RequestBody User user) {
        user.setUserId(java.util.UUID.randomUUID().toString());
        return userService.save(user);
    }*/
}

@@ -518,34 +518,380 @@
     
-/*@RequestMapping(%22/login%22
+@ApiOperation(value = %22login%22, nickname = %22login%22,response = User.class)%0A    @ApiResponses(%7B%0A            @ApiResponse(code = 404, response = String.class, message = %22user not found%22),%0A            @ApiResponse(code = 500, response = String.class, message = %22Internal server error%22)%0A    %7D)%0A    @RequestMapping(value = %22/login%22,method = %7BRequestMethod.GET,RequestMethod.POST%7D
 )%0A  
@@ -1051,18 +1051,17 @@
 );%0A    %7D
-*/
+%0A
 %0A    @Ap
@@ -1072,37 +1072,36 @@
 ration(value = %22
-log
+f
 in
+d
 %22, nickname = %22l
@@ -1091,37 +1091,36 @@
 d%22, nickname = %22
-log
+f
 in
+d
 %22,response = Use
@@ -1370,17 +1370,19 @@
 (path=%22/
-i
+fin
 d/%7Bid%7D%22,
@@ -1425,21 +1425,20 @@
 ic User 
-log
+f
 in
+d
 (@PathVa
@@ -1527,18 +1527,314 @@
  %7D%0A%0A    
-/*
+@ApiOperation(value = %22register%22, nickname = %22register%22,response = User.class)%0A    @ApiResponses(%7B%0A            @ApiResponse(code = 404, response = String.class, message = %22user not found%22),%0A            @ApiResponse(code = 500, response = String.class, message = %22Internal server error%22)%0A    %7D)%0A    
 @Request
@@ -1841,16 +1841,24 @@
 Mapping(
+value = 
 %22/regist
@@ -1860,16 +1860,44 @@
 egister%22
+,method = RequestMethod.POST
 )%0A    pu
@@ -2049,13 +2049,11 @@
 );%0A    %7D
-*/
 %0A%7D%0A

add method for user controller