package com.nicefish.web.controller;

import com.nicefish.model.User;
import com.nicefish.service.UserService;
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);
    }

    @RequestMapping("/id/{id}")
    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);
    }
}

@@ -104,16 +104,147 @@
 ervice;%0A
+import io.swagger.annotations.ApiOperation;%0Aimport io.swagger.annotations.ApiResponse;%0Aimport io.swagger.annotations.ApiResponses;%0A
 import o
@@ -298,16 +298,16 @@
 owired;%0A
-
 import o
@@ -510,24 +510,26 @@
 rvice;%0A%0A    
+/*
 @RequestMapp
@@ -697,33 +697,326 @@
 password);%0A    %7D
-%0A
+*/%0A    @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    @RequestMap
@@ -1020,16 +1020,21 @@
 Mapping(
+path=
 %22/id/%7Bid
@@ -1035,16 +1035,43 @@
 id/%7Bid%7D%22
+,method = RequestMethod.GET
 )%0A    pu
@@ -1179,24 +1179,26 @@
 %0A    %7D%0A%0A    
+/*
 @RequestMapp
@@ -1368,16 +1368,18 @@
 (user);%0A
-
     %7D
+*/
 %0A%7D%0A

configure swagger