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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.kiisoo.ic.department.service;
import com.kiisoo.ic.department.entity.DepartmentDO;
import com.kiisoo.ic.department.mapper.PrivilageDepartmentDOMapper;
import com.kiisoo.ic.wx.service.QWMailListManageService;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
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;
@Autowired
private PrivilageDepartmentDOMapper departmentDOMapper;
@Transactional(rollbackFor = Exception.class)
public Boolean addDepartment(DepartmentDO departmentDO) throws WxErrorException {
//数据库创建部门需要返回部门id
//成功则添加用户到企业微信
qwMailListManageService.addDepartment(departmentDO);
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;
}
}