Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
Y
yifu-mvp
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
fangxinjiang
yifu-mvp
Commits
abc6d0c5
You need to sign in or sign up before continuing.
Commit
abc6d0c5
authored
Jun 16, 2022
by
fangxinjiang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
parents
ffe10304
4393a5da
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
144 additions
and
49 deletions
+144
-49
SysDept.java
...com/yifu.cloud.plus.v1/yifu/admin/api/entity/SysDept.java
+6
-0
SysDeptMapper.java
...m/yifu.cloud.plus.v1/yifu/admin/mapper/SysDeptMapper.java
+2
-0
SysUserMapper.java
...m/yifu.cloud.plus.v1/yifu/admin/mapper/SysUserMapper.java
+8
-0
SysDeptServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysDeptServiceImpl.java
+45
-33
SysUserServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysUserServiceImpl.java
+12
-16
SysUserMapper.xml
...yifu-upms-biz/src/main/resources/mapper/SysUserMapper.xml
+71
-0
No files found.
yifu-upms/yifu-upms-api/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/api/entity/SysDept.java
View file @
abc6d0c5
...
@@ -66,6 +66,12 @@ public class SysDept extends BaseEntity {
...
@@ -66,6 +66,12 @@ public class SysDept extends BaseEntity {
@Schema
(
description
=
"父级部门id"
)
@Schema
(
description
=
"父级部门id"
)
private
Long
parentId
;
private
Long
parentId
;
/**
* dn
*/
@Schema
(
description
=
"部门dn"
)
private
String
deptDn
;
/**
/**
* 是否删除 -1:已删除 0:正常
* 是否删除 -1:已删除 0:正常
*/
*/
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/mapper/SysDeptMapper.java
View file @
abc6d0c5
...
@@ -39,4 +39,6 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
...
@@ -39,4 +39,6 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
*/
*/
List
<
SysDept
>
listDepts
();
List
<
SysDept
>
listDepts
();
List
<
String
>
selectDnList
();
}
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/mapper/SysUserMapper.java
View file @
abc6d0c5
...
@@ -22,10 +22,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -22,10 +22,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserDTO
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.dto.UserDTO
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.entity.PersonVo
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* <p>
* <p>
...
@@ -67,4 +69,10 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
...
@@ -67,4 +69,10 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
*/
*/
List
<
UserVO
>
selectVoList
(
@Param
(
"query"
)
UserDTO
userDTO
);
List
<
UserVO
>
selectVoList
(
@Param
(
"query"
)
UserDTO
userDTO
);
void
batchInsertUser
(
@Param
(
"list"
)
List
<
PersonVo
>
list
);
void
batchUpdateUser
(
@Param
(
"list"
)
List
<
PersonVo
>
list
);
void
updateUser
(
@Param
(
"list"
)
List
<
Map
<
String
,
Object
>>
list
);
}
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysDeptServiceImpl.java
View file @
abc6d0c5
...
@@ -28,6 +28,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
...
@@ -28,6 +28,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDeptRelation
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDeptRelation
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDeptMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDeptMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptRelationService
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptRelationService
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService
;
...
@@ -43,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -43,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
/**
* <p>
* <p>
...
@@ -63,6 +65,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
...
@@ -63,6 +65,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
private
final
LdapUtil
ldapUtil
;
private
final
LdapUtil
ldapUtil
;
private
final
SysDeptMapper
sysDeptMapper
;
private
final
SysUserMapper
sysUserMapper
;
/**
/**
* 添加信息部门
* 添加信息部门
* @param dept 部门
* @param dept 部门
...
@@ -178,12 +184,22 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
...
@@ -178,12 +184,22 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
}
}
/**
/**
* 从ldap中获取
用户
* 从ldap中获取
部门
* @return R
* @return R
*/
*/
@Override
@Override
public
R
<
Boolean
>
updateDeptByLdap
()
{
public
R
<
Boolean
>
updateDeptByLdap
()
{
List
<
SearchResultEntry
>
entryList
=
ldapUtil
.
getAllPersonNamesWithTraditionalWay
();
List
<
SearchResultEntry
>
entryList
=
ldapUtil
.
getAllPersonNamesWithTraditionalWay
();
//获取ldap所有的dn
List
<
String
>
entryDnList
=
entryList
.
stream
().
map
(
SearchResultEntry:
:
getDN
).
collect
(
Collectors
.
toList
());
//获取本地dept表中所有的dn
List
<
String
>
dnList
=
sysDeptMapper
.
selectDnList
();
List
<
String
>
delList
=
dnList
.
stream
().
filter
(
p
->
!
entryDnList
.
contains
(
p
)).
collect
(
Collectors
.
toList
());
//删除ldap中不存在的dn的数据
if
(
delList
.
size
()
>
0
)
{
sysDeptMapper
.
delete
(
Wrappers
.<
SysDept
>
query
().
lambda
().
in
(
SysDept:
:
getDeptDn
,
delList
));
}
List
<
Map
<
String
,
Object
>>
updUserList
=
new
ArrayList
<>();
for
(
SearchResultEntry
entry
:
entryList
)
{
for
(
SearchResultEntry
entry
:
entryList
)
{
String
dn
=
entry
.
getDN
();
String
dn
=
entry
.
getDN
();
String
userId
=
""
;
String
userId
=
""
;
...
@@ -194,52 +210,48 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
...
@@ -194,52 +210,48 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
String
deptName
=
list
.
get
(
0
).
replace
(
"ou="
,
""
);
String
deptName
=
list
.
get
(
0
).
replace
(
"ou="
,
""
);
int
size
=
list
.
size
();
int
size
=
list
.
size
();
if
(
size
==
1
)
{
if
(
size
==
1
)
{
SysDept
sysDept
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
get
Name
,
deptName
));
SysDept
sysDept
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
get
DeptDn
,
dn
));
if
(
null
==
sysDept
)
{
if
(
null
==
sysDept
)
{
SysDept
insertSysDept
=
new
SysDept
();
SysDept
insertSysDept
=
new
SysDept
();
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setParentId
(
CommonConstants
.
MENU_TREE_ROOT_ID
);
insertSysDept
.
setParentId
(
CommonConstants
.
MENU_TREE_ROOT_ID
);
insertSysDept
.
setDeptDn
(
dn
);
this
.
save
(
insertSysDept
);
this
.
save
(
insertSysDept
);
}
else
{
}
else
{
sysDept
.
setName
(
deptName
);
sysDept
.
setName
(
deptName
);
this
.
updateDeptById
(
sysDept
);
this
.
updateDeptById
(
sysDept
);
}
}
}
else
if
(
size
>=
2
)
{
}
else
if
(
size
>=
2
)
{
SysDept
sysDept
=
new
SysDept
();
try
{
if
(
size
>
2
)
{
SysDept
sysDept
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
.
substring
(
dn
.
indexOf
(
"ou="
,
2
),
dn
.
length
())));
SysDept
sysDeptThree
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getName
,
list
.
get
(
2
).
replace
(
"ou="
,
""
)));
if
(
null
!=
sysDept
)
{
sysDept
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getName
,
list
.
get
(
1
).
replace
(
"ou="
,
""
))
SysDept
sysDeptCount
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
));
.
eq
(
SysDept:
:
getParentId
,
sysDeptThree
.
getDeptId
()));
if
(
null
==
sysDeptCount
)
{
}
else
{
SysDept
insertSysDept
=
new
SysDept
();
sysDept
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getName
,
list
.
get
(
1
).
replace
(
"ou="
,
""
)));
insertSysDept
.
setName
(
deptName
);
}
insertSysDept
.
setParentId
(
sysDept
.
getDeptId
());
if
(
null
!=
sysDept
)
{
insertSysDept
.
setDeptDn
(
dn
);
SysDept
sysDeptCount
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getName
,
deptName
).
eq
(
SysDept:
:
getParentId
,
sysDept
.
getDeptId
()));
this
.
save
(
insertSysDept
);
if
(
null
==
sysDeptCount
)
{
}
else
{
SysDept
insertSysDept
=
new
SysDept
();
if
(
StringUtils
.
isNotBlank
(
userId
))
{
insertSysDept
.
setName
(
deptName
);
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
insertSysDept
.
setParentId
(
sysDept
.
getDeptId
());
map
.
put
(
"userId"
,
userId
);
this
.
save
(
insertSysDept
);
map
.
put
(
"deptId"
,
sysDeptCount
.
getDeptId
());
}
else
{
updUserList
.
add
(
map
);
if
(
StringUtils
.
isNotBlank
(
userId
))
{
try
{
SysUser
user
=
sysUserService
.
getOne
(
Wrappers
.<
SysUser
>
query
().
lambda
().
eq
(
SysUser:
:
getUsername
,
userId
));
if
(
null
!=
user
)
{
user
.
setDeptId
(
sysDeptCount
.
getDeptId
());
sysUserService
.
updateById
(
user
);
}
sysDeptCount
.
setName
(
deptName
);
sysDeptCount
.
setParentId
(
sysDept
.
getDeptId
());
this
.
updateDeptById
(
sysDeptCount
);
}
catch
(
Exception
e
)
{
log
.
info
(
"更新异常:"
+
e
.
getMessage
());
return
R
.
failed
(
"同步信息失败!"
);
}
}
sysDeptCount
.
setName
(
deptName
);
sysDeptCount
.
setParentId
(
sysDept
.
getDeptId
());
this
.
updateDeptById
(
sysDeptCount
);
}
}
}
}
}
catch
(
Exception
e
)
{
log
.
info
(
"更新异常:"
+
e
.
getMessage
());
return
R
.
failed
(
"同步信息失败!"
);
}
}
}
}
}
}
return
R
.
ok
();
//更新用户信息
}
sysUserMapper
.
updateUser
(
updUserList
);
return
R
.
ok
();
}
}
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysUserServiceImpl.java
View file @
abc6d0c5
...
@@ -82,6 +82,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
...
@@ -82,6 +82,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
private
final
LdapUtil
ldapUtil
;
private
final
LdapUtil
ldapUtil
;
private
final
SysUserMapper
sysUserMapper
;
/**
/**
* 保存用户信息
* 保存用户信息
* @param userDto DTO 对象
* @param userDto DTO 对象
...
@@ -409,27 +411,21 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
...
@@ -409,27 +411,21 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
List
<
SysUser
>
listUser
=
this
.
list
(
Wrappers
.<
SysUser
>
query
().
lambda
().
eq
(
SysUser:
:
getDelFlag
,
CommonConstants
.
STATUS_NORMAL
));
List
<
SysUser
>
listUser
=
this
.
list
(
Wrappers
.<
SysUser
>
query
().
lambda
().
eq
(
SysUser:
:
getDelFlag
,
CommonConstants
.
STATUS_NORMAL
));
List
<
String
>
list1
=
listUser
.
stream
().
map
(
SysUser:
:
getUsername
).
collect
(
Collectors
.
toList
());
List
<
String
>
list1
=
listUser
.
stream
().
map
(
SysUser:
:
getUsername
).
collect
(
Collectors
.
toList
());
Map
<
String
,
String
>
map
=
listUser
.
stream
().
collect
(
HashMap:
:
new
,
(
m
,
v
)
->
m
.
put
(
v
.
getUsername
(),
v
.
getUserId
()),
HashMap:
:
putAll
);
Map
<
String
,
String
>
map
=
listUser
.
stream
().
collect
(
HashMap:
:
new
,
(
m
,
v
)
->
m
.
put
(
v
.
getUsername
(),
v
.
getUserId
()),
HashMap:
:
putAll
);
List
<
PersonVo
>
updateList
=
new
ArrayList
<>();
List
<
PersonVo
>
insertList
=
new
ArrayList
<>();
for
(
PersonVo
personVo
:
list
)
{
for
(
PersonVo
personVo
:
list
)
{
if
(
list1
.
stream
().
anyMatch
(
e
->
e
.
equals
(
personVo
.
getUid
())))
{
if
(
list1
.
stream
().
anyMatch
(
e
->
e
.
equals
(
personVo
.
getUid
())))
{
SysUser
sysUser
=
this
.
getById
(
map
.
get
(
personVo
.
getUid
()));
updateList
.
add
(
personVo
);
sysUser
.
setUsername
(
personVo
.
getUid
());
sysUser
.
setPhone
(
personVo
.
getTelephoneNumber
());
sysUser
.
setEmail
(
personVo
.
getEmail
());
sysUser
.
setNickname
(
personVo
.
getPersonName
());
sysUser
.
setPassword
(
personVo
.
getPassword
());
this
.
updateById
(
sysUser
);
}
else
{
}
else
{
SysUser
sysUser
=
new
SysUser
();
insertList
.
add
(
personVo
);
sysUser
.
setUsername
(
personVo
.
getUid
());
sysUser
.
setPhone
(
personVo
.
getTelephoneNumber
());
sysUser
.
setEmail
(
personVo
.
getEmail
());
sysUser
.
setNickname
(
personVo
.
getPersonName
());
sysUser
.
setDelFlag
(
CommonConstants
.
STATUS_NORMAL
);
sysUser
.
setPassword
(
personVo
.
getPassword
());
sysUser
.
setUserGroup
(
CommonConstants
.
EMPTY_STRING
);
this
.
save
(
sysUser
);
}
}
}
}
if
(
updateList
.
size
()>
0
)
{
sysUserMapper
.
batchUpdateUser
(
updateList
);
}
if
(
insertList
.
size
()>
0
)
{
sysUserMapper
.
batchInsertUser
(
insertList
);
}
}
}
return
R
.
ok
();
return
R
.
ok
();
}
}
...
...
yifu-upms/yifu-upms-biz/src/main/resources/mapper/SysUserMapper.xml
View file @
abc6d0c5
...
@@ -207,4 +207,75 @@
...
@@ -207,4 +207,75 @@
</where>
</where>
ORDER BY u.create_time DESC
ORDER BY u.create_time DESC
</select>
</select>
<insert
id=
"batchInsertUser"
parameterType=
"java.util.List"
>
insert into sys_user
(user_id,username,phone,email,password,nickname)
VALUES
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(
REPLACE(UUID(),"-",""),
#{item.uid,jdbcType=VARCHAR},
#{item.telephoneNumber,jdbcType=VARCHAR},
#{item.email,jdbcType=VARCHAR},
#{item.password,jdbcType=VARCHAR},
#{item.personName,jdbcType=VARCHAR}
)
</foreach>
</insert>
<update
id=
"batchUpdateUser"
parameterType=
"java.util.List"
>
update sys_user
<trim
prefix=
"set"
suffixOverrides=
","
>
<trim
prefix=
"phone =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.telephoneNumber!=null"
>
when username=#{i.uid} then #{i.telephoneNumber}
</if>
</foreach>
</trim>
<trim
prefix=
"email =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.email!=null"
>
when username=#{i.uid} then #{i.email}
</if>
</foreach>
</trim>
<trim
prefix=
"nickname =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.personName!=null"
>
when username=#{i.uid} then #{i.personName}
</if>
</foreach>
</trim>
<trim
prefix=
"password =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.password!=null"
>
when username=#{i.uid} then #{i.password}
</if>
</foreach>
</trim>
</trim>
where
<foreach
collection=
"list"
separator=
"or"
item=
"i"
index=
"index"
>
username=#{i.uid}
</foreach>
</update>
<update
id=
"updateUser"
parameterType=
"java.util.List"
>
update sys_user
<trim
prefix=
"set"
suffixOverrides=
","
>
<trim
prefix=
"dept_id =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.deptId!=null"
>
when username=#{i.userId} then #{i.deptId}
</if>
</foreach>
</trim>
</trim>
where
<foreach
collection=
"list"
separator=
"or"
item=
"i"
index=
"index"
>
username=#{i.userId}
</foreach>
</update>
</mapper>
</mapper>
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