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));
}
}
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);
}
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);
}
}
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());
}
}
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);
}
}
Aggregations