mirror of https://gitee.com/stylefeng/roses
【7.2.5】【role】更新批量插入roleResource的方法
parent
7b573b530a
commit
e477aa2427
|
@ -24,8 +24,8 @@
|
|||
*/
|
||||
package cn.stylefeng.roses.kernel.system.modular.role.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.mp.injector.CustomBaseMapper;
|
||||
import cn.stylefeng.roses.kernel.system.modular.role.entity.SysRoleResource;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 系统角色资源mapper接口
|
||||
|
@ -33,5 +33,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
* @author majianguo
|
||||
* @date 2020/11/5 下午4:15
|
||||
*/
|
||||
public interface SysRoleResourceMapper extends BaseMapper<SysRoleResource> {
|
||||
public interface SysRoleResourceMapper extends CustomBaseMapper<SysRoleResource> {
|
||||
}
|
||||
|
|
|
@ -73,4 +73,12 @@ public interface SysRoleResourceService extends IService<SysRoleResource> {
|
|||
*/
|
||||
void deleteRoleResourceListByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 保存所有的角色资源
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @date 2022/9/17 14:33
|
||||
*/
|
||||
void quickSaveAll(List<SysRoleResource> sysRoleResourceList);
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ package cn.stylefeng.roses.kernel.system.modular.role.service.impl;
|
|||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.stylefeng.roses.kernel.cache.api.CacheOperatorApi;
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.druid.DruidProperties;
|
||||
import cn.stylefeng.roses.kernel.rule.enums.DbTypeEnum;
|
||||
import cn.stylefeng.roses.kernel.rule.util.DatabaseTypeUtil;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.role.request.SysRoleRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.role.entity.SysRoleResource;
|
||||
import cn.stylefeng.roses.kernel.system.modular.role.mapper.SysRoleResourceMapper;
|
||||
|
@ -53,6 +56,9 @@ public class SysRoleResourceServiceImpl extends ServiceImpl<SysRoleResourceMappe
|
|||
@Resource(name = "roleResourceCacheApi")
|
||||
private CacheOperatorApi<List<String>> roleResourceCacheApi;
|
||||
|
||||
@Resource
|
||||
private DruidProperties druidProperties;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void grantResource(SysRoleRequest sysRoleRequest) {
|
||||
|
@ -143,4 +149,14 @@ public class SysRoleResourceServiceImpl extends ServiceImpl<SysRoleResourceMappe
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void quickSaveAll(List<SysRoleResource> sysRoleResourceList) {
|
||||
DbTypeEnum currentDbType = DatabaseTypeUtil.getDbType(druidProperties.getUrl());
|
||||
if (DbTypeEnum.MYSQL.equals(currentDbType)) {
|
||||
this.getBaseMapper().insertBatchSomeColumn(sysRoleResourceList);
|
||||
} else {
|
||||
this.saveBatch(sysRoleResourceList, sysRoleResourceList.size());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class InitAdminService {
|
|||
sysRoleResource.setRoleId(superAdminRole.getRoleId());
|
||||
sysRoleResources.add(sysRoleResource);
|
||||
}
|
||||
sysRoleResourceService.saveBatch(sysRoleResources, sysRoleResources.size());
|
||||
sysRoleResourceService.quickSaveAll(sysRoleResources);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue