You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.8 KiB
Java

package com.kiisoo.ic.department.service;
import com.kiisoo.ic.department.entity.DepartmentDO;
6 years ago
import com.kiisoo.ic.department.mapper.PrivilageDepartmentDOMapper;
import com.kiisoo.ic.wx.service.QWMailListManageService;
import me.chanjar.weixin.common.error.WxErrorException;
6 years ago
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
6 years ago
import java.util.List;
/**
* @Description: service
* @Auther: yechenhao
* @Date: 2020/4/7 0002 10:06
* @Version: v1
*/
@Service
public class DepartmentService {
@Autowired
private QWMailListManageService qwMailListManageService;
6 years ago
@Autowired
private PrivilageDepartmentDOMapper departmentDOMapper;
@Transactional(rollbackFor = Exception.class)
public Boolean addDepartment(DepartmentDO departmentDO) throws WxErrorException {
//数据库创建部门需要返回部门id
//成功则添加用户到企业微信
qwMailListManageService.addDepartment(departmentDO);
return true;
}
6 years ago
@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;
}
}