From c173eba6145cffa21fca08666cefbc27f5d1f191 Mon Sep 17 00:00:00 2001 From: liyunfengfengfeng <2305743208@qq.com> Date: Sat, 24 Mar 2018 22:22:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yingjun/ssm/service/impl/UserServiceImpl.java | 6 +++++- src/main/java/com/yingjun/ssm/web/UserController.java | 2 +- src/main/webapp/resource/script/userResgiter.js | 6 +----- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java b/src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java index 00f50cd..32cc36f 100644 --- a/src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java +++ b/src/main/java/com/yingjun/ssm/service/impl/UserServiceImpl.java @@ -8,6 +8,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Isolation; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpSession; @@ -87,6 +90,7 @@ public class UserServiceImpl implements UserService { * 处理用户注册 * @param user */ + @Transactional(propagation= Propagation.REQUIRED,isolation = Isolation.READ_COMMITTED,rollbackFor=Throwable.class) @Override public void userRegister(User user, String code,HttpSession session) { try{ @@ -94,7 +98,7 @@ public class UserServiceImpl implements UserService { if(!emailCode.equals(code)){ throw new BizException("验证码错误"); } - if(1 == userDao.insertTUser(user)){ + if(1 != userDao.insertTUser(user)){ throw new Exception("插入数据影响函数不唯一"); } }catch (BizException biz){ diff --git a/src/main/java/com/yingjun/ssm/web/UserController.java b/src/main/java/com/yingjun/ssm/web/UserController.java index 20b849d..afc8b43 100644 --- a/src/main/java/com/yingjun/ssm/web/UserController.java +++ b/src/main/java/com/yingjun/ssm/web/UserController.java @@ -81,7 +81,7 @@ public class UserController { } catch (Exception e) { return new BaseResult<>(false, ResultEnum.INVALID_USER.getMsg()); } - return new BaseResult<>(true, "登陆成功"); + return new BaseResult<>(true, "注册成功"); } /** * 用户注册时获取邮箱验证码 diff --git a/src/main/webapp/resource/script/userResgiter.js b/src/main/webapp/resource/script/userResgiter.js index d4b4bc6..4065ad2 100644 --- a/src/main/webapp/resource/script/userResgiter.js +++ b/src/main/webapp/resource/script/userResgiter.js @@ -93,11 +93,7 @@ function sure(){ dataType: "json", url: '/user/register', success: function (data) { - if (data.success) { - - } else { - - } + window.location.href="/user/login"; } }); -- GitLab