package com.ecep.contract.service; import java.io.IOException; import java.util.ArrayList; import java.util.List; import com.ecep.contract.vo.DepartmentVo; import javafx.collections.ObservableList; import org.springframework.stereotype.Service; import com.ecep.contract.vm.EmployeeRoleViewModel; import com.ecep.contract.vo.EmployeeRoleVo; import com.ecep.contract.vo.FunctionVo; @Service public class EmployeeRoleService extends QueryService { public List getFunctionsByRole(EmployeeRoleVo role) { try { return async("getFunctionsByRoleId", role.getId(), Integer.class).handle((response, ex) -> { if (ex != null) { throw new RuntimeException("远程方法+getFunctionsByRoleId+调用失败", ex); } List list = new ArrayList<>(); try { objectMapper.readerForUpdating(list) .forType(objectMapper.getTypeFactory().constructCollectionType(List.class, FunctionVo.class)) .readValue(response); } catch (IOException e) { throw new RuntimeException(e); } return list; }).get(); } catch (Exception e) { throw new RuntimeException("查询实体失败, Function#" + role.getId(), e); } } public void saveRoleFunctions(EmployeeRoleVo role, List functions) { try { async("saveRoleFunctions", new Object[]{role.getId(), functions.stream().mapToInt(FunctionVo::getId).toArray()}, new Object[]{Integer.class, Integer[].class}).handle((response, ex) -> { if (ex != null) { throw new RuntimeException("远程方法+saveRoleFunctions+调用失败", ex); } return null; }).get(); } catch (Exception e) { throw new RuntimeException("保存角色的功能失败, 角色#" + role.getId(), e); } } }