Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
软件工程实践2022年春W班
穿梭在银河的火箭队
TeamPractice7
提交
0355ba06
T
TeamPractice7
项目概览
软件工程实践2022年春W班
/
穿梭在银河的火箭队
/
TeamPractice7
通知
12
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TeamPractice7
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0355ba06
编写于
4月 23, 2022
作者:
VenseChen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
105_修改注册控制类
上级
18eab5fb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
20 addition
and
12 deletion
+20
-12
src/main/java/com/git/backend/controller/RegisterController.java
...n/java/com/git/backend/controller/RegisterController.java
+20
-12
未找到文件。
src/main/java/com/git/backend/controller/RegisterController.java
浏览文件 @
0355ba06
package
com.git.backend.controller
;
package
com.git.backend.controller
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.git.backend.common.Result
;
import
com.git.backend.common.Result
;
import
com.git.backend.common.TelephoneJudege
;
import
com.git.backend.common.TelephoneJudege
;
import
com.git.backend.entity.User
;
import
com.git.backend.entity.User
;
import
com.git.backend.mapper.UserMapper
;
import
com.git.backend.mapper.UserMapper
;
import
com.git.backend.service.UserService
;
import
com.git.backend.service.impl.UserServiceImpl
;
import
com.git.backend.service.impl.UserServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpSession
;
import
javax.servlet.http.HttpSession
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -20,12 +24,13 @@ import java.util.regex.Pattern;
...
@@ -20,12 +24,13 @@ import java.util.regex.Pattern;
* @author 105_陈玮鑫
* @author 105_陈玮鑫
*
*
* */
* */
@Controller
@
Rest
Controller
public
class
RegisterController
{
public
class
RegisterController
{
private
static
UserMapper
userMapper
;
@Autowired
public
static
boolean
InsertUser
(
String
phone
,
String
password
,
String
name
,
String
address
)
UserService
userService
;
public
boolean
InsertUser
(
String
phone
,
String
password
,
String
name
,
String
address
)
{
{
UserServiceImpl
userService
=
new
UserServiceImpl
();
boolean
flag
=
false
;
boolean
flag
=
false
;
User
user
=
new
User
();
User
user
=
new
User
();
user
.
setPhone
(
phone
);
user
.
setPassword
(
password
);
user
.
setPhone
(
phone
);
user
.
setPassword
(
password
);
...
@@ -33,26 +38,29 @@ public class RegisterController {
...
@@ -33,26 +38,29 @@ public class RegisterController {
flag
=
userService
.
save
(
user
);
flag
=
userService
.
save
(
user
);
return
flag
;
return
flag
;
}
}
public
User
getAttribute
(
String
attributeValue
)
{
QueryWrapper
<
User
>
wrapper
=
new
QueryWrapper
<>();
System
.
out
.
println
(
attributeValue
);
wrapper
.
eq
(
"phone"
,
attributeValue
);
User
user
=
userService
.
getOne
(
wrapper
);
return
user
;
}
@RequestMapping
(
"/user/register"
)
@RequestMapping
(
"/user/register"
)
public
Result
register
(
@RequestParam
(
"phone"
)
String
phone
,
@RequestParam
(
"password"
)
String
password
,
@RequestParam
(
"name"
)
String
name
,
@RequestParam
(
"address"
)
String
address
,
Model
model
,
HttpSession
session
)
{
public
Result
register
(
@RequestParam
(
"phone"
)
String
phone
,
@RequestParam
(
"password"
)
String
password
,
@RequestParam
(
"name"
)
String
name
,
@RequestParam
(
"address"
)
String
address
)
{
//如果用户名和密码正确
//如果用户名和密码正确
UserServiceImpl
userService
=
new
UserServiceImpl
();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
if
(
TelephoneJudege
.
isCellPhoneNo
(
phone
))
{
if
(
TelephoneJudege
.
isCellPhoneNo
(
phone
))
{
session
.
setAttribute
(
"LoginUser"
,
phone
);
session
.
setAttribute
(
"name"
,
name
);
InsertUser
(
phone
,
password
,
name
,
address
);
InsertUser
(
phone
,
password
,
name
,
address
);
//map.put("jump","redirect:/main.html")
map
.
put
(
"id"
,
getAttribute
(
phone
).
getId
());
map
.
put
(
"id"
,
LoginController
.
getAttribute
(
"id"
,
phone
));
map
.
put
(
"name"
,
name
);
map
.
put
(
"name"
,
name
);
map
.
put
(
"phone"
,
phone
);
map
.
put
(
"phone"
,
phone
);
map
.
put
(
"address"
,
address
);
map
.
put
(
"address"
,
address
);
return
Result
.
success
(
200
,
"注册成功"
,
map
);
//跳转到dashboard页面
return
Result
.
success
(
200
,
"注册成功"
,
map
);
//跳转到dashboard页面
}
//如果用户名或者密码不正确
}
//如果用户名或者密码不正确
else
{
else
{
model
.
addAttribute
(
"msg"
,
"手机号码格式错误"
);
//显示错误信息
//map.put("jump","index");
return
Result
.
success
(
400
,
"注册失败"
,
map
);
return
Result
.
success
(
400
,
"注册失败"
,
map
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录