|
@@ -149,6 +149,55 @@ public class DingdingAddressBookController {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 修改部门信息
|
|
|
|
+ */
|
|
|
|
+ @ApiLog("修改部门信息")
|
|
|
|
+ @ApiOperation(value = "修改部门信息")
|
|
|
|
+ @PostMapping("updateDept")
|
|
|
|
+ public ResponseEntity updateDept(@RequestBody DeptDTO deptDTO) {
|
|
|
|
+ try {
|
|
|
|
+ String token = getToken();
|
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/update");
|
|
|
|
+ OapiV2DepartmentUpdateRequest req = new OapiV2DepartmentUpdateRequest();
|
|
|
|
+ req.setDeptId(deptDTO.getDeptId());
|
|
|
|
+ req.setName(deptDTO.getName());
|
|
|
|
+ req.setParentId(deptDTO.getParentId());
|
|
|
|
+ OapiV2DepartmentUpdateResponse rsp = client.execute(req, token);
|
|
|
|
+ return ResponseEntity.ok("修改成功");
|
|
|
|
+ } catch (ApiException e) {
|
|
|
|
+ e.printStackTrace(); // 打印错误日志(开发调试用)
|
|
|
|
+ return ResponseEntity.badRequest ( ).body ( "接口异常,请重试!" );
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace(); // 打印错误日志(开发调试用)
|
|
|
|
+ return ResponseEntity.badRequest ( ).body ( "接口异常,请重试!" );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据部门id查询数据
|
|
|
|
+ */
|
|
|
|
+ @ApiLog("根据部门id查询数据")
|
|
|
|
+ @ApiOperation(value = "根据部门id查询数据")
|
|
|
|
+ @GetMapping("queryById")
|
|
|
|
+ public ResponseEntity queryById(Long deptId) {
|
|
|
|
+ try {
|
|
|
|
+ String token = getToken();
|
|
|
|
+ DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/v2/department/get");
|
|
|
|
+ OapiV2DepartmentGetRequest req = new OapiV2DepartmentGetRequest();
|
|
|
|
+ req.setDeptId(deptId);
|
|
|
|
+ OapiV2DepartmentGetResponse rsp = client.execute(req, token);
|
|
|
|
+ return ResponseEntity.ok(rsp);
|
|
|
|
+ } catch (ApiException e) {
|
|
|
|
+ e.printStackTrace(); // 打印错误日志(开发调试用)
|
|
|
|
+ return ResponseEntity.badRequest ( ).body ( "接口异常,请重试!" );
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace(); // 打印错误日志(开发调试用)
|
|
|
|
+ return ResponseEntity.badRequest ( ).body ( "接口异常,请重试!" );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
public <T> T jsonToObject(String json, Class<T> clazz) {
|
|
public <T> T jsonToObject(String json, Class<T> clazz) {
|