mirror of
https://github.com/dataease/dataease.git
synced 2025-02-24 03:22:56 +08:00
refactor(图表): 区域重名校验
This commit is contained in:
parent
1e87669902
commit
49966ab59e
@ -7,6 +7,7 @@ import io.dataease.api.map.vo.CustomGeoArea;
|
||||
import io.dataease.api.map.vo.CustomGeoSubArea;
|
||||
import io.dataease.constant.StaticResourceConstants;
|
||||
import io.dataease.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.map.bo.AreaBO;
|
||||
import io.dataease.map.dao.auto.entity.Area;
|
||||
import io.dataease.map.dao.auto.entity.CoreCustomGeoArea;
|
||||
@ -210,6 +211,16 @@ public class MapManage {
|
||||
public void saveCustomGeoArea(CustomGeoArea geoArea) {
|
||||
var coreCustomGeoArea = new CoreCustomGeoArea();
|
||||
BeanUtils.copyBean(coreCustomGeoArea, geoArea);
|
||||
var q = new QueryWrapper<CoreCustomGeoArea>();
|
||||
q.eq("name", geoArea.getName());
|
||||
if (StringUtils.isNotBlank(coreCustomGeoArea.getId())) {
|
||||
q.ne("id", coreCustomGeoArea.getId());
|
||||
}
|
||||
var list = coreCustomGeoAreaMapper.selectList(q);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
DEException.throwException(Translator.get("i18n_geo_exists"));
|
||||
return;
|
||||
}
|
||||
if (ObjectUtils.isEmpty(coreCustomGeoArea.getId())) {
|
||||
coreCustomGeoArea.setId("custom_" + IDUtils.snowID());
|
||||
coreCustomGeoAreaMapper.insert(coreCustomGeoArea);
|
||||
@ -227,6 +238,17 @@ public class MapManage {
|
||||
public void saveCustomGeoSubArea(CustomGeoSubArea customGeoSubArea) {
|
||||
var geoSubArea = new CoreCustomGeoSubArea();
|
||||
BeanUtils.copyBean(geoSubArea, customGeoSubArea);
|
||||
var q = new QueryWrapper<CoreCustomGeoSubArea>();
|
||||
q.eq("name", customGeoSubArea.getName());
|
||||
q.eq("geo_area_id", customGeoSubArea.getGeoAreaId());
|
||||
if (ObjectUtils.isNotEmpty(customGeoSubArea.getId())) {
|
||||
q.ne("id", customGeoSubArea.getId());
|
||||
}
|
||||
var list = coreCustomGeoSubAreaMapper.selectList(q);
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
DEException.throwException(Translator.get("i18n_geo_sub_exists"));
|
||||
return;
|
||||
}
|
||||
if (ObjectUtils.isEmpty(geoSubArea.getId())) {
|
||||
geoSubArea.setId(IDUtils.snowID());
|
||||
coreCustomGeoSubAreaMapper.insert(geoSubArea);
|
||||
|
@ -195,3 +195,6 @@ i18n_invalid_connection=Invalid connection.
|
||||
i18n_check_datasource_connection=Please check the validity of the datasource.
|
||||
|
||||
i18n_datasource_not_exists=Datasource not exists!
|
||||
|
||||
i18n_geo_exists=An area with the same name already exists\uFF01
|
||||
i18n_geo_sub_exists=A sub-area with the same name already exists\uFF01
|
||||
|
@ -195,3 +195,5 @@ i18n_check_datasource_connection=\u8BF7\u68C0\u67E5\u6570\u636E\u6E90\u7684\u670
|
||||
|
||||
i18n_datasource_not_exists=\u6570\u636E\u6E90\u4E0D\u5B58\u5728\uFF01
|
||||
|
||||
i18n_geo_exists=\u5DF2\u5B58\u5728\u540C\u540D\u533A\u57DF\uFF01
|
||||
i18n_geo_sub_exists=\u5DF2\u5B58\u5728\u540C\u540D\u5B50\u533A\u57DF\uFF01
|
@ -194,3 +194,6 @@ i18n_invalid_connection=\u9023\u63A5\u7121\u6548,
|
||||
i18n_check_datasource_connection=\u8ACB\u6AA2\u67E5\u6578\u64DA\u6E90\u7684\u6709\u6548\u6027
|
||||
|
||||
i18n_datasource_not_exists=\u6578\u64DA\u6E90\u4E0D\u5B58\u5728\uFF01
|
||||
|
||||
i18n_geo_exists=\u5DF2\u5B58\u5728\u540C\u540D\u5340\u57DF\uFF01
|
||||
i18n_geo_sub_exists=\u5DF2\u5B58\u5728\u540C\u540D\u5B50\u5340\u57DF\uFF01
|
@ -399,7 +399,11 @@ const areaFormRef = ref()
|
||||
const saveGeoArea = async () => {
|
||||
areaFormRef.value?.validate(async valid => {
|
||||
if (valid) {
|
||||
await saveCustomGeoArea(editedCustomArea)
|
||||
const res = await saveCustomGeoArea(editedCustomArea)
|
||||
if (res.code) {
|
||||
ElMessage.error(res.msg)
|
||||
return
|
||||
}
|
||||
await loadCustomGeoArea()
|
||||
customAreaDialog.value = false
|
||||
}
|
||||
@ -547,7 +551,11 @@ const saveGeoSubArea = async () => {
|
||||
return
|
||||
}
|
||||
customSubArea.scope = customSubArea.scopeArr.join(',')
|
||||
await saveCustomGeoSubArea(customSubArea)
|
||||
const res = await saveCustomGeoSubArea(customSubArea)
|
||||
if (res.code) {
|
||||
ElMessage.error(res.msg)
|
||||
return
|
||||
}
|
||||
await loadCustomSubArea({ id: curCustomGeoArea.id }, true)
|
||||
customSubAreaDialog.value = false
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user