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
6acc86f0
Commit
6acc86f0
authored
Mar 23, 2017
by
lee_mingzhu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change something
parent
cebf60ef
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
293 additions
and
0 deletions
+293
-0
IpValidator.java
.../java/cn/quantgroup/xyqb/aspect/ipfilter/IpValidator.java
+12
-0
UserCenterController.java
...controller/external/user/center/UserCenterController.java
+209
-0
UserAttached.java
src/main/java/cn/quantgroup/xyqb/entity/UserAttached.java
+22
-0
IUserAttachedRepository.java
...n/quantgroup/xyqb/repository/IUserAttachedRepository.java
+11
-0
UserCenterService.java
...va/cn/quantgroup/xyqb/service/user/UserCenterService.java
+11
-0
UserCenterServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserCenterServiceImpl.java
+27
-0
xyqb.properties
src/main/resources/config/dev/xyqb.properties
+1
-0
No files found.
src/main/java/cn/quantgroup/xyqb/aspect/ipfilter/IpValidator.java
0 → 100644
View file @
6acc86f0
package
cn
.
quantgroup
.
xyqb
.
aspect
.
ipfilter
;
import
java.lang.annotation.*
;
/**
* Created by 11 on 2017/3/23.
*/
@Documented
@Target
(
ElementType
.
METHOD
)
@Retention
(
RetentionPolicy
.
RUNTIME
)
public
@interface
IpValidator
{
}
src/main/java/cn/quantgroup/xyqb/controller/external/user/center/UserCenterController.java
0 → 100644
View file @
6acc86f0
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
.
user
.
center
;
import
cn.quantgroup.xyqb.entity.*
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.user.*
;
import
org.apache.commons.lang.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.sql.Timestamp
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* Created by 11 on 2017/3/22.
*/
@RestController
@RequestMapping
(
"/user/center"
)
public
class
UserCenterController
{
@Autowired
private
UserCenterService
userCenterService
;
@Autowired
private
IUserDetailService
userDetailService
;
@Autowired
private
IUserExtInfoService
userExtInfoService
;
@Autowired
private
IContactService
contactService
;
@Autowired
private
IAddressService
addressService
;
@Autowired
private
IUserService
userService
;
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
UserCenterController
.
class
);
/**
* 用户中心首页,显示用户头像、昵称、姓名
* @param phoneNo
* @return
*/
@RequestMapping
(
"/index"
)
public
JsonResult
userCenterIndex
(
String
phoneNo
)
{
Long
userId
=
queryUserId
(
phoneNo
);
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
Map
<
String
,
String
>
result
=
new
HashMap
<>();
if
(
userAttached
!=
null
)
{
result
.
put
(
"avatar"
,
userAttached
.
getAvatar
());
result
.
put
(
"nick"
,
userAttached
.
getNick
());
}
UserDetail
userDetail
=
userDetailService
.
findByUserId
(
userId
);
if
(
userDetail
!=
null
)
{
result
.
put
(
"name"
,
userDetail
.
getName
());
}
return
JsonResult
.
buildSuccessResult
(
null
,
result
);
}
/**
* 上传后调用该接口保存用户头像
* @param phoneNo 用户手机号
* @param avatarUrl 上传后生成的头像地址
* @return
*/
@RequestMapping
(
"/save/avatar"
)
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
))
{
LOGGER
.
error
(
"参数不合法:avatarUrl:{}, phoneNo:{}"
,
avatarUrl
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
Long
userId
=
queryUserId
(
phoneNo
);
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
//查询到数据,直接更新头像和更新时间
if
(
null
!=
userAttached
)
{
userAttached
.
setAvatar
(
avatarUrl
);
userAttached
.
setUpdatedAt
(
new
Timestamp
(
System
.
currentTimeMillis
()));
}
else
{
userAttached
=
createUserAttached
(
userId
,
avatarUrl
,
""
);
}
UserAttached
result
=
userCenterService
.
saveUserAttached
(
userAttached
);
if
(
null
==
userAttached
)
{
LOGGER
.
error
(
"保存用户头像昵称失败."
);
return
JsonResult
.
buildErrorStateResult
(
"信息保存失败,请稍后再试."
,
null
);
}
return
JsonResult
.
buildSuccessResult
(
"保存成功"
,
result
);
}
/**
* 根据用户手机号查询昵称.
* @param phoneNo
* @return
*/
@RequestMapping
(
"/queryNick"
)
public
JsonResult
queryUserNick
(
String
phoneNo
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
))
{
LOGGER
.
error
(
"手机号为空,phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
Long
userId
=
queryUserId
(
phoneNo
);
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
if
(
null
!=
userAttached
)
{
LOGGER
.
info
(
"获取用户昵称:{}"
,
userAttached
.
getNick
());
return
JsonResult
.
buildSuccessResult
(
null
,
userAttached
.
getNick
());
}
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
}
/**
* 修改用户的昵称
* @param phoneNo
* @param nick
* @return
*/
@RequestMapping
(
"/saveNick"
)
public
JsonResult
saveUserNick
(
String
phoneNo
,
String
nick
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
))
{
LOGGER
.
error
(
"手机号为空,phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
Long
userId
=
queryUserId
(
phoneNo
);
UserAttached
userAttached
=
userCenterService
.
searchUserAttachedByUserId
(
userId
);
if
(
null
==
userAttached
)
{
userAttached
=
createUserAttached
(
userId
,
""
,
nick
);
}
else
{
userAttached
.
setNick
(
nick
);
userAttached
.
setUpdatedAt
(
new
Timestamp
(
System
.
currentTimeMillis
()));
}
UserAttached
result
=
userCenterService
.
saveUserAttached
(
userAttached
);
return
JsonResult
.
buildSuccessResult
(
null
,
result
.
getNick
());
}
/**
* 查询用户是否实名认证.
* @param phoneNo
* @return
*/
@RequestMapping
(
"/query/verified"
)
public
JsonResult
queryVerified
(
String
phoneNo
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
))
{
LOGGER
.
error
(
"手机号为空,phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
Long
userId
=
queryUserId
(
phoneNo
);
UserDetail
userDetail
=
userDetailService
.
findByUserId
(
userId
);
if
(
null
!=
userDetail
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
userDetail
);
}
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
}
/**
* 个人资料信息
* @param phoneNo
* @return
*/
@RequestMapping
(
"/personalData"
)
public
JsonResult
personalData
(
String
phoneNo
)
{
if
(
StringUtils
.
isEmpty
(
phoneNo
))
{
LOGGER
.
error
(
"手机号为空,phoneNo:{}"
,
phoneNo
);
return
JsonResult
.
buildErrorStateResult
(
"参数不合法"
,
null
);
}
Long
userId
=
queryUserId
(
phoneNo
);
UserExtInfo
userExtInfo
=
userExtInfoService
.
findByUserId
(
userId
);
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
if
(
null
!=
userExtInfo
)
{
result
.
put
(
"contacts"
,
null
!=
contacts
&&
contacts
.
size
()
>
0
?
true
:
false
);
result
.
put
(
"occupation"
,
userExtInfo
.
getOccupationEnum
().
ordinal
());
result
.
put
(
"education"
,
userExtInfo
.
getEducationEnum
().
ordinal
());
result
.
put
(
"income"
,
userExtInfo
.
getIncomeRangeEnum
().
ordinal
());
//查询用户居住地信息
result
.
put
(
"marryStatus"
,
userExtInfo
.
getMarryStatus
().
ordinal
());
}
Address
address
=
addressService
.
findByUserId
(
userId
);
if
(
null
!=
address
)
{
//用户住址信息,返回二级信息:
result
.
put
(
"address"
,
address
.
getProvince
()
+
" "
+
address
.
getCity
());
}
return
JsonResult
.
buildSuccessResult
(
null
,
result
);
}
private
UserAttached
createUserAttached
(
Long
userId
,
String
avatar
,
String
nick
)
{
UserAttached
userAttached
=
new
UserAttached
();
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
userAttached
.
setUserId
(
userId
);
userAttached
.
setAvatar
(
avatar
);
userAttached
.
setNick
(
nick
);
userAttached
.
setCreatedAt
(
now
);
userAttached
.
setUpdatedAt
(
now
);
return
userAttached
;
}
/**
* 根据手机号查询用户id, nodejs调用接口无法获取到userId.
* 所以增加该接口来查询用户id
* @param phoneNo
* @return
*/
private
Long
queryUserId
(
String
phoneNo
)
{
User
user
=
userService
.
findByPhoneInDb
(
phoneNo
);
return
user
.
getId
();
}
}
src/main/java/cn/quantgroup/xyqb/entity/UserAttached.java
0 → 100644
View file @
6acc86f0
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
lombok.Data
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
import
java.sql.Timestamp
;
/**
* Created by 11 on 2017/3/22.
*/
@Data
@Entity
@Table
(
name
=
"user_attached"
)
public
class
UserAttached
{
private
Long
id
;
private
Long
userId
;
private
String
avatar
;
private
String
nick
;
private
Timestamp
createdAt
;
private
Timestamp
updatedAt
;
}
src/main/java/cn/quantgroup/xyqb/repository/IUserAttachedRepository.java
0 → 100644
View file @
6acc86f0
package
cn
.
quantgroup
.
xyqb
.
repository
;
import
cn.quantgroup.xyqb.entity.UserAttached
;
import
org.springframework.data.jpa.repository.JpaRepository
;
/**
* Created by 11 on 2017/3/22.
*/
public
interface
IUserAttachedRepository
extends
JpaRepository
<
UserAttached
,
Long
>
{
UserAttached
findByUserId
(
Long
userId
);
}
src/main/java/cn/quantgroup/xyqb/service/user/UserCenterService.java
0 → 100644
View file @
6acc86f0
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.UserAttached
;
/**
* Created by 11 on 2017/3/22.
*/
public
interface
UserCenterService
{
UserAttached
searchUserAttachedByUserId
(
Long
userId
);
UserAttached
saveUserAttached
(
UserAttached
userAttached
);
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserCenterServiceImpl.java
0 → 100644
View file @
6acc86f0
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
import
cn.quantgroup.xyqb.entity.UserAttached
;
import
cn.quantgroup.xyqb.repository.IUserAttachedRepository
;
import
cn.quantgroup.xyqb.service.user.UserCenterService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
* Created by 11 on 2017/3/22.
*/
@Service
public
class
UserCenterServiceImpl
implements
UserCenterService
{
@Autowired
private
IUserAttachedRepository
userAttachedRepository
;
@Override
public
UserAttached
searchUserAttachedByUserId
(
Long
userId
)
{
return
userAttachedRepository
.
findByUserId
(
userId
);
}
@Override
public
UserAttached
saveUserAttached
(
UserAttached
userAttached
)
{
return
userAttachedRepository
.
save
(
userAttached
);
}
}
src/main/resources/config/dev/xyqb.properties
View file @
6acc86f0
accessable
=
0
configserver.disable
=
1
configserver.disable
=
1
configserver.system
=
xyqb-user
configserver.system
=
xyqb-user
...
...
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