Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
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
92bffdfd
Commit
92bffdfd
authored
Oct 28, 2022
by
hongguangwu
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
parents
2a963ced
794049d1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
157 additions
and
124 deletions
+157
-124
LdapUtil.java
...om/yifu/cloud/plus/v1/yifu/common/ldap/util/LdapUtil.java
+24
-72
TDispatchInfoServiceImpl.java
...v1/yifu/social/service/impl/TDispatchInfoServiceImpl.java
+9
-0
TPaymentInfoServiceImpl.java
.../v1/yifu/social/service/impl/TPaymentInfoServiceImpl.java
+2
-2
UserController.java
...u.cloud.plus.v1/yifu/admin/controller/UserController.java
+2
-1
SysDeptMapper.java
...m/yifu.cloud.plus.v1/yifu/admin/mapper/SysDeptMapper.java
+6
-0
SysUserService.java
...yifu.cloud.plus.v1/yifu/admin/service/SysUserService.java
+2
-1
SysDeptServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysDeptServiceImpl.java
+38
-22
SysUserServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysUserServiceImpl.java
+45
-26
SysDeptMapper.xml
...yifu-upms-biz/src/main/resources/mapper/SysDeptMapper.xml
+29
-0
No files found.
yifu-common/yifu-common-ldap/src/main/java/com/yifu/cloud/plus/v1/yifu/common/ldap/util/LdapUtil.java
View file @
92bffdfd
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.ldap.util;
...
@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.common.ldap.util;
import
com.unboundid.ldap.sdk.*
;
import
com.unboundid.ldap.sdk.*
;
import
com.unboundid.ldap.sdk.controls.SubentriesRequestControl
;
import
com.unboundid.ldap.sdk.controls.SubentriesRequestControl
;
import
com.unboundid.util.Base64
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.config.LdapProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.config.LdapProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.entity.PersonVo
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.entity.PersonVo
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.mapper.PersonAttributesMapper
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.mapper.PersonAttributesMapper
;
...
@@ -10,15 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -10,15 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.ldap.core.LdapTemplate
;
import
org.springframework.ldap.core.LdapTemplate
;
import
javax.naming.Context
;
import
java.security.MessageDigest
;
import
javax.naming.NamingEnumeration
;
import
java.security.NoSuchAlgorithmException
;
import
javax.naming.NamingException
;
import
java.text.ParseException
;
import
javax.naming.directory.SearchControls
;
import
javax.naming.ldap.Control
;
import
javax.naming.ldap.InitialLdapContext
;
import
javax.naming.ldap.LdapContext
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Hashtable
;
import
java.util.List
;
import
java.util.List
;
import
static
org
.
springframework
.
ldap
.
query
.
LdapQueryBuilder
.
query
;
import
static
org
.
springframework
.
ldap
.
query
.
LdapQueryBuilder
.
query
;
...
@@ -33,10 +29,6 @@ public class LdapUtil {
...
@@ -33,10 +29,6 @@ public class LdapUtil {
@Autowired
@Autowired
private
LdapProperties
ldapProperties
;
private
LdapProperties
ldapProperties
;
private
static
LdapContext
ctx
=
null
;
private
static
final
Control
[]
connCtls
=
null
;
/**
/**
* @return List<SearchResultEntry>
* @return List<SearchResultEntry>
* @author huyc
* @author huyc
...
@@ -64,71 +56,31 @@ public class LdapUtil {
...
@@ -64,71 +56,31 @@ public class LdapUtil {
}
}
// 校验用户名密码的方法
// 校验用户名密码的方法
public
Boolean
authenticate
(
String
usr
,
String
pwd
)
{
public
Boolean
authenticate
(
String
usr
,
String
pwd
)
throws
NoSuchAlgorithmException
{
boolean
valide
;
if
(
pwd
==
null
||
""
.
equals
(
pwd
))
if
(
pwd
==
null
||
""
.
equals
(
pwd
))
return
false
;
return
false
;
if
(
ctx
==
null
)
{
getCtx
();
}
String
userDN
=
getUserDN
(
usr
);
if
(
""
.
equals
(
userDN
)
||
userDN
==
null
)
{
return
false
;
}
try
{
ctx
.
addToEnvironment
(
Context
.
SECURITY_PRINCIPAL
,
userDN
);
ctx
.
addToEnvironment
(
Context
.
SECURITY_CREDENTIALS
,
pwd
);
ctx
.
reconnect
(
connCtls
);
valide
=
true
;
closeCtx
();
}
catch
(
NamingException
e
)
{
log
.
error
(
userDN
+
" is not authenticated"
);
valide
=
false
;
}
return
valide
;
}
public
void
getCtx
()
{
if
(
ctx
!=
null
)
{
return
;
}
Hashtable
<
String
,
String
>
env
=
new
Hashtable
<>();
env
.
put
(
Context
.
INITIAL_CONTEXT_FACTORY
,
"com.sun.jndi.ldap.LdapCtxFactory"
);
env
.
put
(
Context
.
PROVIDER_URL
,
"ldap://"
+
ldapProperties
.
getUrl
()
+
":"
+
ldapProperties
.
getPort
()
+
"/"
+
ldapProperties
.
getDn
());
env
.
put
(
Context
.
SECURITY_AUTHENTICATION
,
"simple"
);
env
.
put
(
Context
.
SECURITY_PRINCIPAL
,
ldapProperties
.
getUserName
());
env
.
put
(
Context
.
SECURITY_CREDENTIALS
,
ldapProperties
.
getPassword
());
try
{
try
{
// 链接ldap
List
<
SearchResultEntry
>
entryList
=
this
.
getAllPersonNamesWithTraditionalWay
();
ctx
=
new
InitialLdapContext
(
env
,
connCtls
);
byte
[]
ldapPw
=
new
byte
[
0
];
}
catch
(
NamingException
e
)
{
for
(
SearchResultEntry
resultEntry:
entryList
){
e
.
printStackTrace
();
if
(
resultEntry
.
getDN
().
contains
(
"uid="
+
usr
))
{
}
String
password
=
resultEntry
.
getAttributeValue
(
"userPassword"
);
}
if
(
null
!=
password
)
{
String
ldapPwd1
=
password
.
substring
(
5
);
public
void
closeCtx
()
throws
NamingException
{
ldapPw
=
Base64
.
decode
(
ldapPwd1
);
if
(
ctx
!=
null
)
break
;
ctx
.
close
();
}
else
{
}
return
false
;
}
public
String
getUserDN
(
String
uid
)
{
StringBuilder
userDN
=
new
StringBuilder
();
try
{
SearchControls
constraints
=
new
SearchControls
();
constraints
.
setSearchScope
(
SearchControls
.
SUBTREE_SCOPE
);
NamingEnumeration
<?>
en
=
ctx
.
search
(
""
,
"uid="
+
uid
,
constraints
);
while
(
en
!=
null
&&
en
.
hasMoreElements
())
{
Object
obj
=
en
.
nextElement
();
if
(
obj
instanceof
javax
.
naming
.
directory
.
SearchResult
)
{
javax
.
naming
.
directory
.
SearchResult
si
=
(
javax
.
naming
.
directory
.
SearchResult
)
obj
;
userDN
.
append
(
si
.
getName
());
userDN
.
append
(
","
).
append
(
ldapProperties
.
getDn
());
}
}
}
}
}
catch
(
Exception
e
)
{
MessageDigest
md5
=
MessageDigest
.
getInstance
(
"MD5"
);
e
.
printStackTrace
();
md5
.
update
(
pwd
.
getBytes
());
byte
[]
m
=
md5
.
digest
();
return
MessageDigest
.
isEqual
(
m
,
ldapPw
);
}
catch
(
ParseException
e
)
{
log
.
error
(
" is not authenticated"
);
}
}
return
userDN
.
toString
()
;
return
false
;
}
}
}
}
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TDispatchInfoServiceImpl.java
View file @
92bffdfd
...
@@ -2588,6 +2588,15 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
...
@@ -2588,6 +2588,15 @@ public class TDispatchInfoServiceImpl extends ServiceImpl<TDispatchInfoMapper, T
dispatch
.
setSettleDomainCode
(
setInfoVo
.
getDepartNo
());
dispatch
.
setSettleDomainCode
(
setInfoVo
.
getDepartNo
());
dispatch
.
setBelongUnit
(
setInfoVo
.
getCustomerId
());
dispatch
.
setBelongUnit
(
setInfoVo
.
getCustomerId
());
dispatch
.
setBelongUnitName
(
setInfoVo
.
getCustomerName
());
dispatch
.
setBelongUnitName
(
setInfoVo
.
getCustomerName
());
TEmployeeProject
temp
=
new
TEmployeeProject
();
temp
.
setDeptId
(
dispatch
.
getSettleDomain
());
temp
.
setEmpId
(
dispatch
.
getEmpId
());
R
<
TEmployeeProject
>
res
=
archivesDaprUtil
.
getTEmployeeProjectById
(
temp
);
if
(
Common
.
isNotNull
(
res
)){
if
(
Common
.
isNotNull
(
res
.
getData
().
getWorkingHours
()))
{
dispatch
.
setWorkingHours
(
res
.
getData
().
getWorkingHours
());
}
}
}
}
StringBuffer
temp
=
new
StringBuffer
();
StringBuffer
temp
=
new
StringBuffer
();
if
(
Common
.
isNotNull
(
excel
.
getSocialReduceDate
())){
if
(
Common
.
isNotNull
(
excel
.
getSocialReduceDate
())){
...
...
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TPaymentInfoServiceImpl.java
View file @
92bffdfd
...
@@ -2332,8 +2332,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
...
@@ -2332,8 +2332,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
socialParam
.
setFd_3af9ee3aa9c84a
(
CommonConstants
.
EMPTY_STRING
);
socialParam
.
setFd_3af9ee3aa9c84a
(
CommonConstants
.
EMPTY_STRING
);
}
}
//实缴合计
//实缴合计
if
(
Common
.
isNotNull
(
library
.
getS
umAll
()))
{
if
(
Common
.
isNotNull
(
library
.
getS
ocialSum
()))
{
socialParam
.
setFd_3af9ee3c6bfc74
(
library
.
getS
umAll
().
toString
());
socialParam
.
setFd_3af9ee3c6bfc74
(
library
.
getS
ocialSum
().
toString
());
}
else
{
}
else
{
socialParam
.
setFd_3af9ee3c6bfc74
(
CommonConstants
.
EMPTY_STRING
);
socialParam
.
setFd_3af9ee3c6bfc74
(
CommonConstants
.
EMPTY_STRING
);
}
}
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/controller/UserController.java
View file @
92bffdfd
...
@@ -42,6 +42,7 @@ import org.springframework.validation.BindingResult;
...
@@ -42,6 +42,7 @@ import org.springframework.validation.BindingResult;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -254,7 +255,7 @@ public class UserController {
...
@@ -254,7 +255,7 @@ public class UserController {
*/
*/
@SysLog
(
"登录验证"
)
@SysLog
(
"登录验证"
)
@PostMapping
(
"/ldapLogin"
)
@PostMapping
(
"/ldapLogin"
)
public
R
<
Boolean
>
loginAuthentication
(
@RequestParam
String
userName
,
@RequestParam
String
password
)
{
public
R
<
Boolean
>
loginAuthentication
(
@RequestParam
String
userName
,
@RequestParam
String
password
)
throws
NoSuchAlgorithmException
{
return
userService
.
loginAuthentication
(
userName
,
password
);
return
userService
.
loginAuthentication
(
userName
,
password
);
}
}
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/mapper/SysDeptMapper.java
View file @
92bffdfd
...
@@ -19,6 +19,7 @@ package com.yifu.cloud.plus.v1.yifu.admin.mapper;
...
@@ -19,6 +19,7 @@ package com.yifu.cloud.plus.v1.yifu.admin.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.List
;
...
@@ -41,4 +42,9 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
...
@@ -41,4 +42,9 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
List
<
String
>
selectDnList
();
List
<
String
>
selectDnList
();
SysDept
selectCountId
(
@Param
(
"deptId"
)
Long
deptId
);
int
updateDeptById
(
@Param
(
"dept"
)
SysDept
dept
);
SysDept
selectDeptDn
(
@Param
(
"deptDn"
)
String
deptDn
);
}
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/SysUserService.java
View file @
92bffdfd
...
@@ -27,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO;
...
@@ -27,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.admin.api.vo.UserVO;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -132,6 +133,6 @@ public interface SysUserService extends IService<SysUser> {
...
@@ -132,6 +133,6 @@ public interface SysUserService extends IService<SysUser> {
* 从ldap中验证登录用户
* 从ldap中验证登录用户
* @return R
* @return R
*/
*/
R
<
Boolean
>
loginAuthentication
(
String
userName
,
String
password
);
R
<
Boolean
>
loginAuthentication
(
String
userName
,
String
password
)
throws
NoSuchAlgorithmException
;
}
}
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysDeptServiceImpl.java
View file @
92bffdfd
...
@@ -60,8 +60,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
...
@@ -60,8 +60,6 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
private
final
LdapUtil
ldapUtil
;
private
final
LdapUtil
ldapUtil
;
private
final
SysDeptMapper
sysDeptMapper
;
private
final
SysUserMapper
sysUserMapper
;
private
final
SysUserMapper
sysUserMapper
;
/**
/**
...
@@ -188,11 +186,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
...
@@ -188,11 +186,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
//获取ldap所有的dn
//获取ldap所有的dn
List
<
String
>
entryDnList
=
entryList
.
stream
().
map
(
SearchResultEntry:
:
getDN
).
collect
(
Collectors
.
toList
());
List
<
String
>
entryDnList
=
entryList
.
stream
().
map
(
SearchResultEntry:
:
getDN
).
collect
(
Collectors
.
toList
());
//获取本地dept表中所有的dn
//获取本地dept表中所有的dn
List
<
String
>
dnList
=
sysDept
Mapper
.
selectDnList
();
List
<
String
>
dnList
=
base
Mapper
.
selectDnList
();
List
<
String
>
delList
=
dnList
.
stream
().
filter
(
p
->
!
entryDnList
.
contains
(
p
)).
collect
(
Collectors
.
toList
());
List
<
String
>
delList
=
dnList
.
stream
().
filter
(
p
->
!
entryDnList
.
contains
(
p
)).
collect
(
Collectors
.
toList
());
//删除ldap中不存在的dn的数据
//删除ldap中不存在的dn的数据
if
(!
delList
.
isEmpty
())
{
if
(!
delList
.
isEmpty
())
{
sysDept
Mapper
.
delete
(
Wrappers
.<
SysDept
>
query
().
lambda
().
in
(
SysDept:
:
getDeptDn
,
delList
));
base
Mapper
.
delete
(
Wrappers
.<
SysDept
>
query
().
lambda
().
in
(
SysDept:
:
getDeptDn
,
delList
));
}
}
List
<
Map
<
String
,
Object
>>
updUserList
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
updUserList
=
new
ArrayList
<>();
for
(
SearchResultEntry
entry
:
entryList
)
{
for
(
SearchResultEntry
entry
:
entryList
)
{
...
@@ -206,35 +204,52 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
...
@@ -206,35 +204,52 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
String
deptName
=
saveDnList
.
get
(
0
).
replace
(
"ou="
,
""
);
String
deptName
=
saveDnList
.
get
(
0
).
replace
(
"ou="
,
""
);
int
size
=
saveDnList
.
size
();
int
size
=
saveDnList
.
size
();
if
(
size
==
1
)
{
if
(
size
==
1
)
{
SysDept
sysDept
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
)
);
SysDept
sysDept
=
baseMapper
.
selectDeptDn
(
dn
);
if
(
null
==
sysDept
)
{
if
(
null
==
sysDept
)
{
SysDept
insertSysDept
=
new
SysDept
();
if
(
StringUtils
.
isEmpty
(
userId
))
{
insertSysDept
.
setName
(
deptName
);
SysDept
ins
=
baseMapper
.
selectCountId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
insertSysDept
.
setParentId
(
0L
);
if
(
Common
.
isNotNull
(
ins
))
{
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
ins
.
setName
(
deptName
);
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
ins
.
setDeptDn
(
dn
);
baseMapper
.
updateDeptById
(
ins
);
}
else
{
SysDept
insertSysDept
=
new
SysDept
();
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setParentId
(
0L
);
insertSysDept
.
setDeptDn
(
dn
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
}
baseMapper
.
insert
(
insertSysDept
);
}
}
}
insertSysDept
.
setDeptDn
(
dn
);
this
.
save
(
insertSysDept
);
}
else
{
}
else
{
sysDept
.
setName
(
deptName
);
sysDept
.
setName
(
deptName
);
this
.
updateDeptById
(
sysDept
);
baseMapper
.
updateDeptById
(
sysDept
);
}
}
}
else
{
}
else
{
try
{
try
{
SysDept
sysDept
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
.
substring
(
dn
.
indexOf
(
"ou="
,
2
),
dn
.
length
())));
SysDept
sysDept
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
.
substring
(
dn
.
indexOf
(
"ou="
,
2
),
dn
.
length
())));
if
(
null
!=
sysDept
)
{
if
(
null
!=
sysDept
)
{
SysDept
sysDeptCount
=
this
.
getOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
)
);
SysDept
sysDeptCount
=
baseMapper
.
selectDeptDn
(
dn
);
if
(
null
==
sysDeptCount
)
{
if
(
null
==
sysDeptCount
)
{
if
(
StringUtils
.
isEmpty
(
userId
))
{
if
(
StringUtils
.
isEmpty
(
userId
))
{
SysDept
insertSysDept
=
new
SysDept
();
SysDept
ins
=
baseMapper
.
selectCountId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
insertSysDept
.
setName
(
deptName
);
if
(
Common
.
isNotNull
(
ins
))
{
insertSysDept
.
setParentId
(
sysDept
.
getDeptId
());
ins
.
setName
(
deptName
);
insertSysDept
.
setDeptDn
(
dn
);
ins
.
setDeptDn
(
dn
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
ins
.
setParentId
(
sysDept
.
getDeptId
());
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
baseMapper
.
updateDeptById
(
ins
);
}
else
{
SysDept
insertSysDept
=
new
SysDept
();
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setParentId
(
sysDept
.
getDeptId
());
insertSysDept
.
setDeptDn
(
dn
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
}
baseMapper
.
insert
(
insertSysDept
);
}
}
this
.
save
(
insertSysDept
);
}
}
}
else
{
}
else
{
if
(!
StringUtils
.
isEmpty
(
userId
))
{
if
(!
StringUtils
.
isEmpty
(
userId
))
{
...
@@ -246,7 +261,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
...
@@ -246,7 +261,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
}
else
{
}
else
{
sysDeptCount
.
setName
(
deptName
);
sysDeptCount
.
setName
(
deptName
);
sysDeptCount
.
setParentId
(
sysDept
.
getDeptId
());
sysDeptCount
.
setParentId
(
sysDept
.
getDeptId
());
this
.
updateDeptById
(
sysDeptCount
);
sysDeptCount
.
setDeptDn
(
dn
);
baseMapper
.
updateDeptById
(
sysDeptCount
);
}
}
}
}
}
}
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysUserServiceImpl.java
View file @
92bffdfd
...
@@ -55,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -55,6 +55,7 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.BindingResult
;
import
java.security.NoSuchAlgorithmException
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -82,8 +83,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
...
@@ -82,8 +83,6 @@ 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 对象
...
@@ -431,10 +430,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
...
@@ -431,10 +430,10 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}
}
}
}
if
(!
updateList
.
isEmpty
())
{
if
(!
updateList
.
isEmpty
())
{
sysUser
Mapper
.
batchUpdateUser
(
updateList
);
base
Mapper
.
batchUpdateUser
(
updateList
);
}
}
if
(!
insertList
.
isEmpty
())
{
if
(!
insertList
.
isEmpty
())
{
sysUser
Mapper
.
batchInsertUser
(
insertList
);
base
Mapper
.
batchInsertUser
(
insertList
);
}
}
}
}
List
<
SearchResultEntry
>
entryList
=
ldapUtil
.
getAllPersonNamesWithTraditionalWay
();
List
<
SearchResultEntry
>
entryList
=
ldapUtil
.
getAllPersonNamesWithTraditionalWay
();
...
@@ -455,38 +454,55 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
...
@@ -455,38 +454,55 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
userId
=
dn
.
substring
(
4
,
dn
.
indexOf
(
","
,
1
));
userId
=
dn
.
substring
(
4
,
dn
.
indexOf
(
","
,
1
));
dn
=
dn
.
substring
(
dn
.
indexOf
(
","
,
1
)
+
1
);
dn
=
dn
.
substring
(
dn
.
indexOf
(
","
,
1
)
+
1
);
}
}
List
<
String
>
saveDnList
=
Arrays
.
stream
(
dn
.
split
(
","
)
).
filter
(
e
->
(
e
.
contains
(
"ou="
)
&&
!
e
.
equals
(
"ou=wanxin"
))).
collect
(
Collectors
.
toList
());
List
<
String
>
saveDnList
=
Arrays
.
asList
(
dn
.
split
(
","
)).
stream
(
).
filter
(
e
->
(
e
.
contains
(
"ou="
)
&&
!
e
.
equals
(
"ou=wanxin"
))).
collect
(
Collectors
.
toList
());
String
deptName
=
saveDnList
.
get
(
0
).
replace
(
"ou="
,
""
);
String
deptName
=
saveDnList
.
get
(
0
).
replace
(
"ou="
,
""
);
int
size
=
saveDnList
.
size
();
int
size
=
saveDnList
.
size
();
if
(
size
==
1
)
{
if
(
size
==
1
)
{
SysDept
sysDept
=
sysDeptMapper
.
select
One
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
)
);
SysDept
sysDept
=
sysDeptMapper
.
select
DeptDn
(
dn
);
if
(
null
==
sysDept
)
{
if
(
null
==
sysDept
)
{
SysDept
insertSysDept
=
new
SysDept
();
if
(
StringUtils
.
isEmpty
(
userId
))
{
insertSysDept
.
setName
(
deptName
);
SysDept
ins
=
sysDeptMapper
.
selectCountId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
insertSysDept
.
setParentId
(
0L
);
if
(
Common
.
isNotNull
(
ins
))
{
insertSysDept
.
setDeptDn
(
dn
);
ins
.
setName
(
deptName
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
ins
.
setDeptDn
(
dn
);
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
sysDeptMapper
.
updateDeptById
(
ins
);
}
else
{
SysDept
insertSysDept
=
new
SysDept
();
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setParentId
(
0L
);
insertSysDept
.
setDeptDn
(
dn
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
}
sysDeptMapper
.
insert
(
insertSysDept
);
}
}
}
sysDeptMapper
.
insert
(
insertSysDept
);
}
else
{
}
else
{
sysDept
.
setName
(
deptName
);
sysDept
.
setName
(
deptName
);
sysDeptMapper
.
updateById
(
sysDept
);
sysDeptMapper
.
update
Dept
ById
(
sysDept
);
}
}
}
else
{
}
else
{
SysDept
sysDept
=
sysDeptMapper
.
selectOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
.
substring
(
dn
.
indexOf
(
"ou="
,
2
),
dn
.
length
())));
SysDept
sysDept
=
sysDeptMapper
.
selectOne
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
.
substring
(
dn
.
indexOf
(
"ou="
,
2
),
dn
.
length
())));
if
(
null
!=
sysDept
)
{
if
(
null
!=
sysDept
)
{
SysDept
sysDeptCount
=
sysDeptMapper
.
select
One
(
Wrappers
.<
SysDept
>
query
().
lambda
().
eq
(
SysDept:
:
getDeptDn
,
dn
)
);
SysDept
sysDeptCount
=
sysDeptMapper
.
select
DeptDn
(
dn
);
if
(
null
==
sysDeptCount
)
{
if
(
null
==
sysDeptCount
)
{
if
(
StringUtils
.
isEmpty
(
userId
))
{
if
(
StringUtils
.
isEmpty
(
userId
))
{
SysDept
insertSysDept
=
new
SysDept
();
SysDept
ins
=
sysDeptMapper
.
selectCountId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
insertSysDept
.
setName
(
deptName
);
if
(
Common
.
isNotNull
(
ins
))
{
insertSysDept
.
setParentId
(
sysDept
.
getDeptId
());
ins
.
setName
(
deptName
);
insertSysDept
.
setDeptDn
(
dn
);
ins
.
setDeptDn
(
dn
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
ins
.
setParentId
(
sysDept
.
getDeptId
());
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
sysDeptMapper
.
updateDeptById
(
ins
);
}
else
{
SysDept
insertSysDept
=
new
SysDept
();
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setParentId
(
sysDept
.
getDeptId
());
insertSysDept
.
setDeptDn
(
dn
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
}
sysDeptMapper
.
insert
(
insertSysDept
);
}
}
sysDeptMapper
.
insert
(
insertSysDept
);
}
}
}
else
{
}
else
{
if
(!
StringUtils
.
isEmpty
(
userId
))
{
if
(!
StringUtils
.
isEmpty
(
userId
))
{
...
@@ -497,15 +513,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
...
@@ -497,15 +513,18 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
updUserList
.
add
(
map
);
updUserList
.
add
(
map
);
}
else
{
}
else
{
sysDeptCount
.
setName
(
deptName
);
sysDeptCount
.
setName
(
deptName
);
sysDeptCount
.
setDeptDn
(
dn
);
sysDeptCount
.
setParentId
(
sysDept
.
getDeptId
());
sysDeptCount
.
setParentId
(
sysDept
.
getDeptId
());
sysDeptMapper
.
updateById
(
sysDeptCount
);
sysDeptMapper
.
update
Dept
ById
(
sysDeptCount
);
}
}
}
}
}
}
}
}
}
}
//更新用户信息
//更新用户信息
sysUserMapper
.
updateUser
(
updUserList
);
if
(!
updUserList
.
isEmpty
())
{
baseMapper
.
updateUser
(
updUserList
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
"用户部门信息同步异常:"
+
e
.
getMessage
());
log
.
info
(
"用户部门信息同步异常:"
+
e
.
getMessage
());
return
R
.
failed
(
"用户部门信息同步异常!"
);
return
R
.
failed
(
"用户部门信息同步异常!"
);
...
@@ -518,8 +537,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
...
@@ -518,8 +537,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
* @return R
* @return R
*/
*/
@Override
@Override
public
R
<
Boolean
>
loginAuthentication
(
String
userName
,
String
password
)
{
public
R
<
Boolean
>
loginAuthentication
(
String
userName
,
String
password
)
throws
NoSuchAlgorithmException
{
if
(
ldapUtil
.
authenticate
(
userName
,
password
))
{
if
(
Boolean
.
TRUE
.
equals
(
ldapUtil
.
authenticate
(
userName
,
password
)
))
{
return
R
.
ok
();
return
R
.
ok
();
}
}
return
R
.
failed
(
"验证不通过"
);
return
R
.
failed
(
"验证不通过"
);
...
...
yifu-upms/yifu-upms-biz/src/main/resources/mapper/SysDeptMapper.xml
View file @
92bffdfd
...
@@ -38,4 +38,33 @@
...
@@ -38,4 +38,33 @@
WHERE a.del_flag = 0
WHERE a.del_flag = 0
AND a.dept_dn IS NOT NULL
AND a.dept_dn IS NOT NULL
</select>
</select>
<select
id=
"selectCountId"
resultType=
"com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept"
>
SELECT
*
from sys_dept a
<where>
a.dept_id = #{deptId}
</where>
</select>
<select
id=
"selectDeptDn"
resultType=
"com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept"
>
SELECT
*
from sys_dept a
<where>
a.dept_dn = #{deptDn}
</where>
</select>
<update
id=
"updateDeptById"
>
update sys_dept
<trim
prefix=
"set"
suffixOverrides=
","
>
<if
test=
"dept.name != null"
>
name=#{dept.name},
</if>
<if
test=
"dept.parentId != null"
>
parent_id=#{dept.parentId},
</if>
<if
test=
"dept.deptDn != null"
>
dept_dn=#{dept.deptDn},
</if>
update_time = now()
</trim>
WHERE dept_id=#{dept.deptId}
</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