| | |
| | | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | 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.domain.vo.InviteQrcodeVo; |
| | | import com.ruoyi.auth.form.AccountRegisterBody; |
| | | import com.ruoyi.auth.form.InviteQrcodeQuery; |
| | | import com.ruoyi.auth.form.PartnerLoginBody; |
| | | import com.ruoyi.auth.form.PhoneCodeLoginBody; |
| | | import com.ruoyi.auth.form.PhoneLoginBody; |
| | | import com.ruoyi.auth.form.ResetPasswordBody; |
| | | import com.ruoyi.auth.form.SmsCodeBody; |
| | | import com.ruoyi.auth.service.AccountLoginService; |
| | | import com.ruoyi.auth.service.PartnerLoginService; |
| | | import com.ruoyi.auth.service.PasswordResetService; |
| | | import com.ruoyi.auth.service.SmsCodeService; |
| | | import com.ruoyi.auth.service.WeChatMiniappService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | |
| | | /** |
| | | * 用户端/服务商端小程序认证控制器 |
| | | * |
| | | * 网关侧统一前缀为 /miniapp/auth(StripPrefix=2),故服务内路径为 /sms/code、/phone/login、/account/register。 |
| | | * 网关侧统一前缀为 /miniapp/auth(StripPrefix=2),故服务内路径为 /sms/code、/phone/login、/account/register、/partner/login。 |
| | | * |
| | | * @author hugray |
| | | */ |
| | |
| | | |
| | | @Autowired |
| | | private AccountLoginService accountLoginService; |
| | | |
| | | @Autowired |
| | | private PartnerLoginService partnerLoginService; |
| | | |
| | | @Autowired |
| | | private PasswordResetService passwordResetService; |
| | | |
| | | @Autowired |
| | | private WeChatMiniappService weChatMiniappService; |
| | | |
| | | /** |
| | | * 下发短信验证码 |
| | |
| | | } |
| | | |
| | | /** |
| | | * 服务商端账号密码登录 |
| | | * |
| | | * 仅需账号 + 密码;校验通过后强校验服务商身份(provider_flag='1')。 |
| | | */ |
| | | @PostMapping("/partner/login") |
| | | public R<?> partnerLogin(@Validated @RequestBody PartnerLoginBody body) |
| | | { |
| | | return R.ok(partnerLoginService.partnerLogin(body.getUsername(), body.getPassword())); |
| | | } |
| | | |
| | | /** |
| | | * C端会员注册 |
| | | */ |
| | | @PostMapping("/account/register") |
| | |
| | | accountLoginService.accountRegister(body.getPhone(), body.getCode(), body.getReferralCode()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 重置密码(忘记密码) |
| | | * |
| | | * 凭手机号 + 短信验证码(scene=reset)校验身份后设置新密码。 |
| | | */ |
| | | @PostMapping("/password/reset") |
| | | public R<?> resetPassword(@Validated @RequestBody ResetPasswordBody body) |
| | | { |
| | | passwordResetService.resetPassword(body.getPhone(), body.getCode(), body.getPassword()); |
| | | return R.ok(); |
| | | } |
| | | |
| | | /** |
| | | * 生成邀请码小程序码 |
| | | * |
| | | * 以邀请码作为 scene 调用微信 getUnlimited 接口,扫码直达注册页并自动填入邀请码。 |
| | | * |
| | | * @param query 邀请码入参(code) |
| | | * @return 小程序码 base64 DataURI |
| | | */ |
| | | @GetMapping("/invite-qrcode") |
| | | public R<InviteQrcodeVo> inviteQrcode(@Validated InviteQrcodeQuery query) |
| | | { |
| | | InviteQrcodeVo vo = new InviteQrcodeVo(); |
| | | vo.setQrcode(weChatMiniappService.getUnlimitedQrcode(query.getCode())); |
| | | return R.ok(vo); |
| | | } |
| | | } |