Search in sources :

Example 1 with DepartmentVO

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));
    }
}
Also used : Department(org.mx.comps.rbac.dal.entity.Department) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) DepartmentVO(org.mx.comps.rbac.rest.vo.DepartmentVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 2 with DepartmentVO

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));
    }
}
Also used : Pagination(org.mx.dal.Pagination) Department(org.mx.comps.rbac.dal.entity.Department) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) DepartmentVO(org.mx.comps.rbac.rest.vo.DepartmentVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 3 with DepartmentVO

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));
    }
}
Also used : Department(org.mx.comps.rbac.dal.entity.Department) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) DepartmentVO(org.mx.comps.rbac.rest.vo.DepartmentVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException)

Example 4 with DepartmentVO

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));
    }
}
Also used : Department(org.mx.comps.rbac.dal.entity.Department) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) DepartmentVO(org.mx.comps.rbac.rest.vo.DepartmentVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Aggregations

Department (org.mx.comps.rbac.dal.entity.Department)4 DepartmentVO (org.mx.comps.rbac.rest.vo.DepartmentVO)4 UserInterfaceException (org.mx.error.UserInterfaceException)4 UserInterfaceSystemErrorException (org.mx.error.UserInterfaceSystemErrorException)4 PaginationDataVO (org.mx.service.rest.vo.PaginationDataVO)4 AuthenticateAround (org.mx.comps.jwt.AuthenticateAround)3 DataVO (org.mx.service.rest.vo.DataVO)3 Pagination (org.mx.dal.Pagination)1