Browse Source

!41 【修复】修复issues中单页管理-新增单页报错(https://gitee.com/xiaonuobase/snowy/issues/I5TZ60

Merge pull request !41 from 小诺/dev
pull/42/head
小诺 2 years ago committed by Gitee
parent
commit
e04a242459
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
  1. 6
      snowy-admin-web/src/views/sys/resource/spa/form.vue
  2. 3
      snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaAddParam.java
  3. 3
      snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/param/spa/SysSpaEditParam.java
  4. 43
      snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/resource/service/impl/SysSpaServiceImpl.java

6
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) {

3
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;
/** 排序码 */

3
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;
/** 排序码 */

43
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<SysSpaMapper, SysSpa> impleme
@Override
public void add(SysSpaAddParam sysSpaAddParam) {
checkParam(sysSpaAddParam);
SysSpa sysSpa = BeanUtil.toBean(sysSpaAddParam, SysSpa.class);
boolean repeatTitle = this.count(new LambdaQueryWrapper<SysSpa>().eq(SysSpa::getCategory,
SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle())) > 0;
@ -77,9 +79,30 @@ public class SysSpaServiceImpl extends ServiceImpl<SysSpaMapper, SysSpa> 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<SysSpa>().eq(SysSpa::getCategory,
SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle())
@ -90,6 +113,26 @@ public class SysSpaServiceImpl extends ServiceImpl<SysSpaMapper, SysSpa> 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<SysSpaIdParam> sysSpaIdParamList) {
List<String> sysSpaIdList = CollStreamUtil.toList(sysSpaIdParamList, SysSpaIdParam::getId);

Loading…
Cancel
Save