根据手机查询用户,新增登录逻辑验证
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package com.ruoyi.fadapp.controller;
|
||||
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.fadapp.domain.dto.LoginByCodeDto;
|
||||
import com.ruoyi.fadapp.domain.dto.SendCodeDto;
|
||||
import com.ruoyi.fadapp.domain.vo.LoginResultVo;
|
||||
import com.ruoyi.fadapp.service.IFadAppAuthService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* FAD APP认证控制器
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/fadapp/auth")
|
||||
public class FadAppAuthController {
|
||||
|
||||
private final IFadAppAuthService authService;
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
@PostMapping("/send-code")
|
||||
public R<Void> sendCode(@Valid @RequestBody SendCodeDto dto) {
|
||||
authService.sendCode(dto.getPhone());
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码登录
|
||||
*/
|
||||
@PostMapping("/login-by-code")
|
||||
public R<LoginResultVo> loginByCode(@Valid @RequestBody LoginByCodeDto dto) {
|
||||
LoginResultVo result = authService.loginByCode(dto.getPhone(), dto.getCode());
|
||||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*/
|
||||
@PostMapping("/logout")
|
||||
public R<Void> logout(@RequestHeader("Authorization") String token) {
|
||||
authService.logout(token);
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.ruoyi.fadapp.controller;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.fadapp.domain.vo.FadAppUserVo;
|
||||
import com.ruoyi.fadapp.service.IFadAppUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* FAD APP用户管理Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/fadapp/user")
|
||||
public class FadAppUserController extends BaseController {
|
||||
|
||||
private final IFadAppUserService userService;
|
||||
|
||||
/**
|
||||
* 查询用户列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<FadAppUserVo> list(FadAppUserVo bo, PageQuery pageQuery) {
|
||||
return userService.queryUserList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户详细信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
@GetMapping("/{userId}")
|
||||
public R<FadAppUserVo> getInfo(@NotNull(message = "主键不能为空")
|
||||
@PathVariable Long userId) {
|
||||
return R.ok(userService.getUserInfo(userId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机号获取用户信息
|
||||
*/
|
||||
@GetMapping("/phone/{phone}")
|
||||
public R<Object> getUserByPhone(@NotNull(message = "手机号不能为空")
|
||||
@PathVariable String phone) {
|
||||
return R.ok(userService.getUserByPhone(phone));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户统计信息
|
||||
*/
|
||||
@GetMapping("/stats")
|
||||
public R<Object> getUserStats() {
|
||||
return R.ok(userService.getUserStats());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user