Search in sources :

Example 16 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.

the class AccountManageResource method changePersonal.

@Path("accounts/{id}/personal/change")
@POST
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<AccountVO> changePersonal(@PathParam("id") String id, @QueryParam("userCode") String userCode, ChangePersonalVO vo) {
    sessionDataStore.setCurrentUserCode(userCode);
    if (vo == null) {
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_ILLEGAL_PARAM));
    }
    try {
        Account account = accountManageService.changePersonal(vo.getAccountPersonalInfo());
        AccountVO accountVO = AccountVO.transform(account, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(accountVO);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    }
}
Also used : Account(org.mx.comps.rbac.dal.entity.Account) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 17 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.

the class AccountManageResource method logs.

@Path("logs")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<OperateLogVO>> logs(Pagination pagination, @Context Request request) {
    if (pagination == null) {
        pagination = new Pagination();
    }
    try {
        List<OperateLog> logs = accessor.list(pagination, OperateLog.class);
        List<OperateLogVO> vos = OperateLogVO.transform(logs);
        return new PaginationDataVO(pagination, vos);
    } catch (UserInterfaceException ex) {
        return new PaginationDataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("List logs fail.", ex);
        }
        return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Pagination(org.mx.dal.Pagination) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) OperateLog(org.mx.dal.entity.OperateLog) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 18 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.

the class AccreditManageResource method getAccredit.

@Path("accredits/{id}")
@GET
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<AccreditVO> getAccredit(@QueryParam("id") String id) {
    if (StringUtils.isBlank(id)) {
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_ILLEGAL_PARAM));
    }
    try {
        Accredit accredit = accessor.getById(id, Accredit.class);
        AccreditVO vo = AccreditVO.transform(accredit, true);
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Get accredit fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Accredit(org.mx.comps.rbac.dal.entity.Accredit) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) AccreditVO(org.mx.comps.rbac.rest.vo.AccreditVO) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 19 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround 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)

Example 20 with AuthenticateAround

use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.

the class PrivilegeManageResource method getPrivilege.

@Path("privileges/{id}")
@GET
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<PrivilegeVO> getPrivilege(@PathParam("id") String id) {
    try {
        Privilege privilege = accessor.getById(id, Privilege.class);
        PrivilegeVO vo = PrivilegeVO.transform(privilege, true);
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Get privilege fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) PrivilegeVO(org.mx.comps.rbac.rest.vo.PrivilegeVO) Privilege(org.mx.comps.rbac.dal.entity.Privilege) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Aggregations

AuthenticateAround (org.mx.comps.jwt.AuthenticateAround)27 UserInterfaceException (org.mx.error.UserInterfaceException)27 UserInterfaceSystemErrorException (org.mx.error.UserInterfaceSystemErrorException)27 PaginationDataVO (org.mx.service.rest.vo.PaginationDataVO)27 DataVO (org.mx.service.rest.vo.DataVO)20 Pagination (org.mx.dal.Pagination)7 Account (org.mx.comps.rbac.dal.entity.Account)5 User (org.mx.comps.rbac.dal.entity.User)5 UserVO (org.mx.comps.rbac.rest.vo.UserVO)5 Accredit (org.mx.comps.rbac.dal.entity.Accredit)4 Role (org.mx.comps.rbac.dal.entity.Role)4 AccreditVO (org.mx.comps.rbac.rest.vo.AccreditVO)4 RoleVO (org.mx.comps.rbac.rest.vo.RoleVO)4 Department (org.mx.comps.rbac.dal.entity.Department)3 Privilege (org.mx.comps.rbac.dal.entity.Privilege)3 DepartmentVO (org.mx.comps.rbac.rest.vo.DepartmentVO)3 PrivilegeVO (org.mx.comps.rbac.rest.vo.PrivilegeVO)3 LoginHistory (org.mx.comps.rbac.dal.entity.LoginHistory)2 AccountVO (org.mx.comps.rbac.rest.vo.AccountVO)1 OperateLog (org.mx.dal.entity.OperateLog)1