Commit 17a55781 by 陶光胜

配置表

parent df5cc949
......@@ -226,6 +226,11 @@
<artifactId>gic-member-filter-api</artifactId>
<version>${gic-member-filter-api}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-dubbo-extension</artifactId>
<version>4.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
......
......@@ -2,6 +2,8 @@ package com.gic.enterprise.service.outer.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ctrip.framework.apollo.Config;
import com.ctrip.framework.apollo.ConfigService;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.ToolUtil;
......@@ -11,6 +13,8 @@ import com.gic.dsmongo.api.dto.MongoQueryDTO;
import com.gic.dsmongo.api.dto.MongoSaveDTO;
import com.gic.dsmongo.api.dto.MongoUpdateDTO;
import com.gic.dsmongo.api.service.MongoOperApiService;
import com.gic.dubbo.util.DubboContextUtil;
import com.gic.dubbo.util.DubboInvokeUtil;
import com.gic.enterprise.constant.FieldTypeEnum;
import com.gic.enterprise.dto.TableSettingDTO;
import com.gic.enterprise.dto.TableSettingFieldDTO;
......@@ -23,6 +27,7 @@ import com.gic.enterprise.service.TableSettingService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.rpc.service.GenericService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -91,6 +96,10 @@ public class CustomSettingApiServiceImpl implements CustomSettingApiService {
ServiceResponse<Integer> update = mongoOperApiService.update(mongoUpdateDTO);
log.info("update:{},{}", JSON.toJSONString(map), JSON.toJSONString(update));
if(update.isSuccess()){
String saveExtInterface = tableSetting.getSaveExtInterface();
if(StringUtils.isNotBlank(saveExtInterface)){
extendInterface(saveExtInterface, params);
}
return ServiceResponse.success();
} else {
return ServiceResponse.failure(update.getCode(), update.getMessage());
......@@ -106,6 +115,10 @@ public class CustomSettingApiServiceImpl implements CustomSettingApiService {
ServiceResponse<String> save = mongoOperApiService.save(mongoSaveDTO);
log.info("save:{}", JSON.toJSONString(save));
if(save.isSuccess()){
String saveExtInterface = tableSetting.getSaveExtInterface();
if(StringUtils.isNotBlank(saveExtInterface)){
extendInterface(saveExtInterface, params);
}
return ServiceResponse.success();
} else {
return ServiceResponse.failure(save.getCode(), save.getMessage());
......@@ -113,6 +126,7 @@ public class CustomSettingApiServiceImpl implements CustomSettingApiService {
}
}
@Override
public ServiceResponse<Map<String, Object>> getDetail(String tableName, String searchParams) {
Map<String, Object> map = JSON.parseObject(searchParams, Map.class);
......@@ -169,6 +183,12 @@ public class CustomSettingApiServiceImpl implements CustomSettingApiService {
mongoUpdateDTO.setDataBaseAndCollectionName(DATABASENAME, tableName, PRIMARYKEY);
mongoUpdateDTO.setData(map);
ServiceResponse<Integer> update = mongoOperApiService.update(mongoUpdateDTO);
if(update.isSuccess()){
TabTableSetting tableSetting = tableSettingService.getTableSetting(tableName);
if(StringUtils.isNotBlank(tableSetting.getDelExtInterface())){
extendInterface(tableSetting.getDelExtInterface(), JSON.toJSONString(map));
}
}
return update;
}
......@@ -207,4 +227,17 @@ public class CustomSettingApiServiceImpl implements CustomSettingApiService {
criteriaList.add(criteria);
return criteriaList;
}
private void extendInterface(String extInterface, String param){
Config config = ConfigService.getConfig("COMMON.4.0-dubbo");
String zookeeperHost = config.getProperty("zookeeper_host", "");
String host = zookeeperHost.substring(zookeeperHost.indexOf("//")+2, zookeeperHost.lastIndexOf(":"));
String port = zookeeperHost.substring(zookeeperHost.lastIndexOf(":")+1);
String service = extInterface.substring(0, extInterface.lastIndexOf("."));
String method = extInterface.substring(extInterface.lastIndexOf(".")+1);
DubboContextUtil.initRegistryConfig(host, Integer.valueOf(port));
GenericService genericService = DubboInvokeUtil.getGenericService(service);
Object o = genericService.$invoke(method, new String[]{String.class.getName()}, new String[]{param});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment