package com.ruoyi.auth.controller;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RestController;
|
import com.ruoyi.auth.form.AccountRegisterBody;
|
import com.ruoyi.auth.form.PhoneCodeLoginBody;
|
import com.ruoyi.auth.form.PhoneLoginBody;
|
import com.ruoyi.auth.form.SmsCodeBody;
|
import com.ruoyi.auth.service.AccountLoginService;
|
import com.ruoyi.auth.service.SmsCodeService;
|
import com.ruoyi.common.core.domain.R;
|
|
/**
|
* 用户端/服务商端小程序认证控制器
|
*
|
* 网关侧统一前缀为 /miniapp/auth(StripPrefix=2),故服务内路径为 /sms/code、/phone/login、/account/register。
|
*
|
* @author hugray
|
*/
|
@RestController
|
public class AccountAuthController
|
{
|
@Autowired
|
private SmsCodeService smsCodeService;
|
|
@Autowired
|
private AccountLoginService accountLoginService;
|
|
/**
|
* 下发短信验证码
|
*/
|
@PostMapping("/sms/code")
|
public R<?> sendSmsCode(@Validated @RequestBody SmsCodeBody body)
|
{
|
smsCodeService.sendCode(body.getPhone(), body.getScene());
|
return R.ok();
|
}
|
|
/**
|
* 手机号一键登录(微信手机号快速验证)
|
*/
|
@PostMapping("/phone/login")
|
public R<?> phoneLogin(@Validated @RequestBody PhoneLoginBody body)
|
{
|
return R.ok(accountLoginService.phoneLogin(body.getCode()));
|
}
|
|
/**
|
* 手机号验证码登录(短信验证码)
|
*/
|
@PostMapping("/phone/code-login")
|
public R<?> phoneCodeLogin(@Validated @RequestBody PhoneCodeLoginBody body)
|
{
|
return R.ok(accountLoginService.phoneCodeLogin(body.getPhone(), body.getCode()));
|
}
|
|
/**
|
* C端会员注册
|
*/
|
@PostMapping("/account/register")
|
public R<?> accountRegister(@Validated @RequestBody AccountRegisterBody body)
|
{
|
accountLoginService.accountRegister(body.getPhone(), body.getCode(), body.getReferralCode());
|
return R.ok();
|
}
|
}
|