Search in sources :

Example 1 with RBACUserRole

use of cn.opencil.po.RBACUserRole in project CILManagement-Server by LiuinStein.

the class UserController method register.

/**
 * Sign up a new member
 */
@RequestMapping(value = "/", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ResponseStatus(HttpStatus.CREATED)
public RestfulResult register(@RequestBody JSONObject input) throws SimpleHttpException, ValidationException {
    RBACUser user = ValidationUtils.validate(input.toJavaObject(RBACUser.class), RegisterValidation.class);
    UserInfo info = ValidationUtils.validate(input.toJavaObject(UserInfo.class), RegisterValidation.class);
    RBACUserRole role = ValidationUtils.validate(input.toJavaObject(RBACUserRole.class), RegisterValidation.class);
    if (!userService.addMember(user, info, role)) {
        throw new SimpleHttpException(500, "database access error", HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return new RestfulResult(0, "new member created", new HashMap<>());
}
Also used : RBACUserRole(cn.opencil.po.RBACUserRole) RBACUser(cn.opencil.po.RBACUser) SimpleHttpException(cn.opencil.exception.SimpleHttpException) RestfulResult(cn.opencil.vo.RestfulResult) UserInfo(cn.opencil.po.UserInfo)

Aggregations

SimpleHttpException (cn.opencil.exception.SimpleHttpException)1 RBACUser (cn.opencil.po.RBACUser)1 RBACUserRole (cn.opencil.po.RBACUserRole)1 UserInfo (cn.opencil.po.UserInfo)1 RestfulResult (cn.opencil.vo.RestfulResult)1