int 数组的值总和可能大于 int 的最大值,使用 long 类型的变量存储其结果。
parent
cc3c4be8de
commit
78cdded667
|
@ -86,18 +86,18 @@ public abstract class PlusoneJdbcDaoSupport {
|
||||||
return update(sql, new MapSqlParameterSource(paramName, value));
|
return update(sql, new MapSqlParameterSource(paramName, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final int batchUpdate(String sql, SqlParameterSource[] batchArgs) {
|
protected final long batchUpdate(String sql, SqlParameterSource[] batchArgs) {
|
||||||
int[] i = this.jdbc.batchUpdate(sql, batchArgs);
|
int[] i = this.jdbc.batchUpdate(sql, batchArgs);
|
||||||
return NumberUtil.sum(i);
|
return NumberUtil.sum(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final <T> int batchUpdate(String sql, Stream<T> c,
|
protected final <T> long batchUpdate(String sql, Stream<T> c,
|
||||||
@Nonnull Function<T, SqlParameterSource> paramSourceBuilder) {
|
@Nonnull Function<T, SqlParameterSource> paramSourceBuilder) {
|
||||||
int[] i = this.jdbc.batchUpdate(sql, buildSqlParameterSourceArray(c, paramSourceBuilder));
|
int[] i = this.jdbc.batchUpdate(sql, buildSqlParameterSourceArray(c, paramSourceBuilder));
|
||||||
return NumberUtil.sum(i);
|
return NumberUtil.sum(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final <T> int batchUpdate(String sql, Collection<T> c,
|
protected final <T> long batchUpdate(String sql, Collection<T> c,
|
||||||
@Nonnull Function<T, SqlParameterSource> paramSourceBuilder) {
|
@Nonnull Function<T, SqlParameterSource> paramSourceBuilder) {
|
||||||
int[] i = this.jdbc.batchUpdate(sql, buildSqlParameterSourceArray(c, paramSourceBuilder));
|
int[] i = this.jdbc.batchUpdate(sql, buildSqlParameterSourceArray(c, paramSourceBuilder));
|
||||||
return NumberUtil.sum(i);
|
return NumberUtil.sum(i);
|
||||||
|
|
|
@ -31,7 +31,7 @@ class AccountRoleRefDAO extends PlusoneJdbcDaoSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
void insertAccountRoleRefs(Long accountId, Set<Long> roleRefs) {
|
void insertAccountRoleRefs(Long accountId, Set<Long> roleRefs) {
|
||||||
int i = batchUpdate(
|
long i = batchUpdate(
|
||||||
"INSERT INTO sys_account_role (account_id, role_id) VALUES (:accountId, :roleId)",
|
"INSERT INTO sys_account_role (account_id, role_id) VALUES (:accountId, :roleId)",
|
||||||
roleRefs,
|
roleRefs,
|
||||||
(Long roleId) -> new MapSqlParameterSource()
|
(Long roleId) -> new MapSqlParameterSource()
|
||||||
|
|
|
@ -21,11 +21,11 @@ class DictValueDAO extends PlusoneJdbcDaoSupport {
|
||||||
void updateDictValues(Dict entity) {
|
void updateDictValues(Dict entity) {
|
||||||
update("DELETE FROM sys_dict_value WHERE dict_type = :dictType",
|
update("DELETE FROM sys_dict_value WHERE dict_type = :dictType",
|
||||||
"dictType", entity.getId().orElseThrow());
|
"dictType", entity.getId().orElseThrow());
|
||||||
int i = insertDictValues(entity.getId().orElseThrow(), entity);
|
long i = insertDictValues(entity.getId().orElseThrow(), entity);
|
||||||
assertResultEquals(i, entity.count());
|
assertResultEquals(i, entity.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
int insertDictValues(Long dictId, Dict entity) {
|
long insertDictValues(Long dictId, Dict entity) {
|
||||||
if (Objects.isNull(dictId) || Objects.isNull(entity) || CollectionUtils.isEmpty(entity.getValues())) {
|
if (Objects.isNull(dictId) || Objects.isNull(entity) || CollectionUtils.isEmpty(entity.getValues())) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class RoleMenuRefDAO extends PlusoneJdbcDaoSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveRoleMenuRefs(Long roleId, Role entity) {
|
void saveRoleMenuRefs(Long roleId, Role entity) {
|
||||||
int i = batchUpdate(
|
long i = batchUpdate(
|
||||||
"INSERT INTO sys_role_menu(role_id, menu_id) VALUES (:roleId, :menuId)",
|
"INSERT INTO sys_role_menu(role_id, menu_id) VALUES (:roleId, :menuId)",
|
||||||
entity.getMenus(),
|
entity.getMenus(),
|
||||||
menuRef -> new MapSqlParameterSource()
|
menuRef -> new MapSqlParameterSource()
|
||||||
|
|
|
@ -30,7 +30,7 @@ class RolePermissionRefDAO extends PlusoneJdbcDaoSupport {
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveRolePermissionRefs(Long roleId, Role entity) {
|
void saveRolePermissionRefs(Long roleId, Role entity) {
|
||||||
int i = batchUpdate(
|
long i = batchUpdate(
|
||||||
"INSERT INTO sys_role_permission(role_id, permission_id) VALUES (:roleId, :permissionId)",
|
"INSERT INTO sys_role_permission(role_id, permission_id) VALUES (:roleId, :permissionId)",
|
||||||
entity.getPermissions(),
|
entity.getPermissions(),
|
||||||
actionRef -> new MapSqlParameterSource()
|
actionRef -> new MapSqlParameterSource()
|
||||||
|
|
Loading…
Reference in New Issue