手机号授权: 获取该手机是否绑定授权
This commit is contained in:
@@ -45,6 +45,10 @@ public class PhoneAuthRecord implements Serializable {
|
||||
* 设备id
|
||||
*/
|
||||
private String deviceId;
|
||||
/**
|
||||
* 1有效 0无效
|
||||
*/
|
||||
private Byte status;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@@ -13,5 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
public interface PhoneAuthRecordService extends IService<PhoneAuthRecord> {
|
||||
|
||||
|
||||
|
||||
Boolean isBoundPhoneAuthCode(String phone);
|
||||
}
|
@@ -43,7 +43,7 @@ public class PhoneAuthApplyRecordServiceImpl extends ServiceImpl<PhoneAuthApplyR
|
||||
throw new ServiceException(BusiStatus.PARAMETERILLEGAL);
|
||||
}
|
||||
|
||||
if (!phone.startsWith("86")) {
|
||||
if (!phoneAreaCode.equals("86")) {
|
||||
throw new ServiceException("手機號格式不正確");
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ public class PhoneAuthApplyRecordServiceImpl extends ServiceImpl<PhoneAuthApplyR
|
||||
throw new ServiceException(BusiStatus.SERVER_BUSY);
|
||||
}
|
||||
try {
|
||||
|
||||
boolean flag = smsService.verifySmsCode(phone, code);
|
||||
String phoneStr = phoneAreaCode + phone;
|
||||
boolean flag = smsService.verifySmsCode(phoneStr, code);
|
||||
if (flag) {
|
||||
throw new ServiceException(BusiStatus.SMSCODEERROR);
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ package com.accompany.business.service.phone.impl;
|
||||
import com.accompany.business.model.phone.PhoneAuthRecord;
|
||||
import com.accompany.business.mybatismapper.PhoneAuthRecordMapper;
|
||||
import com.accompany.business.service.phone.PhoneAuthRecordService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -17,4 +19,10 @@ import org.springframework.stereotype.Service;
|
||||
public class PhoneAuthRecordServiceImpl extends ServiceImpl<PhoneAuthRecordMapper, PhoneAuthRecord> implements PhoneAuthRecordService {
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean isBoundPhoneAuthCode(String phone) {
|
||||
QueryWrapper<PhoneAuthRecord> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(PhoneAuthRecord::getPhone, phone).eq(PhoneAuthRecord::getStatus,Constant.GlobalStatus.valid);
|
||||
return this.getOne(queryWrapper,false) != null;
|
||||
}
|
||||
}
|
@@ -31,7 +31,7 @@ public class PhoneAuthApplyRecordController extends BaseController {
|
||||
@ApiOperation("手机号申请授权码操作")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "phoneAreaCode", value = "区号", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "phone", value = "区号 + 手机号 如: 86178xxxxxxxx", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "phone", value = "手机号 如: 178xxxxxxxx", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "code", value = "验证码", required = true, dataType = "String"),
|
||||
})
|
||||
@PostMapping("/apply")
|
||||
|
@@ -2,8 +2,15 @@ package com.accompany.business.controller.phone;
|
||||
|
||||
import com.accompany.business.common.BaseController;
|
||||
import com.accompany.business.service.phone.PhoneAuthRecordService;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -21,4 +28,15 @@ public class PhoneAuthRecordController extends BaseController {
|
||||
@Autowired
|
||||
private PhoneAuthRecordService phoneAuthRecordService;
|
||||
|
||||
@ApiOperation("手机号申请授权码操作")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "phoneAreaCode", value = "区号", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "phone", value = "区号 + 手机号 如: 86178xxxxxxxx", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "code", value = "验证码", required = true, dataType = "String"),
|
||||
})
|
||||
@GetMapping("/isBoundPhoneAuthCode")
|
||||
public BusiResult apply(String phone) {
|
||||
Boolean flag = phoneAuthRecordService.isBoundPhoneAuthCode(phone);
|
||||
return new BusiResult(BusiStatus.SUCCESS,flag);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user