提交 065bc20e 编写于 作者: sq3536's avatar sq3536

repair

上级 7f802de5
......@@ -5,6 +5,8 @@ import cn.ibizlab.core.lite.service.IDstDataSourceService;
import cn.ibizlab.core.lite.service.impl.DstDataSourceServiceImpl;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.dynamic.datasource.DynamicRoutingDataSource;
import com.baomidou.dynamic.datasource.creator.BasicDataSourceCreator;
import com.baomidou.dynamic.datasource.creator.DataSourceCreator;
import com.baomidou.dynamic.datasource.creator.DruidDataSourceCreator;
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
......@@ -43,26 +45,30 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
public DstDataSource buildDS(DstDataSource dstDataSource) {
if(!(StringUtils.isEmpty(dstDataSource.getDsCfg())))
{
synchronized (lock)
{
DataSourceProperty dataSourceProperty = new DataSourceProperty();
DynamicRoutingDataSource ds = dataSource;
List<Setting> settings= JSONArray.parseArray(dstDataSource.getDsCfg(),Setting.class);
for(Setting setting:settings)
List<Setting> settings = JSONArray.parseArray(dstDataSource.getDsCfg(), Setting.class);
for (Setting setting : settings)
{
if(setting.getProperty().equalsIgnoreCase("driver-class-name"))
if (setting.getProperty().equalsIgnoreCase("driver-class-name"))
dataSourceProperty.setDriverClassName(setting.getValue());
else if(setting.getProperty().equalsIgnoreCase("username"))
else if (setting.getProperty().equalsIgnoreCase("username"))
dataSourceProperty.setUsername(setting.getValue());
else if(setting.getProperty().equalsIgnoreCase("password"))
else if (setting.getProperty().equalsIgnoreCase("password"))
dataSourceProperty.setPassword(setting.getValue());
else if(setting.getProperty().equalsIgnoreCase("url"))
else if (setting.getProperty().equalsIgnoreCase("url"))
dataSourceProperty.setUrl(setting.getValue());
else if(setting.getProperty().equalsIgnoreCase("defaultSchema"))
else if (setting.getProperty().equalsIgnoreCase("defaultSchema"))
dataSourceProperty.setSchema(setting.getValue());
}
DataSource dataSource = druidDataSourceCreator.createDataSource(dataSourceProperty);
DataSource dataSource = BasicDataSourceCreator.getInstance().createDataSource(dataSourceProperty);
ds.addDataSource(dstDataSource.getDsName(), dataSource);
check.put(dstDataSource.getDsName(), 1);
}
}
return super.buildDS(dstDataSource);
......@@ -77,29 +83,47 @@ public class DstDataSourceExService extends DstDataSourceServiceImpl {
private DruidDataSourceCreator druidDataSourceCreator;
private HashMap<String,Integer> check=new HashMap<>();
private Object lock=new Object();
public void initDataSource(String dsName)
{
// if(dataSource.getDataSource(dsName)==null)
synchronized (lock)
{
if (check.containsKey(dsName))
return;
}
DstDataSource dstDataSource=this.getOne(Wrappers.<DstDataSource>lambdaQuery().eq(DstDataSource::getDsId,dsName).or().eq(DstDataSource::getDsName,dsName),false);
if(dstDataSource!=null)
{
dstDataSource.setDsName(dsName);
buildDS(dstDataSource);
}
}
}
@Override
public boolean update(DstDataSource et) {
if(!super.update(et))
return false;
synchronized (lock)
{
DynamicRoutingDataSource ds = (DynamicRoutingDataSource) dataSource;
if(ds.getDataSource(et.getDsId())!=null)
if (check.containsKey(et.getDsId()))
{
ds.removeDataSource(et.getDsId());
if(ds.getDataSource(et.getDsName())!=null)
check.remove(et.getDsId());
}
if (check.containsKey(et.getDsName()))
{
ds.removeDataSource(et.getDsName());
check.remove(et.getDsName());
}
}
buildDS(et);
return true;
}
}
......
......@@ -37,7 +37,8 @@ public class DataObj<K,V> extends ConcurrentHashMap<K,V> {
public <T> T set(String key, V value)
{
return (T)this.put((K)key.toUpperCase(),value);
this.put((K)key.toUpperCase(),value);
return (T)this;
}
@Override
......
......@@ -99,6 +99,11 @@ public class EntityObj extends DataObj<String,Object> {
return this.set("_DSTSYSTEMID",dstSystemId);
}
@Override
public EntityObj set(String key, Object value)
{
return super.set(key,value);
}
@JsonIgnore
@JSONField(serialize = false)
......
......@@ -46,7 +46,7 @@ public class ModelObj extends DataObj<String,Object> {
@JsonIgnore
@JSONField(serialize = false)
public EntityObj setDataModelId(String dataModelId)
public ModelObj setDataModelId(String dataModelId)
{
return this.set("_DATAMODELID",dataModelId);
}
......@@ -144,7 +144,11 @@ public class ModelObj extends DataObj<String,Object> {
DataModel model=this.getDataModel().getNestedDataModel(name);
if(model!=null)
return new NestedArray().setParent(this);
{
NestedArray array = new NestedArray().setParent(this);
this.set(model.getDataModelName(),array);
return array;
}
if(recursion)
{
......@@ -158,6 +162,7 @@ public class ModelObj extends DataObj<String,Object> {
tmpModel=model.getParentDataModel();
steps.add(0,tmpModel.getDataModelName());
}
steps.add(model.getDataModelName());
if(steps.size()>1)
{
......@@ -198,6 +203,12 @@ public class ModelObj extends DataObj<String,Object> {
return super.get(key);
}
@Override
public ModelObj set(String key, Object value)
{
return super.set(key,value);
}
@Override
public String getRowKey()
{
......
......@@ -138,7 +138,6 @@ public class Property {
{
if(!StringUtils.isEmpty(cond))
cond += ",";
else
cond += val;
}
......
......@@ -100,8 +100,8 @@ public class DbEntityService extends ServiceImpl<DbEntityMapper, EntityObj> impl
FieldModel lastModifyField=entityModel.getLastModifyField();
QueryFilter filter=new QueryFilter();
//if(lastModifyField!=null)
// filter.ge(lastModifyField.getColumnName(), lastModify);
if(lastModifyField!=null)
filter.ge(lastModifyField.getColumnName(), lastModify);
List<EntityObj> kEntityObjs=this.selectCore(entityModel, filter);
......
......@@ -3,7 +3,7 @@
<mapper namespace="cn.ibizlab.core.extensions.mapper.DbEntityMapper">
<!--数据集合[Default]-->
<select id="searchDefault" parameterType="cn.ibizlab.core.lite.extensions.filter.DbEntitySearchContext" resultType="cn.ibizlab.core.lite.extensions.domain.EntityObj">
<select id="search" parameterType="cn.ibizlab.core.lite.extensions.filter.DbEntitySearchContext" resultType="cn.ibizlab.core.lite.extensions.domain.EntityObj">
${sql}
<where><if test="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
<if test="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
......
......@@ -56,7 +56,9 @@ public class LiteCoreResource {
if(StringUtils.isEmpty(modelid))
modelid="dataModelff8080816a8b510c016a8c2f18b10001";
return ResponseEntity.ok(dbEntityService.getModelObjs(modelid, DataObject.getBeginDate()));
List<ModelObj> list=dbEntityService.getModelObjs(modelid, DataObject.getBeginDate());
return ResponseEntity.ok(list);
}
@RequestMapping(method = RequestMethod.GET, value = "/lite/{system}/entitys")
......
......@@ -130,7 +130,7 @@ public class QueryFilter {
public QueryFilter cust(String custSqlSegment)
{
this.custSqlSegment=custSqlSegment;
return null;
return this;
}
@JsonIgnore
@Transient
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册