70 lines
2.4 KiB
Java
70 lines
2.4 KiB
Java
package com.bwie.auth.controller;
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.bwie.auth.service.AuthService;
|
|
import com.bwie.common.pojo.DTO.UserDto;
|
|
import com.bwie.common.pojo.vo.UserVo;
|
|
import com.bwie.common.result.Result;
|
|
import lombok.extern.log4j.Log4j2;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
/**
|
|
* @author 86175
|
|
*/
|
|
@RestController
|
|
@RequestMapping("/auth")
|
|
@Log4j2
|
|
public class AuthController {
|
|
|
|
@Autowired
|
|
private AuthService authService;
|
|
@Autowired
|
|
private HttpServletRequest request;
|
|
|
|
/**
|
|
* 手机号验证码登录
|
|
*
|
|
* @param userPhone
|
|
* @return
|
|
*/
|
|
@PostMapping("/sendCode/{userPhone}")
|
|
public Result sendCode(@PathVariable String userPhone) {
|
|
log.info("功能描述:发送验证码,请求URI:{},请求方式:{},请求参数:{}", request.getServletPath(), request.getMethod(), userPhone);
|
|
Result result = authService.sendCode(userPhone);
|
|
log.info("功能描述:发送验证码,请求URI:{},请求方式:{},响应结果:{}", request.getServletPath(), request.getMethod(), JSON.toJSONString(result));
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 登录+注册
|
|
* 登录时判断这个用户是否存在,存在的话,登录,不存在直接注册,然后再登录
|
|
* 不登录无法停车
|
|
*/
|
|
@PostMapping("/users")
|
|
public Result<UserDto> users(@RequestBody UserVo userVo) {
|
|
|
|
log.info("功能描述:登录进入停车页面,请求URI:{},请求方式:{},请求参数:{}", request.getServletPath(), request.getMethod(), userVo);
|
|
Result result = authService.users(userVo);
|
|
log.info("功能描述:登录进入停车页面,请求URI:{},请求方式:{},响应结果:{}", request.getServletPath(), request.getMethod(), JSON.toJSONString(result));
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* 注册
|
|
*/
|
|
@PostMapping("/register")
|
|
public Result register(@RequestBody UserVo userVo){
|
|
|
|
log.info("功能描述:注册,请求URI:{},请求方式:{},请求参数:{}",request.getServletPath(),request.getMethod(),userVo);
|
|
Result result= authService.register(userVo);
|
|
log.info("功能描述:注册,请求URI:{},请求方式:{},响应结果:{}",request.getServletPath(),request.getMethod(), JSON.toJSONString(result));
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
}
|