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
81f28e1c
Commit
81f28e1c
authored
Apr 26, 2017
by
wudi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into wechat-pay
parents
1229d1b9
86bb1bac
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
483 additions
and
301 deletions
+483
-301
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+346
-301
UserSpouse.java
src/main/java/cn/quantgroup/xyqb/entity/UserSpouse.java
+47
-0
UserSpouseRet.java
src/main/java/cn/quantgroup/xyqb/model/UserSpouseRet.java
+42
-0
IUserSpouseRepository.java
.../cn/quantgroup/xyqb/repository/IUserSpouseRepository.java
+8
-0
IUserSpouseService.java
...a/cn/quantgroup/xyqb/service/user/IUserSpouseService.java
+10
-0
UserSpouseServiceImpl.java
...ntgroup/xyqb/service/user/impl/UserSpouseServiceImpl.java
+30
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
81f28e1c
...
...
@@ -45,6 +45,8 @@ public class InnerController {
private
IAddressService
addressService
;
@Autowired
private
IWechatService
wechatService
;
@Autowired
private
IUserSpouseService
userSpouseService
;
@RequestMapping
(
"/user/search/phoneNo"
)
...
...
@@ -72,19 +74,19 @@ public class InnerController {
String
phoneNo
,
Long
registeredFrom
,
Long
createdAt
,
Long
updatedAt
,
String
password
,
String
uuid
)
{
//参数验证
if
(
StringUtils
.
isBlank
(
phoneNo
))
{
if
(
StringUtils
.
isBlank
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"用户手机号不能为空."
,
null
);
}
if
(
registeredFrom
==
null
)
{
if
(
registeredFrom
==
null
)
{
registeredFrom
=
0L
;
}
if
(
StringUtils
.
isBlank
(
password
))
{
if
(
StringUtils
.
isBlank
(
password
))
{
password
=
""
;
}
if
(
StringUtils
.
isBlank
(
uuid
))
{
if
(
StringUtils
.
isBlank
(
uuid
))
{
return
JsonResult
.
buildErrorStateResult
(
"用户uuid为空."
,
null
);
}
if
(
createdAt
==
0L
||
updatedAt
==
0L
)
{
if
(
createdAt
==
0L
||
updatedAt
==
0L
)
{
createdAt
=
System
.
currentTimeMillis
();
updatedAt
=
System
.
currentTimeMillis
();
}
...
...
@@ -103,7 +105,7 @@ public class InnerController {
user
.
setPassword
(
password
);
user
=
userService
.
saveUser
(
user
);
UserRet
userRet
=
null
;
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
userRet
=
UserRet
.
getUserRet
(
user
);
}
return
JsonResult
.
buildSuccessResult
(
null
,
userRet
);
...
...
@@ -111,6 +113,7 @@ public class InnerController {
/**
* 保存用户详细信息
*
* @param userId
* @param phoneNo
* @param name
...
...
@@ -120,22 +123,22 @@ public class InnerController {
*/
@RequestMapping
(
"/user_detail/save"
)
public
JsonResult
saveUserDetail
(
Long
userId
,
String
phoneNo
,
String
name
,
String
idNo
,
String
email
,
Long
id
)
{
String
email
,
Long
id
)
{
//参数验证
if
(
userId
==
null
||
userId
==
0L
)
{
if
(
userId
==
null
||
userId
==
0L
)
{
return
JsonResult
.
buildErrorStateResult
(
"用户id为空."
,
null
);
}
if
(
StringUtils
.
isBlank
(
phoneNo
))
{
if
(
StringUtils
.
isBlank
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"用户手机号为空."
,
null
);
}
if
(
StringUtils
.
isBlank
(
name
))
{
if
(
StringUtils
.
isBlank
(
name
))
{
return
JsonResult
.
buildErrorStateResult
(
"用户名为空."
,
null
);
}
if
(
StringUtils
.
isBlank
(
idNo
))
{
if
(
StringUtils
.
isBlank
(
idNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"用户身份证为空."
,
null
);
}
UserDetail
userDetail
=
new
UserDetail
();
if
(
id
!=
null
&&
id
>
0
)
{
if
(
id
!=
null
&&
id
>
0
)
{
userDetail
.
setId
(
id
);
}
userDetail
.
setUserId
(
userId
);
...
...
@@ -154,47 +157,48 @@ public class InnerController {
}
userDetail
.
setEmail
(
email
);
userDetail
=
userDetailService
.
saveUserDetail
(
userDetail
);
if
(
userDetail
!=
null
)
{
if
(
userDetail
!=
null
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
UserDetailRet
.
getUserDetail
(
userDetail
));
}
return
JsonResult
.
buildErrorStateResult
(
""
,
null
);
return
JsonResult
.
buildErrorStateResult
(
""
,
null
);
}
/**
* 根据用户id查询用户的详细信息
*
* @param userId
* @return
*/
@RequestMapping
(
"/user_detail/search/userId"
)
public
JsonResult
findUserDetailByUserId
(
Long
userId
)
{
public
JsonResult
findUserDetailByUserId
(
Long
userId
)
{
UserDetail
userDetail
=
userDetailService
.
findByUserId
(
userId
);
if
(
userDetail
!=
null
)
{
if
(
userDetail
!=
null
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
UserDetailRet
.
getUserDetail
(
userDetail
));
}
return
JsonResult
.
buildErrorStateResult
(
""
,
null
);
}
@RequestMapping
(
"/user/search/userId"
)
public
JsonResult
findUserByUserId
(
Long
userId
)
{
public
JsonResult
findUserByUserId
(
Long
userId
)
{
User
user
=
userService
.
findById
(
userId
);
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
UserRet
.
getUserRet
(
user
));
}
return
JsonResult
.
buildErrorStateResult
(
""
,
null
);
}
@RequestMapping
(
"/user_detail/search/phone"
)
public
JsonResult
findUserDetailByPhone
(
String
phoneNo
)
{
public
JsonResult
findUserDetailByPhone
(
String
phoneNo
)
{
UserDetail
userDetail
=
userDetailService
.
findByPhoneNo
(
phoneNo
);
if
(
userDetail
!=
null
)
{
if
(
userDetail
!=
null
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
UserDetailRet
.
getUserDetail
(
userDetail
));
}
return
JsonResult
.
buildErrorStateResult
(
""
,
null
);
}
@RequestMapping
(
"/user_detail/update/qq"
)
public
JsonResult
updateUserQQ
(
String
qq
,
Long
userId
)
{
if
(
StringUtils
.
isEmpty
(
qq
)
||
userId
==
null
||
userId
==
0L
)
{
public
JsonResult
updateUserQQ
(
String
qq
,
Long
userId
)
{
if
(
StringUtils
.
isEmpty
(
qq
)
||
userId
==
null
||
userId
==
0L
)
{
return
JsonResult
.
buildErrorStateResult
(
"参数校验失败,qq或用户id为空"
,
null
);
}
userDetailService
.
updateUserQQ
(
userId
,
qq
);
...
...
@@ -207,7 +211,7 @@ public class InnerController {
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
);
if
(
null
==
contacts
||
contacts
.
size
()
==
0
)
{
if
(
null
==
contacts
||
contacts
.
size
()
==
0
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
Collections
.
emptyList
());
}
return
JsonResult
.
buildSuccessResult
(
null
,
ContactRet
.
contacts2ContactRets
(
contacts
));
...
...
@@ -223,10 +227,11 @@ public class InnerController {
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
List
<
Contact
>
userContact
=
contactService
.
findByUserId
(
userId
);
if
(
userContact
!=
null
&&
userContact
.
size
()
>=
2
)
{
if
(
userContact
!=
null
&&
userContact
.
size
()
>=
2
)
{
return
JsonResult
.
buildSuccessResult
(
null
,
ContactRet
.
contacts2ContactRets
(
userContact
));
}
List
<
Contact
>
contacts
=
JSONObject
.
parseObject
(
contactsStr
,
new
TypeReference
<
List
<
Contact
>>()
{});
List
<
Contact
>
contacts
=
JSONObject
.
parseObject
(
contactsStr
,
new
TypeReference
<
List
<
Contact
>>()
{
});
if
(
CollectionUtils
.
isEmpty
(
contacts
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
...
...
@@ -346,11 +351,11 @@ public class InnerController {
@RequestMapping
(
"/user/query/openId"
)
public
JsonResult
queryOpenIdByUserId
(
Long
userId
)
{
if
(
userId
==
null
)
{
if
(
userId
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
"userId不能为空"
,
null
);
}
WechatUserInfo
wechatUserInfo
=
wechatService
.
queryOpenIdByUserId
(
userId
);
if
(
wechatUserInfo
==
null
)
{
if
(
wechatUserInfo
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
return
JsonResult
.
buildSuccessResult
(
"success"
,
wechatUserInfo
.
getOpenId
());
...
...
@@ -358,14 +363,54 @@ public class InnerController {
@RequestMapping
(
"/user/wechat/phone_no"
)
public
JsonResult
queryOpenIdByPhoneNo
(
String
phoneNo
)
{
if
(
StringUtils
.
isBlank
(
phoneNo
))
{
if
(
StringUtils
.
isBlank
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号错误"
,
null
);
}
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
if
(!
ValidationUtil
.
validatePhoneNo
(
phoneNo
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式错误"
,
null
);
}
WechatUserInfo
wechatUserInfo
=
wechatService
.
findWechatUserInfoByPhoneNo
(
phoneNo
);
return
JsonResult
.
buildSuccessResult
(
null
,
null
==
wechatUserInfo
?
null
:
wechatUserInfo
.
getOpenId
());
}
@RequestMapping
(
"/user/spouse/save"
)
public
JsonResult
saveSpouse
(
Long
userId
,
MaritalStatus
status
,
String
spousePhone
,
String
spouseName
)
{
if
(
userId
==
null
||
userId
==
0
)
{
return
JsonResult
.
buildErrorStateResult
(
"用户不能为空"
,
null
);
}
if
(
status
==
MaritalStatus
.
MARRIED
)
{
if
(!
ValidationUtil
.
validatePhoneNo
(
spousePhone
))
{
return
JsonResult
.
buildErrorStateResult
(
"手机号格式错误"
,
null
);
}
if
(
StringUtils
.
isBlank
(
spouseName
))
{
return
JsonResult
.
buildErrorStateResult
(
"配偶姓名不能为空"
,
null
);
}
}
UserSpouse
userSpouse
=
userSpouseService
.
findByUserId
(
userId
);
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
if
(
userSpouse
==
null
)
{
userSpouse
=
new
UserSpouse
(
userId
);
userSpouse
.
setCreatedAt
(
timestamp
);
}
userSpouse
.
setSpouseName
(
status
==
MaritalStatus
.
MARRIED
?
spouseName
:
""
);
userSpouse
.
setSpousePhone
(
status
==
MaritalStatus
.
MARRIED
?
spousePhone
:
""
);
userSpouse
.
setStatus
(
status
);
userSpouse
.
setUpdateAt
(
timestamp
);
userSpouse
=
userSpouseService
.
save
(
userSpouse
);
return
JsonResult
.
buildSuccessResult
(
null
,
UserSpouseRet
.
getUserSpouseRet
(
userSpouse
));
}
@RequestMapping
(
"/user/spouse/findByUserId"
)
public
JsonResult
querySpouse
(
Long
userId
)
{
if
(
userId
==
null
||
userId
==
0
)
{
return
JsonResult
.
buildErrorStateResult
(
"用户不能为空"
,
null
);
}
UserSpouse
userSpouse
=
userSpouseService
.
findByUserId
(
userId
);
if
(
userSpouse
==
null
)
{
userSpouse
=
new
UserSpouse
(
userId
);
userSpouse
.
setStatus
(
MaritalStatus
.
UNKNOWN
);
}
return
JsonResult
.
buildSuccessResult
(
null
,
UserSpouseRet
.
getUserSpouseRet
(
userSpouse
));
}
}
\ No newline at end of file
src/main/java/cn/quantgroup/xyqb/entity/UserSpouse.java
0 → 100644
View file @
81f28e1c
package
cn
.
quantgroup
.
xyqb
.
entity
;
import
cn.quantgroup.xyqb.entity.enumerate.MaritalStatus
;
import
lombok.*
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
@Data
@Entity
@Table
(
name
=
"user_spouse"
,
uniqueConstraints
=
@UniqueConstraint
(
columnNames
=
"user_id"
))
@Getter
@Setter
@ToString
@NoArgsConstructor
public
class
UserSpouse
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1L
;
@Id
@Column
(
name
=
"id"
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
@Column
(
name
=
"user_id"
)
private
Long
userId
;
@Column
(
name
=
"spouse_phone"
)
private
String
spousePhone
;
@Column
(
name
=
"spouse_name"
)
private
String
spouseName
;
@Column
(
name
=
"created_at"
)
private
Timestamp
createdAt
;
@Column
(
name
=
"updated_at"
)
private
Timestamp
updateAt
;
@Column
(
name
=
"status"
)
private
MaritalStatus
status
;
public
UserSpouse
(
Long
userId
)
{
this
.
userId
=
userId
;
}
}
src/main/java/cn/quantgroup/xyqb/model/UserSpouseRet.java
0 → 100644
View file @
81f28e1c
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.UserSpouse
;
import
cn.quantgroup.xyqb.entity.enumerate.MaritalStatus
;
import
lombok.Data
;
/**
* Created by 11 on 2017/4/19.
*/
@Data
public
class
UserSpouseRet
{
private
Long
userId
;
private
String
spousePhone
;
private
String
spouseName
;
private
Long
createdAt
;
private
Long
updateAt
;
private
MaritalStatus
status
;
public
static
UserSpouseRet
getUserSpouseRet
(
UserSpouse
userSpouse
)
{
if
(
userSpouse
==
null
)
{
return
null
;
}
UserSpouseRet
ret
=
new
UserSpouseRet
();
ret
.
setUserId
(
userSpouse
.
getUserId
());
ret
.
setSpouseName
(
userSpouse
.
getSpouseName
());
ret
.
setSpousePhone
(
userSpouse
.
getSpousePhone
());
if
(
userSpouse
.
getUpdateAt
()
!=
null
)
{
ret
.
setUpdateAt
(
userSpouse
.
getUpdateAt
().
getTime
());
}
if
(
userSpouse
.
getCreatedAt
()
!=
null
)
{
ret
.
setCreatedAt
(
userSpouse
.
getCreatedAt
().
getTime
());
}
ret
.
setStatus
(
userSpouse
.
getStatus
());
return
ret
;
}
}
src/main/java/cn/quantgroup/xyqb/repository/IUserSpouseRepository.java
0 → 100644
View file @
81f28e1c
package
cn
.
quantgroup
.
xyqb
.
repository
;
import
cn.quantgroup.xyqb.entity.UserSpouse
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
IUserSpouseRepository
extends
JpaRepository
<
UserSpouse
,
Long
>
{
UserSpouse
findByUserId
(
Long
userId
);
}
src/main/java/cn/quantgroup/xyqb/service/user/IUserSpouseService.java
0 → 100644
View file @
81f28e1c
package
cn
.
quantgroup
.
xyqb
.
service
.
user
;
import
cn.quantgroup.xyqb.entity.UserSpouse
;
public
interface
IUserSpouseService
{
UserSpouse
findByUserId
(
Long
userId
);
UserSpouse
save
(
UserSpouse
userSpouse
);
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserSpouseServiceImpl.java
0 → 100644
View file @
81f28e1c
package
cn
.
quantgroup
.
xyqb
.
service
.
user
.
impl
;
import
cn.quantgroup.xyqb.entity.UserSpouse
;
import
cn.quantgroup.xyqb.repository.IUserSpouseRepository
;
import
cn.quantgroup.xyqb.service.user.IUserSpouseService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
@Service
public
class
UserSpouseServiceImpl
implements
IUserSpouseService
{
@Autowired
private
IUserSpouseRepository
userSpouseRepository
;
@Override
@Cacheable
(
value
=
"userSpouseCache"
,
key
=
"'spouse' + #userId"
,
unless
=
"#result == null"
,
cacheManager
=
"cacheManager"
)
public
UserSpouse
findByUserId
(
Long
userId
)
{
return
userSpouseRepository
.
findByUserId
(
userId
);
}
@Override
@CacheEvict
(
value
=
"userSpouseCache"
,
key
=
"'spouse' + #userSpouse.userId"
,
cacheManager
=
"cacheManager"
)
public
UserSpouse
save
(
UserSpouse
userSpouse
)
{
return
userSpouseRepository
.
save
(
userSpouse
);
}
}
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