Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
a0104e38
Commit
a0104e38
authored
Nov 06, 2019
by
杨锐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code review。
parent
4111bc9e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
69 additions
and
65 deletions
+69
-65
AuditReq.java
...uantgroup/xyqb/controller/modifyphoneno/req/AuditReq.java
+1
-1
Step1Req.java
...uantgroup/xyqb/controller/modifyphoneno/req/Step1Req.java
+2
-2
ModifyPhoneNo.java
src/main/java/cn/quantgroup/xyqb/entity/ModifyPhoneNo.java
+2
-2
IUserDetailRepository.java
.../cn/quantgroup/xyqb/repository/IUserDetailRepository.java
+0
-4
IUserRepository.java
...n/java/cn/quantgroup/xyqb/repository/IUserRepository.java
+2
-0
ModifyPhoneNoServiceImpl.java
...roup/xyqb/service/user/impl/ModifyPhoneNoServiceImpl.java
+16
-12
DateUtils.java
src/main/java/cn/quantgroup/xyqb/util/DateUtils.java
+46
-1
DateUtilsV1.java
src/main/java/cn/quantgroup/xyqb/util/DateUtilsV1.java
+0
-43
No files found.
src/main/java/cn/quantgroup/xyqb/controller/modifyphoneno/req/AuditReq.java
View file @
a0104e38
...
@@ -16,7 +16,7 @@ import javax.validation.constraints.NotNull;
...
@@ -16,7 +16,7 @@ import javax.validation.constraints.NotNull;
public
class
AuditReq
{
public
class
AuditReq
{
@NotNull
(
message
=
"id不能为空"
)
@NotNull
(
message
=
"id不能为空"
)
private
Long
id
;
private
Long
id
;
@ApiModelProperty
(
"申请状态
INIT处理中; DONE修改完成; NO_ALLOW不允许修改
;"
)
@ApiModelProperty
(
"申请状态
DONE 通过; NO_ALLOW 不通过
;"
)
@NotNull
(
message
=
"申请状态不能为空"
)
@NotNull
(
message
=
"申请状态不能为空"
)
private
ModifyPhoneNoApplyStatusEnum
applyStatus
;
private
ModifyPhoneNoApplyStatusEnum
applyStatus
;
@ApiModelProperty
(
"申请状态补充原因"
)
@ApiModelProperty
(
"申请状态补充原因"
)
...
...
src/main/java/cn/quantgroup/xyqb/controller/modifyphoneno/req/Step1Req.java
View file @
a0104e38
...
@@ -63,8 +63,8 @@ public class Step1Req {
...
@@ -63,8 +63,8 @@ public class Step1Req {
ModifyPhoneNo
modifyPhoneNo
=
new
ModifyPhoneNo
();
ModifyPhoneNo
modifyPhoneNo
=
new
ModifyPhoneNo
();
BeanUtils
.
copyProperties
(
step1Req
,
modifyPhoneNo
);
BeanUtils
.
copyProperties
(
step1Req
,
modifyPhoneNo
);
Date
date
=
new
Date
();
Date
date
=
new
Date
();
modifyPhoneNo
.
setCreateAt
(
date
);
modifyPhoneNo
.
setCreate
d
At
(
date
);
modifyPhoneNo
.
setUpdateAt
(
date
);
modifyPhoneNo
.
setUpdate
d
At
(
date
);
return
modifyPhoneNo
;
return
modifyPhoneNo
;
}
}
}
}
src/main/java/cn/quantgroup/xyqb/entity/ModifyPhoneNo.java
View file @
a0104e38
...
@@ -91,11 +91,11 @@ public class ModifyPhoneNo {
...
@@ -91,11 +91,11 @@ public class ModifyPhoneNo {
*
*
*/
*/
@Column
(
name
=
"created_at"
)
@Column
(
name
=
"created_at"
)
private
Date
createAt
;
private
Date
create
d
At
;
/**
/**
*
*
*/
*/
@Column
(
name
=
"updated_at"
)
@Column
(
name
=
"updated_at"
)
private
Date
updateAt
;
private
Date
update
d
At
;
}
}
src/main/java/cn/quantgroup/xyqb/repository/IUserDetailRepository.java
View file @
a0104e38
...
@@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
...
@@ -6,7 +6,6 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.JpaSpecificationExecutor
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.List
;
import
java.util.List
;
...
@@ -70,7 +69,4 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>,
...
@@ -70,7 +69,4 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>,
@Query
(
nativeQuery
=
true
,
value
=
"select * from user_detail where user_id = ?1 and phone_no = ?2 "
+
@Query
(
nativeQuery
=
true
,
value
=
"select * from user_detail where user_id = ?1 and phone_no = ?2 "
+
"and name = ?3 and id_no = ?4 limit 1"
)
"and name = ?3 and id_no = ?4 limit 1"
)
UserDetail
findByUserIdAndPhoneNoAndNameAndIdNo
(
Long
userId
,
String
phoneNo
,
String
name
,
String
idNo
);
UserDetail
findByUserIdAndPhoneNoAndNameAndIdNo
(
Long
userId
,
String
phoneNo
,
String
name
,
String
idNo
);
@Query
(
nativeQuery
=
true
,
value
=
"select * from user_detail where phone_no =:phoneNo limit 1"
)
UserDetail
findOneByPhoneNo
(
@Param
(
"phoneNo"
)
String
phoneNo
);
}
}
src/main/java/cn/quantgroup/xyqb/repository/IUserRepository.java
View file @
a0104e38
...
@@ -17,6 +17,8 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica
...
@@ -17,6 +17,8 @@ public interface IUserRepository extends JpaRepository<User, Long>, JpaSpecifica
User
findByPhoneNo
(
String
phoneNo
);
User
findByPhoneNo
(
String
phoneNo
);
User
findFirstByPhoneNo
(
String
phoneNo
);
User
findByUuid
(
String
uuid
);
User
findByUuid
(
String
uuid
);
/**
/**
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/ModifyPhoneNoServiceImpl.java
View file @
a0104e38
...
@@ -11,11 +11,12 @@ import cn.quantgroup.xyqb.entity.ModifyPhoneNo;
...
@@ -11,11 +11,12 @@ import cn.quantgroup.xyqb.entity.ModifyPhoneNo;
import
cn.quantgroup.xyqb.exception.DataException
;
import
cn.quantgroup.xyqb.exception.DataException
;
import
cn.quantgroup.xyqb.repository.IModifyPhoneNoRepository
;
import
cn.quantgroup.xyqb.repository.IModifyPhoneNoRepository
;
import
cn.quantgroup.xyqb.repository.IUserDetailRepository
;
import
cn.quantgroup.xyqb.repository.IUserDetailRepository
;
import
cn.quantgroup.xyqb.repository.IUserRepository
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.user.IModifyPhoneNoService
;
import
cn.quantgroup.xyqb.service.user.IModifyPhoneNoService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.util.DateUtils
V1
;
import
cn.quantgroup.xyqb.util.DateUtils
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -53,6 +54,8 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
...
@@ -53,6 +54,8 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
private
IHttpService
httpService
;
private
IHttpService
httpService
;
@Resource
@Resource
private
IUserService
userService
;
private
IUserService
userService
;
@Resource
private
IUserRepository
userRepository
;
@Value
(
"${api.https}"
)
@Value
(
"${api.https}"
)
public
String
apiHttps
;
public
String
apiHttps
;
...
@@ -126,10 +129,10 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
...
@@ -126,10 +129,10 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"prevPhoneNo"
),
modifyPhoneNoQueryReq
.
getPhoneNo
()));
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"prevPhoneNo"
),
modifyPhoneNoQueryReq
.
getPhoneNo
()));
}
}
if
(
StringUtils
.
isNotBlank
(
modifyPhoneNoQueryReq
.
getStartAt
()))
{
if
(
StringUtils
.
isNotBlank
(
modifyPhoneNoQueryReq
.
getStartAt
()))
{
list
.
add
(
criteriaBuilder
.
greaterThanOrEqualTo
(
root
.
get
(
"create
At"
),
DateUtilsV1
.
strToDate
(
modifyPhoneNoQueryReq
.
getStartAt
(),
DateUtilsV1
.
YMD_FORMAT
)));
list
.
add
(
criteriaBuilder
.
greaterThanOrEqualTo
(
root
.
get
(
"create
dAt"
),
DateUtils
.
strToDate
(
modifyPhoneNoQueryReq
.
getStartAt
(),
DateUtils
.
YMD_FORMAT
)));
}
}
if
(
StringUtils
.
isNotBlank
(
modifyPhoneNoQueryReq
.
getEndAt
()))
{
if
(
StringUtils
.
isNotBlank
(
modifyPhoneNoQueryReq
.
getEndAt
()))
{
list
.
add
(
criteriaBuilder
.
lessThanOrEqualTo
(
root
.
get
(
"create
At"
),
DateUtilsV1
.
strToDate
(
modifyPhoneNoQueryReq
.
getEndAt
(),
DateUtilsV1
.
YMD_FORMAT
)));
list
.
add
(
criteriaBuilder
.
lessThanOrEqualTo
(
root
.
get
(
"create
dAt"
),
DateUtils
.
strToDate
(
modifyPhoneNoQueryReq
.
getEndAt
(),
DateUtils
.
YMD_FORMAT
)));
}
}
if
(
modifyPhoneNoQueryReq
.
getApplyStatus
()
!=
null
)
{
if
(
modifyPhoneNoQueryReq
.
getApplyStatus
()
!=
null
)
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"applyStatus"
),
modifyPhoneNoQueryReq
.
getApplyStatus
().
getType
()));
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"applyStatus"
),
modifyPhoneNoQueryReq
.
getApplyStatus
().
getType
()));
...
@@ -170,7 +173,8 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
...
@@ -170,7 +173,8 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
modifyPhoneNo
.
setApplyStatusReason
(
auditReq
.
getApplyStatusReason
());
modifyPhoneNo
.
setApplyStatusReason
(
auditReq
.
getApplyStatusReason
());
}
}
if
(
ModifyPhoneNoApplyStatusEnum
.
DONE
==
auditReq
.
getApplyStatus
())
{
if
(
ModifyPhoneNoApplyStatusEnum
.
DONE
==
auditReq
.
getApplyStatus
())
{
allowModifyHttp
(
modifyPhoneNo
.
getUserId
());
allowModifyHttp
(
modifyPhoneNo
.
getUserId
(),
modifyPhoneNo
.
getName
(),
modifyPhoneNo
.
getIdCard
(),
modifyPhoneNo
.
getPrevPhoneNo
(),
modifyPhoneNo
.
getCurPhoneNo
());
userService
.
modifyPhoneNo
(
modifyPhoneNo
.
getPrevPhoneNo
(),
modifyPhoneNo
.
getCurPhoneNo
());
userService
.
modifyPhoneNo
(
modifyPhoneNo
.
getPrevPhoneNo
(),
modifyPhoneNo
.
getCurPhoneNo
());
modifyPhoneNo
.
setApplyStatus
(
ModifyPhoneNoApplyStatusEnum
.
DONE
.
getType
());
modifyPhoneNo
.
setApplyStatus
(
ModifyPhoneNoApplyStatusEnum
.
DONE
.
getType
());
}
}
...
@@ -197,22 +201,22 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
...
@@ -197,22 +201,22 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
if
(
modifyPhoneNoRepository
.
findFirstByUserIdAndApplyStatus
(
userId
,
ModifyPhoneNoProcessingStatusEnum
.
INIT
.
getType
())
!=
null
)
{
if
(
modifyPhoneNoRepository
.
findFirstByUserIdAndApplyStatus
(
userId
,
ModifyPhoneNoProcessingStatusEnum
.
INIT
.
getType
())
!=
null
)
{
throw
new
DataException
(
"已存在处理中的申请单,不支持再次更换。"
);
throw
new
DataException
(
"已存在处理中的申请单,不支持再次更换。"
);
}
}
if
(
userDetailRepository
.
findByUserIdAndPhoneNoAndNameAndIdNo
(
userId
,
prevPhoneNo
,
name
,
idCard
)
==
null
)
{
throw
new
DataException
(
"信息填写有误,请重新填写。"
);
}
if
(
userDetailRepository
.
findOneByPhoneNo
(
curPhoneNo
)
!=
null
)
{
throw
new
DataException
(
"信息填写有误,请重新填写。"
);
}
if
(!
smsService
.
verifyPhoneAndCode
(
curPhoneNo
,
smsCode
))
{
if
(!
smsService
.
verifyPhoneAndCode
(
curPhoneNo
,
smsCode
))
{
throw
new
DataException
(
"验证码不正确。"
);
throw
new
DataException
(
"验证码不正确。"
);
}
}
allowModifyHttp
(
userId
);
allowModifyHttp
(
userId
,
name
,
idCard
,
prevPhoneNo
,
curPhoneNo
);
}
}
/**
/**
* @param userId user.id
* @param userId user.id
*/
*/
public
void
allowModifyHttp
(
Long
userId
)
{
public
void
allowModifyHttp
(
Long
userId
,
String
name
,
String
idCard
,
String
prevPhoneNo
,
String
curPhoneNo
)
{
if
(
userDetailRepository
.
findByUserIdAndPhoneNoAndNameAndIdNo
(
userId
,
prevPhoneNo
,
name
,
idCard
)
==
null
)
{
throw
new
DataException
(
"信息填写有误,请重新填写。"
);
}
if
(
userRepository
.
findFirstByPhoneNo
(
curPhoneNo
)
!=
null
)
{
throw
new
DataException
(
"信息填写有误,请重新填写。"
);
}
log
.
info
(
"allowModify userId = 【{}】"
,
userId
);
log
.
info
(
"allowModify userId = 【{}】"
,
userId
);
String
res
=
httpService
.
get
(
apiHttps
+
"?userId="
+
userId
);
String
res
=
httpService
.
get
(
apiHttps
+
"?userId="
+
userId
);
log
.
info
(
"allowModify res = 【{}】"
,
res
);
log
.
info
(
"allowModify res = 【{}】"
,
res
);
...
...
src/main/java/cn/quantgroup/xyqb/util/DateUtils.java
View file @
a0104e38
package
cn
.
quantgroup
.
xyqb
.
util
;
package
cn
.
quantgroup
.
xyqb
.
util
;
import
org.apache.commons.lang3.StringUtils
;
import
org.joda.time.DateTime
;
import
org.joda.time.Days
;
import
org.joda.time.format.DateTimeFormat
;
import
org.joda.time.format.DateTimeFormatter
;
import
java.util.Calendar
;
import
java.util.Calendar
;
import
java.util.Date
;
/**
/**
* Created by xuran on 2017/7/4.
* joda-time
* <p>
* Date: 2019/11/6
* Time: 上午11:18
*
* @author: yangrui
*/
*/
public
class
DateUtils
{
public
class
DateUtils
{
public
static
final
String
STANDARD_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
String
YMD_FORMAT
=
"yyyy-MM-dd"
;
public
static
Date
strToDate
(
String
dateTimeStr
,
String
formatStr
)
{
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormat
.
forPattern
(
formatStr
);
DateTime
dateTime
=
dateTimeFormatter
.
parseDateTime
(
dateTimeStr
);
return
dateTime
.
toDate
();
}
/**
* yyyy-MM-dd -> yyyy-MM-dd HH:mm:ss => yyyy-MM-dd 00:00:00
*
* @param date
* @param formatStr
* @return
*/
public
static
String
dateToStr
(
Date
date
,
String
formatStr
)
{
if
(
date
==
null
)
{
return
StringUtils
.
EMPTY
;
}
DateTime
dateTime
=
new
DateTime
(
date
);
return
dateTime
.
toString
(
formatStr
);
}
public
static
int
daysBetween
(
DateTime
fromDate
,
DateTime
toDate
)
{
return
Days
.
daysBetween
(
fromDate
,
toDate
).
getDays
();
}
/**
/**
* 计算当前时间到当天 23:59:59.999 时间差,
* 计算当前时间到当天 23:59:59.999 时间差,
* 返回时间差(单位秒)
* 返回时间差(单位秒)
...
@@ -22,4 +63,8 @@ public class DateUtils {
...
@@ -22,4 +63,8 @@ public class DateUtils {
long
now
=
System
.
currentTimeMillis
();
long
now
=
System
.
currentTimeMillis
();
return
(
timeStamp
-
now
)
/
1000
;
return
(
timeStamp
-
now
)
/
1000
;
}
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
dateToStr
(
strToDate
(
"2019-11-06"
,
DateUtils
.
YMD_FORMAT
),
"yyyy-MM-dd HH:mm:ss"
));
}
}
}
src/main/java/cn/quantgroup/xyqb/util/DateUtilsV1.java
deleted
100644 → 0
View file @
4111bc9e
package
cn
.
quantgroup
.
xyqb
.
util
;
import
org.apache.commons.lang3.StringUtils
;
import
org.joda.time.DateTime
;
import
org.joda.time.Days
;
import
org.joda.time.format.DateTimeFormat
;
import
org.joda.time.format.DateTimeFormatter
;
import
java.util.Date
;
/**
*
*
* Date: 2019/11/5
* Time: 下午5:07
*
* @author: yangrui
*/
public
class
DateUtilsV1
{
public
static
final
String
STANDARD_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
public
static
final
String
YMD_FORMAT
=
"yyyy-MM-dd"
;
public
static
Date
strToDate
(
String
dateTimeStr
,
String
formatStr
)
{
DateTimeFormatter
dateTimeFormatter
=
DateTimeFormat
.
forPattern
(
formatStr
);
DateTime
dateTime
=
dateTimeFormatter
.
parseDateTime
(
dateTimeStr
);
return
dateTime
.
toDate
();
}
public
static
String
dateToStr
(
Date
date
,
String
formatStr
)
{
if
(
date
==
null
)
{
return
StringUtils
.
EMPTY
;
}
DateTime
dateTime
=
new
DateTime
(
date
);
return
dateTime
.
toString
(
formatStr
);
}
public
static
int
daysBetween
(
DateTime
fromDate
,
DateTime
toDate
)
{
return
Days
.
daysBetween
(
fromDate
,
toDate
).
getDays
();
}
public
static
void
main
(
String
[]
args
)
{
}
}
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