Commit 8c15754f by fudahua

同步通讯录 同步判断

parent 0bcf1597
......@@ -3,7 +3,9 @@ package com.gic.haoban.manage.service.service.impl;
import java.util.Date;
import java.util.List;
import com.gic.haoban.base.api.common.Constant;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -38,11 +40,22 @@ public class DepartmentServiceImpl implements DepartmentService {
public String add(DepartmentDTO department) {
Date now = new Date();
TabHaobanDepartment tab = EntityUtil.changeEntityByJSON(TabHaobanDepartment.class, department);
Integer sort = tab.getSort();
if(sort == null) {
int maxSort = mapper.selectMaxSort(department.getParentDepartmentId());
tab.setSort(maxSort + 1);
}
tab.setDepartmentId(StringUtil.randomUUID());
Integer sort = tab.getSort();
if(sort == null) {
int maxSort = mapper.selectMaxSort(department.getParentDepartmentId());
tab.setSort(maxSort + 1);
}
if (StringUtils.isBlank(department.getChainId())) {
TabHaobanDepartment pDepartment = this.selectById(department.getParentDepartmentId());
if (null == pDepartment) {
throw new RuntimeException("父部门不存在");
}
tab.setChainId(pDepartment.getChainId() + Constant.ID_SEPARATOR + tab.getDepartmentId());
tab.setChainName(pDepartment.getChainName() + Constant.NAME_SEPARATOR + tab.getDepartmentName());
}
Integer isStore = department.getIsStore();
if(isStore == null){
department.setIsStore(0);
......@@ -54,8 +67,8 @@ public class DepartmentServiceImpl implements DepartmentService {
if (department.getTempFlag() == null) {
department.setTempFlag(0);
}
tab.setDepartmentId(StringUtil.randomUUID());
mapper.insert(tab);
mapper.insert(tab);
return tab.getDepartmentId();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment