Search in sources :

Example 1 with Department

use of com.jeecg.qywx.api.department.vo.Department in project jeecg-boot by jeecgboot.

the class ThirdAppWechatEnterpriseServiceImpl method syncThirdAppDepartmentToLocal.

@Override
public SyncInfoVo syncThirdAppDepartmentToLocal(String ids) {
    SyncInfoVo syncInfo = new SyncInfoVo();
    String accessToken = this.getAccessToken();
    if (accessToken == null) {
        syncInfo.addFailInfo("accessToken获取失败!");
        return syncInfo;
    }
    // 获取企业微信所有的部门
    List<Department> departments = JwDepartmentAPI.getAllDepartment(accessToken);
    if (departments == null) {
        syncInfo.addFailInfo("企业微信部门信息获取失败!");
        return syncInfo;
    }
    String username = JwtUtil.getUserNameByToken(SpringContextUtils.getHttpServletRequest());
    // 将list转为tree
    List<JwDepartmentTreeVo> departmentTreeList = JwDepartmentTreeVo.listToTree(departments);
    // 递归同步部门
    this.syncDepartmentToLocalRecursion(departmentTreeList, null, username, syncInfo);
    return syncInfo;
}
Also used : SyncInfoVo(org.jeecg.modules.system.vo.thirdapp.SyncInfoVo) Department(com.jeecg.qywx.api.department.vo.Department) JwDepartmentTreeVo(org.jeecg.modules.system.vo.thirdapp.JwDepartmentTreeVo)

Example 2 with Department

use of com.jeecg.qywx.api.department.vo.Department in project kykms by mahonelau.

the class ThirdAppWechatEnterpriseServiceImpl method syncLocalDepartmentToThirdApp.

@Override
public boolean syncLocalDepartmentToThirdApp(String ids) {
    String accessToken = this.getAccessToken();
    if (accessToken == null) {
        return false;
    }
    // 获取企业微信所有的部门
    List<Department> departments = JwDepartmentAPI.getAllDepartment(accessToken);
    if (departments == null) {
        return false;
    }
    // 删除企业微信有但本地没有的部门(以本地部门数据为主)(以为企业微信不能创建同名部门,所以只能先删除)
    List<JwDepartmentTreeVo> departmentTreeList = JwDepartmentTreeVo.listToTree(departments);
    this.deleteDepartRecursion(departmentTreeList, accessToken, true);
    // 获取本地所有部门树结构
    List<SysDepartTreeModel> sysDepartsTree = sysDepartService.queryTreeList();
    // -- 企业微信不能创建新的顶级部门,所以新的顶级部门的parentId就为1
    Department parent = new Department();
    parent.setId("1");
    // 递归同步部门
    departments = JwDepartmentAPI.getAllDepartment(accessToken);
    this.syncDepartmentRecursion(sysDepartsTree, departments, parent, accessToken);
    return true;
}
Also used : Department(com.jeecg.qywx.api.department.vo.Department) JwDepartmentTreeVo(org.jeecg.modules.system.vo.thirdapp.JwDepartmentTreeVo) SysDepartTreeModel(org.jeecg.modules.system.model.SysDepartTreeModel)

Example 3 with Department

use of com.jeecg.qywx.api.department.vo.Department in project kms by mahonelau.

the class ThirdAppWechatEnterpriseServiceImpl method syncThirdAppDepartmentToLocal.

@Override
public SyncInfoVo syncThirdAppDepartmentToLocal(String ids) {
    SyncInfoVo syncInfo = new SyncInfoVo();
    String accessToken = this.getAccessToken();
    if (accessToken == null) {
        syncInfo.addFailInfo("accessToken获取失败!");
        return syncInfo;
    }
    // 获取企业微信所有的部门
    List<Department> departments = JwDepartmentAPI.getAllDepartment(accessToken);
    if (departments == null) {
        syncInfo.addFailInfo("企业微信部门信息获取失败!");
        return syncInfo;
    }
    String username = JwtUtil.getUserNameByToken(SpringContextUtils.getHttpServletRequest());
    // 将list转为tree
    List<JwDepartmentTreeVo> departmentTreeList = JwDepartmentTreeVo.listToTree(departments);
    // 递归同步部门
    this.syncDepartmentToLocalRecursion(departmentTreeList, null, username, syncInfo);
    return syncInfo;
}
Also used : SyncInfoVo(org.jeecg.modules.system.vo.thirdapp.SyncInfoVo) Department(com.jeecg.qywx.api.department.vo.Department) JwDepartmentTreeVo(org.jeecg.modules.system.vo.thirdapp.JwDepartmentTreeVo)

