Commit 71de27dc by 唐功亮

1.【修改】 手机号验证码 使用一次就删除redis中的数据

2.【修改】  用户注册使用的手机号和 修改的手机号  做重复校验
parent 47854f8c
...@@ -45,6 +45,13 @@ public interface MemberDao extends BaseMapper<MemberEntity> { ...@@ -45,6 +45,13 @@ public interface MemberDao extends BaseMapper<MemberEntity> {
@Update("UPDATE member SET Applystate = #{applystate} WHERE username = #{userName}") @Update("UPDATE member SET Applystate = #{applystate} WHERE username = #{userName}")
void updateByIdApplystate(@Param("applystate") String applystate,@Param("userName")String userName); void updateByIdApplystate(@Param("applystate") String applystate,@Param("userName")String userName);
@Select("select count(1) from member where phone=#{phone}")
int selectByPhone(@Param("phone") String phone);
@Select("select count(1) from member where phone=#{phone} and id<>#{id}")
int selectByPhoneNot(@Param("phone")String phone,@Param("id")String id);
/*@Select("select * from member where username=#{userName} or firmcode=#{userName}") /*@Select("select * from member where username=#{userName} or firmcode=#{userName}")
MemberEntity selectByNameAndSn(@Param("userName") String userName);*/ MemberEntity selectByNameAndSn(@Param("userName") String userName);*/
......
...@@ -100,6 +100,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl ...@@ -100,6 +100,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl
if (memberEntityName!=null){ if (memberEntityName!=null){
throw new RRException("用户名已存在"); throw new RRException("用户名已存在");
} }
//判断手机号是否存在
int count=memberDao.selectByPhone(phone);
if (count!=0){
throw new RRException("手机号已存在");
}
//利用获取验证码时保存的session,判断手机验证码非空,和发送的短信内容是否一致,提交时的手机号与接收验证码的手机号是否相同,验证码是否已失效 //利用获取验证码时保存的session,判断手机验证码非空,和发送的短信内容是否一致,提交时的手机号与接收验证码的手机号是否相同,验证码是否已失效
ValueOperations forValue = redisTemplate.opsForValue(); ValueOperations forValue = redisTemplate.opsForValue();
...@@ -176,6 +181,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl ...@@ -176,6 +181,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl
if (id.equals("")) { if (id.equals("")) {
throw new RRException("请先登录"); throw new RRException("请先登录");
} }
//判断手机号是否存在
int count=memberDao.selectByPhoneNot(phone,id);
if (count!=0){
throw new RRException("手机号已存在");
}
int flag = 1; int flag = 1;
TimescodeChphoneEntity timescodeChphoneEntity = timescodeChphoneDao.selectById(phone); TimescodeChphoneEntity timescodeChphoneEntity = timescodeChphoneDao.selectById(phone);
if (timescodeChphoneEntity != null) { // 该手机号码是否发送过短信 if (timescodeChphoneEntity != null) { // 该手机号码是否发送过短信
...@@ -258,6 +268,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl ...@@ -258,6 +268,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl
if (!o.toString().equals(verification)) { if (!o.toString().equals(verification)) {
throw new RRException("验证码输入错误"); throw new RRException("验证码输入错误");
} }
redisTemplate.delete(phone);//验证码填写成功后删除 验证码
memberDao.updateByIDPhone(Integer.valueOf(id), phone); memberDao.updateByIDPhone(Integer.valueOf(id), phone);
} }
...@@ -355,6 +366,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl ...@@ -355,6 +366,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberDao, MemberEntity> impl
if (!matchPhoneNumber(phone)) { if (!matchPhoneNumber(phone)) {
throw new RRException("手机格式不正确,请重新填写"); throw new RRException("手机格式不正确,请重新填写");
} }
//判断手机号是否存在
int count=memberDao.selectByPhone(phone);
if (count!=0){
throw new RRException("手机号已存在");
}
//TODO tgl 判断手机号码是否在黑名单内 //TODO tgl 判断手机号码是否在黑名单内
//写入session //写入session
//手机验证码写入redis //手机验证码写入redis
......
...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; ...@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import io.office.common.exception.RRException; import io.office.common.exception.RRException;
import io.office.common.utils.IPUtils; import io.office.common.utils.IPUtils;
import io.office.modules.manage.dao.LogMessageDao; import io.office.modules.manage.dao.LogMessageDao;
import io.office.modules.manage.dao.MemberDao;
import io.office.modules.manage.dao.TimescodeRegiIpDao; import io.office.modules.manage.dao.TimescodeRegiIpDao;
import io.office.modules.manage.entity.LogMessageEntity; import io.office.modules.manage.entity.LogMessageEntity;
import io.office.modules.manage.entity.TimescodeRegiIpEntity; import io.office.modules.manage.entity.TimescodeRegiIpEntity;
...@@ -57,6 +58,8 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time ...@@ -57,6 +58,8 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
@Autowired @Autowired
private RedisTemplate<String,String> redisTemplate; private RedisTemplate<String,String> redisTemplate;
@Autowired
private MemberDao memberDao;
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
IPage<TimescodeRegiEntity> page = this.page( IPage<TimescodeRegiEntity> page = this.page(
...@@ -106,6 +109,11 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time ...@@ -106,6 +109,11 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
if (!matchPhoneNumber(phone)){ if (!matchPhoneNumber(phone)){
throw new RRException("手机格式不正确,请重新填写"); throw new RRException("手机格式不正确,请重新填写");
} }
//判断手机号是否存在
int count=memberDao.selectByPhone(phone);
if (count!=0){
throw new RRException("手机号已存在");
}
//TODO tgl 判断手机号码是否在黑名单内 //TODO tgl 判断手机号码是否在黑名单内
//手机验证码写入redis //手机验证码写入redis
ValueOperations forValue = redisTemplate.opsForValue(); ValueOperations forValue = redisTemplate.opsForValue();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment