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
24a01bee
Commit
24a01bee
authored
Mar 27, 2017
by
lee_mingzhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除切面逻辑,只打印获取到的用户请求IP
parent
69409ec4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
156 additions
and
5 deletions
+156
-5
UserCenterController.java
...controller/external/user/center/UserCenterController.java
+156
-5
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/center/UserCenterController.java
View file @
24a01bee
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
.
user
.
center
;
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
.
user
.
center
;
import
cn.quantgroup.xyqb.entity.*
;
import
cn.quantgroup.xyqb.entity.*
;
import
cn.quantgroup.xyqb.model.AddressRet
;
import
cn.quantgroup.xyqb.model.ContactRet
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.user.*
;
import
cn.quantgroup.xyqb.service.user.*
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -11,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
...
@@ -11,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -45,6 +51,9 @@ public class UserCenterController {
...
@@ -45,6 +51,9 @@ public class UserCenterController {
@RequestMapping
(
"/index"
)
@RequestMapping
(
"/index"
)
public
JsonResult
userCenterIndex
(
String
phoneNo
)
{
public
JsonResult
userCenterIndex
(
String
phoneNo
)
{
Long
userId
=
queryUserId
(
phoneNo
);
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
Map
<
String
,
String
>
result
=
new
HashMap
<>();
Map
<
String
,
String
>
result
=
new
HashMap
<>();
if
(
userAttached
!=
null
)
{
if
(
userAttached
!=
null
)
{
...
@@ -66,15 +75,14 @@ public class UserCenterController {
...
@@ -66,15 +75,14 @@ public class UserCenterController {
*/
*/
@RequestMapping
(
"/save/avatar"
)
@RequestMapping
(
"/save/avatar"
)
public
JsonResult
SaveUserAvatarAddr
(
String
phoneNo
,
String
avatarUrl
)
{
public
JsonResult
SaveUserAvatarAddr
(
String
phoneNo
,
String
avatarUrl
)
{
/*if(null == phoneNo || userId == 0) {
LOGGER.error("用户修改头像、昵称,用户id未获取到:{}", userId);
return JsonResult.buildErrorStateResult("参数不完整,请校验参数.", null);
}*/
if
(
StringUtils
.
isEmpty
(
avatarUrl
)
||
StringUtils
.
isEmpty
(
phoneNo
))
{
if
(
StringUtils
.
isEmpty
(
avatarUrl
)
||
StringUtils
.
isEmpty
(
phoneNo
))
{
LOGGER
.
error
(
"参数不合法:avatarUrl:{}, phoneNo:{}"
,
avatarUrl
,
phoneNo
);
LOGGER
.
error
(
"参数不合法:avatarUrl:{}, phoneNo:{}"
,
avatarUrl
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
}
Long
userId
=
queryUserId
(
phoneNo
);
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
//查询到数据,直接更新头像和更新时间
//查询到数据,直接更新头像和更新时间
if
(
null
!=
userAttached
)
{
if
(
null
!=
userAttached
)
{
...
@@ -103,6 +111,9 @@ public class UserCenterController {
...
@@ -103,6 +111,9 @@ public class UserCenterController {
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
}
Long
userId
=
queryUserId
(
phoneNo
);
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
if
(
null
!=
userAttached
)
{
if
(
null
!=
userAttached
)
{
LOGGER
.
info
(
"获取用户昵称:{}"
,
userAttached
.
getNick
());
LOGGER
.
info
(
"获取用户昵称:{}"
,
userAttached
.
getNick
());
...
@@ -124,6 +135,9 @@ public class UserCenterController {
...
@@ -124,6 +135,9 @@ public class UserCenterController {
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
}
Long
userId
=
queryUserId
(
phoneNo
);
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
if
(
null
==
userAttached
)
{
if
(
null
==
userAttached
)
{
userAttached
=
createUserAttached
(
userId
,
""
,
nick
);
userAttached
=
createUserAttached
(
userId
,
""
,
nick
);
...
@@ -147,6 +161,9 @@ public class UserCenterController {
...
@@ -147,6 +161,9 @@ public class UserCenterController {
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
}
Long
userId
=
queryUserId
(
phoneNo
);
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
UserDetail
userDetail
=
userDetailService
.
findByUserId
(
userId
);
UserDetail
userDetail
=
userDetailService
.
findByUserId
(
userId
);
if
(
null
!=
userDetail
)
{
if
(
null
!=
userDetail
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
userDetail
);
return
JsonResult
.
buildSuccessResult
(
null
,
userDetail
);
...
@@ -166,6 +183,9 @@ public class UserCenterController {
...
@@ -166,6 +183,9 @@ public class UserCenterController {
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
}
Long
userId
=
queryUserId
(
phoneNo
);
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
UserExtInfo
userExtInfo
=
userExtInfoService
.
findByUserId
(
userId
);
UserExtInfo
userExtInfo
=
userExtInfoService
.
findByUserId
(
userId
);
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
);
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
...
@@ -185,6 +205,137 @@ public class UserCenterController {
...
@@ -185,6 +205,137 @@ public class UserCenterController {
return
JsonResult
.
buildSuccessResult
(
null
,
result
);
return
JsonResult
.
buildSuccessResult
(
null
,
result
);
}
}
/**
* 保存用户联系人,
* @param phoneNo 用户手机号
* @param contactJson 要保存的联系人json串
* @return
*/
@RequestMapping
(
"/save/contacts"
)
public
JsonResult
saveUserContact
(
String
phoneNo
,
String
contactJson
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
))
{
LOGGER
.
error
(
"保存联系人,参数错误. phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"参数有误."
,
null
);
}
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
LOGGER
.
error
(
"保存联系人,未获取到用户id. userId:{}"
,
userId
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
if
(
StringUtils
.
isEmpty
(
contactJson
))
{
LOGGER
.
error
(
"保存联系人,联系人参数为空.contactJson:{}"
,
contactJson
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
List
<
Contact
>
userContact
=
contactService
.
findByUserId
(
userId
);
if
(
userContact
!=
null
&&
userContact
.
size
()
>=
2
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
ContactRet
.
contacts2ContactRets
(
userContact
));
}
List
<
Contact
>
contacts
=
JSONObject
.
parseObject
(
contactJson
,
new
TypeReference
<
List
<
Contact
>>()
{});
if
(
CollectionUtils
.
isEmpty
(
contacts
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
for
(
Contact
c
:
contacts
)
{
c
.
setId
(
null
);
c
.
setUserId
(
userId
);
c
.
setCreatedAt
(
now
);
c
.
setUpdateAt
(
now
);
}
List
<
Contact
>
result
=
contactService
.
save
(
contacts
);
return
JsonResult
.
buildSuccessResult
(
null
,
result
);
}
/**
* 保存用户住址信息
* @param province
* @param provinceCode
* @param city
* @param cityCode
* @param address
* @return
*/
@RequestMapping
(
"/address/save"
)
public
JsonResult
saveUserAddress
(
String
phoneNo
,
String
province
,
Long
provinceCode
,
String
city
,
Long
cityCode
,
String
address
)
{
LOGGER
.
info
(
"保存用户地址信息, phoneNo:{}, province:{}, provinceCode:{}, city:{}, cityCode:{}"
,
phoneNo
,
province
,
provinceCode
,
city
,
cityCode
);
if
(
StringUtils
.
isEmpty
(
phoneNo
)
||
provinceCode
==
null
||
cityCode
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
LOGGER
.
error
(
"保存联系人,未获取到用户id. userId:{}"
,
userId
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
//查询用户是否有保存地址信息
Address
addressInfo
=
addressService
.
findByUserId
(
userId
);
if
(
null
==
address
)
{
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
addressInfo
=
new
Address
();
addressInfo
.
setCreatedAt
(
now
);
addressInfo
.
setUpdateAt
(
now
);
}
addressInfo
.
setUserId
(
userId
);
addressInfo
.
setProvince
(
province
);
addressInfo
.
setProvinceCode
(
provinceCode
);
addressInfo
.
setCity
(
city
);
addressInfo
.
setCityCode
(
cityCode
);
addressInfo
.
setAddress
(
address
);
//更新时间
addressInfo
.
setUpdateAt
(
new
Timestamp
(
System
.
currentTimeMillis
()));
addressService
.
saveAddress
(
addressInfo
);
return
JsonResult
.
buildSuccessResult
(
null
,
address
);
}
/**
* 查询用户住址信息
* @param phoneNo
* @return
*/
@RequestMapping
(
"/searchAddress/phoneNo"
)
public
JsonResult
searchUserAddress
(
String
phoneNo
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
LOGGER
.
error
(
"保存联系人,未获取到用户id. userId:{}"
,
userId
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
Address
address
=
addressService
.
findByUserId
(
userId
);
if
(
address
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
return
JsonResult
.
buildSuccessResult
(
null
,
address
);
}
/**
* 查询用户联系人
* @param phoneNo
* @return
*/
@RequestMapping
(
"/searchContacts/phoneNo"
)
public
JsonResult
searchUserContacts
(
String
phoneNo
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
Long
userId
=
queryUserId
(
phoneNo
);
if
(
null
==
userId
||
userId
==
0L
)
{
LOGGER
.
error
(
"保存联系人,未获取到用户id. userId:{}"
,
userId
);
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
);
if
(
null
==
contacts
||
contacts
.
size
()
==
0
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
Collections
.
emptyList
());
}
return
JsonResult
.
buildSuccessResult
(
null
,
contacts
);
}
/**
* 创建用户附加信息实体
* @param userId
* @param avatar
* @param nick
* @return
*/
private
UserAttached
createUserAttached
(
Long
userId
,
String
avatar
,
String
nick
)
{
private
UserAttached
createUserAttached
(
Long
userId
,
String
avatar
,
String
nick
)
{
UserAttached
userAttached
=
new
UserAttached
();
UserAttached
userAttached
=
new
UserAttached
();
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
...
@@ -204,6 +355,6 @@ public class UserCenterController {
...
@@ -204,6 +355,6 @@ public class UserCenterController {
*/
*/
private
Long
queryUserId
(
String
phoneNo
)
{
private
Long
queryUserId
(
String
phoneNo
)
{
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
);
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
);
return
user
.
getId
();
return
null
==
user
?
null
:
user
.
getId
();
}
}
}
}
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