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
7dbbdaac
Commit
7dbbdaac
authored
Jan 09, 2018
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改善代码
parent
1721e3a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
25 deletions
+20
-25
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+19
-22
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+1
-3
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
7dbbdaac
...
...
@@ -7,7 +7,6 @@ import cn.quantgroup.xyqb.controller.IBaseController;
import
cn.quantgroup.xyqb.entity.*
;
import
cn.quantgroup.xyqb.entity.enumerate.*
;
import
cn.quantgroup.xyqb.exception.UserNotExistException
;
import
cn.quantgroup.xyqb.exception.VerificationCodeErrorException
;
import
cn.quantgroup.xyqb.model.*
;
import
cn.quantgroup.xyqb.service.api.IUserApiService
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
...
...
@@ -28,6 +27,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
import
com.google.common.base.MoreObjects
;
import
com.google.common.collect.ImmutableMap
;
import
com.google.common.collect.Maps
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -46,6 +46,7 @@ import java.text.ParseException;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
* Created by Miraculous on 2016/12/19.
*/
...
...
@@ -90,8 +91,6 @@ public class InnerController implements IBaseController {
@Value
(
"${xyqb.auth.url}"
)
private
String
hanguguanUrl
;
private
final
String
pwdSalt
=
"_lkb"
;
private
static
final
ObjectMapper
MAPPER
=
new
ObjectMapper
();
static
{
...
...
@@ -214,7 +213,7 @@ public class InnerController implements IBaseController {
if
(
user
==
null
)
{
user
=
new
User
();
}
else
if
(!
user
.
getEnable
())
{
LOGGER
.
info
(
"用户已经注销,phoneNo:{}
,
"
,
phoneNo
);
LOGGER
.
info
(
"用户已经注销,phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"用户已经注销"
,
null
);
}
if
(
org
.
apache
.
commons
.
lang
.
StringUtils
.
isEmpty
(
user
.
getUuid
()))
{
...
...
@@ -400,8 +399,7 @@ public class InnerController implements IBaseController {
LOGGER
.
info
(
"用户ID不能为空"
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
List
<
Contact
>
contacts
=
JSONObject
.
parseObject
(
contactsStr
,
new
TypeReference
<
List
<
Contact
>>()
{
});
List
<
Contact
>
contacts
=
JSONObject
.
parseObject
(
contactsStr
,
new
TypeReference
<
List
<
Contact
>>(){});
if
(
CollectionUtils
.
isEmpty
(
contacts
))
{
LOGGER
.
info
(
"联系人不能空"
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
...
...
@@ -693,7 +691,7 @@ public class InnerController implements IBaseController {
@LogHttpCaller
@RequestMapping
(
"/user-association/search/userId"
)
public
JsonResult
findUserAssociationModelByUserId
(
Long
userId
)
{
if
(
Objects
.
isNull
(
userId
)
||
userId
<
0
)
{
if
(
Objects
.
isNull
(
userId
)
||
userId
<
1
)
{
return
JsonResult
.
buildErrorStateResult
(
""
,
""
);
}
UserAssociationModel
bean
=
null
;
...
...
@@ -1162,17 +1160,23 @@ public class InnerController implements IBaseController {
@LogHttpCaller
@RequestMapping
(
"/verifyPhoneAndCode"
)
public
JsonResult
verifyPhoneAndCode
(
@RequestParam
String
phoneNo
,
@RequestParam
String
verificationCode
)
{
User
user
=
null
;
if
(
smsService
.
verifyPhoneAndCode
(
phoneNo
,
verificationCode
))
{
return
JsonResult
.
buildSuccessResult
(
"校验成功"
,
""
);
user
=
userService
.
findByPhoneWithCache
(
phoneNo
);
}
else
{
return
JsonResult
.
buildErrorStateResult
(
"校验失败"
,
""
);
}
if
(
Objects
.
isNull
(
user
))
{
return
JsonResult
.
buildErrorStateResult
(
"用户不存在"
,
""
);
}
else
{
return
JsonResult
.
buildSuccessResult
(
"校验成功"
,
new
UserRet
(
user
));
}
return
JsonResult
.
buildErrorStateResult
(
"校验失败"
,
""
);
}
@LogHttpCaller
@RequestMapping
(
"/login"
)
public
JsonResult
login
(
@RequestParam
String
phoneNo
,
@RequestParam
String
password
)
{
User
user
=
checkPhoneNoAndPassword
(
phoneNo
,
password
);
if
(
user
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"用户名或密码不正确"
,
null
);
}
...
...
@@ -1180,8 +1184,8 @@ public class InnerController implements IBaseController {
return
JsonResult
.
buildSuccessResult
(
"校验成功"
,
model
);
}
private
User
checkPhoneNoAndPassword
(
@RequestParam
String
phoneNo
,
@RequestParam
String
password
)
{
byte
[]
byPhoneNo
=
org
.
apache
.
commons
.
codec
.
binary
.
Base64
.
decodeBase64
(
phoneNo
);
private
User
checkPhoneNoAndPassword
(
String
phoneNo
,
String
password
)
{
byte
[]
byPhoneNo
=
Base64
.
decodeBase64
(
phoneNo
);
String
bufPhoneNo
=
""
;
try
{
bufPhoneNo
=
new
String
(
byPhoneNo
,
"UTF-8"
);
...
...
@@ -1192,7 +1196,7 @@ public class InnerController implements IBaseController {
LOGGER
.
info
(
"手机号错误, phoneNo:{}"
,
bufPhoneNo
);
throw
new
UserNotExistException
(
"手机号错误"
);
}
byte
[]
byPassword
=
org
.
apache
.
commons
.
codec
.
binary
.
Base64
.
decodeBase64
(
password
);
byte
[]
byPassword
=
Base64
.
decodeBase64
(
password
);
String
bufPassword
=
""
;
try
{
bufPassword
=
new
String
(
byPassword
,
"UTF-8"
);
...
...
@@ -1200,23 +1204,16 @@ public class InnerController implements IBaseController {
LOGGER
.
error
(
"不支持的编码: "
,
e
);
}
User
user
=
userService
.
findByPhoneWithCache
(
bufPhoneNo
);
if
(
user
==
null
||
!
user
.
getEnable
())
{
if
(
Objects
.
isNull
(
user
)
||
Objects
.
equals
(
Boolean
.
FALSE
,
user
.
getEnable
()))
{
return
null
;
}
//验证密码
if
(!
validatePassword
(
bufPassword
,
user
.
getPassword
()))
{
if
(!
Objects
.
equals
(
PasswordUtil
.
MD5
(
bufPassword
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
),
user
.
getPassword
()))
{
return
null
;
}
return
user
;
}
private
boolean
validatePassword
(
String
paramPass
,
String
targetPassword
)
{
return
org
.
apache
.
commons
.
lang
.
StringUtils
.
defaultString
(
targetPassword
,
""
).
equals
(
PasswordUtil
.
MD5
(
paramPass
.
toLowerCase
()
+
pwdSalt
));
}
/**
* 查询用户是否存在
*
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
7dbbdaac
...
...
@@ -52,9 +52,7 @@ import java.util.Objects;
@RequestMapping
(
"/user"
)
public
class
UserController
implements
IBaseController
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
UserController
.
class
);
private
final
String
pwdSalt
=
"_lkb"
;
@Autowired
private
IUserService
userService
;
...
...
@@ -441,7 +439,7 @@ public class UserController implements IBaseController {
}
private
boolean
validatePassword
(
String
paramPass
,
String
targetPassword
)
{
return
StringUtils
.
defaultString
(
targetPassword
,
""
).
equals
(
PasswordUtil
.
MD5
(
paramPass
.
toLowerCase
()
+
pwdSalt
));
return
StringUtils
.
defaultString
(
targetPassword
,
""
).
equals
(
PasswordUtil
.
MD5
(
paramPass
.
toLowerCase
()
+
Constants
.
PASSWORD_SALT
));
}
private
JsonResult
loginWithUserId
(
Long
channelId
,
String
appChannel
,
Long
createdFrom
,
String
userId
,
Merchant
merchant
,
String
dimension
)
{
...
...
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