use of io.github.tesla.ops.system.domain.RoleMenuDO in project tesla by linking12.
the class RoleServiceImpl method save.
@CacheEvict(value = CACHE_NAME, key = ROLE_ALL_KEY)
@Transactional
@Override
public int save(RoleDO role) {
int count = roleMapper.save(role);
List<Long> menuIds = role.getMenuIds();
Long roleId = role.getRoleId();
List<RoleMenuDO> rms = new ArrayList<>();
for (Long menuId : menuIds) {
RoleMenuDO rmDo = new RoleMenuDO();
rmDo.setRoleId(roleId);
rmDo.setMenuId(menuId);
rms.add(rmDo);
}
roleMenuMapper.removeByRoleId(roleId);
if (rms.size() > 0) {
roleMenuMapper.batchSave(rms);
}
return count;
}
use of io.github.tesla.ops.system.domain.RoleMenuDO in project tesla by linking12.
the class RoleServiceImpl method update.
@CacheEvict(value = CACHE_NAME, key = ROLE_ALL_KEY)
@Override
public int update(RoleDO role) {
int r = roleMapper.update(role);
List<Long> menuIds = role.getMenuIds();
Long roleId = role.getRoleId();
roleMenuMapper.removeByRoleId(roleId);
List<RoleMenuDO> rms = new ArrayList<>();
for (Long menuId : menuIds) {
RoleMenuDO rmDo = new RoleMenuDO();
rmDo.setRoleId(roleId);
rmDo.setMenuId(menuId);
rms.add(rmDo);
}
if (rms.size() > 0) {
roleMenuMapper.batchSave(rms);
}
return r;
}
Aggregations