DDClient_Role.java 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. package com.malk.service.dingtalk;
  2. import java.util.Collection;
  3. import java.util.List;
  4. import java.util.Map;
  5. /**
  6. * 钉钉应用 + 角色管理
  7. * <p>
  8. * Phase 1:getMicroAppVisibleScopes + roleGroupCreate(数据落库 + 全局角色组)
  9. * Phase 2:roleCreate + roleAddUsers + roleDeleteUsers(每应用一角色 + 全量绑人员)
  10. *
  11. * @apiNote https://open.dingtalk.com/document/orgapp/contacts-overview
  12. */
  13. public interface DDClient_Role {
  14. /**
  15. * 获取微应用可见范围
  16. *
  17. * @return Map { deptVisibleScopes: List<Long>, userVisibleScopes: List<String>, isHidden: Boolean }
  18. * @apiNote https://open.dingtalk.com/document/orgapp/queries-the-visible-range-of-a-microapp
  19. */
  20. Map getMicroAppVisibleScopes(String access_token, long agentId);
  21. /**
  22. * 创建角色组
  23. *
  24. * @return groupId(字符串形式)
  25. * @apiNote https://open.dingtalk.com/document/development/add-a-role-group
  26. */
  27. String roleGroupCreate(String access_token, String name);
  28. /**
  29. * 创建角色
  30. *
  31. * @return roleId(字符串形式)
  32. * @apiNote https://open.dingtalk.com/document/development/add-roles
  33. */
  34. String roleCreate(String access_token, String roleName, String groupId);
  35. /**
  36. * 批量增加员工角色(单批最多 100 用户;impl 内部自动分批)
  37. *
  38. * @apiNote https://open.dingtalk.com/document/development/add-role-information-to-employees-in-batches
  39. */
  40. void roleAddUsers(String access_token, String roleId, Collection<String> userIds);
  41. /**
  42. * 批量删除员工角色(单批最多 100 用户;impl 内部自动分批)
  43. *
  44. * @apiNote https://open.dingtalk.com/document/development/delete-the-color-information-of-employee-corners-in-batches
  45. */
  46. void roleDeleteUsers(String access_token, String roleId, Collection<String> userIds);
  47. /**
  48. * 更新角色名
  49. *
  50. * @apiNote https://open.dingtalk.com/document/development/update-role-information
  51. */
  52. void roleUpdate(String access_token, String roleId, String roleName);
  53. /**
  54. * 删除角色。
  55. *
  56. * @param access_token 钉钉 accessToken
  57. * @param roleId 角色 ID
  58. * @apiNote https://open.dingtalk.com/document/orgapp/delete-role
  59. */
  60. void roleDelete(String access_token, String roleId);
  61. /**
  62. * 查询角色列表。
  63. *
  64. * @param access_token 钉钉 accessToken
  65. * @param body_ext 可选参数:size、offset
  66. * @return 钉钉角色列表 result
  67. * @apiNote https://open.dingtalk.com/document/orgapp/obtains-a-list-of-enterprise-roles
  68. */
  69. Map roleList(String access_token, Map body_ext);
  70. /**
  71. * 查询角色详情。
  72. *
  73. * @param access_token 钉钉 accessToken
  74. * @param roleId 角色 ID
  75. * @return 钉钉角色详情 result
  76. * @apiNote https://open.dingtalk.com/document/orgapp/queries-role-details
  77. */
  78. Map roleGet(String access_token, String roleId);
  79. /**
  80. * 查询角色下员工列表。
  81. *
  82. * @param access_token 钉钉 accessToken
  83. * @param roleId 角色 ID
  84. * @param size 每页数量
  85. * @param offset 分页偏移
  86. * @return 钉钉角色员工列表 result
  87. * @apiNote https://open.dingtalk.com/document/orgapp/obtain-the-list-of-employees-of-a-role
  88. */
  89. Map roleListEmployees(String access_token, String roleId, long size, long offset);
  90. /**
  91. * 设置应用可见范围(支持 dept/user/role 三种维度 add/del)
  92. * <p>
  93. * 钉钉单次 delUserIds 上限约 50,业务方需自行分批
  94. *
  95. * @apiNote https://open.dingtalk.com/document/development/update-the-visible-range-of-micro-applications
  96. */
  97. void setMicroAppVisibleScopes(String access_token, long agentId,
  98. List<Long> addDeptIds, List<String> addUserIds, List<String> addRoleIds,
  99. List<Long> delDeptIds, List<String> delUserIds, List<String> delRoleIds);
  100. /**
  101. * 获取企业自建应用列表(返回 [ {agentId, appKey, name}, ... ])
  102. *
  103. * @apiNote https://open.dingtalk.com/document/development/obtain-the-list-of-internal-h5-applications-created-by-the
  104. */
  105. List<Map> listMicroApp(String access_token);
  106. }