Search in sources :

Example 1 with OrganizationalStructure

use of com.topcom.cms.yuqing.domain.OrganizationalStructure in project topcom-cloud by 545314690.

the class OrganizationalStructureController method getFullTree.

@ResponseBody
@RequestMapping(value = { "/getFullTree.json" }, method = { RequestMethod.GET }, produces = { "application/json" })
public List<OrganizationalStructure> getFullTree(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "id", required = false) Long id) {
    List<OrganizationalStructure> result = null;
    if (id == null) {
        result = this.treeManager.getRoot();
    } else {
        BaseTreeEntityModel node = (BaseTreeEntityModel) this.treeManager.findById(id);
        result = node.getChildren();
    }
    for (int i = 0; i < result.size(); i++) {
        result.set(i, handleOne(result.get(i)));
    }
    return result;
}
Also used : OrganizationalStructure(com.topcom.cms.yuqing.domain.OrganizationalStructure) BaseTreeEntityModel(com.topcom.cms.base.model.BaseTreeEntityModel)

Example 2 with OrganizationalStructure

use of com.topcom.cms.yuqing.domain.OrganizationalStructure in project topcom-cloud by 545314690.

the class OrganizationalStructureController method handleOne.

private OrganizationalStructure handleOne(OrganizationalStructure OS) {
    List<OrganizationalStructure> organizationList = OS.getChildren();
    if (organizationList != null && organizationList.size() > 0) {
        for (int i = 0; i < organizationList.size(); i++) {
            organizationList.set(i, handleOne(organizationList.get(i)));
        }
    } else {
        if (OS.isLeaf()) {
            Long id = OS.getId();
            List<Staff> byOrganizationalStructureId = staffManager.findByOrganizationalStructureId(id);
            List<OrganizationalStructure> childList = new ArrayList<>();
            for (Staff s : byOrganizationalStructureId) {
                childList.add(new OrganizationalStructure(s.getPosition() + ":" + s.getName(), s.getId()));
            }
            OS.setChildren(childList);
        }
    }
    return OS;
}
Also used : Staff(com.topcom.cms.yuqing.domain.Staff) ArrayList(java.util.ArrayList) OrganizationalStructure(com.topcom.cms.yuqing.domain.OrganizationalStructure)

Aggregations

OrganizationalStructure (com.topcom.cms.yuqing.domain.OrganizationalStructure)2 BaseTreeEntityModel (com.topcom.cms.base.model.BaseTreeEntityModel)1 Staff (com.topcom.cms.yuqing.domain.Staff)1 ArrayList (java.util.ArrayList)1