极光推送参数修改,中文乱码修改,增加接口手机,邮箱忘记密码修改,邮箱忘记密码发送验证邮件
This commit is contained in:
parent
230187426e
commit
56c7fa0818
|
|
@ -7,9 +7,12 @@ package com.ifish.API;
|
|||
|
||||
import cn.jpush.api.JPushClient;
|
||||
import cn.jpush.api.push.PushResult;
|
||||
import cn.jpush.api.push.model.Message;
|
||||
import cn.jpush.api.push.model.Options;
|
||||
import cn.jpush.api.push.model.Platform;
|
||||
import cn.jpush.api.push.model.PushPayload;
|
||||
import cn.jpush.api.push.model.audience.Audience;
|
||||
import cn.jpush.api.push.model.notification.IosNotification;
|
||||
import cn.jpush.api.push.model.notification.Notification;
|
||||
import java.util.Map;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -45,6 +48,7 @@ public class JiGuangPush {
|
|||
.setPlatform(Platform.android())
|
||||
.setAudience(Audience.alias(userId))
|
||||
.setNotification(Notification.android(title, message, map))
|
||||
.setMessage(Message.newBuilder().setTitle(title).setMsgContent(message).addExtras(map).build())
|
||||
.build();
|
||||
|
||||
PushResult result = jPushClient.sendPush(payload);
|
||||
|
|
@ -59,10 +63,13 @@ public class JiGuangPush {
|
|||
|
||||
public boolean pushMessageByIOS(String title, String message, String userId, Map map) {
|
||||
try {
|
||||
|
||||
PushPayload payload = PushPayload.newBuilder()
|
||||
.setPlatform(Platform.ios())
|
||||
.setAudience(Audience.alias(userId))
|
||||
.setNotification(Notification.ios(message, map))
|
||||
.setNotification(Notification.newBuilder().addPlatformNotification(IosNotification.newBuilder().setSound("happy").setAlert(message).build()).build())
|
||||
.setMessage(Message.newBuilder().setTitle(title).setMsgContent(message).addExtras(map).build())
|
||||
.setOptions(Options.newBuilder().setApnsProduction(false).build())
|
||||
.build();
|
||||
|
||||
PushResult result = jPushClient.sendPush(payload);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ public class Mail {
|
|||
private static Logger log = LoggerFactory.getLogger(Mail.class);
|
||||
private static HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
||||
private static String registerEmail = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/api" + request.getContextPath() + "/registerEmail?md5=";
|
||||
private static String updatePasswordEmail = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + "/api" + request.getContextPath() + "/updatePasswordEmail?md5=";
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
|
|
@ -320,4 +321,86 @@ public class Mail {
|
|||
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮箱注册链接
|
||||
*
|
||||
* @param email 发送目标邮箱
|
||||
* @param value 发送有效时间验证
|
||||
* @return
|
||||
*/
|
||||
public static boolean sendUpdatePasswordCodeTest(String email, String value) {
|
||||
try {
|
||||
// 1. 创建参数配置, 用于连接邮件服务器的参数配置
|
||||
Properties props = new Properties(); // 参数配置
|
||||
props.setProperty("mail.transport.protocol", "smtp"); // 使用的协议(JavaMail规范要求)
|
||||
props.setProperty("mail.smtp.host", smtp); // 发件人的邮箱的 SMTP 服务器地址
|
||||
props.setProperty("mail.smtp.auth", "true"); // 需要请求认证
|
||||
|
||||
// PS: 某些邮箱服务器要求 SMTP 连接需要使用 SSL 安全认证 (为了提高安全性, 邮箱支持SSL连接, 也可以自己开启),
|
||||
// 如果无法连接邮件服务器, 仔细查看控制台打印的 log, 如果有有类似 “连接失败, 要求 SSL 安全连接” 等错误,
|
||||
// 打开下面 /* ... */ 之间的注释代码, 开启 SSL 安全连接。
|
||||
/*
|
||||
// SMTP 服务器的端口 (非 SSL 连接的端口一般默认为 25, 可以不添加, 如果开启了 SSL 连接,
|
||||
// 需要改为对应邮箱的 SMTP 服务器的端口, 具体可查看对应邮箱服务的帮助,
|
||||
// QQ邮箱的SMTP(SLL)端口为465或587, 其他邮箱自行去查看)
|
||||
final String smtpPort = "465";
|
||||
props.setProperty("mail.smtp.port", smtpPort);
|
||||
props.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
||||
props.setProperty("mail.smtp.socketFactory.fallback", "false");
|
||||
props.setProperty("mail.smtp.socketFactory.port", smtpPort);
|
||||
*/
|
||||
// 2. 根据配置创建会话对象, 用于和邮件服务器交互
|
||||
Session session = Session.getDefaultInstance(props);
|
||||
session.setDebug(true); // 设置为debug模式, 可以查看详细的发送 log
|
||||
// 3. 创建一封邮件
|
||||
MimeMessage message = createupdatePasswordMessage(session, email, value);
|
||||
// 4. 根据 Session 获取邮件传输对象
|
||||
Transport transport = session.getTransport();
|
||||
|
||||
// 5. 使用 邮箱账号 和 密码 连接邮件服务器, 这里认证的邮箱必须与 message 中的发件人邮箱一致, 否则报错
|
||||
//
|
||||
// PS_01: 成败的判断关键在此一句, 如果连接服务器失败, 都会在控制台输出相应失败原因的 log,
|
||||
// 仔细查看失败原因, 有些邮箱服务器会返回错误码或查看错误类型的链接, 根据给出的错误
|
||||
// 类型到对应邮件服务器的帮助网站上查看具体失败原因。
|
||||
//
|
||||
// PS_02: 连接失败的原因通常为以下几点, 仔细检查代码:
|
||||
// (1) 邮箱没有开启 SMTP 服务;
|
||||
// (2) 邮箱密码错误, 例如某些邮箱开启了独立密码;
|
||||
// (3) 邮箱服务器要求必须要使用 SSL 安全连接;
|
||||
// (4) 请求过于频繁或其他原因, 被邮件服务器拒绝服务;
|
||||
// (5) 如果以上几点都确定无误, 到邮件服务器网站查找帮助。
|
||||
//
|
||||
// PS_03: 仔细看log, 认真看log, 看懂log, 错误原因都在log已说明。
|
||||
transport.connect(username, password);
|
||||
// 6. 发送邮件, 发到所有的收件地址, message.getAllRecipients() 获取到的是在创建邮件对象时添加的所有收件人, 抄送人, 密送人
|
||||
transport.sendMessage(message, message.getAllRecipients());
|
||||
// 7. 关闭连接
|
||||
transport.close();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
String a = e.getMessage();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static MimeMessage createupdatePasswordMessage(Session session, String receiveMail, String value) throws Exception {
|
||||
// 1. 创建一封邮件
|
||||
MimeMessage message = new MimeMessage(session);
|
||||
// 2. From: 发件人
|
||||
message.setFrom(new InternetAddress(from, "爱鱼奇", "UTF-8"));
|
||||
// 3. To: 收件人(可以增加多个收件人、抄送、密送)
|
||||
message.setRecipient(MimeMessage.RecipientType.TO, new InternetAddress(receiveMail, "XX用户", "UTF-8"));
|
||||
// 4. Subject: 邮件主题
|
||||
message.setSubject("修改账号密码激活链接", "UTF-8");
|
||||
// 5. Content: 邮件正文(可以使用html标签)
|
||||
String content = "您的改密码链接为:" + updatePasswordEmail + value + " ,请在半小时内进行激活!";
|
||||
message.setContent(content, "text/html;charset=UTF-8");
|
||||
// 6. 设置发件时间
|
||||
message.setSentDate(new Date());
|
||||
// 7. 保存设置
|
||||
message.saveChanges();
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,6 +45,10 @@ public class SecurityValidateInterceptor extends HandlerInterceptorAdapter {
|
|||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
|
||||
|
||||
request.setCharacterEncoding("UTF-8");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
|
||||
//开发模式
|
||||
if (!devModel) {
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class Tbl_User implements java.io.Serializable {
|
|||
/**
|
||||
* 版本号
|
||||
*/
|
||||
private static final long serialVersionUID = 1916426418064460350L;
|
||||
private static final long serialVersionUID = -7318879296790573758L;
|
||||
|
||||
/**
|
||||
* 用户Id
|
||||
|
|
@ -99,6 +99,11 @@ public class Tbl_User implements java.io.Serializable {
|
|||
@Column(name = "create_time", nullable = true)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* */
|
||||
@Column(name = "phone_type", nullable = true, length = 10)
|
||||
private String phoneType;
|
||||
|
||||
/**
|
||||
* 登陆手机类型
|
||||
*/
|
||||
|
|
@ -380,6 +385,25 @@ public class Tbl_User implements java.io.Serializable {
|
|||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPhoneType() {
|
||||
return this.phoneType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置
|
||||
*
|
||||
* @param phoneType
|
||||
*
|
||||
*/
|
||||
public void setPhoneType(String phoneType) {
|
||||
this.phoneType = phoneType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登陆手机类型
|
||||
*
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public class Device {
|
|||
* @param macAddress
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/bindDevice.do", method = RequestMethod.POST)
|
||||
@RequestMapping(value = "/bindDevice.do", method = RequestMethod.GET)
|
||||
public Object bindDevice(Integer userId, String macAddress) {
|
||||
try {
|
||||
return deviceHelperI.bindDevice(userId, macAddress);
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
@Controller
|
||||
public class Index {
|
||||
|
||||
@RequestMapping(value = "/", method = RequestMethod.GET) //处理路由的请求
|
||||
@RequestMapping(value = "/index", method = RequestMethod.GET) //处理路由的请求
|
||||
public String index() {
|
||||
return "index"; //返回的视图名为index(指向/WEB-INF/Views/index.jsp)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,20 +46,9 @@ public class Login {
|
|||
}
|
||||
|
||||
/**
|
||||
* 修改用户信息发送邮件验证
|
||||
* 注册账号发送邮件验证
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/updateUserEmail", method = RequestMethod.POST)
|
||||
public Object updateUserEmail(Tbl_User user) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件验证
|
||||
*
|
||||
* @param user
|
||||
* @param user 注册的账号邮箱和账号密码
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/registerByEmail", method = RequestMethod.POST)
|
||||
|
|
@ -88,6 +77,28 @@ public class Login {
|
|||
return userHelperI.touristRegister(loginType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户信息发送邮件验证
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/forgetPasswordByEmail", method = RequestMethod.POST)
|
||||
public Object updateUserEmail(String userEmail, String userPassword) {
|
||||
return userHelperI.forgetPasswordByEmail(userEmail, userPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱修改密码激活地址
|
||||
*
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/updatePasswordEmail", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
|
||||
public Object updatePasswordEmail(String md5) {
|
||||
return userHelperI.updatePasswordEmail(md5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户属性
|
||||
*
|
||||
|
|
@ -124,4 +135,15 @@ public class Login {
|
|||
return userHelperI.updateUserPassword(userId, password, phoneNumber, token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 忘记密码,根据手机号修改密码
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/forgetPassword", method = RequestMethod.POST)
|
||||
public Object forgetPasswordByMobile(String phoneNumber, String password) {
|
||||
return userHelperI.forgetPassword(phoneNumber, password);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,6 +272,16 @@ public class RedisKeyHelper implements RedisKeyHelperI {
|
|||
return RedisKey.EMAIL_REGIESTER + md5;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据MD5值获取redis缓存key键值(修改密码用)
|
||||
*
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
public String getEmailUpdatePasswordRedisKey(String md5) {
|
||||
return RedisKey.EMAIL_UPDATEPASSWORD + md5;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除redis中某个设备详情Tbl_Device的缓存
|
||||
*
|
||||
|
|
|
|||
|
|
@ -190,13 +190,21 @@ public interface RedisKeyHelperI {
|
|||
public String getTbl_Push_List_RedisByPushId(Integer pushId);
|
||||
|
||||
/**
|
||||
* 根据MD5值获取redis缓存key键值
|
||||
* 根据MD5值获取redis缓存key键值(注册账号用)
|
||||
*
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
public String getEmailRedisKey(String md5);
|
||||
|
||||
/**
|
||||
* 根据MD5值获取redis缓存key键值(修改密码用)
|
||||
*
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
public String getEmailUpdatePasswordRedisKey(String md5);
|
||||
|
||||
/**
|
||||
* 删除redis中某个设备详情的缓存
|
||||
*
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ public class UserHelper implements UserHelperI {
|
|||
user.setUserType("1");
|
||||
Date date = new Date();
|
||||
user.setCreateTime(date);
|
||||
user.setPhoneType(user.getLoginType());
|
||||
user.setUserImg("http://139.196.24.156:83/00/00/" + (new Random().nextInt(7) + 1) + ".png");
|
||||
user.setUpdateTime(date);
|
||||
int i = tbl_User_Mapper.insertUserByPhoneNumberAndEmail(user);
|
||||
|
|
@ -173,6 +174,9 @@ public class UserHelper implements UserHelperI {
|
|||
if (StringUtils.isNotBlank(user.getToken())) {
|
||||
map.put("token", user.getToken());
|
||||
}
|
||||
if (StringUtils.isNotBlank(user.getLoginType())) {
|
||||
map.put("logintype", user.getLoginType());
|
||||
}
|
||||
String key = redisKeyHelperI.getEmailRedisKey(md5);
|
||||
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(map), 30, TimeUnit.MINUTES);
|
||||
Mail.sendRegisterCodeTest(user.getUserEmail(), md5);
|
||||
|
|
@ -203,6 +207,10 @@ public class UserHelper implements UserHelperI {
|
|||
if (map.get("token") != null && StringUtils.isNotBlank(map.get("token").toString())) {
|
||||
user.setToken(map.get("token").toString());
|
||||
}
|
||||
if (map.get("logintype") != null && StringUtils.isNotBlank(map.get("logintype").toString())) {
|
||||
user.setLoginType(map.get("logintype").toString());
|
||||
user.setPhoneType(map.get("logintype").toString());
|
||||
}
|
||||
//随机生成6位用户名
|
||||
user.setNickName("鱼友" + IfishUtil.getCharAndNumr(5));
|
||||
user.setIsRegisterGwell("0");
|
||||
|
|
@ -227,76 +235,38 @@ public class UserHelper implements UserHelperI {
|
|||
return "注册失败,请联系管理员!";
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 根据类型和手机号,发送验证码
|
||||
// *
|
||||
// * @param sendType
|
||||
// * @param phoneNumber
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
//
|
||||
// public Object getSecurityCodeByPhoneNumber(String sendType, String phoneNumber) {
|
||||
// Tbl_User user = getUserByPhoneNumber(phoneNumber);
|
||||
// if (sendType.equals(SendTypeEnum.register.getKey())) {
|
||||
// if (user != null) {
|
||||
// //手机号注册过,发送错误码
|
||||
// return IfishUtil.returnJson(ResultEnum.warn201.getKey(), "");
|
||||
// } else {
|
||||
// //手机未被注册,获取验证码
|
||||
// return sendSecurityCode(phoneNumber, SmsSignEnum.sign4.getValue(), SmsTemplateEnum.SMS_720018.getKey());
|
||||
// }
|
||||
// } //找回密码
|
||||
// else if (sendType.equals(SendTypeEnum.findpwd.getKey())) {
|
||||
// if (user != null) {
|
||||
// //手机号存在,获取验证码
|
||||
// return sendSecurityCode(phoneNumber, SmsSignEnum.sign5.getValue(), SmsTemplateEnum.SMS_720021.getKey());
|
||||
// } else {
|
||||
// //手机号不存在,发送错误码
|
||||
// return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "");
|
||||
// }
|
||||
// } else {
|
||||
// //未知操作,返回错误码
|
||||
// return IfishUtil.returnJson(ResultEnum.warn203.getKey(), "");
|
||||
// }
|
||||
// }
|
||||
// /**
|
||||
// * 根据类型和邮件地址,发送验证码
|
||||
// *
|
||||
// * @param sendType
|
||||
// * @param phoneNumber
|
||||
// * @return
|
||||
// */
|
||||
// @Override
|
||||
// public Object getSecurityCodeByEmail(String sendType, String Email) {
|
||||
// Tbl_User user = getUserByEmail(Email);
|
||||
// if (sendType.equals(SendTypeEnum.register.getKey())) {
|
||||
// if (user != null) {
|
||||
// //邮箱注册过,发送错误码
|
||||
// return IfishUtil.returnJson(ResultEnum.warn201.getKey(), "");
|
||||
// } else {
|
||||
// //邮箱未被注册,获取验证码
|
||||
//// String code = Mail.sendRegisterCodeTest(Email);
|
||||
//// if (StringUtils.isNotBlank(code)) {
|
||||
//// return IfishUtil.returnJson(ResultEnum.success.getKey(),"");
|
||||
//// }
|
||||
// }
|
||||
// } //找回密码
|
||||
// else if (sendType.equals(SendTypeEnum.findpwd.getKey())) {
|
||||
// if (user != null) {
|
||||
// //手机号存在,获取验证码
|
||||
// String code = Mail.sendRegisterCode(Email);
|
||||
// return IfishUtil.returnJson(ResultEnum.success.getKey(), code.toString());
|
||||
// } else {
|
||||
// //手机号不存在,发送错误码
|
||||
// return IfishUtil.returnJson(ResultEnum.warn202.getKey(), "");
|
||||
// }
|
||||
// } else {
|
||||
// //未知操作,返回错误码
|
||||
// return IfishUtil.returnJson(ResultEnum.warn203.getKey(), "");
|
||||
// }
|
||||
// return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
// }
|
||||
/**
|
||||
* 邮箱用户修改密码
|
||||
*
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String updatePasswordEmail(String md5) {
|
||||
String key = redisKeyHelperI.getEmailUpdatePasswordRedisKey(md5);
|
||||
String redisString = redisHelperI.getRedis(key);
|
||||
if (StringUtils.isBlank(redisString)) {
|
||||
return "链接超时,请重新申请!";
|
||||
} else {
|
||||
Map map = (Map) IfishUtil.JsonToRealMap(redisString);
|
||||
Tbl_User user = getUserByEmail(map.get("email").toString());
|
||||
if (user == null) {
|
||||
return "修改失败,请联系管理员!";
|
||||
}
|
||||
|
||||
user.setUserPassword(map.get("password").toString());
|
||||
Date date = new Date();
|
||||
user.setUpdateTime(date);
|
||||
|
||||
int i = tbl_User_Mapper.updateUser(user);
|
||||
if (i > 0) {
|
||||
redisKeyHelperI.deleteRedisByTbl_User(user);
|
||||
return "修改成功,请用邮箱和新密码进行登陆!";
|
||||
}
|
||||
}
|
||||
return "修改失败,请联系管理员!";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID从缓存中获取用户对象
|
||||
*
|
||||
|
|
@ -334,6 +304,7 @@ public class UserHelper implements UserHelperI {
|
|||
}
|
||||
user.setUserType("0");
|
||||
user.setLoginType(loginType);
|
||||
user.setCreateTime(new Date());
|
||||
int i = tbl_User_Mapper.insertUserByTourist(user);
|
||||
Map result = new HashMap();
|
||||
if (i > 0 && user.getUserId() > 0) {
|
||||
|
|
@ -358,6 +329,12 @@ public class UserHelper implements UserHelperI {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户信息
|
||||
*
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object updateUser(Tbl_User user) {
|
||||
try {
|
||||
|
|
@ -492,6 +469,68 @@ public class UserHelper implements UserHelperI {
|
|||
return IfishUtil.toJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 忘记密码,根据手机号修改密码
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object forgetPassword(String phoneNumber, String password) {
|
||||
try {
|
||||
if (StringUtils.isBlank(phoneNumber) || StringUtils.isBlank(password)) {
|
||||
return IfishUtil.toJson(ResultEnum.error401.getKey(), "");
|
||||
}
|
||||
Tbl_User user = getUserByPhoneNumber(phoneNumber);
|
||||
if (user == null || user.getUserId() <= 0) {
|
||||
return IfishUtil.toJson(ResultEnum.error401.getKey(), "");
|
||||
}
|
||||
if (StringUtils.isNotBlank(password)) {
|
||||
user.setUserPassword(password);
|
||||
}
|
||||
int i = tbl_User_Mapper.updateUser(user);
|
||||
if (i > 0) {
|
||||
redisKeyHelperI.deleteRedisByTbl_User(user);
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return IfishUtil.toJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱账号忘记密码,发送邮件验证
|
||||
*
|
||||
* @param email
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object forgetPasswordByEmail(String email, String password) {
|
||||
try {
|
||||
if (StringUtils.isBlank(email) || StringUtils.isBlank(password)) {
|
||||
return IfishUtil.returnJson(ResultEnum.error401.getKey(), "");
|
||||
} else {
|
||||
Tbl_User tmpUser = getUserByEmail(email);
|
||||
if (tmpUser == null) {
|
||||
return IfishUtil.returnJson(ResultEnum.warn201.getKey(), "");
|
||||
}
|
||||
String md5 = IfishUtil.EncoderByMd5(email + password);
|
||||
Map map = new HashMap();
|
||||
map.put("email", email);
|
||||
map.put("password", password);
|
||||
String key = redisKeyHelperI.getEmailUpdatePasswordRedisKey(md5);
|
||||
redisHelperI.setRedis(key, IfishUtil.ObjectToJson(map), 30, TimeUnit.MINUTES);
|
||||
Mail.sendUpdatePasswordCodeTest(email, md5);
|
||||
return IfishUtil.returnJson(ResultEnum.success.getKey(), "");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手机号从缓存或数据库中取得用户对象
|
||||
*
|
||||
|
|
@ -647,6 +686,13 @@ public class UserHelper implements UserHelperI {
|
|||
tmpUser = (Tbl_User) gwellMap.get("user");
|
||||
isUpdate = (Boolean) gwellMap.get("isUpdate");
|
||||
|
||||
//4.3登陆次数修改
|
||||
Integer logincount = tbl_User_Mapper.executeLoginUpdate(tmpUser.getUserId(), tmpUser.getLoginType());
|
||||
//修改失败,返回错误信息
|
||||
if (logincount <= 0) {
|
||||
return IfishUtil.returnJson(ResultEnum.fail101.getKey(), "");
|
||||
}
|
||||
|
||||
//4.4验证是否需要修改技威等信息,如果需要则进行修改
|
||||
if (isUpdate) {
|
||||
Integer updateInteger = tbl_User_Mapper.updateUser(tmpUser);
|
||||
|
|
|
|||
|
|
@ -75,22 +75,14 @@ public interface UserHelperI {
|
|||
*/
|
||||
public String registerEmail(String md5);
|
||||
|
||||
// /**
|
||||
// * 根据类型和手机号,发送验证码
|
||||
// *
|
||||
// * @param sendType
|
||||
// * @param phoneNumber
|
||||
// * @return
|
||||
// */
|
||||
// public Object getSecurityCodeByPhoneNumber(String sendType, String phoneNumber);
|
||||
// /**
|
||||
// * 根据类型和邮件地址,发送验证码
|
||||
// *
|
||||
// * @param sendType
|
||||
// * @param phoneNumber
|
||||
// * @return
|
||||
// */
|
||||
// public Object getSecurityCodeByEmail(String sendType, String Email);
|
||||
/**
|
||||
* 邮箱用户修改密码
|
||||
*
|
||||
* @param md5
|
||||
* @return
|
||||
*/
|
||||
public String updatePasswordEmail(String md5);
|
||||
|
||||
/**
|
||||
* 修改用户属性
|
||||
*
|
||||
|
|
@ -109,7 +101,7 @@ public interface UserHelperI {
|
|||
public Object updateUserImg(MultipartFile file, Integer userId, String path);
|
||||
|
||||
/**
|
||||
* 修改用户手机号码和密码
|
||||
* 已知用户ID修改用户手机号码和密码
|
||||
*
|
||||
* @param userId
|
||||
* @param password
|
||||
|
|
@ -117,4 +109,22 @@ public interface UserHelperI {
|
|||
* @return
|
||||
*/
|
||||
public Object updateUserPassword(Integer userId, String password, String phoneNumber, String token);
|
||||
|
||||
/**
|
||||
* 忘记密码,根据手机号修改密码
|
||||
*
|
||||
* @param phoneNumber
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public Object forgetPassword(String phoneNumber, String password);
|
||||
|
||||
/**
|
||||
* 邮箱账号忘记密码,发送邮件验证
|
||||
*
|
||||
* @param email
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
public Object forgetPasswordByEmail(String email, String password);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,10 +94,10 @@ public interface Tbl_User_Mapper {
|
|||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@Insert("INSERT INTO tbl_user (`nick_name`, `user_password`, `phone_number`, `user_email`, `user_type`, `user_img`, `user_sex`, `login_count`, `update_time`, `login_time`, `create_time`, `login_type`, `remarks`, `address`, `P2PVerify_code1`, `P2PVerify_code2`, `gwell_userID`, `is_register_gwell`, `jiguang_userID`,`token`, `longitude`, `latitude`) "
|
||||
@Insert("INSERT INTO tbl_user (`nick_name`, `user_password`, `phone_number`, `user_email`, `user_type`, `user_img`, `user_sex`, `login_count`, `update_time`, `login_time`, `create_time`, `login_type`, `remarks`, `address`, `P2PVerify_code1`, `P2PVerify_code2`, `gwell_userID`, `is_register_gwell`, `jiguang_userID`,`token`, `longitude`, `latitude`, `phone_type`) "
|
||||
+ "VALUES (#{user.nickName},#{user.userPassword},#{user.phoneNumber},#{user.userEmail},#{user.userType},#{user.userImg},#{user.userSex},#{user.loginCount},#{user.updateTime},#{user.loginTime},"
|
||||
+ "#{user.createTime},#{user.loginType},#{user.remarks},#{user.address},#{user.p2pverifyCode1},#{user.p2pverifyCode2},#{user.gwellUserid},#{user.isRegisterGwell},#{user.jiguangUserid},"
|
||||
+ "#{user.token},#{user.longitude},#{user.latitude})")
|
||||
+ "#{user.token},#{user.longitude},#{user.latitude},#{user.loginType})")
|
||||
@SelectKey(statement = "select @@IDENTITY as user_id", keyProperty = "user.userId", keyColumn = "userId", before = false, resultType = int.class)
|
||||
Integer insertUserByPhoneNumberAndEmail(@Param("user") Tbl_User user);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ public class Tbl_User_MapperSql {
|
|||
public String registerUserByTourist(@Param("user") Tbl_User user) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("INSERT tbl_user (user_type,token) value ('0',#{user.token})");
|
||||
sb.append("INSERT tbl_user (user_type,token,create_time,login_type,login_count) value ('0',#{user.token},NOW(),#{user.loginType},0)");
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,4 +119,9 @@ public class RedisKey {
|
|||
* 邮箱验证有效缓存key
|
||||
*/
|
||||
public static final String EMAIL_REGIESTER = "emailkeyE:";
|
||||
|
||||
/**
|
||||
* 邮箱验证修改密码有效缓存key
|
||||
*/
|
||||
public static final String EMAIL_UPDATEPASSWORD = "emialupE:";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue