Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
6eb13e72
提交
6eb13e72
authored
10月 28, 2020
作者:
Whispa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit commit
上级
4f5450b7
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
281 行增加
和
248 行删除
+281
-248
AuthController.java
...a/com/example/afrishop_v3/controllers/AuthController.java
+278
-245
application.properties
src/main/resources/application.properties
+3
-3
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/AuthController.java
浏览文件 @
6eb13e72
...
@@ -11,7 +11,6 @@ import com.example.afrishop_v3.models.TbCfCoupon;
...
@@ -11,7 +11,6 @@ import com.example.afrishop_v3.models.TbCfCoupon;
import
com.example.afrishop_v3.models.TbCfToicoupon
;
import
com.example.afrishop_v3.models.TbCfToicoupon
;
import
com.example.afrishop_v3.models.TbCfUserInfo
;
import
com.example.afrishop_v3.models.TbCfUserInfo
;
import
com.example.afrishop_v3.payload.request.LoginRequest
;
import
com.example.afrishop_v3.payload.request.LoginRequest
;
import
com.example.afrishop_v3.payload.response.MessageResponse
;
import
com.example.afrishop_v3.repository.NetworkRepository
;
import
com.example.afrishop_v3.repository.NetworkRepository
;
import
com.example.afrishop_v3.repository.TbCfCouponRepository
;
import
com.example.afrishop_v3.repository.TbCfCouponRepository
;
import
com.example.afrishop_v3.repository.TbCfToicouponRepository
;
import
com.example.afrishop_v3.repository.TbCfToicouponRepository
;
...
@@ -20,7 +19,6 @@ import com.example.afrishop_v3.security.jwt.JwtUtils;
...
@@ -20,7 +19,6 @@ import com.example.afrishop_v3.security.jwt.JwtUtils;
import
com.example.afrishop_v3.security.services.UserDetailsImpl
;
import
com.example.afrishop_v3.security.services.UserDetailsImpl
;
import
com.example.afrishop_v3.util.IdUtil
;
import
com.example.afrishop_v3.util.IdUtil
;
import
org.hashids.Hashids
;
import
org.hashids.Hashids
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.authentication.AuthenticationManager
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
...
@@ -30,6 +28,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
...
@@ -30,6 +28,8 @@ import org.springframework.security.core.context.SecurityContextHolder;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.persistence.EntityManager
;
import
javax.persistence.Query
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.Calendar
;
import
java.util.Calendar
;
...
@@ -48,6 +48,7 @@ public class AuthController extends Controller {
...
@@ -48,6 +48,7 @@ public class AuthController extends Controller {
private
final
TbCfCouponRepository
couponRepository
;
private
final
TbCfCouponRepository
couponRepository
;
private
final
TbCfToicouponRepository
toicouponRepository
;
private
final
TbCfToicouponRepository
toicouponRepository
;
private
final
NetworkRepository
networkRepository
;
private
final
NetworkRepository
networkRepository
;
private
final
EntityManager
entityManager
;
private
final
PasswordEncoder
encoder
;
private
final
PasswordEncoder
encoder
;
...
@@ -55,12 +56,13 @@ public class AuthController extends Controller {
...
@@ -55,12 +56,13 @@ public class AuthController extends Controller {
private
final
JwtUtils
jwtUtils
;
private
final
JwtUtils
jwtUtils
;
public
AuthController
(
AuthenticationManager
authenticationManager
,
UserRepository
userRepository
,
TbCfCouponRepository
couponRepository
,
TbCfToicouponRepository
toicouponRepository
,
NetworkRepository
networkRepository
,
PasswordEncoder
encoder
,
DomainProperties
domainProperties
,
JwtUtils
jwtUtils
)
{
public
AuthController
(
AuthenticationManager
authenticationManager
,
UserRepository
userRepository
,
TbCfCouponRepository
couponRepository
,
TbCfToicouponRepository
toicouponRepository
,
NetworkRepository
networkRepository
,
EntityManager
entityManager
,
PasswordEncoder
encoder
,
DomainProperties
domainProperties
,
JwtUtils
jwtUtils
)
{
this
.
authenticationManager
=
authenticationManager
;
this
.
authenticationManager
=
authenticationManager
;
this
.
userRepository
=
userRepository
;
this
.
userRepository
=
userRepository
;
this
.
couponRepository
=
couponRepository
;
this
.
couponRepository
=
couponRepository
;
this
.
toicouponRepository
=
toicouponRepository
;
this
.
toicouponRepository
=
toicouponRepository
;
this
.
networkRepository
=
networkRepository
;
this
.
networkRepository
=
networkRepository
;
this
.
entityManager
=
entityManager
;
this
.
encoder
=
encoder
;
this
.
encoder
=
encoder
;
this
.
domainProperties
=
domainProperties
;
this
.
domainProperties
=
domainProperties
;
this
.
jwtUtils
=
jwtUtils
;
this
.
jwtUtils
=
jwtUtils
;
...
@@ -69,16 +71,33 @@ public class AuthController extends Controller {
...
@@ -69,16 +71,33 @@ public class AuthController extends Controller {
@PostMapping
(
"/signin"
)
@PostMapping
(
"/signin"
)
public
Result
authenticateUser
(
@RequestBody
LoginRequest
loginRequest
)
{
public
Result
authenticateUser
(
@RequestBody
LoginRequest
loginRequest
)
{
Optional
<
TbCfUserInfo
>
byAccount
=
userRepository
.
findByFirebaseUid
(
loginRequest
.
getAccount
());
Optional
<
TbCfUserInfo
>
byAccount
=
userRepository
.
findByFirebaseUid
(
loginRequest
.
getAccount
());
if
(
!
byAccount
.
isPresent
()
){
Result
<
Object
>
notFound
=
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"User not found"
);
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"User not found"
);
if
(!
byAccount
.
isPresent
())
{
boolean
b
=
userRepository
.
existsByAccount
(
loginRequest
.
getAccount
());
if
(
b
)
{
Optional
<
TbCfUserInfo
>
firstByAccount
=
userRepository
.
findFirstByAccount
(
loginRequest
.
getAccount
());
if
(
firstByAccount
.
isPresent
())
{
TbCfUserInfo
userInfo
=
firstByAccount
.
get
();
userInfo
.
setFirebaseUid
(
loginRequest
.
getAccount
());
try
{
userRepository
.
save
(
userInfo
);
}
catch
(
Exception
e
)
{
return
notFound
;
}
byAccount
=
Optional
.
of
(
userInfo
);
}
else
return
notFound
;
}
else
return
notFound
;
}
}
Authentication
authentication
;
Authentication
authentication
;
try
{
try
{
authentication
=
authenticationManager
.
authenticate
(
authentication
=
authenticationManager
.
authenticate
(
new
UsernamePasswordAuthenticationToken
(
loginRequest
.
getAccount
(),
loginRequest
.
getPassword
()));
new
UsernamePasswordAuthenticationToken
(
loginRequest
.
getAccount
(),
loginRequest
.
getPassword
()));
}
catch
(
BadCredentialsException
e
)
{
}
catch
(
BadCredentialsException
e
)
{
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Invalid username or password"
);
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Invalid username or password"
);
}
}
SecurityContextHolder
.
getContext
().
setAuthentication
(
authentication
);
SecurityContextHolder
.
getContext
().
setAuthentication
(
authentication
);
...
@@ -93,22 +112,23 @@ public class AuthController extends Controller {
...
@@ -93,22 +112,23 @@ public class AuthController extends Controller {
userInfo
.
setToken
(
jwt
);
userInfo
.
setToken
(
jwt
);
if
(
loginRequest
.
getFcm
()
!=
null
)
{
if
(
loginRequest
.
getFcm
()
!=
null
)
{
userInfo
.
setFcm
(
loginRequest
.
getFcm
());
userInfo
.
setFcm
(
loginRequest
.
getFcm
());
}
}
userInfo
.
setLastLoginTime
(
new
Date
());
userInfo
.
setLastLoginTime
(
new
Date
());
userRepository
.
save
(
userInfo
);
userRepository
.
save
(
userInfo
);
if
(
userInfo
.
hasFcm
()
)
{
if
(
userInfo
.
hasFcm
())
{
sendNotification
(
userInfo
.
getFcm
(),
"Welcome "
,
userInfo
.
display
()
+
", Welcome and start shopping !!!"
);
sendNotification
(
userInfo
.
getFcm
(),
"Welcome "
,
userInfo
.
display
()
+
", Welcome and start shopping !!!"
);
}
}
return
new
Result
<>(
userInfo
);
return
new
Result
<>(
userInfo
);
}
}
@PostMapping
(
"/signup"
)
@PostMapping
(
"/signup"
)
public
Result
<?>
registerUser
(
@RequestBody
TbCfUserInfo
signUpRequest
)
{
public
Result
<?>
registerUser
(
@RequestBody
TbCfUserInfo
signUpRequest
)
{
try
{
try
{
// boolean byAccount = userRepository.existsByAccount(signUpRequest.getEmail());
// boolean byAccount = userRepository.existsByAccount(signUpRequest.getEmail());
// if ( byAccount ) {
// if ( byAccount ) {
...
@@ -122,41 +142,42 @@ public class AuthController extends Controller {
...
@@ -122,41 +142,42 @@ public class AuthController extends Controller {
email
=
email
==
null
?
""
:
email
.
trim
();
email
=
email
==
null
?
""
:
email
.
trim
();
if
(
email
.
isEmpty
()
)
{
if
(
email
.
isEmpty
())
{
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Email is empty"
);
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Email is empty"
);
}
}
if
(
!
isEmailValid
(
email
)
)
{
if
(!
isEmailValid
(
email
))
{
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Invalid email"
);
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Invalid email"
);
}
}
if
(
password
==
null
||
password
.
isEmpty
()
)
{
if
(
password
==
null
||
password
.
isEmpty
())
{
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Password is Empty"
);
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Password is Empty"
);
}
}
if
(
!
isPasswordValid
(
password
)
)
{
if
(!
isPasswordValid
(
password
))
{
String
string
=
"Password is not strong"
;
String
string
=
"Password is not strong"
;
if
(
!
isPasswordValidDigit
(
password
)
)
{
if
(!
isPasswordValidDigit
(
password
))
{
string
+=
", a digit must occur at least once"
;
string
+=
", a digit must occur at least once"
;
}
}
if
(
!
isPasswordValidUpperCase
(
password
)
)
{
if
(!
isPasswordValidUpperCase
(
password
))
{
string
+=
", an upper case letter must occur at least once"
;
string
+=
", an upper case letter must occur at least once"
;
}
}
if
(
!
isPasswordValidLength
(
password
)
)
{
if
(!
isPasswordValidLength
(
password
))
{
string
+=
", at least eight characters though"
;
string
+=
", at least eight characters though"
;
}
}
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
string
);
return
new
Result
<>(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
string
);
}
}
boolean
byEmail
=
userRepository
.
existsByFirebaseUid
(
email
);
boolean
byEmail
=
userRepository
.
existsByFirebaseUid
(
email
);
boolean
byEmail2
=
userRepository
.
existsByAccount
(
email
);
if
(
byEmail
)
{
if
(
byEmail
||
byEmail2
)
{
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Error: Email is already in use!"
);
return
new
Result
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
(),
"Error: Email is already in use!"
);
}
}
...
@@ -182,18 +203,14 @@ public class AuthController extends Controller {
...
@@ -182,18 +203,14 @@ public class AuthController extends Controller {
fixCoupon
(
signUpRequest
);
fixCoupon
(
signUpRequest
);
return
authenticateUser
(
new
LoginRequest
(
userInfo
.
getFirebaseUid
(),
password
,
userInfo
.
getFcm
()));
return
authenticateUser
(
new
LoginRequest
(
userInfo
.
getFirebaseUid
(),
password
,
userInfo
.
getFcm
()));
}
}
catch
(
Exception
e
)
{
catch
(
Exception
e
){
System
.
out
.
println
(
e
.
getMessage
());
System
.
out
.
println
(
e
.
getMessage
());
return
new
Result
<>(
ResultCodeEnum
.
SERVICE_ERROR
.
getCode
(),
e
.
getMessage
());
return
new
Result
<>(
ResultCodeEnum
.
SERVICE_ERROR
.
getCode
(),
e
.
getMessage
());
}
}
}
}
@PostMapping
(
value
=
"/register/user"
)
@PostMapping
(
value
=
"/register/user"
)
public
Result
checkFirebase
(
@RequestBody
TbCfUserInfo
user
)
throws
ParseException
{
public
Result
checkFirebase
(
@RequestBody
TbCfUserInfo
user
)
throws
ParseException
{
//Data to be userInfoVo
//Data to be userInfoVo
...
@@ -214,9 +231,12 @@ public class AuthController extends Controller {
...
@@ -214,9 +231,12 @@ public class AuthController extends Controller {
if
(
isTokenValid
)
{
if
(
isTokenValid
)
{
//Query to find user from database by firebase uid
//Query to find user from database by firebase uid
Optional
<
TbCfUserInfo
>
optional
=
userRepository
.
findByFirebaseUid
(
user
.
getFirebaseUid
());
Optional
<
TbCfUserInfo
>
optional
=
userRepository
.
findByFirebaseUid
(
user
.
getFirebaseUid
());
if
(
!
optional
.
isPresent
()
)
{
if
(
user
.
getEmail
()
!=
null
&&
!
user
.
getEmail
().
isEmpty
()
&&
userRepository
.
existsByAccount
(
user
.
getEmail
()))
{
optional
=
userRepository
.
findFirstByAccount
(
user
.
getEmail
());
}
if
(!
optional
.
isPresent
())
{
String
userid
=
IdUtil
.
createIdbyUUID
();
String
userid
=
IdUtil
.
createIdbyUUID
();
...
@@ -228,13 +248,12 @@ public class AuthController extends Controller {
...
@@ -228,13 +248,12 @@ public class AuthController extends Controller {
user
=
userRepository
.
save
(
user
);
user
=
userRepository
.
save
(
user
);
//赠送用户优惠券
//赠送用户优惠券
fixCoupon
(
user
);
fixCoupon
(
user
);
}
else
{
}
else
{
TbCfUserInfo
userInfo
=
optional
.
get
();
TbCfUserInfo
userInfo
=
optional
.
get
();
if
(
user
.
hasFcm
()
)
{
if
(
user
.
hasFcm
())
{
userInfo
.
setFcm
(
user
.
getFcm
());
userInfo
.
setFcm
(
user
.
getFcm
());
}
}
...
@@ -245,20 +264,24 @@ public class AuthController extends Controller {
...
@@ -245,20 +264,24 @@ public class AuthController extends Controller {
boolean
b
=
property
.
equals
(
userInfo
.
getAvatar
())
||
userInfo
.
getAvatar
()
==
null
||
userInfo
.
getAvatar
().
isEmpty
();
boolean
b
=
property
.
equals
(
userInfo
.
getAvatar
())
||
userInfo
.
getAvatar
()
==
null
||
userInfo
.
getAvatar
().
isEmpty
();
if
(
user
.
getAvatar
()
!=
null
&&
b
)
{
if
(
user
.
getAvatar
()
!=
null
&&
b
)
{
userInfo
.
setAvatar
(
user
.
getAvatar
());
userInfo
.
setAvatar
(
user
.
getAvatar
());
}
}
boolean
b1
=
userInfo
.
getNick
()
==
null
||
userInfo
.
getNick
().
isEmpty
();
boolean
b1
=
userInfo
.
getNick
()
==
null
||
userInfo
.
getNick
().
isEmpty
();
if
(
user
.
getNick
()
!=
null
&&
b1
)
{
if
(
user
.
getNick
()
!=
null
&&
b1
)
{
userInfo
.
setNick
(
user
.
getNick
());
userInfo
.
setNick
(
user
.
getNick
());
}
}
if
(
user
.
getEmail
()
!=
null
)
{
if
(
user
.
getEmail
()
!=
null
)
{
userInfo
.
setEmail
(
user
.
getEmail
());
userInfo
.
setEmail
(
user
.
getEmail
());
}
}
if
(
user
.
getPhone
()
!=
null
){
if
(
user
.
getUserType
()
!=
null
)
{
userInfo
.
setUserType
(
user
.
getUserType
());
}
if
(
user
.
getPhone
()
!=
null
)
{
userInfo
.
setPhone
(
user
.
getPhone
());
userInfo
.
setPhone
(
user
.
getPhone
());
}
}
...
@@ -267,13 +290,11 @@ public class AuthController extends Controller {
...
@@ -267,13 +290,11 @@ public class AuthController extends Controller {
}
}
// generate token codes has been moved downwards from if condition of checking if user doesn't exist in database, because even if
// generate token codes has been moved downwards from if condition of checking if user doesn't exist in database, because even if
// user exist we have to generate token also
// user exist we have to generate token also
if
(
user
.
getPassword
()
==
null
)
{
if
(
user
.
getPassword
()
==
null
)
{
user
.
setPassword
(
encoder
.
encode
(
user
.
getFirebaseUid
()));
// Assign user from database to the user we have to return back to request
user
.
setPassword
(
encoder
.
encode
(
user
.
getFirebaseUid
()));
// Assign user from database to the user we have to return back to request
}
}
fixCode
(
user
);
fixCode
(
user
);
//addToNetwork(user);
//addToNetwork(user);
...
@@ -282,18 +303,18 @@ public class AuthController extends Controller {
...
@@ -282,18 +303,18 @@ public class AuthController extends Controller {
userRepository
.
save
(
user
);
userRepository
.
save
(
user
);
//注册成功 创建token
//注册成功 创建token
return
authenticateUser
(
new
LoginRequest
(
user
.
getFirebaseUid
(),
user
.
getFirebaseUid
()));
return
authenticateUser
(
new
LoginRequest
(
user
.
getFirebaseUid
(),
user
.
getFirebaseUid
()));
}
else
{
}
else
{
return
new
Result
<>(
ResultCodeEnum
.
ILLEGAL_ARGUMENT
.
getCode
(),
ResultCodeEnum
.
ILLEGAL_ARGUMENT
.
getDesc
());
return
new
Result
<>(
ResultCodeEnum
.
ILLEGAL_ARGUMENT
.
getCode
(),
ResultCodeEnum
.
ILLEGAL_ARGUMENT
.
getDesc
());
}
}
}
}
private
void
fixCoupon
(
TbCfUserInfo
user
)
{
private
void
fixCoupon
(
TbCfUserInfo
user
)
{
try
{
try
{
List
<
TbCfCoupon
>
couponVailList
=
couponRepository
.
findAllByCouponVaild
(
1
);
List
<
TbCfCoupon
>
couponVailList
=
couponRepository
.
findAllByCouponVaild
(
1
);
//获取当前时间的时分秒
//获取当前时间的时分秒
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd 00:00:00"
);
//设置日期格式
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd 00:00:00"
);
//设置日期格式
...
@@ -314,13 +335,24 @@ public class AuthController extends Controller {
...
@@ -314,13 +335,24 @@ public class AuthController extends Controller {
toi
.
setEndTime
(
endDate
);
toi
.
setEndTime
(
endDate
);
toicouponRepository
.
save
(
toi
);
toicouponRepository
.
save
(
toi
);
}
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
)
{
}
}
private
void
fixCode
(
TbCfUserInfo
user
)
{
if
(
user
.
getCode
()
==
null
)
{
Query
nativeQuery
=
entityManager
.
createNativeQuery
(
"select b.code as data FROM user_info b where b.external_id=:user limit 1"
);
nativeQuery
.
setParameter
(
"user"
,
user
.
getUserId
());
if
(
nativeQuery
.
getSingleResult
()
!=
null
)
{
user
.
setCode
((
String
)
nativeQuery
.
getSingleResult
());
}
}
}
}
private
void
fixCode
(
TbCfUserInfo
user
){
if
(
user
.
getCode
()
==
null
)
{
if
(
user
.
getCode
()
==
null
){
Hashids
hashids
=
new
Hashids
(
"big_afr_dev"
,
6
);
Hashids
hashids
=
new
Hashids
(
"big_afr_dev"
,
6
);
Long
codeCount
=
user
.
getCodeCount
();
Long
codeCount
=
user
.
getCodeCount
();
...
@@ -331,7 +363,7 @@ public class AuthController extends Controller {
...
@@ -331,7 +363,7 @@ public class AuthController extends Controller {
long
range
=
Math
.
abs
((
long
)
(
Math
.
random
()
*
(
Max
-
Min
))
+
Min
);
long
range
=
Math
.
abs
((
long
)
(
Math
.
random
()
*
(
Max
-
Min
))
+
Min
);
long
id
=
Math
.
addExact
(
currentTime
,
range
);
long
id
=
Math
.
addExact
(
currentTime
,
range
);
if
(
codeCount
==
null
)
{
if
(
codeCount
==
null
)
{
id
=
userRepository
.
count
()
+
id
;
id
=
userRepository
.
count
()
+
id
;
}
}
...
@@ -339,11 +371,11 @@ public class AuthController extends Controller {
...
@@ -339,11 +371,11 @@ public class AuthController extends Controller {
}
}
}
}
private
void
addToNetwork
(
TbCfUserInfo
user
)
{
private
void
addToNetwork
(
TbCfUserInfo
user
)
{
Network
top
=
networkRepository
.
findTopByOrderByIdDesc
();
Network
top
=
networkRepository
.
findTopByOrderByIdDesc
();
if
(
top
!=
null
&&
!
user
.
invited
()
)
{
if
(
top
!=
null
&&
!
user
.
invited
()
)
{
if
(!
networkRepository
.
existsByUserInfo_UserIdAndNetworkInfo_UserId
(
top
.
getNetworkId
(),
user
.
getUserId
()))
{
if
(!
networkRepository
.
existsByUserInfo_UserIdAndNetworkInfo_UserId
(
top
.
getNetworkId
(),
user
.
getUserId
()))
{
Network
network
=
new
Network
();
Network
network
=
new
Network
();
network
.
setUserInfo
(
top
.
getNetworkInfo
());
network
.
setUserInfo
(
top
.
getNetworkInfo
());
network
.
setNetworkInfo
(
user
);
network
.
setNetworkInfo
(
user
);
...
@@ -355,7 +387,7 @@ public class AuthController extends Controller {
...
@@ -355,7 +387,7 @@ public class AuthController extends Controller {
}
}
private
void
fillUserNecessayInfo
(
TbCfUserInfo
tbCfUserInfoVo
)
{
private
void
fillUserNecessayInfo
(
TbCfUserInfo
tbCfUserInfoVo
)
{
if
(
tbCfUserInfoVo
.
getAvatar
()
==
null
)
tbCfUserInfoVo
.
setAvatar
(
domainProperties
.
getProperty
(
"user.avatar"
));
if
(
tbCfUserInfoVo
.
getAvatar
()
==
null
)
tbCfUserInfoVo
.
setAvatar
(
domainProperties
.
getProperty
(
"user.avatar"
));
tbCfUserInfoVo
.
setUserNo
(
IdUtil
.
createIdByDate
());
tbCfUserInfoVo
.
setUserNo
(
IdUtil
.
createIdByDate
());
tbCfUserInfoVo
.
setPhoneFlag
(
StateConstant
.
INVALID
);
tbCfUserInfoVo
.
setPhoneFlag
(
StateConstant
.
INVALID
);
tbCfUserInfoVo
.
setLoginCount
(
0
);
tbCfUserInfoVo
.
setLoginCount
(
0
);
...
@@ -364,7 +396,8 @@ public class AuthController extends Controller {
...
@@ -364,7 +396,8 @@ public class AuthController extends Controller {
tbCfUserInfoVo
.
setInvitedCount
(
0
);
tbCfUserInfoVo
.
setInvitedCount
(
0
);
tbCfUserInfoVo
.
setEnableFlag
(
StateConstant
.
VALID
);
tbCfUserInfoVo
.
setEnableFlag
(
StateConstant
.
VALID
);
//目前有验证码的都是邮箱类型
//目前有验证码的都是邮箱类型
tbCfUserInfoVo
.
setUserType
(
UserTypeEnum
.
FACEBOOK
.
getCode
());
if
(
tbCfUserInfoVo
.
getUserType
()
==
null
)
tbCfUserInfoVo
.
setUserType
(
UserTypeEnum
.
UN_KNOW
.
getCode
());
tbCfUserInfoVo
.
setEmailFlag
(
StateConstant
.
INVALID
);
tbCfUserInfoVo
.
setEmailFlag
(
StateConstant
.
INVALID
);
}
}
}
}
src/main/resources/application.properties
浏览文件 @
6eb13e72
server.servlet.context-path
=
/zion
server.servlet.context-path
=
/zion
spring.jpa.hibernate.ddl-auto
=
update
spring.jpa.hibernate.ddl-auto
=
update
server.port
=
700
1
server.port
=
700
0
spring.datasource.url
=
jdbc:mysql://${MYSQL_HOST:
159.138.48.71}:3306/chinafrica_ref
?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.url
=
jdbc:mysql://${MYSQL_HOST:
47.106.242.175}:3306/afrishop_test
?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
spring.datasource.username
=
root
spring.datasource.username
=
root
spring.datasource.password
=
Diaoyunnuli.8
spring.datasource.password
=
diaoyun666
spring.jpa.database-platform
=
org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.database-platform
=
org.hibernate.dialect.MySQL5InnoDBDialect
spring.datasource.connectionInitSql
:
SET NAMES 'utf8mb4'
spring.datasource.connectionInitSql
:
SET NAMES 'utf8mb4'
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
#spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论