Exemplo n.º 1
0
 /**
  * 修改部门
  *
  * @param token
  * @param jsonStr
  * @return
  */
 public static Result<String> updateDepartment(String token, String jsonStr) {
   Result<String> result = new Result<String>();
   JSONObject jo = DepartmentAPI.updateDepartment(token, jsonStr);
   if (jo != null) {
     result.setErrmsg(ErrorCodeText.errorMsg(jo.getString("errcode")));
     result.setErrcode(jo.getString("errcode"));
     result.setObject("");
   }
   return result;
 }
Exemplo n.º 2
0
 /**
  * 获取部门列表
  *
  * @return
  */
 public static Result<QiYeDepartment[]> getDepartment(String token) {
   Result<QiYeDepartment[]> result = new Result<QiYeDepartment[]>();
   JSONObject jo = DepartmentAPI.getDepartment(token);
   if (jo != null) {
     result.setErrmsg(ErrorCodeText.errorMsg(jo.getString("errcode")));
     result.setErrcode(jo.getString("errcode"));
     JSONArray ja = jo.getJSONArray("department");
     if (ja != null && ja.size() > 0) {
       QiYeDepartment[] departments = new QiYeDepartment[ja.size()];
       for (int i = 0; i < ja.size(); i++) {
         JSONObject jsonObject = ja.getJSONObject(i);
         int id = jsonObject.getInt("id");
         int parentid = jsonObject.getInt("parentid");
         departments[i] = new QiYeDepartment(id, jsonObject.get("name") + "", parentid);
       }
       result.setObject(departments);
     }
   }
   return result;
 }