本文整理了Java中com.jfinal.plugin.activerecord.Db.batchSave()
方法的一些代码示例,展示了Db.batchSave()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Db.batchSave()
方法的具体详情如下:
包路径:com.jfinal.plugin.activerecord.Db
类名称:Db
方法名:batchSave
暂无
代码示例来源:origin: JpressProjects/jpress
@Override
public void run() {
if (utmList.isEmpty()) {
return;
}
List<Utm> tempUtmList = new ArrayList<>(utmList);
utmList.clear();
Db.batchSave(tempUtmList, 1000);
}
代码示例来源:origin: JpressProjects/jpress
@Override
public void doUpdateCategorys(long articleId, Long[] categoryIds) {
Db.tx(() -> {
Db.update("delete from article_category_mapping where article_id = ?", articleId);
if (categoryIds != null && categoryIds.length > 0) {
List<Record> records = new ArrayList<>();
for (long categoryId : categoryIds) {
Record record = new Record();
record.set("article_id", articleId);
record.set("category_id", categoryId);
records.add(record);
}
Db.batchSave("article_category_mapping", records, records.size());
}
return true;
});
}
代码示例来源:origin: JpressProjects/jpress
@Override
public boolean doChangeRoleByIds(Long roleId, Object... ids) {
for (Object id : ids) {
//删除role缓存
Jboot.me().getCache().remove("role", "user_roles:" + id);
}
return Db.tx(() -> {
//清空用户的其他所有角色
for (Object id : ids) {
Db.delete("delete from user_role_mapping where user_id = ? ", id);
}
//添加新的映射
List<Record> records = new ArrayList<>();
for (Object id : ids) {
Record record = new Record();
record.set("user_id", id);
record.set("role_id", roleId);
records.add(record);
}
Db.batchSave("user_role_mapping", records, records.size());
return true;
});
}
代码示例来源:origin: JpressProjects/jpress
@Override
@CachesEvict({
@CacheEvict(name = "user_role", key = "user_roles:#(userId)"),
@CacheEvict(name = "user_permission", key = "*")
})
public boolean doResetUserRoles(long userId, Long... RoleIds) {
if (RoleIds == null || RoleIds.length == 0) {
return Db.delete("delete from user_role_mapping where user_id = ? ", userId) > 0;
}
return Db.tx(() -> {
Db.delete("delete from user_role_mapping where user_id = ? ", userId);
List<Record> records = new ArrayList<>();
for (Long roleId : RoleIds) {
Record record = new Record();
record.set("user_id", userId);
record.set("role_id", roleId);
records.add(record);
}
Db.batchSave("user_role_mapping", records, records.size());
return true;
});
}
代码示例来源:origin: pkanyue/jboot-admin
@Override
public int[] batchSave(List<RoleRes> list) {
return Db.batchSave(list, list.size());
}
}
代码示例来源:origin: pkanyue/jboot-admin
@Override
public int[] batchSave(List<UserRole> list) {
return Db.batchSave(list, list.size());
}
}
代码示例来源:origin: ticktack/kungfu
public int batchSave(List<? extends Model<?>> list) {
return Db.batchSave(list, list.size()).length;
}
代码示例来源:origin: ticktack/kungfu
public int saveOrUpdate(List<? extends Model<?>> list, boolean flag) {
if (flag) {
return Db.batchSave(list, list.size()).length;
}
else {
return Db.batchUpdate(list, list.size()).length;
}
}
代码示例来源:origin: yjjdick/sdb-mall
@Override
@JFinalTx
public void saveOrUpdate(Long roleId, List<Long> menuIdList) {
//先删除角色与菜单关系
deleteBatch(new Long[]{roleId});
if(menuIdList.size() == 0){
return ;
}
//保存角色与菜单关系
List<SysRoleMenu> list = new ArrayList<>(menuIdList.size());
for(Long menuId : menuIdList){
SysRoleMenu sysRoleMenu = new SysRoleMenu();
sysRoleMenu.setMenuId(menuId);
sysRoleMenu.setRoleId(roleId);
list.add(sysRoleMenu);
}
Db.batchSave(list, list.size());
}
代码示例来源:origin: pkanyue/jboot-admin
@Override
public boolean run() throws SQLException {
roleResService.deleteByRoleId(id);
if (StrKit.notBlank(resIds)) {
String[] ress = resIds.split(",");
for (String resId : ress) {
RoleRes roleRes = new RoleRes();
roleRes.setRoleId(id);
roleRes.setResId(Long.parseLong(resId));
roleResList.add(roleRes);
}
int[] rets = Db.batchSave(roleResList, roleResList.size());
for (int ret : rets) {
if (ret < 1) {
return false;
}
}
}
return true;
}
});
代码示例来源:origin: yjjdick/sdb-mall
@Override
@JFinalTx
public void saveOrUpdate(Long userId, List<Long> roleIdList) {
//先删除用户与角色关系
SysUserRole delSysUserRole = new SysUserRole();
delSysUserRole.setUserId(userId);
this.deleteByModel(delSysUserRole);
if(roleIdList == null || roleIdList.size() == 0){
return ;
}
//保存用户与角色关系
List<SysUserRole> list = new ArrayList<>(roleIdList.size());
for(Long roleId : roleIdList){
SysUserRole sysUserRole = new SysUserRole();
sysUserRole.setUserId(userId);
sysUserRole.setRoleId(roleId);
list.add(sysUserRole);
}
Db.batchSave(list, list.size());
}
代码示例来源:origin: yjjdick/sdb-mall
Db.batchUpdate(products, products.size());
} else {
Db.batchSave(products, products.size());
内容来源于网络,如有侵权,请联系作者删除!