Commit 6aabb1fb by 陶光胜

加日志

parent 49b32169
......@@ -58,6 +58,16 @@ public class QywxCorpInfoSimpleDTO implements Serializable{
/* 有效0 删除1 */
private Integer delStatus = 0;
/**
* 权限等级。
1:通讯录基本信息只读
2:通讯录全部信息只读(已废弃)
3:通讯录全部信息读写
4:单个基本信息只读
5:通讯录全部信息只写(已废弃)
* **/
private Integer level;
public Integer getErrcode() {
return errcode;
}
......@@ -202,4 +212,11 @@ public class QywxCorpInfoSimpleDTO implements Serializable{
this.delStatus = delStatus;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
}
......@@ -123,6 +123,9 @@ public class MessageApiServiceImpl implements MessageApiService {
departmentDTO.setIsStore(0);
departmentDTO.setRelatedId(qywxCallBackDTO.getId()+"");
TabHaobanDepartment parentDepartment = this.departmentService.getByWxId(qywxCallBackDTO.getParentId() + "");
if(parentDepartment == null){
return;
}
departmentDTO.setParentDepartmentId(parentDepartment.getDepartmentId());
departmentDTO.setChainId(parentDepartment.getChainId()+ Constant.ID_SEPARATOR + parentDepartment.getDepartmentId());
departmentDTO.setChainName(parentDepartment.getChainName() + Constant.NAME_SEPARATOR + parentDepartment.getChainName());
......
......@@ -4,6 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import com.alibaba.fastjson.JSON;
import com.gic.haoban.base.api.common.Constant;
import com.gic.haoban.manage.service.entity.TabHaobanDepartment;
import com.gic.haoban.manage.service.service.DepartmentService;
import com.gic.wechat.api.dto.qywx.DepartmentDTO;
import com.gic.wechat.api.service.qywx.QywxDepartmentApiService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
......@@ -35,6 +41,10 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
private WxEnterpriseMapper wxEnterpriseMapper;
@Autowired
private WxApplicationService wxApplicationService;
@Autowired
private QywxDepartmentApiService qywxDepartmentApiService;
@Autowired
private DepartmentService departmentService;
@Override
public void callbackReviceEnterprise(QywxCorpInfoSimpleDTO dto) {
......@@ -70,6 +80,13 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
wxApplicationService.update(tab);
}
log.info("企业微信授权处理完成");
if(dto.getLevel() != null && dto.getLevel() == 3){ //如果是通讯录应用拉取所有部门初始化
List<DepartmentDTO> list = this.qywxDepartmentApiService.listDepartment(dto.getCorpid(), dto.getSuiteId(), null);
log.info("企业所有部门数据:{}", JSON.toJSONString(list));
if(CollectionUtils.isNotEmpty(list)){
this.addAllDepartment(list, 1, wxEnterpriseId);
}
}
}
@Override
......@@ -89,6 +106,33 @@ public class WxEnterpriseApiServiceImpl implements WxEnterpriseApiService {
return wxDTO;
}
private void addAllDepartment(List<DepartmentDTO> list, Integer parentId, String wxEnterpriseId){
int level = 1;
String chainId = "0";
String chainName = "0";
if(parentId != 1){
TabHaobanDepartment parent = this.departmentService.getByWxId(parentId + "");
if(parent != null){
level = parent.getLevel() + 1;
chainId = parent.getChainId() + Constant.ID_SEPARATOR + parent.getDepartmentId();
chainName = parent.getChainName() + Constant.NAME_SEPARATOR + parent.getChainName();
}
}
for(DepartmentDTO departmentDTO : list){
if(parentId == departmentDTO.getParentid()){
com.gic.haoban.manage.api.dto.DepartmentDTO dto = new com.gic.haoban.manage.api.dto.DepartmentDTO();
dto.setDepartmentName(departmentDTO.getName());
dto.setLevel(level);
dto.setWxEnterpriseId(wxEnterpriseId);
dto.setWxDepartmentId(departmentDTO.getId()+"");
dto.setParentDepartmentId(parentId+"");
dto.setChainId(chainId);
dto.setChainName(chainName);
this.departmentService.add(dto);
this.addAllDepartment(list, departmentDTO.getId(), wxEnterpriseId);
}
}
}
}
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