use of org.mx.comps.rbac.rest.vo.DepartmentVO in project main by JohnPeng739.
the class DepartmentManageResource method deleteDepartment.
@Path("departments/{id}")
@DELETE
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<DepartmentVO> deleteDepartment(@QueryParam("userCode") String userCode, @PathParam("id") String id) {
sessionDataStore.setCurrentUserCode(userCode);
try {
Department department = accessor.remove(id, Department.class);
DepartmentVO vo = DepartmentVO.transform(department, true);
sessionDataStore.removeCurrentUserCode();
return new DataVO<>(vo);
} catch (UserInterfaceException ex) {
return new DataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("Delete department fail.", ex);
}
return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
use of org.mx.comps.rbac.rest.vo.DepartmentVO in project main by JohnPeng739.
the class DepartmentManageResource method departments.
@Path("departments")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<DepartmentVO>> departments(Pagination pagination) {
if (pagination == null) {
pagination = new Pagination();
}
try {
List<Department> departments = accessor.list(pagination, Department.class);
List<DepartmentVO> vos = DepartmentVO.transform(departments);
return new PaginationDataVO<>(pagination, vos);
} catch (UserInterfaceException ex) {
return new PaginationDataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("List departments fail.", ex);
}
return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
use of org.mx.comps.rbac.rest.vo.DepartmentVO in project main by JohnPeng739.
the class DepartmentManageResource method saveDepartment.
private DataVO<DepartmentVO> saveDepartment(DepartmentInfoVO departmentInfoVO) {
try {
Department department = departmentManageService.saveDepartment(departmentInfoVO.getDepartInfo());
DepartmentVO vo = DepartmentVO.transform(department, true);
sessionDataStore.removeCurrentUserCode();
return new DataVO<>(vo);
} catch (UserInterfaceException ex) {
return new DataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("Save department fail.", ex);
}
return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
use of org.mx.comps.rbac.rest.vo.DepartmentVO in project main by JohnPeng739.
the class DepartmentManageResource method getDepartment.
@Path("departments/{id}")
@GET
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<DepartmentVO> getDepartment(@PathParam("id") String id) {
try {
Department department = accessor.getById(id, Department.class);
DepartmentVO vo = DepartmentVO.transform(department, true);
return new DataVO<>(vo);
} catch (UserInterfaceException ex) {
return new DataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("Get department fail.", ex);
}
return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
Aggregations