From e285257f242fd5d8533a18c986f2b8150e4334e7 Mon Sep 17 00:00:00 2001 From: panlinlin <648540858@qq.com> Date: Sun, 28 Jul 2024 07:36:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/RegionServiceImpl.java | 10 +++++++- web_src/src/components/common/RegionTree.vue | 2 +- web_src/src/components/region.vue | 23 +++++++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java index 1654bebd..318a1c9c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/RegionServiceImpl.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.gb28181.service.impl; import com.genersoft.iot.vmp.common.CivilCodePo; +import com.genersoft.iot.vmp.conf.exception.ControllerException; import com.genersoft.iot.vmp.gb28181.bean.Region; import com.genersoft.iot.vmp.gb28181.bean.RegionTree; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; @@ -9,9 +10,11 @@ import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.service.IRegionService; import com.genersoft.iot.vmp.utils.CivilCodeUtil; import com.genersoft.iot.vmp.utils.DateUtil; +import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.dao.DuplicateKeyException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; @@ -45,7 +48,12 @@ public class RegionServiceImpl implements IRegionService { } region.setCreateTime(DateUtil.getNow()); region.setUpdateTime(DateUtil.getNow()); - regionMapper.add(region); + try { + regionMapper.add(region); + }catch (DuplicateKeyException e){ + throw new ControllerException(ErrorCode.ERROR100.getCode(), "此行政区划已存在"); + } + } @Override diff --git a/web_src/src/components/common/RegionTree.vue b/web_src/src/components/common/RegionTree.vue index 44e448b2..4880038e 100755 --- a/web_src/src/components/common/RegionTree.vue +++ b/web_src/src/components/common/RegionTree.vue @@ -1,6 +1,6 @@