Search in sources :

Example 11 with DataVO

use of org.mx.service.rest.vo.DataVO in project main by JohnPeng739.

the class RoleManageResource method saveRole.

@Path("roles/new")
@POST
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<RoleVO> saveRole(@QueryParam("userCode") String userCode, RoleInfoVO roleInfoVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        roleInfoVO.setId(null);
        Role role = roleManageService.saveRole(roleInfoVO.getRoleInfo());
        RoleVO vo = RoleVO.transform(role, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Save role fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Role(org.mx.comps.rbac.dal.entity.Role) RoleVO(org.mx.comps.rbac.rest.vo.RoleVO) DataVO(org.mx.service.rest.vo.DataVO) 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) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 12 with DataVO

use of org.mx.service.rest.vo.DataVO in project main by JohnPeng739.

the class NotifyServerResource method sendNotify.

/**
 * 推送通知
 *
 * @param notifyCommand JSON格式的通知命令字符串
 * @return 返回true表示处理成功
 */
@Path("notify/send")
@POST
public DataVO<Boolean> sendNotify(String notifyCommand) {
    JSONObject json = JSON.parseObject(notifyCommand);
    notifyProcessor.notifyProcess(json);
    return new DataVO<>(true);
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO)

Example 13 with DataVO

use of org.mx.service.rest.vo.DataVO in project main by JohnPeng739.

the class FfeeFamilyManageResource method createFamily.

@Path("family/create")
@POST
public DataVO<FamilyVO> createFamily(@QueryParam("userCode") String userCode, FamilyManageVO familyManageVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Family family = familyManageService.createFamily(familyManageVO.getName(), familyManageVO.getFfeeAccountId(), familyManageVO.getMemberRole());
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(FamilyVO.transform(family));
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    }
}
Also used : DataVO(org.mx.service.rest.vo.DataVO) Family(org.mx.tools.ffee.dal.entity.Family) UserInterfaceException(org.mx.error.UserInterfaceException)

Example 14 with DataVO

use of org.mx.service.rest.vo.DataVO in project main by JohnPeng739.

the class TestServer method testHttpServer.

@Test
public void testHttpServer() {
    AbstractServerFactory factory = context.getBean(HttpServerFactory.class);
    assertNotNull(factory);
    Server server = factory.getServer();
    assertNotNull(server);
    // test service client
    try {
        RestClientInvoke invoke = new RestClientInvoke();
        DataVO<String> str = invoke.get("http://localhost:9999/service/get", DataVO.class);
        assertNotNull(str);
        assertEquals("match the response data.", "get data.", str.getData());
        String data = "hello world";
        str = invoke.post("http://localhost:9999/service/post", data, DataVO.class);
        assertNotNull(str);
        assertEquals("match the response data.", String.format("post data: %s.", data), str.getData());
        data = "hello world";
        str = invoke.put("http://localhost:9999/service/put", data, DataVO.class);
        assertNotNull(str);
        assertEquals("match the response data.", String.format("put data: %s.", data), str.getData());
        invoke.close();
    } catch (RestInvokeException ex) {
        ex.printStackTrace();
        fail(ex.getMessage());
    }
}
Also used : Server(org.eclipse.jetty.server.Server) DataVO(org.mx.service.rest.vo.DataVO) RestInvokeException(org.mx.service.client.rest.RestInvokeException) RestClientInvoke(org.mx.service.client.rest.RestClientInvoke) Test(org.junit.Test)

Example 15 with DataVO

use of org.mx.service.rest.vo.DataVO 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)

Aggregations

DataVO (org.mx.service.rest.vo.DataVO)26 UserInterfaceException (org.mx.error.UserInterfaceException)24 PaginationDataVO (org.mx.service.rest.vo.PaginationDataVO)24 UserInterfaceSystemErrorException (org.mx.error.UserInterfaceSystemErrorException)23 AuthenticateAround (org.mx.comps.jwt.AuthenticateAround)20 Account (org.mx.comps.rbac.dal.entity.Account)5 User (org.mx.comps.rbac.dal.entity.User)4 UserVO (org.mx.comps.rbac.rest.vo.UserVO)4 Accredit (org.mx.comps.rbac.dal.entity.Accredit)3 Department (org.mx.comps.rbac.dal.entity.Department)3 Privilege (org.mx.comps.rbac.dal.entity.Privilege)3 Role (org.mx.comps.rbac.dal.entity.Role)3 AccreditVO (org.mx.comps.rbac.rest.vo.AccreditVO)3 DepartmentVO (org.mx.comps.rbac.rest.vo.DepartmentVO)3 PrivilegeVO (org.mx.comps.rbac.rest.vo.PrivilegeVO)3 RoleVO (org.mx.comps.rbac.rest.vo.RoleVO)3 LoginHistory (org.mx.comps.rbac.dal.entity.LoginHistory)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Server (org.eclipse.jetty.server.Server)1 Test (org.junit.Test)1