Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzou
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzou
提交
76b38834
提交
76b38834
编写于
5月 05, 2020
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
id初始化
上级
7cc1cbb5
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
98 行增加
和
42 行删除
+98
-42
IBZEmp2UserAspect.java
.../cn/ibizlab/core/extensions/aspect/IBZEmp2UserAspect.java
+98
-42
未找到文件。
ibzou-core/src/main/java/cn/ibizlab/core/extensions/aspect/IBZEmp2UserAspect.java
浏览文件 @
76b38834
...
...
@@ -2,8 +2,12 @@ package cn.ibizlab.core.extensions.aspect;
import
cn.ibizlab.core.extensions.mapping.IBZEmp2UserMapping
;
import
cn.ibizlab.core.extensions.service.OUModelService
;
import
cn.ibizlab.core.ou.domain.IBZDepartment
;
import
cn.ibizlab.core.ou.domain.IBZEmployee
;
import
cn.ibizlab.core.ou.domain.IBZOrganization
;
import
cn.ibizlab.core.ou.service.IIBZDepartmentService
;
import
cn.ibizlab.core.ou.service.IIBZEmployeeService
;
import
cn.ibizlab.core.ou.service.IIBZOrganizationService
;
import
cn.ibizlab.util.domain.IBZUSER
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.service.IBZUSERService
;
...
...
@@ -31,6 +35,14 @@ public class IBZEmp2UserAspect
@Lazy
private
IBZUSERService
ibzuserService
;
@Autowired
@Lazy
private
IIBZDepartmentService
iibzDepartmentService
;
@Autowired
@Lazy
private
IIBZOrganizationService
iibzOrganizationService
;
@Autowired
@Lazy
private
IBZEmp2UserMapping
ibzEmp2UserMapping
;
...
...
@@ -43,11 +55,24 @@ public class IBZEmp2UserAspect
@Before
(
value
=
"execution(* cn.ibizlab.core.ou.service.IIBZEmployeeService.creat*(..))"
)
public
void
BeforeCreateEmp
(
JoinPoint
point
)
throws
Exception
{
prepar
eEmp
(
point
);
beforeSav
eEmp
(
point
);
}
@Before
(
value
=
"execution(* cn.ibizlab.core.ou.service.IIBZEmployeeService.updat*(..))"
)
public
void
BeforeUpdateEmp
(
JoinPoint
point
)
throws
Exception
{
prepareEmp
(
point
);
beforeSaveEmp
(
point
);
}
@Before
(
value
=
"execution(* cn.ibizlab.core.ou.service.IIBZEmployeeService.sav*(..))"
)
public
void
BeforeSaveEmp
(
JoinPoint
point
)
throws
Exception
{
beforeSaveEmp
(
point
);
}
@Before
(
value
=
"execution(* cn.ibizlab.core.ou.service.IIBZEmployeeService.creat*(..))"
)
public
void
BeforeCreateDept
(
JoinPoint
point
)
throws
Exception
{
beforeSaveDept
(
point
);
}
@Before
(
value
=
"execution(* cn.ibizlab.core.ou.service.IIBZEmployeeService.sav*(..))"
)
public
void
BeforeSaveDept
(
JoinPoint
point
)
throws
Exception
{
beforeSaveDept
(
point
);
}
@After
(
value
=
"execution(* cn.ibizlab.core.ou.service.IIBZEmployeeService.creat*(..))"
)
...
...
@@ -75,7 +100,7 @@ public class IBZEmp2UserAspect
initPwd
(
point
);
}
private
void
prepar
eEmp
(
JoinPoint
point
)
private
void
beforeSav
eEmp
(
JoinPoint
point
)
{
Object
[]
args
=
point
.
getArgs
();
if
(
args
.
length
>
0
)
...
...
@@ -83,57 +108,88 @@ public class IBZEmp2UserAspect
Object
obj
=
args
[
0
];
if
(
obj
instanceof
IBZEmployee
)
{
IBZEmployee
emp
=
((
IBZEmployee
)
obj
);
String
userName
=
emp
.
getUsername
();
if
(
StringUtils
.
isEmpty
(
userName
))
{
if
(!
StringUtils
.
isEmpty
(
emp
.
getDomains
()))
userName
=
emp
.
getLoginname
()+
"|"
+
emp
.
getDomains
();
else
userName
=
emp
.
getLoginname
();
emp
.
setUsername
(
userName
);
}
String
password
=
emp
.
getPassword
();
if
(
StringUtils
.
isEmpty
(
password
))
prepareEmp
((
IBZEmployee
)
obj
);
}
else
if
(
obj
instanceof
List
)
{
List
<
IBZEmployee
>
list
=(
List
<
IBZEmployee
>)
obj
;
for
(
IBZEmployee
emp:
list
)
{
password
=
defaultPasswd
;
if
(
pwencrymode
==
1
)
password
=
DigestUtils
.
md5DigestAsHex
(
password
.
getBytes
());
else
if
(
pwencrymode
==
2
)
password
=
DigestUtils
.
md5DigestAsHex
(
String
.
format
(
"%1$s||%2$s"
,
userName
,
password
).
getBytes
());
emp
.
setPassword
(
password
);
prepareEmp
(
emp
);
}
}
}
}
private
void
beforeSaveDept
(
JoinPoint
point
)
{
Object
[]
args
=
point
.
getArgs
();
if
(
args
.
length
>
0
)
{
Object
obj
=
args
[
0
];
if
(
obj
instanceof
IBZDepartment
)
{
prepareDept
((
IBZDepartment
)
obj
);
}
else
if
(
obj
instanceof
List
)
{
List
<
IBZ
Employee
>
list
=(
List
<
IBZEmployee
>)
obj
;
for
(
IBZ
Employee
emp
:
list
)
List
<
IBZ
Department
>
list
=(
List
<
IBZDepartment
>)
obj
;
for
(
IBZ
Department
dept
:
list
)
{
String
userName
=
emp
.
getUsername
();
if
(
StringUtils
.
isEmpty
(
userName
))
{
if
(!
StringUtils
.
isEmpty
(
emp
.
getDomains
()))
userName
=
emp
.
getLoginname
()+
"|"
+
emp
.
getDomains
();
else
userName
=
emp
.
getLoginname
();
emp
.
setUsername
(
userName
);
}
String
password
=
emp
.
getPassword
();
if
(
StringUtils
.
isEmpty
(
password
))
{
password
=
defaultPasswd
;
if
(
pwencrymode
==
1
)
password
=
DigestUtils
.
md5DigestAsHex
(
password
.
getBytes
());
else
if
(
pwencrymode
==
2
)
password
=
DigestUtils
.
md5DigestAsHex
(
String
.
format
(
"%1$s||%2$s"
,
userName
,
password
).
getBytes
());
emp
.
setPassword
(
password
);
}
prepareDept
(
dept
);
}
}
}
}
private
void
prepareEmp
(
IBZEmployee
emp
)
{
String
userName
=
emp
.
getUsername
();
if
(
StringUtils
.
isEmpty
(
emp
.
getUserid
())&&(!
StringUtils
.
isEmpty
(
emp
.
getUsercode
()))&&(!
StringUtils
.
isEmpty
(
emp
.
getOrgid
())))
{
emp
.
setUserid
(
emp
.
getOrgid
()+
"-"
+
emp
.
getUsercode
());
}
if
(
StringUtils
.
isEmpty
(
emp
.
getOrgcode
())&&(!
StringUtils
.
isEmpty
(
emp
.
getOrgid
())))
{
IBZOrganization
org
=
iibzOrganizationService
.
get
(
emp
.
getOrgid
());
emp
.
setOrgcode
(
org
.
getOrgcode
());
emp
.
setOrgname
(
org
.
getOrgname
());
}
if
(
StringUtils
.
isEmpty
(
emp
.
getMdeptcode
())&&(!
StringUtils
.
isEmpty
(
emp
.
getMdeptid
())))
{
IBZDepartment
dept
=
iibzDepartmentService
.
get
(
emp
.
getMdeptid
());
emp
.
setMdeptcode
(
dept
.
getDeptcode
());
emp
.
setMdeptname
(
dept
.
getDeptname
());
emp
.
setBcode
(
dept
.
getBcode
());
}
if
(
StringUtils
.
isEmpty
(
userName
))
{
if
(!
StringUtils
.
isEmpty
(
emp
.
getDomains
()))
userName
=
emp
.
getLoginname
()+
"|"
+
emp
.
getDomains
();
else
userName
=
emp
.
getLoginname
();
emp
.
setUsername
(
userName
);
}
String
password
=
emp
.
getPassword
();
if
(
StringUtils
.
isEmpty
(
password
))
{
password
=
defaultPasswd
;
if
(
pwencrymode
==
1
)
password
=
DigestUtils
.
md5DigestAsHex
(
password
.
getBytes
());
else
if
(
pwencrymode
==
2
)
password
=
DigestUtils
.
md5DigestAsHex
(
String
.
format
(
"%1$s||%2$s"
,
userName
,
password
).
getBytes
());
emp
.
setPassword
(
password
);
}
}
private
void
prepareDept
(
IBZDepartment
dept
)
{
if
(
StringUtils
.
isEmpty
(
dept
.
getDeptid
())
&&
(!
StringUtils
.
isEmpty
(
dept
.
getDeptcode
()))
&&
(!
StringUtils
.
isEmpty
(
dept
.
getOrgid
())))
{
dept
.
setDeptid
(
dept
.
getOrgid
()
+
dept
.
getDeptcode
());
}
}
private
void
saveUser
(
JoinPoint
point
)
{
Object
[]
args
=
point
.
getArgs
();
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录