update 优化以逗号拼接元素

This commit is contained in:
AprilWind
2025-08-06 11:43:37 +08:00
parent 0c1e39ea14
commit 5d69832423
5 changed files with 16 additions and 26 deletions

View File

@ -37,7 +37,7 @@ public class SysTenantPackageBo extends BaseEntity {
/**
* 关联菜单id
*/
@AutoMapping(target = "menuIds", expression = "java(org.dromara.common.core.utils.StringUtils.join(source.getMenuIds(), \",\"))")
@AutoMapping(target = "menuIds", expression = "java(org.dromara.common.core.utils.StringUtils.joinComma(source.getMenuIds()))")
private Long[] menuIds;
/**

View File

@ -88,11 +88,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
SysTenantPackage add = MapstructUtils.convert(bo, SysTenantPackage.class);
// 保存菜单id
List<Long> menuIds = Arrays.asList(bo.getMenuIds());
if (CollUtil.isNotEmpty(menuIds)) {
add.setMenuIds(StringUtils.join(menuIds, ", "));
} else {
add.setMenuIds("");
}
add.setMenuIds(CollUtil.isNotEmpty(menuIds) ? StringUtils.joinComma(menuIds) : "");
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setPackageId(add.getPackageId());
@ -109,11 +105,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
SysTenantPackage update = MapstructUtils.convert(bo, SysTenantPackage.class);
// 保存菜单id
List<Long> menuIds = Arrays.asList(bo.getMenuIds());
if (CollUtil.isNotEmpty(menuIds)) {
update.setMenuIds(StringUtils.join(menuIds, ", "));
} else {
update.setMenuIds("");
}
update.setMenuIds(CollUtil.isNotEmpty(menuIds) ? StringUtils.joinComma(menuIds) : "");
return baseMapper.updateById(update) > 0;
}