yingp 5 лет назад
Родитель
Сommit
01a1ad9aea

+ 11 - 0
uas-office-core/src/main/java/com/usoftchina/uas/office/dto/UasEvent.java

@@ -51,6 +51,17 @@ public class UasEvent {
         this.timestamp = timestamp;
         this.timestamp = timestamp;
     }
     }
 
 
+    public UasEvent() {
+    }
+
+    public UasEvent(String operation, String caller, Object key, String master) {
+        this.operation = operation;
+        this.caller = caller;
+        this.key = key;
+        this.master = master;
+        this.timestamp = System.currentTimeMillis();
+    }
+
     @Override
     @Override
     public String toString() {
     public String toString() {
         return "UasEvent{" +
         return "UasEvent{" +

+ 33 - 0
uas-office-qywx/src/main/java/com/usoftchina/uas/office/qywx/manage/controller/QywxAddrBookController.java

@@ -2,8 +2,10 @@ package com.usoftchina.uas.office.qywx.manage.controller;
 
 
 import com.usoftchina.qywx.sdk.AddrBookSdk;
 import com.usoftchina.qywx.sdk.AddrBookSdk;
 import com.usoftchina.uas.office.dto.Result;
 import com.usoftchina.uas.office.dto.Result;
+import com.usoftchina.uas.office.dto.UasEvent;
 import com.usoftchina.uas.office.entity.DataCenter;
 import com.usoftchina.uas.office.entity.DataCenter;
 import com.usoftchina.uas.office.jdbc.DataSourceHolder;
 import com.usoftchina.uas.office.jdbc.DataSourceHolder;
+import com.usoftchina.uas.office.listener.UasEventListenerFactory;
 import com.usoftchina.uas.office.qywx.service.UasEmployeeService;
 import com.usoftchina.uas.office.qywx.service.UasEmployeeService;
 import com.usoftchina.uas.office.qywx.service.UasOrgService;
 import com.usoftchina.uas.office.qywx.service.UasOrgService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -29,6 +31,9 @@ public class QywxAddrBookController {
     @Autowired
     @Autowired
     private AddrBookSdk addrBookSdk;
     private AddrBookSdk addrBookSdk;
 
 
+    @Autowired
+    private UasEventListenerFactory eventListenerFactory;
+
     @PostMapping(path = "/addrbook/sync")
     @PostMapping(path = "/addrbook/sync")
     public Result syncAll() {
     public Result syncAll() {
         DataCenter dataCenter = DataCenter.INSTANCE;
         DataCenter dataCenter = DataCenter.INSTANCE;
@@ -58,4 +63,32 @@ public class QywxAddrBookController {
     public Result getDepartmentList() {
     public Result getDepartmentList() {
         return Result.success(addrBookSdk.getDepartmentList());
         return Result.success(addrBookSdk.getDepartmentList());
     }
     }
+
+    /**
+     * 同步单个用户
+     *
+     * @param id
+     * @return
+     */
+    @RequestMapping(path = "/addrbook/user/sync")
+    public Result syncUser(Integer id) {
+        UasEvent event = new UasEvent("AUDIT", "Employeemanager", id,
+                DataCenter.INSTANCE.getUsername());
+        eventListenerFactory.invokeListeners(event);
+        return Result.success();
+    }
+
+    /**
+     * 同步单个组织
+     *
+     * @param id
+     * @return
+     */
+    @RequestMapping(path = "/addrbook/org/sync")
+    public Result syncOrg(Integer id) {
+        UasEvent event = new UasEvent("UPDATE", "HrOrg", id,
+                DataCenter.INSTANCE.getUsername());
+        eventListenerFactory.invokeListeners(event);
+        return Result.success();
+    }
 }
 }