提交 edfb0170 authored 作者: taojinlong's avatar taojinlong

fix: 冲突

...@@ -18,6 +18,7 @@ import io.dataease.datasource.provider.ProviderFactory; ...@@ -18,6 +18,7 @@ import io.dataease.datasource.provider.ProviderFactory;
import io.dataease.datasource.request.DatasourceRequest; import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.dto.DatasourceDTO; import io.dataease.dto.DatasourceDTO;
import io.dataease.dto.dataset.DataTableInfoDTO; import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.i18n.Translator;
import io.dataease.service.dataset.DataSetGroupService; import io.dataease.service.dataset.DataSetGroupService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -46,11 +47,7 @@ public class DatasourceService { ...@@ -46,11 +47,7 @@ public class DatasourceService {
private CommonThreadPool commonThreadPool; private CommonThreadPool commonThreadPool;
public Datasource addDatasource(Datasource datasource) { public Datasource addDatasource(Datasource datasource) {
DatasourceExample example = new DatasourceExample(); checkName(datasource);
example.createCriteria().andNameEqualTo(datasource.getName());
if (CollectionUtils.isNotEmpty(datasourceMapper.selectByExample(example))) {
DEException.throwException("Exist data connection with the same name ");
}
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();
datasource.setId(UUID.randomUUID().toString()); datasource.setId(UUID.randomUUID().toString());
datasource.setUpdateTime(currentTimeMillis); datasource.setUpdateTime(currentTimeMillis);
...@@ -67,7 +64,7 @@ public class DatasourceService { ...@@ -67,7 +64,7 @@ public class DatasourceService {
public List<DatasourceDTO> gridQuery(BaseGridRequest request) { public List<DatasourceDTO> gridQuery(BaseGridRequest request) {
//如果没有查询条件增加一个默认的条件 //如果没有查询条件增加一个默认的条件
if(CollectionUtils.isEmpty(request.getConditions())){ if (CollectionUtils.isEmpty(request.getConditions())) {
ConditionEntity conditionEntity = new ConditionEntity(); ConditionEntity conditionEntity = new ConditionEntity();
conditionEntity.setField("1"); conditionEntity.setField("1");
conditionEntity.setOperator("eq"); conditionEntity.setOperator("eq");
...@@ -84,6 +81,7 @@ public class DatasourceService { ...@@ -84,6 +81,7 @@ public class DatasourceService {
} }
public void updateDatasource(Datasource datasource) { public void updateDatasource(Datasource datasource) {
checkName(datasource);
datasource.setCreateTime(null); datasource.setCreateTime(null);
datasource.setUpdateTime(System.currentTimeMillis()); datasource.setUpdateTime(System.currentTimeMillis());
datasourceMapper.updateByPrimaryKeySelective(datasource); datasourceMapper.updateByPrimaryKeySelective(datasource);
...@@ -135,11 +133,11 @@ public class DatasourceService { ...@@ -135,11 +133,11 @@ public class DatasourceService {
return datasourceMapper.selectByPrimaryKey(id); return datasourceMapper.selectByPrimaryKey(id);
} }
public void initAllDataSourceConnectionPool(){ public void initAllDataSourceConnectionPool() {
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample()); List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
datasources.forEach(datasource -> { datasources.forEach(datasource -> {
try { try {
commonThreadPool.addTask(() ->{ commonThreadPool.addTask(() -> {
try { try {
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType()); DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest(); DatasourceRequest datasourceRequest = new DatasourceRequest();
...@@ -150,9 +148,21 @@ public class DatasourceService { ...@@ -150,9 +148,21 @@ public class DatasourceService {
LogUtil.error("Failed to init datasource connection pool: " + datasource.getName(), e); LogUtil.error("Failed to init datasource connection pool: " + datasource.getName(), e);
} }
}); });
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}); });
} }
private void checkName(Datasource datasource) {
DatasourceExample example = new DatasourceExample();
DatasourceExample.Criteria criteria = example.createCriteria();
criteria.andNameEqualTo(datasource.getName());
if (StringUtils.isNotEmpty(datasource.getId())) {
criteria.andIdNotEqualTo(datasource.getId());
}
if (CollectionUtils.isNotEmpty(datasourceMapper.selectByExample(example))) {
DEException.throwException(Translator.get("i18n_ds_name_exists"));
}
}
} }
...@@ -241,4 +241,5 @@ i18n_union_field_exists=The same field can't in two dataset ...@@ -241,4 +241,5 @@ i18n_union_field_exists=The same field can't in two dataset
i18n_cron_time_error=Start time can't greater then end time i18n_cron_time_error=Start time can't greater then end time
i18n_auth_source_be_canceled=This Auth Resource Already Be Canceled i18n_auth_source_be_canceled=This Auth Resource Already Be Canceled
i18n_username_exists=ID is already exists i18n_username_exists=ID is already exists
i18n_ds_name_exists=Datasource name exists
...@@ -243,3 +243,4 @@ i18n_union_field_exists=两个数据集之间关联不能出现多次相同字 ...@@ -243,3 +243,4 @@ i18n_union_field_exists=两个数据集之间关联不能出现多次相同字
i18n_cron_time_error=开始时间不能大于结束时间 i18n_cron_time_error=开始时间不能大于结束时间
i18n_auth_source_be_canceled=当前资源授权权限已经被取消 i18n_auth_source_be_canceled=当前资源授权权限已经被取消
i18n_username_exists=用户ID已存在 i18n_username_exists=用户ID已存在
i18n_ds_name_exists=数据源名称已存在
...@@ -243,3 +243,4 @@ i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字 ...@@ -243,3 +243,4 @@ i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字
i18n_cron_time_error=開始時間不能大於結束時間 i18n_cron_time_error=開始時間不能大於結束時間
i18n_auth_source_be_canceled=當前資源授權權限已經被取消 i18n_auth_source_be_canceled=當前資源授權權限已經被取消
i18n_username_exists=用戶ID已存在 i18n_username_exists=用戶ID已存在
i18n_ds_name_exists=數據源名稱已存在
...@@ -94,8 +94,10 @@ export default { ...@@ -94,8 +94,10 @@ export default {
this.$refs.dsForm.validate(valid => { this.$refs.dsForm.validate(valid => {
if (valid) { if (valid) {
const method = this.formType === 'add' ? addDs : editDs const method = this.formType === 'add' ? addDs : editDs
this.form.configuration = JSON.stringify(this.form.configuration) // this.form.configuration = JSON.stringify(this.form.configuration)
method(this.form).then(res => { const form = JSON.parse(JSON.stringify(this.form))
form.configuration = JSON.stringify(form.configuration)
method(form).then(res => {
this.$success(this.$t('commons.save_success')) this.$success(this.$t('commons.save_success'))
this.backToList() this.backToList()
}) })
......
...@@ -25,6 +25,24 @@ ...@@ -25,6 +25,24 @@
<div>{{ scope.row.dept && scope.row.dept.deptName }}</div> <div>{{ scope.row.dept && scope.row.dept.deptName }}</div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="roles" :label="$t('commons.role')">
<template slot-scope="scope">
<div v-if="scope.row.roles && scope.row.roles.length <= 2">
<div v-for="role in scope.row.roles" :key="role.roleId">{{ role.roleName }}</div>
</div>
<div v-if="scope.row.roles && scope.row.roles.length > 2">
<el-tooltip placement="top">
<div slot="content">
<div v-for="role in scope.row.roles" :key="role.roleId">{{ role.roleName }}</div>
</div>
<div>
<div v-for="(role,index) in scope.row.roles" v-if="index < 2" :key="role.roleId">{{ role.roleName }}</div>
<div>...</div>
</div>
</el-tooltip>
</div>
</template>
</el-table-column>
<el-table-column prop="status" :label="$t('commons.status')"> <el-table-column prop="status" :label="$t('commons.status')">
<template v-slot:default="scope"> <template v-slot:default="scope">
<el-switch v-model="scope.row.enabled" :active-value="1" :inactive-value="0" inactive-color="#DCDFE6" @change="changeSwitch(scope.row)" /> <el-switch v-model="scope.row.enabled" :active-value="1" :inactive-value="0" inactive-color="#DCDFE6" @change="changeSwitch(scope.row)" />
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论