Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
beauty_ssm
提交
d7b2911a
B
beauty_ssm
项目概览
爱吃血肠
/
beauty_ssm
通知
9
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
B
beauty_ssm
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d7b2911a
编写于
3月 25, 2018
作者:
爱吃血肠
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
用户注册模块完成
上级
c173eba6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
46 addition
and
29 deletion
+46
-29
beauty_ssm.iml
beauty_ssm.iml
+1
-0
pom.xml
pom.xml
+7
-0
src/main/java/com/yingjun/ssm/dto/BaseResult.java
src/main/java/com/yingjun/ssm/dto/BaseResult.java
+1
-1
src/main/java/com/yingjun/ssm/enums/ResultEnum.java
src/main/java/com/yingjun/ssm/enums/ResultEnum.java
+2
-1
src/main/java/com/yingjun/ssm/web/UserController.java
src/main/java/com/yingjun/ssm/web/UserController.java
+9
-6
src/main/webapp/WEB-INF/jsp/user/userResgiter.jsp
src/main/webapp/WEB-INF/jsp/user/userResgiter.jsp
+26
-0
src/main/webapp/resource/script/userResgiter.js
src/main/webapp/resource/script/userResgiter.js
+0
-21
未找到文件。
beauty_ssm.iml
浏览文件 @
d7b2911a
...
...
@@ -98,5 +98,6 @@
<orderEntry
type=
"library"
name=
"Maven: javax.mail:mail:1.4.5"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: javax.activation:activation:1.1"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.sun.mail:javax.mail:1.5.4"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: com.google.code.gson:gson:2.8.2"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
pom.xml
浏览文件 @
d7b2911a
...
...
@@ -253,6 +253,13 @@
<version
>
1.5.4
</version >
</dependency >
<!--将邮箱工具类发送邮箱验证码 end -->
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson start -->
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.8.2
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson end -->
</dependencies>
<!-- Build Settings -->
<!--http://maven.apache.org/pom.html#Build_Settings -->
...
...
src/main/java/com/yingjun/ssm/dto/BaseResult.java
浏览文件 @
d7b2911a
...
...
@@ -6,7 +6,7 @@ import java.io.Serializable;
/**
*
* @author
yingjun
* @author
liyunfeng
*
* ajax 请求的返回类型封装JSON结果
*/
...
...
src/main/java/com/yingjun/ssm/enums/ResultEnum.java
浏览文件 @
d7b2911a
...
...
@@ -20,7 +20,8 @@ public enum ResultEnum {
SESSION_IS_OUT_TIME
(
99980003
,
"会话超时"
),
// 用户相关异常
INVALID_USER
(
1001001
,
"无效用户"
);
INVALID_USER
(
1001001
,
"无效用户"
),
USER_REGISTER_SUCCESS
(
1001002
,
"注册成功"
);
private
int
state
;
...
...
src/main/java/com/yingjun/ssm/web/UserController.java
浏览文件 @
d7b2911a
package
com.yingjun.ssm.web
;
import
com.google.gson.Gson
;
import
com.yingjun.ssm.dto.BaseResult
;
import
com.yingjun.ssm.entity.User
;
import
com.yingjun.ssm.enums.ResultEnum
;
...
...
@@ -72,16 +73,17 @@ public class UserController {
* @return
*/
@ResponseBody
@RequestMapping
(
value
=
"/register"
,
produces
=
{
"application/json;charset=UTF-8"
})
public
BaseResult
<
Object
>
register
(
User
user
,
String
code
,
HttpSession
session
)
{
@RequestMapping
(
value
=
"/register"
)
public
Object
register
(
User
user
,
String
code
,
HttpSession
session
)
{
Gson
gson
=
new
Gson
();
try
{
userService
.
userRegister
(
user
,
code
,
session
);
}
catch
(
BizException
e
)
{
return
new
BaseResult
<>(
false
,
e
.
getMessage
(
));
return
gson
.
toJson
(
new
BaseResult
(
false
,
e
.
getMessage
()
));
}
catch
(
Exception
e
)
{
return
new
BaseResult
<>(
false
,
ResultEnum
.
INVALID_USER
.
getMsg
(
));
return
gson
.
toJson
(
new
BaseResult
(
false
,
ResultEnum
.
INVALID_USER
.
getMsg
()
));
}
return
new
BaseResult
<>(
true
,
"注册成功"
);
return
gson
.
toJson
(
new
BaseResult
(
true
,
ResultEnum
.
USER_REGISTER_SUCCESS
.
getMsg
())
);
}
/**
* 用户注册时获取邮箱验证码
...
...
@@ -92,7 +94,8 @@ public class UserController {
public
BaseResult
<
Object
>
getEmailCode
(
@RequestParam
String
email
,
HttpSession
session
)
{
try
{
String
code
=
CodeUtil
.
rand
();
MailUtil
.
sendMail
(
email
,
code
);
System
.
out
.
println
(
"code is "
+
code
);
//MailUtil.sendMail(email,code);
session
.
setAttribute
(
"code"
,
code
);
}
catch
(
BizException
e
)
{
return
new
BaseResult
<>(
false
,
e
.
getMessage
());
...
...
src/main/webapp/WEB-INF/jsp/user/userResgiter.jsp
浏览文件 @
d7b2911a
...
...
@@ -86,3 +86,29 @@
</footer>
</body>
</html>
<script>
function
sure
(){
var
$newPwd
=
$
(
"
#newPwd
"
).
val
();
var
$pwda
=
$
(
"
#pwd-a
"
).
val
();
if
(
$pwda
!=
$newPwd
)
{
$
(
"
#pwd-a
"
).
next
().
remove
();
$
(
"
#pwd-a
"
).
addClass
(
'
noPass
'
)
$
(
"
#pwd-a
"
).
after
(
'
<span class="noPassImg-bounce"><img src="/resource/img/refuse.png"/>输入不一致</span>
'
)
return
;
}
$
.
ajax
({
type
:
'
POST
'
,
data
:
$
(
'
#register
'
).
serialize
(),
dataType
:
"
json
"
,
url
:
'
/user/register
'
,
success
:
function
(
data
)
{
if
(
data
.
success
){
alert
(
"
注册成功
"
);
window
.
location
.
href
=
"
/user/login
"
;
}
else
{
alert
(
"
注册失败
"
);
}
}
});
}
</script>
src/main/webapp/resource/script/userResgiter.js
浏览文件 @
d7b2911a
...
...
@@ -78,24 +78,3 @@ function settime(val) {
},
1000
)
}
}
function
sure
(){
var
$newPwd
=
$
(
"
#newPwd
"
).
val
();
var
$pwda
=
$
(
"
#pwd-a
"
).
val
();
if
(
$pwda
!=
$newPwd
)
{
$
(
"
#pwd-a
"
).
next
().
remove
();
$
(
"
#pwd-a
"
).
addClass
(
'
noPass
'
)
$
(
"
#pwd-a
"
).
after
(
'
<span class="noPassImg-bounce"><img src="/resource/img/refuse.png"/>输入不一致</span>
'
)
return
;
}
$
.
ajax
({
type
:
'
POST
'
,
data
:
$
(
'
#register
'
).
serialize
(),
dataType
:
"
json
"
,
url
:
'
/user/register
'
,
success
:
function
(
data
)
{
window
.
location
.
href
=
"
/user/login
"
;
}
});
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录