Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴迪
gs1-office-web-sit
Commits
20964509
Commit
20964509
authored
Dec 08, 2021
by
wangtian
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
0cadb562
2c619c17
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
549 additions
and
4 deletions
+549
-4
MemberController.java
...io/office/modules/manage/controller/MemberController.java
+103
-0
MemberDao.java
src/main/java/io/office/modules/manage/dao/MemberDao.java
+17
-0
TimescodeRegiDao.java
...n/java/io/office/modules/manage/dao/TimescodeRegiDao.java
+5
-3
MemberEntity.java
...in/java/io/office/modules/manage/entity/MemberEntity.java
+196
-0
TimescodeRegiEntity.java
.../io/office/modules/manage/entity/TimescodeRegiEntity.java
+1
-1
MemberService.java
.../java/io/office/modules/manage/service/MemberService.java
+24
-0
MemberServiceImpl.java
...office/modules/manage/service/impl/MemberServiceImpl.java
+186
-0
TimescodeRegiServiceImpl.java
...modules/manage/service/impl/TimescodeRegiServiceImpl.java
+17
-0
No files found.
src/main/java/io/office/modules/manage/controller/MemberController.java
0 → 100644
View file @
20964509
package
io
.
office
.
modules
.
manage
.
controller
;
import
java.util.Arrays
;
import
java.util.Map
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
io.office.modules.manage.entity.MemberEntity
;
import
io.office.modules.manage.service.MemberService
;
import
io.office.common.utils.PageUtils
;
import
io.office.common.utils.R
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 13:54:50
*/
@RestController
@RequestMapping
(
"/member"
)
public
class
MemberController
{
@Autowired
private
MemberService
memberService
;
/**
* 用户注册
*/
@RequestMapping
(
"/api/userRegistered"
)
// @RequiresPermissions("manage:member:list")
public
R
userRegistered
(
@RequestBody
Map
<
String
,
Object
>
params
,
HttpServletRequest
request
,
HttpServletResponse
response
){
memberService
.
userRegistered
(
params
,
request
,
response
);
return
R
.
ok
();
}
/**
* 列表
*/
@RequestMapping
(
"/list"
)
// @RequiresPermissions("manage:member:list")
public
R
list
(
@RequestParam
Map
<
String
,
Object
>
params
){
PageUtils
page
=
memberService
.
queryPage
(
params
);
return
R
.
ok
().
put
(
"page"
,
page
);
}
/**
* 信息
*/
@RequestMapping
(
"/info/{id}"
)
// @RequiresPermissions("manage:member:info")
public
R
info
(
@PathVariable
(
"id"
)
Integer
id
){
MemberEntity
member
=
memberService
.
getById
(
id
);
return
R
.
ok
().
put
(
"member"
,
member
);
}
/**
* 保存
*/
@RequestMapping
(
"/save"
)
// @RequiresPermissions("manage:member:save")
public
R
save
(
@RequestBody
MemberEntity
member
){
memberService
.
save
(
member
);
return
R
.
ok
();
}
/**
* 修改
*/
@RequestMapping
(
"/update"
)
// @RequiresPermissions("manage:member:update")
public
R
update
(
@RequestBody
MemberEntity
member
){
memberService
.
updateById
(
member
);
return
R
.
ok
();
}
/**
* 删除
*/
@RequestMapping
(
"/delete"
)
// @RequiresPermissions("manage:member:delete")
public
R
delete
(
@RequestBody
Integer
[]
ids
){
memberService
.
removeByIds
(
Arrays
.
asList
(
ids
));
return
R
.
ok
();
}
}
src/main/java/io/office/modules/manage/dao/MemberDao.java
0 → 100644
View file @
20964509
package
io
.
office
.
modules
.
manage
.
dao
;
import
io.office.modules.manage.entity.MemberEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 13:54:50
*/
@Mapper
public
interface
MemberDao
extends
BaseMapper
<
MemberEntity
>
{
}
src/main/java/io/office/modules/manage/dao/TimescodeRegiDao.java
View file @
20964509
...
...
@@ -2,9 +2,7 @@ package io.office.modules.manage.dao;
import
io.office.modules.manage.entity.TimescodeRegiEntity
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Select
;
import
org.apache.ibatis.annotations.*
;
/**
* ${comments}
...
...
@@ -18,4 +16,8 @@ public interface TimescodeRegiDao extends BaseMapper<TimescodeRegiEntity> {
@Select
(
"select * from timescode_regi where phone=#{phone} "
)
TimescodeRegiEntity
findByPhone
(
@Param
(
"phone"
)
String
phone
);
@Update
(
"UPDATE timescode_regi SET times_validate = #{times_validate} WHERE phone=#{phone}"
)
int
updateById
(
@Param
(
"phone"
)
String
phone
,
@Param
(
"times_validate"
)
Integer
times_validate
);
}
src/main/java/io/office/modules/manage/entity/MemberEntity.java
0 → 100644
View file @
20964509
package
io
.
office
.
modules
.
manage
.
entity
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
java.io.Serializable
;
import
java.util.Date
;
import
lombok.Data
;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 13:54:50
*/
@Data
@TableName
(
"Member"
)
public
class
MemberEntity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* $column.comments
*/
@TableId
private
Integer
id
;
/**
* $column.comments
*/
private
String
username
;
/**
* $column.comments
*/
private
String
password
;
/**
* $column.comments
*/
private
String
email
;
/**
* $column.comments
*/
private
String
email1
;
/**
* $column.comments
*/
private
String
realname
;
/**
* $column.comments
*/
private
String
realname1
;
/**
* $column.comments
*/
private
String
area
;
/**
* $column.comments
*/
private
String
birth
;
/**
* $column.comments
*/
private
String
idcard
;
/**
* $column.comments
*/
private
String
idcard1
;
/**
* $column.comments
*/
private
String
phone
;
/**
* $column.comments
*/
private
String
phone1
;
/**
* $column.comments
*/
private
String
address
;
/**
* $column.comments
*/
private
String
address1
;
/**
* $column.comments
*/
private
String
gender
;
/**
* $column.comments
*/
private
String
sign1
;
/**
* $column.comments
*/
private
String
sign
;
/**
* $column.comments
*/
private
Date
registerdate
;
/**
* $column.comments
*/
private
Date
updatedate
;
/**
* $column.comments
*/
private
String
registerip
;
/**
* $column.comments
*/
private
Integer
levels
;
/**
* $column.comments
*/
private
Date
lasttime
;
/**
* $column.comments
*/
private
Integer
perid
;
/**
* $column.comments
*/
private
String
qustion
;
/**
* $column.comments
*/
private
String
answer
;
/**
* $column.comments
*/
private
String
oicq
;
/**
* $column.comments
*/
private
String
homepage
;
/**
* $column.comments
*/
private
String
company1
;
/**
* $column.comments
*/
private
String
company
;
/**
* $column.comments
*/
private
String
depart1
;
/**
* $column.comments
*/
private
String
depart
;
/**
* $column.comments
*/
private
String
postalcode
;
/**
* $column.comments
*/
private
Integer
vocation
;
/**
* $column.comments
*/
private
Integer
playat
;
/**
* $column.comments
*/
private
String
firmcode
;
/**
* $column.comments
*/
private
String
rights
;
/**
* $column.comments
*/
private
String
mobilenum
;
/**
* $column.comments
*/
private
Integer
atype
;
/**
* $column.comments
*/
private
String
applystate
;
/**
* $column.comments
*/
private
String
alias
;
/**
* $column.comments
*/
private
String
source
;
/**
* $column.comments
*/
private
String
pass
;
}
src/main/java/io/office/modules/manage/entity/TimescodeRegiEntity.java
View file @
20964509
...
...
@@ -24,7 +24,7 @@ public class TimescodeRegiEntity implements Serializable {
/**
* 手机号
*/
@TableId
(
type
=
IdType
.
INPUT
)
@TableId
(
type
=
IdType
.
NONE
)
private
String
phone
;
/**
* 时间
...
...
src/main/java/io/office/modules/manage/service/MemberService.java
0 → 100644
View file @
20964509
package
io
.
office
.
modules
.
manage
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
io.office.common.utils.PageUtils
;
import
io.office.modules.manage.entity.MemberEntity
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Map
;
/**
* ${comments}
*
* @author wudi
* @email
* @date 2021-12-08 13:54:50
*/
public
interface
MemberService
extends
IService
<
MemberEntity
>
{
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
);
void
userRegistered
(
Map
<
String
,
Object
>
params
,
HttpServletRequest
request
,
HttpServletResponse
response
);
}
src/main/java/io/office/modules/manage/service/impl/MemberServiceImpl.java
0 → 100644
View file @
20964509
package
io
.
office
.
modules
.
manage
.
service
.
impl
;
import
io.office.common.exception.RRException
;
import
io.office.common.utils.IPUtils
;
import
io.office.modules.manage.dao.TimescodeRegiDao
;
import
io.office.modules.manage.entity.TimescodeRegiEntity
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Map
;
import
java.util.regex.Pattern
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
io.office.common.utils.PageUtils
;
import
io.office.common.utils.Query
;
import
io.office.modules.manage.dao.MemberDao
;
import
io.office.modules.manage.entity.MemberEntity
;
import
io.office.modules.manage.service.MemberService
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
@Service
(
"memberService"
)
public
class
MemberServiceImpl
extends
ServiceImpl
<
MemberDao
,
MemberEntity
>
implements
MemberService
{
@Autowired
private
TimescodeRegiDao
timescodeRegiDao
;
@Autowired
private
MemberDao
memberDao
;
@Override
public
PageUtils
queryPage
(
Map
<
String
,
Object
>
params
)
{
IPage
<
MemberEntity
>
page
=
this
.
page
(
new
Query
<
MemberEntity
>().
getPage
(
params
),
new
QueryWrapper
<
MemberEntity
>()
);
return
new
PageUtils
(
page
);
}
@Override
public
void
userRegistered
(
Map
<
String
,
Object
>
params
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
String
userName
=
params
.
get
(
"userName"
)
==
null
?
""
:
String
.
valueOf
(
params
.
get
(
"userName"
));
String
emiail
=
params
.
get
(
"e-miail"
)
==
null
?
""
:
String
.
valueOf
(
params
.
get
(
"e-miail"
));
String
phone
=
params
.
get
(
"phone"
)
==
null
?
""
:
String
.
valueOf
(
params
.
get
(
"phone"
));
String
subjoin
=
params
.
get
(
"subjoin"
)
==
null
?
""
:
String
.
valueOf
(
params
.
get
(
"subjoin"
));
//验证码
String
passWord
=
params
.
get
(
"passWord"
)
==
null
?
""
:
String
.
valueOf
(
params
.
get
(
"passWord"
));
String
passWord_repeat
=
params
.
get
(
"passWord_repeat"
)
==
null
?
""
:
String
.
valueOf
(
params
.
get
(
"passWord_repeat"
));
//重复密码
//判断用户名合法性
if
(!
checkUserName
(
userName
)){
throw
new
RRException
(
"用户名只能是数字加字母,长度2-8位"
);
}
//判断密码合法性
if
(!
checkPassWord
(
passWord
)){
throw
new
RRException
(
"密码只能是数字加字母,长度5-12位"
);
}
//判断重复密码
if
(!
passWord
.
equals
(
passWord_repeat
)){
throw
new
RRException
(
"两次密码不一致"
);
}
//判断email
if
(!
isValidEmail
(
emiail
)){
throw
new
RRException
(
"e-miail格式错误"
);
}
//判断联系电话非空,且为11位数字
if
(!
matchPhoneNumber
(
phone
)){
throw
new
RRException
(
"手机格式不正确,请重新填写"
);
}
//利用获取验证码时保存的session,判断手机验证码非空,和发送的短信内容是否一致,提交时的手机号与接收验证码的手机号是否相同,验证码是否已失效
String
subjoinReq
=
request
.
getSession
().
getAttribute
(
"subjoin"
)==
null
?
""
:
String
.
valueOf
(
request
.
getSession
().
getAttribute
(
"subjoin"
));
String
telReq
=
request
.
getSession
().
getAttribute
(
"tel"
)==
null
?
""
:
String
.
valueOf
(
request
.
getSession
().
getAttribute
(
"tel"
));
Long
dateReq
=
request
.
getSession
().
getAttribute
(
"date"
)==
null
?
0
:
Long
.
valueOf
(
String
.
valueOf
(
request
.
getSession
().
getAttribute
(
"date"
)));
//毫秒值
//获取验证码验证次数
TimescodeRegiEntity
timescodeRegiEntity
=
timescodeRegiDao
.
selectById
(
phone
);
Integer
timesValidate
=
timescodeRegiEntity
.
getTimesValidate
();
//验证码输入错误次数;
//校验验证码
checkSubjoinRegi
(
subjoin
,
subjoinReq
,
phone
,
telReq
,
dateReq
,
timesValidate
);
//存入数据库 密码加密
MemberEntity
memberEntity
=
new
MemberEntity
();
memberEntity
.
setUsername
(
userName
);
//TODO tgl MD5加密密码
memberEntity
.
setPassword
(
"MD5加密"
);
memberEntity
.
setEmail
(
emiail
);
memberEntity
.
setPhone
(
phone
);
memberEntity
.
setOicq
(
""
);
memberEntity
.
setRegisterip
(
IPUtils
.
getIpAddr
(
request
));
memberDao
.
insert
(
memberEntity
);
}
/**
* 以下为短信验证码验证次数判断
* @param sub 验证码
* @param reSub session存储的验证码
* @param tel 手机号
* @param reTel session存储的手机号
* @param time_diff session存储的毫秒值
* @param times_validate 验证码失败次数
* @return
*/
public
boolean
checkSubjoinRegi
(
String
sub
,
String
reSub
,
String
tel
,
String
reTel
,
long
time_diff
,
int
times_validate
){
if
(
sub
.
equals
(
""
)){
throw
new
RRException
(
"手机验证码不能为空!"
);
}
else
if
(
time_diff
>=
300
){
throw
new
RRException
(
"验证码已超时!"
);
}
else
if
(
times_validate
>=
3
){
throw
new
RRException
(
"该验证码输入错误满3次,已失效,请重新获取!"
);
}
else
{
if
(!
sub
.
equals
(
reSub
)){
if
(
times_validate
<=
3
){
times_validate
+=
1
;
timescodeRegiDao
.
updateById
(
reTel
,
times_validate
);
throw
new
RRException
(
"验证码已输入错误"
+
times_validate
+
"次(输入错误满3次时,该验证码失效)!"
);
}
}
if
(!
tel
.
equals
(
reTel
)){
throw
new
RRException
(
"手机号码错误!"
);
}
}
return
false
;
}
public
static
void
main
(
String
[]
args
)
{
boolean
validEmail
=
isValidEmail
(
"123"
);
System
.
out
.
println
(
validEmail
);
}
//用户名校验
public
boolean
checkUserName
(
String
logname
){
String
t1
=
"^[0-9A-Za-z]{2,8}$"
;
//判断密码用户名和密码是否为数字,字母(数字或字母)
String
t2
=
"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{2,8}$"
;
//(数字和字母)
if
(
logname
.
matches
(
t2
))
{
return
logname
.
matches
(
t2
);
}
else
{
//System.out.println("用户名只能是数字加字母,长度2-8位");
return
false
;
}
}
public
static
boolean
isValidEmail
(
String
email
)
{
if
((
email
!=
null
)
&&
(!
email
.
isEmpty
()))
{
return
Pattern
.
matches
(
"^(\\w+([-.][A-Za-z0-9]+)*){3,18}@\\w+([-.][A-Za-z0-9]+)*\\.\\w+([-.][A-Za-z0-9]+)*$"
,
email
);
}
return
false
;
}
public
boolean
checkPassWord
(
String
passWord
){
String
t1
=
"^[0-9A-Za-z]{2,8}$"
;
//判断密码用户名和密码是否为数字,字母(数字或字母)
String
t2
=
"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{5,12}$"
;
//(数字和字母)
if
(
passWord
.
matches
(
t2
))
{
return
passWord
.
matches
(
t2
);
}
else
{
//System.out.println("用户名只能是数字加字母,长度2-8位");
return
false
;
}
}
/**
* 验证手机号 由于号码段不断的更新,只需要判断手机号有11位,并且全是数字以及1开头等
* @param phoneNumber 手机号码
* @return
*/
private
static
boolean
matchPhoneNumber
(
String
phoneNumber
)
{
String
regex
=
"1[358][0-9]{9}"
;
if
(
phoneNumber
==
null
||
phoneNumber
.
length
()<=
0
){
return
false
;
}
return
Pattern
.
matches
(
regex
,
phoneNumber
);
}
}
\ No newline at end of file
src/main/java/io/office/modules/manage/service/impl/TimescodeRegiServiceImpl.java
View file @
20964509
...
...
@@ -34,6 +34,7 @@ import io.office.modules.manage.service.TimescodeRegiService;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpSession
;
@Service
(
"timescodeRegiService"
)
...
...
@@ -71,6 +72,16 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
return
Pattern
.
matches
(
regex
,
phoneNumber
);
}
public
static
void
main
(
String
[]
args
)
{
long
l
=
System
.
currentTimeMillis
();
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
long
l2
=
System
.
currentTimeMillis
();
System
.
out
.
println
((
l2
-
l
)/
1000
+
"秒"
);
}
@Override
public
String
getVerificationCode
(
Map
<
String
,
Object
>
params
,
HttpServletRequest
request
,
HttpServletResponse
response
)
{
...
...
@@ -89,6 +100,12 @@ public class TimescodeRegiServiceImpl extends ServiceImpl<TimescodeRegiDao, Time
}
//TODO tgl 判断手机号码是否在黑名单内
//写入session
HttpSession
session
=
request
.
getSession
();
session
.
setAttribute
(
"subjoin"
,
pass
);
//验证码
session
.
setAttribute
(
"tel"
,
pass
);
//手机号
session
.
setAttribute
(
"date"
,
System
.
currentTimeMillis
());
//毫秒值
//发送状态
String
state
=
""
;
// 以下添加同一个手机号短信发送次数验证
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment