作者 mxy

个人信息的手机号验证

... ... @@ -4,6 +4,7 @@ import cn.bronet.admin.common.core.domain.AjaxResult;
import com.example.client.domain.bo.CBasicInformationStudentBo;
import com.example.client.domain.bo.CPersonalInformationBo;
import com.example.client.domain.bo.MySchoolTypeBO;
import com.example.client.domain.bo.checkPhoneBo;
import com.example.client.service.MineService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
... ... @@ -64,6 +65,14 @@ public class MineController {
}
@ApiOperation("手机号验证码验证")
@PostMapping("checkPhoneNumber")
public AjaxResult checkPhoneNumber(@RequestBody checkPhoneBo bo){
log.info("<<<接收的参数<<<::"+bo);
return mineService.checkPhone(bo);
}
@ApiOperation("我的学校")
@PostMapping("/openMySchool")
... ...
package com.example.client.domain.bo;
import lombok.Data;
@Data
public class checkPhoneBo {
/**
* 手机号
*/
private String PhoneNumber;
/**
* 验证码
*/
private String code;
}
... ...
... ... @@ -4,6 +4,7 @@ import cn.bronet.admin.common.core.domain.AjaxResult;
import com.example.client.domain.bo.CBasicInformationStudentBo;
import com.example.client.domain.bo.CPersonalInformationBo;
import com.example.client.domain.bo.MySchoolTypeBO;
import com.example.client.domain.bo.checkPhoneBo;
/**
* Created with IDEA
... ... @@ -92,7 +93,10 @@ public interface MineService {
AjaxResult openMyTeacher();
/**
* 手机号验证
* @param bo
* @return
*/
AjaxResult checkPhone(checkPhoneBo bo);
}
... ...
... ... @@ -3,15 +3,14 @@ package com.example.client.service.impl;
import cn.bronet.admin.common.core.domain.AjaxResult;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.client.constant.RedisConstants;
import com.example.client.domain.*;
import com.example.client.domain.bo.CBasicInformationStudentBo;
import com.example.client.domain.bo.CPersonalInformationBo;
import com.example.client.domain.bo.CRelationshipStudentSgcBo;
import com.example.client.domain.bo.MySchoolTypeBO;
import com.example.client.domain.bo.*;
import com.example.client.domain.vo.*;
import com.example.client.domin.UserContext;
import com.example.client.enumeration.Identity;
import com.example.client.mapper.*;
import com.example.client.redis.RedisCache;
import com.example.client.service.MineService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.loadtime.Aj;
... ... @@ -35,6 +34,9 @@ import java.util.List;
public class MineServiceImpl implements MineService {
@Autowired
private RedisCache redisCache;
@Autowired
private CPersonalInformationMapper cPersonalInformationMapper;
@Autowired
... ... @@ -281,7 +283,7 @@ public class MineServiceImpl implements MineService {
log.info("<<<uId<<<::" + uId);
CPersonalInformation personalInfo = cPersonalInformationMapper.getPersonalInfo(uId);
/*CPersonalInformation personalInfo = cPersonalInformationMapper.selectById(bo.getId());
if (!bo.getEmail().isEmpty()){
personalInfo.setEmail(bo.getEmail());
... ... @@ -301,19 +303,19 @@ public class MineServiceImpl implements MineService {
personalInfo.setResume(bo.getResume());
}
personalInfo.setUpdateTime(LocalDateTime.now());
personalInfo.setUpdateTime(LocalDateTime.now());*/
//判断 等于null 没有个人信息
if (personalInfo == null) {
CPersonalInformation personalInformation = new CPersonalInformation();
BeanUtils.copyProperties(bo,personalInformation);
personalInformation.setCreateTime(LocalDateTime.now())
.setUpdateTime(LocalDateTime.now());
CPersonalInformation personalInformation = new CPersonalInformation();
BeanUtils.copyProperties(bo,personalInformation);
personalInformation.setCreateTime(LocalDateTime.now())
.setUpdateTime(LocalDateTime.now());
//判断 等于null 没有个人信息
if (bo.getId() == null) {
cPersonalInformationMapper.insert(personalInformation);
}
cPersonalInformationMapper.updateById(personalInfo);
cPersonalInformationMapper.updateById(personalInformation);
//根据denglurenID查询用户表
CUser cUser = cUserMapper.selectById(uId);
... ... @@ -761,6 +763,29 @@ public class MineServiceImpl implements MineService {
}
/**
* 手机号验证
* @param bo
* @return
*/
@Override
public AjaxResult checkPhone(checkPhoneBo bo) {
//判断验证码是否正确
String cacheObject = this.redisCache.getCacheObject(RedisConstants.getPhoneCodeKey(bo.getPhoneNumber()));
if (cacheObject == null) {
return AjaxResult.error("验证码已过期");
}
if (!bo.getCode().equals(cacheObject)) {
return AjaxResult.error("验证码错误");
}
//删除验证码
this.redisCache.deleteObject(RedisConstants.getPhoneCodeKey(bo.getPhoneNumber()));
return AjaxResult.success();
}
/**
* 学生查看我的学校
* @param userId
* @return
... ...