|
|
@ -1,12 +1,18 @@
|
|
|
|
package com.kiisoo.ic.department.service;
|
|
|
|
package com.kiisoo.ic.department.service;
|
|
|
|
|
|
|
|
|
|
|
|
import com.kiisoo.ic.department.entity.DepartmentDO;
|
|
|
|
import com.kiisoo.ic.department.entity.DepartmentDO;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.department.mapper.PrivilageDepartmentDOMapper;
|
|
|
|
import com.kiisoo.ic.wx.service.QWMailListManageService;
|
|
|
|
import com.kiisoo.ic.wx.service.QWMailListManageService;
|
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
|
|
|
|
|
import me.chanjar.weixin.cp.bean.WxCpDepart;
|
|
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @Description: 部门管理service
|
|
|
|
* @Description: 部门管理service
|
|
|
|
* @Auther: yechenhao
|
|
|
|
* @Auther: yechenhao
|
|
|
@ -19,6 +25,9 @@ public class DepartmentService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private QWMailListManageService qwMailListManageService;
|
|
|
|
private QWMailListManageService qwMailListManageService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private PrivilageDepartmentDOMapper departmentDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public Boolean addDepartment(DepartmentDO departmentDO) throws WxErrorException {
|
|
|
|
public Boolean addDepartment(DepartmentDO departmentDO) throws WxErrorException {
|
|
|
|
//数据库创建部门(需要返回部门id)
|
|
|
|
//数据库创建部门(需要返回部门id)
|
|
|
@ -28,4 +37,19 @@ public class DepartmentService {
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
public Boolean syncDepartment() throws WxErrorException {
|
|
|
|
|
|
|
|
//获取企业微信部门架构
|
|
|
|
|
|
|
|
List<WxCpDepart> wxCpDeparts = qwMailListManageService.syncDepartment();
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(wxCpDeparts)){
|
|
|
|
|
|
|
|
wxCpDeparts.forEach(wxDept -> {
|
|
|
|
|
|
|
|
DepartmentDO departmentDO = new DepartmentDO();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(wxDept,departmentDO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// departmentDOMapper.insert(departmentDO);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|