57 lines
1.5 KiB
Java
57 lines
1.5 KiB
Java
![]() |
|
||
|
|
||
|
// 用户登录demo
|
||
|
package net.carbon.controller;
|
||
|
|
||
|
|
||
|
import io.swagger.annotations.ApiOperation;
|
||
|
import io.swagger.annotations.ApiParam;
|
||
|
import net.carbon.request.UserRegisterRequest;
|
||
|
import net.carbon.request.UserLoginRequest;
|
||
|
import net.carbon.service.UserService;
|
||
|
import net.carbon.utils.JsonData;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||
|
import org.springframework.web.bind.annotation.RestController;
|
||
|
|
||
|
@RestController
|
||
|
@RequestMapping("/api/user/v1")
|
||
|
public class UserController {
|
||
|
|
||
|
@Autowired
|
||
|
private UserService userService;
|
||
|
|
||
|
/**
|
||
|
* 用户注册
|
||
|
*
|
||
|
* @param registerRequest
|
||
|
* @return
|
||
|
*/
|
||
|
@ApiOperation("用户注册")
|
||
|
@PostMapping(value = "register")
|
||
|
public JsonData register(
|
||
|
@ApiParam(value = "用户注册对象", required = true)
|
||
|
@RequestBody UserRegisterRequest registerRequest) {
|
||
|
JsonData jsonData = userService.register(registerRequest);
|
||
|
|
||
|
return jsonData;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* 用户登录
|
||
|
*
|
||
|
* @param loginRequest
|
||
|
* @return
|
||
|
*/
|
||
|
|
||
|
@ApiOperation("用户登录")
|
||
|
@PostMapping("login")
|
||
|
public JsonData userLogin(@ApiParam("用户登陆对象") @RequestBody UserLoginRequest loginRequest) {
|
||
|
|
||
|
JsonData jsonData = userService.login(loginRequest);
|
||
|
return jsonData;
|
||
|
}
|
||
|
|
||
|
}
|