提交 5b8508ce 编写于 作者: sq3536's avatar sq3536

上级选择时加上了递归判断

上级 bdd6b287
package cn.ibizlab.core.extensions.aspect;
import cn.ibizlab.core.extensions.mapping.IBZEmp2UserMapping;
import cn.ibizlab.core.extensions.service.OUCoreService;
import cn.ibizlab.core.extensions.service.OUModelService;
import cn.ibizlab.core.ou.domain.IBZDepartment;
import cn.ibizlab.core.ou.domain.IBZEmployee;
......@@ -37,6 +38,9 @@ public class IBZEmp2UserAspect
@Qualifier("userservice")
private IBZUSERService ibzuserService;
@Autowired
@Lazy
private OUCoreService ouCoreService;
@Autowired
@Lazy
......@@ -61,14 +65,32 @@ public class IBZEmp2UserAspect
beforeSaveEmp(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZOrganizationService.updat*(..))")
public void BeforeUpdateOrg(JoinPoint point) throws Exception {
beforeSaveOrg(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZOrganizationService.sav*(..))")
public void BeforeSaveOrg(JoinPoint point) throws Exception {
beforeSaveOrg(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZDepartmentService.creat*(..))")
public void BeforeCreateDept(JoinPoint point) throws Exception {
beforeSaveDept(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZDepartmentService.sav*(..))")
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZDepartmentService.save(..))")
public void BeforeSaveDept(JoinPoint point) throws Exception {
beforeSaveDept(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZDepartmentService.updat*(..))")
public void BeforeUpdateDept(JoinPoint point) throws Exception {
beforeSaveDept(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZDepartmentService.saveBatch(..))")
public void BeforeSaveBatchDept(JoinPoint point) throws Exception {
beforeSaveDept(point);
}
@After(value = "execution(* cn.ibizlab.core.ou.service.IIBZEmployeeService.creat*(..))")
public void AfterCreateEmp(JoinPoint point) throws Exception {
......@@ -137,6 +159,27 @@ public class IBZEmp2UserAspect
}
}
private void beforeSaveOrg(JoinPoint point)
{
Object[] args = point.getArgs();
if (args.length > 0)
{
Object obj = args[0];
if(obj instanceof IBZOrganization)
{
prepareOrg((IBZOrganization)obj);
}
else if (obj instanceof List)
{
List<IBZOrganization> list=(List<IBZOrganization>)obj;
for(IBZOrganization org:list)
{
prepareOrg(org);
}
}
}
}
private void prepareEmp(IBZEmployee emp)
{
String userName=emp.getUsername();
......@@ -166,12 +209,26 @@ public class IBZEmp2UserAspect
private void prepareDept(IBZDepartment dept)
{
if ((!StringUtils.isEmpty(dept.getDeptid()))&&(!StringUtils.isEmpty(dept.getParentdeptid())))
{
if(ouCoreService.getDeptModel(dept.getDeptid()).getSub().contains(dept.getParentdeptid()))
throw new BadRequestAlertException("上级部门选择有误","IBZDepartment",dept.getDeptid());
}
if (StringUtils.isEmpty(dept.getDeptid()) && (!StringUtils.isEmpty(dept.getDeptcode())) && (!StringUtils.isEmpty(dept.getOrgid())))
{
dept.setDeptid(dept.getOrgid() + dept.getDeptcode());
}
}
private void prepareOrg(IBZOrganization org)
{
if ((!StringUtils.isEmpty(org.getOrgid()))&&(!StringUtils.isEmpty(org.getParentorgid())))
{
if(ouCoreService.getOrgModel(org.getOrgid()).getSub().contains(org.getParentorgid()))
throw new BadRequestAlertException("上级单位选择有误","IBZOrganization",org.getOrgid());
}
}
private void saveUser(JoinPoint point)
{
Object[] args = point.getArgs();
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册