wanyuan 7 miesięcy temu
rodzic
commit
87be0eb141

+ 2 - 2
tip-api/src/main/java/com/minto/app/organization/workpro/WorkProMessagePipeline.java

@@ -58,7 +58,7 @@ public class WorkProMessagePipeline implements MessagePipeline{
 
     @Override
     public String getName(){
-        return " WorkPro";
+        return "WorkPro";
     }
 
     @Override
@@ -82,6 +82,6 @@ public class WorkProMessagePipeline implements MessagePipeline{
     @Override
     public boolean isEnabled(){
         WorkProConfig config = WorkProConfig.getInstance();
-        return config.isEnable();
+        return config.enable();
     }
 }

+ 7 - 2
tip-api/src/main/java/com/minto/app/organization/workpro/config/WorkProConfig.java

@@ -15,6 +15,8 @@ import org.apache.commons.lang3.StringUtils;
 public class WorkProConfig{
     private static WorkProConfig INSTANCE = null;
 
+    private boolean enable;
+
     private String url;
 
     private String appid;
@@ -39,6 +41,8 @@ public class WorkProConfig{
                 if(INSTANCE == null){
                     INSTANCE = new WorkProConfig();
                     SystemProperties instance = SystemProperties.getInstance();
+                    INSTANCE.setEnable(
+                            Boolean.TRUE.toString().equalsIgnoreCase(instance.getProperty("workpro.enable")));
                     INSTANCE.setUrl(instance.getProperty("workpro.url"));
                     INSTANCE.setAppid(instance.getProperty("workpro.appid"));
                     INSTANCE.setAppSecret(instance.getProperty("workpro.appSecret"));
@@ -52,8 +56,9 @@ public class WorkProConfig{
         return INSTANCE;
     }
 
-    public boolean isEnable(){
-        return StringUtils.isNoneEmpty(this.url, this.appid, this.appSecret, this.userId, this.account, this.password);
+    public boolean enable(){
+        return this.enable && StringUtils.isNoneEmpty(this.url, this.appid, this.appSecret, this.userId, this.account,
+                this.password);
     }
 
 }

+ 3 - 3
tip-api/src/main/java/com/minto/app/organization/workpro/service/impl/WorkProServiceImpl.java

@@ -61,7 +61,7 @@ public class WorkProServiceImpl implements IWorkProService{
     @Override
     public <P, R> void callApi(IWorkProImApi<P, R> api, String uid) throws BusinessException{
         WorkProConfig workProConfig = WorkProConfig.getInstance();
-        if(!workProConfig.isEnable()){
+        if(!workProConfig.enable()){
             throw new BusinessException("workPro IM 配置错误!");
         }
         if(api == null){
@@ -80,7 +80,7 @@ public class WorkProServiceImpl implements IWorkProService{
     @Override
     public void syncSystem(Long accountId){
         WorkProConfig workProConfig = WorkProConfig.getInstance();
-        if(!workProConfig.isEnable()){
+        if(!workProConfig.enable()){
             throw new BusinessException("workPro IM 配置错误");
         }
         OrgUnitBean org = orgManager.findAccountById(accountId);
@@ -379,7 +379,7 @@ public class WorkProServiceImpl implements IWorkProService{
         // 获取工作平台配置实例
         WorkProConfig workProConfig = WorkProConfig.getInstance();
         // 检查工作平台配置是否启用,如果未启用,则记录错误并返回null
-        if(!workProConfig.isEnable()){
+        if(!workProConfig.enable()){
             log.error("workPro IM 配置错误!");
             return null;
         }