代码优化

This commit is contained in:
2023-04-19 21:38:09 +08:00
parent ed1e288ec2
commit 94c409bcde

View File

@@ -200,13 +200,15 @@ public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, Function> i
public Boolean updateRoleComponent(RoleParam.RoleFunctionComponent roleFunctionComponent) { public Boolean updateRoleComponent(RoleParam.RoleFunctionComponent roleFunctionComponent) {
deleteComponentsByRoleIndex(roleFunctionComponent.getId()); deleteComponentsByRoleIndex(roleFunctionComponent.getId());
if (!roleFunctionComponent.getIdList().isEmpty()){ if (!roleFunctionComponent.getIdList().isEmpty()){
List<RoleFunction> list = new ArrayList<>();
RoleFunction roleFunction = new RoleFunction(); RoleFunction roleFunction = new RoleFunction();
for (String pojo : roleFunctionComponent.getIdList()) {
roleFunction = new RoleFunction();
roleFunction.setRoleId(roleFunctionComponent.getId()); roleFunction.setRoleId(roleFunctionComponent.getId());
roleFunctionComponent.getIdList().forEach(
pojo->{
roleFunction.setFunctionId(pojo); roleFunction.setFunctionId(pojo);
roleFunctionMapper.insert(roleFunction); list.add(roleFunction);
}); }
roleFunctionService.saveBatch(list);
} }
refreshRolesFunctionsCache(); refreshRolesFunctionsCache();
return true; return true;