This commit is contained in:
2025-11-26 16:10:17 +08:00
parent f0e85c5a18
commit c10bd369c0
83 changed files with 1755 additions and 541 deletions

View File

@@ -1,7 +1,11 @@
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;
@@ -11,11 +15,38 @@ import com.ecep.contract.vo.FunctionVo;
@Service
public class EmployeeRoleService extends QueryService<EmployeeRoleVo, EmployeeRoleViewModel> {
public List<FunctionVo> getFunctionsByRoleId(int roleId) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getFunctionsByRoleId'");
public List<FunctionVo> getFunctionsByRole(EmployeeRoleVo role) {
try {
return async("getFunctionsByRoleId", role.getId(), Integer.class).handle((response, ex) -> {
if (ex != null) {
throw new RuntimeException("远程方法+getFunctionsByRoleId+调用失败", ex);
}
List<FunctionVo> 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<FunctionVo> 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);
}
}
}