From 57a3bf84f31622de3b52d53459d652dd025f455c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=AF=BA?= <1253070437@qq.com> Date: Sat, 1 Oct 2022 15:18:49 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E5=A4=8D=E3=80=91=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dissues=E4=B8=AD=E5=8D=95=E9=A1=B5=E7=AE=A1=E7=90=86-?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8D=95=E9=A1=B5=E6=8A=A5=E9=94=99=EF=BC=88?= =?UTF-8?q?https://gitee.com/xiaonuobase/snowy/issues/I5TZ60=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/sys/resource/spa/form.vue | 6 +-- .../resource/param/spa/SysSpaAddParam.java | 3 -- .../resource/param/spa/SysSpaEditParam.java | 3 -- .../service/impl/SysSpaServiceImpl.java | 43 +++++++++++++++++++ 4 files changed, 45 insertions(+), 10 deletions(-) diff --git a/snowy-admin-web/src/views/sys/resource/spa/form.vue b/snowy-admin-web/src/views/sys/resource/spa/form.vue index 34edfb01..fa471f9d 100644 --- a/snowy-admin-web/src/views/sys/resource/spa/form.vue +++ b/snowy-admin-web/src/views/sys/resource/spa/form.vue @@ -149,14 +149,12 @@ const param = parameterChanges(formData.value) submitLoading.value = true spaApi.submitForm(param, !param.id).then(() => { - submitLoading.value = false visible = false emit('successful') + }).finally(() => { + submitLoading.value = false }) }) - .catch(() => { - submitLoading.value = false - }) } const parameterChanges = (data) => { if (!data.component) { diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaAddParam.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaAddParam.java index 03d34f1e..6a3a5037 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaAddParam.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaAddParam.java @@ -41,7 +41,6 @@ public class SysSpaAddParam { /** 别名 */ @ApiModelProperty(value = "别名", required = true, position = 3) - @NotBlank(message = "name不能为空") private String name; /** 路径 */ @@ -51,12 +50,10 @@ public class SysSpaAddParam { /** 组件 */ @ApiModelProperty(value = "组件", required = true, position = 5) - @NotBlank(message = "component不能为空") private String component; /** 图标 */ @ApiModelProperty(value = "图标", required = true, position = 6) - @NotBlank(message = "icon不能为空") private String icon; /** 排序码 */ diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaEditParam.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaEditParam.java index d2473718..a8ae4d6e 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaEditParam.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaEditParam.java @@ -46,7 +46,6 @@ public class SysSpaEditParam { /** 别名 */ @ApiModelProperty(value = "别名", required = true, position = 4) - @NotBlank(message = "name不能为空") private String name; /** 路径 */ @@ -56,12 +55,10 @@ public class SysSpaEditParam { /** 组件 */ @ApiModelProperty(value = "组件", required = true, position = 6) - @NotBlank(message = "component不能为空") private String component; /** 图标 */ @ApiModelProperty(value = "图标", required = true, position = 7) - @NotBlank(message = "icon不能为空") private String icon; /** 排序码 */ diff --git a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/service/impl/SysSpaServiceImpl.java b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/service/impl/SysSpaServiceImpl.java index 9b45b934..ed65f239 100644 --- a/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/service/impl/SysSpaServiceImpl.java +++ b/snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/service/impl/SysSpaServiceImpl.java @@ -28,6 +28,7 @@ import vip.xiaonuo.common.page.CommonPageRequest; import vip.xiaonuo.sys.core.enums.SysBuildInEnum; import vip.xiaonuo.sys.modular.resource.entity.SysSpa; import vip.xiaonuo.sys.modular.resource.enums.SysResourceCategoryEnum; +import vip.xiaonuo.sys.modular.resource.enums.SysResourceMenuTypeEnum; import vip.xiaonuo.sys.modular.resource.mapper.SysSpaMapper; import vip.xiaonuo.sys.modular.resource.param.spa.SysSpaAddParam; import vip.xiaonuo.sys.modular.resource.param.spa.SysSpaEditParam; @@ -66,6 +67,7 @@ public class SysSpaServiceImpl extends ServiceImpl impleme @Override public void add(SysSpaAddParam sysSpaAddParam) { + checkParam(sysSpaAddParam); SysSpa sysSpa = BeanUtil.toBean(sysSpaAddParam, SysSpa.class); boolean repeatTitle = this.count(new LambdaQueryWrapper().eq(SysSpa::getCategory, SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle())) > 0; @@ -77,9 +79,30 @@ public class SysSpaServiceImpl extends ServiceImpl impleme this.save(sysSpa); } + @SuppressWarnings("all") + private void checkParam(SysSpaAddParam sysSpaAddParam) { + SysResourceMenuTypeEnum.validate(sysSpaAddParam.getMenuType()); + if(SysResourceMenuTypeEnum.MENU.getValue().equals(sysSpaAddParam.getMenuType())) { + if(ObjectUtil.isEmpty(sysSpaAddParam.getName())) { + throw new CommonException("name不能为空"); + } + if(ObjectUtil.isEmpty(sysSpaAddParam.getComponent())) { + throw new CommonException("component不能为空"); + } + } else if(SysResourceMenuTypeEnum.IFRAME.getValue().equals(sysSpaAddParam.getMenuType()) || + SysResourceMenuTypeEnum.LINK.getValue().equals(sysSpaAddParam.getMenuType())) { + sysSpaAddParam.setName(RandomUtil.randomNumbers(10)); + sysSpaAddParam.setComponent(null); + } else { + sysSpaAddParam.setName(null); + sysSpaAddParam.setComponent(null); + } + } + @Override public void edit(SysSpaEditParam sysSpaEditParam) { SysSpa sysSpa = this.queryEntity(sysSpaEditParam.getId()); + checkParam(sysSpaEditParam); BeanUtil.copyProperties(sysSpaEditParam, sysSpa); boolean repeatTitle = this.count(new LambdaQueryWrapper().eq(SysSpa::getCategory, SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle()) @@ -90,6 +113,26 @@ public class SysSpaServiceImpl extends ServiceImpl impleme this.updateById(sysSpa); } + @SuppressWarnings("all") + private void checkParam(SysSpaEditParam sysSpaEditParam) { + SysResourceMenuTypeEnum.validate(sysSpaEditParam.getMenuType()); + if(SysResourceMenuTypeEnum.MENU.getValue().equals(sysSpaEditParam.getMenuType())) { + if(ObjectUtil.isEmpty(sysSpaEditParam.getName())) { + throw new CommonException("name不能为空"); + } + if(ObjectUtil.isEmpty(sysSpaEditParam.getComponent())) { + throw new CommonException("component不能为空"); + } + } else if(SysResourceMenuTypeEnum.IFRAME.getValue().equals(sysSpaEditParam.getMenuType()) || + SysResourceMenuTypeEnum.LINK.getValue().equals(sysSpaEditParam.getMenuType())) { + sysSpaEditParam.setName(RandomUtil.randomNumbers(10)); + sysSpaEditParam.setComponent(null); + } else { + sysSpaEditParam.setName(null); + sysSpaEditParam.setComponent(null); + } + } + @Override public void delete(List sysSpaIdParamList) { List sysSpaIdList = CollStreamUtil.toList(sysSpaIdParamList, SysSpaIdParam::getId);