fix: 冲突

This commit is contained in:
taojinlong 2021-05-28 12:51:26 +08:00
commit edfb017066
6 changed files with 44 additions and 11 deletions

View File

@ -18,6 +18,7 @@ import io.dataease.datasource.provider.ProviderFactory;
import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.dto.DatasourceDTO;
import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.i18n.Translator;
import io.dataease.service.dataset.DataSetGroupService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
@ -46,11 +47,7 @@ public class DatasourceService {
private CommonThreadPool commonThreadPool;
public Datasource addDatasource(Datasource datasource) {
DatasourceExample example = new DatasourceExample();
example.createCriteria().andNameEqualTo(datasource.getName());
if (CollectionUtils.isNotEmpty(datasourceMapper.selectByExample(example))) {
DEException.throwException("Exist data connection with the same name ");
}
checkName(datasource);
long currentTimeMillis = System.currentTimeMillis();
datasource.setId(UUID.randomUUID().toString());
datasource.setUpdateTime(currentTimeMillis);
@ -67,7 +64,7 @@ public class DatasourceService {
public List<DatasourceDTO> gridQuery(BaseGridRequest request) {
//如果没有查询条件增加一个默认的条件
if(CollectionUtils.isEmpty(request.getConditions())){
if (CollectionUtils.isEmpty(request.getConditions())) {
ConditionEntity conditionEntity = new ConditionEntity();
conditionEntity.setField("1");
conditionEntity.setOperator("eq");
@ -84,6 +81,7 @@ public class DatasourceService {
}
public void updateDatasource(Datasource datasource) {
checkName(datasource);
datasource.setCreateTime(null);
datasource.setUpdateTime(System.currentTimeMillis());
datasourceMapper.updateByPrimaryKeySelective(datasource);
@ -135,11 +133,11 @@ public class DatasourceService {
return datasourceMapper.selectByPrimaryKey(id);
}
public void initAllDataSourceConnectionPool(){
public void initAllDataSourceConnectionPool() {
List<Datasource> datasources = datasourceMapper.selectByExampleWithBLOBs(new DatasourceExample());
datasources.forEach(datasource -> {
try {
commonThreadPool.addTask(() ->{
commonThreadPool.addTask(() -> {
try {
DatasourceProvider datasourceProvider = ProviderFactory.getProvider(datasource.getType());
DatasourceRequest datasourceRequest = new DatasourceRequest();
@ -150,9 +148,21 @@ public class DatasourceService {
LogUtil.error("Failed to init datasource connection pool: " + datasource.getName(), e);
}
});
}catch (Exception e){
} catch (Exception e) {
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"));
}
}
}

View File

@ -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_auth_source_be_canceled=This Auth Resource Already Be Canceled
i18n_username_exists=ID is already exists
i18n_ds_name_exists=Datasource name exists

View File

@ -243,3 +243,4 @@ i18n_union_field_exists=两个数据集之间关联不能出现多次相同字
i18n_cron_time_error=开始时间不能大于结束时间
i18n_auth_source_be_canceled=当前资源授权权限已经被取消
i18n_username_exists=用户ID已存在
i18n_ds_name_exists=数据源名称已存在

View File

@ -243,3 +243,4 @@ i18n_union_field_exists=兩個數據集之間關聯不能出現多次相同字
i18n_cron_time_error=開始時間不能大於結束時間
i18n_auth_source_be_canceled=當前資源授權權限已經被取消
i18n_username_exists=用戶ID已存在
i18n_ds_name_exists=數據源名稱已存在

View File

@ -94,8 +94,10 @@ export default {
this.$refs.dsForm.validate(valid => {
if (valid) {
const method = this.formType === 'add' ? addDs : editDs
this.form.configuration = JSON.stringify(this.form.configuration)
method(this.form).then(res => {
// this.form.configuration = JSON.stringify(this.form.configuration)
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.backToList()
})

View File

@ -25,6 +25,24 @@
<div>{{ scope.row.dept && scope.row.dept.deptName }}</div>
</template>
</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')">
<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)" />