Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
relation
Commits
b99cbb59
Commit
b99cbb59
authored
Aug 01, 2025
by
wujipeng
Browse files
新增用户逻辑修改-优化
parent
19cbccd6
Changes
2
Show whitespace changes
Inline
Side-by-side
src/main/java/com/platform/model/dto/RelationShipDTO.java
View file @
b99cbb59
...
...
@@ -13,7 +13,7 @@ import lombok.Data;
public
class
RelationShipDTO
{
@ApiModelProperty
(
value
=
"id"
)
private
String
id
;
private
Integer
id
;
@ApiModelProperty
(
value
=
"用户名"
)
private
String
userName
;
...
...
src/main/java/com/platform/service/impl/UserServiceImpl.java
View file @
b99cbb59
...
...
@@ -69,34 +69,37 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserEntity> impleme
public
Boolean
add
(
UserDTO
userDTO
)
{
//数据转化成json
List
<
RelationShipDTO
>
relationShipList
=
userDTO
.
getRelationShipList
();
//解析身份证号
Map
<
String
,
String
>
idCardInfo
=
IdCardUtils
.
parseIdCardInfo
(
userDTO
.
getIdCard
());
if
(
MapUtil
.
isNotEmpty
(
idCardInfo
)){
userDTO
.
setAge
(
Integer
.
parseInt
(
idCardInfo
.
get
(
"age"
)));
userDTO
.
setSex
(
idCardInfo
.
get
(
"sex"
));
userDTO
.
setIdType
(
"身份证"
);
}
if
(!
relationShipList
.
isEmpty
()){
userDTO
.
setRelationShip
(
JSON
.
toJSONString
(
relationShipList
));
}
save
(
userDTO
);
//更新被选中人的关系
if
(!
relationShipList
.
isEmpty
()){
for
(
RelationShipDTO
relationShipDTO
:
relationShipList
)
{
//查询被选中人信息
UserEntity
user
=
getById
(
relationShipDTO
.
getId
());
//更新被选中人的关系
String
relationShip
=
user
.
getRelationShip
();
//关系反转
relationShipDTO
.
setId
(
userDTO
.
getId
());
if
(
StringUtils
.
isNotEmpty
(
relationShip
)){
String
oldRelationShip
=
user
.
getRelationShip
();
List
<
RelationShipDTO
>
oldRelationShipList
=
JSON
.
parseArray
(
oldRelationShip
,
RelationShipDTO
.
class
);
oldRelationShipList
.
add
(
relationShipDTO
);
user
.
setRelationShip
(
JSON
.
toJSONString
(
oldRelationShipList
));
updateById
(
user
);
}
else
{
List
<
RelationShipDTO
>
relationShipList1
=
Lists
.
newArrayList
();
relationShipList1
.
add
(
relationShipDTO
);
user
.
setRelationShip
(
JSON
.
toJSONString
(
relationShipList1
));
}
updateById
(
user
);
}
String
relationShip
=
JSON
.
toJSONString
(
relationShipList
);
userDTO
.
setRelationShip
(
relationShip
);
}
//解析身份证号
Map
<
String
,
String
>
idCardInfo
=
IdCardUtils
.
parseIdCardInfo
(
userDTO
.
getIdCard
());
if
(
MapUtil
.
isNotEmpty
(
idCardInfo
)){
userDTO
.
setAge
(
Integer
.
parseInt
(
idCardInfo
.
get
(
"age"
)));
userDTO
.
setSex
(
idCardInfo
.
get
(
"sex"
));
userDTO
.
setIdType
(
"身份证"
);
}
return
save
(
userDTO
)
;
return
Boolean
.
TRUE
;
}
}
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