Get Department List

2020-03-24 10:07:27
John Ten
3403
Last edited by Taotao on 2020-03-24 13:56:06
Share links
Summary : By requesting this method, the data of the department list can be obtained. Based on the department list data, it can be used to add child departments.
Method Description

By requesting this method, the department list data can be obtained. Based on the department list data, it can be used to add child departments.

Example
public function getDeptList() 
{
    include_once('../vendor/zentao/zentao.php');
    $zentao      = new \zentao();
    $params      = array('deptID' => 1);    // parameters of the method
    $extraFields = array('title', 'deptID', 'parentDepts', 'sons', 'tree');    // customize fields returned
    $result      = $zentao->getDeptList($params, $extraFields);
    return $result;
}
Request GET
Method

getDeptList

Parameter
Name Type Required Description

deptID

int Optional Department ID
Result
success error
{
    "status": 1,
    "msg": "success",
    "result": {
        //the navbar of ZenTao
        "title": "Manage Department-ZenTao",
        //Department ID
        "deptID": "1",
        //Department information
        "parentDepts": [
            {
                "id": "1",
                "name": "Manager",
                "parent": "0",
                "path": ",1,",
                "grade": "1",
                "order": "0",
                "position": "",
                "function": "",
                "manager": ""
            }
        ],
        //child department list of the current department
        "sons": [
            {
                "id": "11",
                "name": "PO",
                "parent": "1",
                "path": ",1,11,",
                "grade": "2",
                "order": "10",
                "position": "",
                "function": "",
                "manager": ""
            },
            {
                "id": "12",
                "name": "PM",
                "parent": "1",
                "path": ",1,12,",
                "grade": "2",
                "order": "20",
                "position": "",
                "function": "",
                "manager": ""
            }
        ],
        //department tree
        "tree": [
            {
                "id": "1",
                "name": "Manager",
                "parent": "0",
                "path": ",1,",
                "grade": "1",
                "order": "0",
                "position": "",
                "function": "",
                "manager": "",
                "managerName": "",
                "children": [
                    {
                        "id": "11",
                        "name": "PO",
                        "parent": "1",
                        "path": ",1,11,",
                        "grade": "2",
                        "order": "10",
                        "position": "",
                        "function": "",
                        "manager": "",
                        "managerName": ""
                    },
                    {
                        "id": "12",
                        "name": "PM",
                        "parent": "1",
                        "path": ",1,12,",
                        "grade": "2",
                        "order": "20",
                        "position": "",
                        "function": "",
                        "manager": "",
                        "managerName": ""
                    }
                ],
                "actions": {
                    "delete": false
                }
            },
            {
                "id": "2",
                "name": "Dev",
                "parent": "0",
                "path": ",2,",
                "grade": "1",
                "order": "1",
                "position": "",
                "function": "",
                "manager": "",
                "managerName": ""
            },
            {
                "id": "3",
                "name": "QA",
                "parent": "0",
                "path": ",3,",
                "grade": "1",
                "order": "2",
                "position": "",
                "function": "",
                "manager": "",
                "managerName": ""
            },
            {
                "id": "4",
                "name": "Sales",
                "parent": "0",
                "path": ",4,",
                "grade": "1",
                "order": "3",
                "position": "",
                "function": "",
                "manager": "",
                "managerName": ""
            },
            {
                "id": "8",
                "name": "Customer",
                "parent": "0",
                "path": ",8,",
                "grade": "1",
                "order": "13",
                "position": "",
                "function": "",
                "manager": "",
                "managerName": ""
            }
        ]
    }
}
{
    "status": 0,
    "msg": "error",
    "result": []
}

Write a Comment
Comment will be posted after it is reviewed.