Example 4 with Department

use of com.jeecg.qywx.api.department.vo.Department in project kms by mahonelau.

the class ThirdAppWechatEnterpriseServiceImpl method syncLocalDepartmentToThirdApp.

@Override
public boolean syncLocalDepartmentToThirdApp(String ids) {
    String accessToken = this.getAccessToken();
    if (accessToken == null) {
        return false;
    }
    // 获取企业微信所有的部门
    List<Department> departments = JwDepartmentAPI.getAllDepartment(accessToken);
    if (departments == null) {
        return false;
    }
    // 删除企业微信有但本地没有的部门(以本地部门数据为主)(以为企业微信不能创建同名部门,所以只能先删除)
    List<JwDepartmentTreeVo> departmentTreeList = JwDepartmentTreeVo.listToTree(departments);
    this.deleteDepartRecursion(departmentTreeList, accessToken, true);
    // 获取本地所有部门树结构
    List<SysDepartTreeModel> sysDepartsTree = sysDepartService.queryTreeList();
    // -- 企业微信不能创建新的顶级部门,所以新的顶级部门的parentId就为1
    Department parent = new Department();
    parent.setId("1");
    // 递归同步部门
    departments = JwDepartmentAPI.getAllDepartment(accessToken);
    this.syncDepartmentRecursion(sysDepartsTree, departments, parent, accessToken);
    return true;
}
Also used : Department(com.jeecg.qywx.api.department.vo.Department) JwDepartmentTreeVo(org.jeecg.modules.system.vo.thirdapp.JwDepartmentTreeVo) SysDepartTreeModel(org.jeecg.modules.system.model.SysDepartTreeModel)

Example 5 with Department

use of com.jeecg.qywx.api.department.vo.Department in project jeecg-boot by jeecgboot.

the class ThirdAppWechatEnterpriseServiceImpl method syncLocalDepartmentToThirdApp.

@Override
public SyncInfoVo syncLocalDepartmentToThirdApp(String ids) {
    SyncInfoVo syncInfo = new SyncInfoVo();
    String accessToken = this.getAccessToken();
    if (accessToken == null) {
        syncInfo.addFailInfo("accessToken获取失败!");
        return syncInfo;
    }
    // 获取企业微信所有的部门
    List<Department> departments = JwDepartmentAPI.getAllDepartment(accessToken);
    if (departments == null) {
        syncInfo.addFailInfo("获取企业微信所有部门失败!");
        return syncInfo;
    }
    // 删除企业微信有但本地没有的部门(以本地部门数据为主)(以为企业微信不能创建同名部门,所以只能先删除)
    List<JwDepartmentTreeVo> departmentTreeList = JwDepartmentTreeVo.listToTree(departments);
    this.deleteDepartRecursion(departmentTreeList, accessToken, true);
    // 获取本地所有部门树结构
    List<SysDepartTreeModel> sysDepartsTree = sysDepartService.queryTreeList();
    // -- 企业微信不能创建新的顶级部门,所以新的顶级部门的parentId就为1
    Department parent = new Department();
    parent.setId("1");
    // 递归同步部门
    departments = JwDepartmentAPI.getAllDepartment(accessToken);
    this.syncDepartmentRecursion(sysDepartsTree, departments, parent, accessToken);
    return syncInfo;
}
Also used : SyncInfoVo(org.jeecg.modules.system.vo.thirdapp.SyncInfoVo) Department(com.jeecg.qywx.api.department.vo.Department) JwDepartmentTreeVo(org.jeecg.modules.system.vo.thirdapp.JwDepartmentTreeVo) SysDepartTreeModel(org.jeecg.modules.system.model.SysDepartTreeModel)

Aggregations

Department (com.jeecg.qywx.api.department.vo.Department)6 JwDepartmentTreeVo (org.jeecg.modules.system.vo.thirdapp.JwDepartmentTreeVo)6 SyncInfoVo (org.jeecg.modules.system.vo.thirdapp.SyncInfoVo)4 SysDepartTreeModel (org.jeecg.modules.system.model.SysDepartTreeModel)3