|
|
@@ -0,0 +1,44 @@
|
|
|
+package com.usoftchina.uas.office.dingtalk.listener;
|
|
|
+
|
|
|
+import com.usoftchina.dingtalk.sdk.AddrBookSdk;
|
|
|
+import com.usoftchina.uas.office.dingtalk.entity.Employee;
|
|
|
+import com.usoftchina.uas.office.dingtalk.service.UasEmpTurnoverService;
|
|
|
+import com.usoftchina.uas.office.dingtalk.service.UasEmployeeService;
|
|
|
+import com.usoftchina.uas.office.dto.UasEvent;
|
|
|
+import com.usoftchina.uas.office.entity.DataCenter;
|
|
|
+import com.usoftchina.uas.office.listener.UasEventListener;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author yingp
|
|
|
+ * @date 2020/4/10
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class UasEmpTurnoverListener {
|
|
|
+ @Autowired
|
|
|
+ private AddrBookSdk addrBookSdk;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UasEmpTurnoverService empTurnoverService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UasEmployeeService employeeService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * uas人员离职,删除企业微信通讯录人员
|
|
|
+ */
|
|
|
+ @UasEventListener(caller = "Turnover", operation = "AUDIT")
|
|
|
+ public void onEmployeeLeave(UasEvent event) {
|
|
|
+ if (!event.getMaster().equals(DataCenter.INSTANCE.getUsername())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String emCode = empTurnoverService.getEmCodeById(Integer.parseInt(event.getKey().toString()));
|
|
|
+ if (null != emCode) {
|
|
|
+ Employee employee = employeeService.getByCode(emCode);
|
|
|
+ if (null != employee && null != employee.getEm_ding()) {
|
|
|
+ addrBookSdk.deleteUser("Uas", employee.getEm_ding());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|