提交 e889e19d authored 作者: zgy's avatar zgy

优化登录功能

上级 b55beae9
......@@ -40,6 +40,13 @@
<artifactId>yunpian-java-sdk</artifactId>
<version>1.2.7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-elasticsearch -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<!--springframework.boot-->
<dependency>
<groupId>org.springframework.boot</groupId>
......@@ -200,11 +207,11 @@
</dependency>
<!--net.sf.json-lib-->
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<!-- <dependency>-->
<!-- <groupId>org.apache.httpcomponents</groupId>-->
<!-- <artifactId>httpclient</artifactId>-->
<!-- &lt;!&ndash;<version>4.5.2</version>&ndash;&gt;-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.apache.httpcomponents</groupId>-->
<!-- <artifactId>httpclient</artifactId>-->
<!-- &lt;!&ndash;<version>4.5.2</version>&ndash;&gt;-->
<!-- </dependency>-->
<!--apache httpclient-->
......
......@@ -9,6 +9,7 @@ import com.diaoyun.zion.master.enums.ResultCodeEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apiguardian.api.API;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -104,4 +105,11 @@ public class LoginController extends BaseController {
result.setData(userInfo);
return result;
}
@ApiOperation("验证手机号")
@GetMapping("/checkByPhone/{phone}")
public Result checkByPhone(@ApiParam("手机号") @PathVariable("phone") String phone) {
return tbCfUserInfoService.checkByPhone(phone);
}
}
......@@ -70,4 +70,5 @@ public interface TbCfUserInfoDao extends BaseDao<TbCfUserInfoEntity> {
String findEmails();
int updateIsSend(String email);
}
......@@ -4,7 +4,9 @@ import com.diaoyun.zion.chinafrica.entity.TbCfUserInfoEntity;
import com.diaoyun.zion.chinafrica.vo.TbCfUserInfoVo;
import com.diaoyun.zion.master.base.Result;
import freemarker.template.TemplateException;
import io.swagger.annotations.ApiParam;
import org.apache.commons.mail.EmailException;
import org.springframework.web.bind.annotation.PathVariable;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
......@@ -186,4 +188,6 @@ public interface TbCfUserInfoService {
String findEmails();
int updateIsSend(String email);
Result checkByPhone(String phone);
}
package com.diaoyun.zion.chinafrica.service.impl;
import autovalue.shaded.com.google$.common.collect.$BiMap;
import com.diaoyun.zion.chinafrica.constant.EmailTemplateConstant;
import com.diaoyun.zion.chinafrica.constant.KeyConstant;
import com.diaoyun.zion.chinafrica.dao.TbCfCouponDao;
......@@ -45,10 +46,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 用户表Service实现类
......@@ -301,6 +299,10 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
String phone = "+" + phoneNum.trim();
Result result = new Result();
TbCfUserInfoEntity user = tbCfUserInfoDao.checkUserByPhone(phone);
if (user == null) {
result.setData(ResultCodeEnum.QUERY_ERROR.getCode()).setMessage("You haven't registered yet, please register first!");
return result;
}
String phoneCode = (String) captchaRedisCache.get(KeyConstant.CAPTCHA_PHONE + phone);
if (phoneCode == null) {
result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode()).setMessage("Verification code failure");
......@@ -308,6 +310,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
}
if (user != null && phoneCode.equals(code)) {
result = loginByPhoneCode(ip, phone);
captchaRedisCache.delete(KeyConstant.CAPTCHA_PHONE + phone);
} else {
result.setCode(ResultCodeEnum.VALIDATE_ERROR.getCode());
result.setMessage("Login failed");
......@@ -567,7 +570,7 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
}
@Override
public String findEmails() {
public String findEmails() {
return tbCfUserInfoDao.findEmails();
}
......@@ -576,6 +579,20 @@ public class TbCfUserInfoServiceImpl implements TbCfUserInfoService {
return tbCfUserInfoDao.updateIsSend(email);
}
@Override
public Result checkByPhone(String phone) {
Result result = new Result();
Map map = new HashMap();
boolean isRegistered = true;
TbCfUserInfoEntity user = tbCfUserInfoDao.checkUserByPhone("+" + phone.trim());
if (user == null) {
isRegistered = false;
}
map.put("isRegistered", isRegistered);
result.setData(map).setMessage(ResultCodeEnum.SUCCESS.getDesc());
return result;
}
/**
* 获取用户类型
......
......@@ -115,6 +115,7 @@ public class SMSUtil {
+ URLEncoder.encode(code, ENCODING);
String s = SMSUtil.tplSendSms(API_KEY, tpl_id, tpl_value, phone);
System.out.println(s);
System.out.println(code);
return code;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论