@AccessLevel(level = 2) public Result create() { Form<ActivityChoice> choiceForm = Form.form(ActivityChoice.class).bindFromRequest(); if (choiceForm.hasErrors()) { return status( ErrDefinition.E_ACTIVITY_CHOICE_FORM_HASERROR, Messages.get("activitychoice.failure")); } try { ActivityChoice choice = choiceForm.get(); choice.id = CodeGenerator.GenerateUUId(); choice.content = new ActivityContent(); choice.content.id = choice.id; Ebean.save(choice); return ok(Json.toJson(choice)); } catch (Throwable e) { return status( ErrDefinition.E_ACTIVITY_CHOICE_CREATE_FAILED, Messages.get("activitychoice.failure")); } }
public Result create() { Logger.info("enter create"); Form<ShakeRecord> shakeForm = Form.form(ShakeRecord.class).bindFromRequest(); if (shakeForm.hasErrors()) { Logger.info("form has error"); return status(ErrDefinition.E_SHAKE_RECORD_FORM_ERROR, Messages.get("shakerecord.failure")); } DynamicForm form = Form.form().bindFromRequest(); String userId = form.get("userId"); String appId = form.get("appId"); if (null == userId) { Logger.info("userId is null"); return status(ErrDefinition.E_SHAKE_RECORD_CREATE_ERROR, Messages.get("shakerecord.failure")); } try { ShakeRecord shakeRecord = shakeForm.get(); shakeRecord.id = CodeGenerator.GenerateUUId(); shakeRecord.shop = Shop.find.byId(shakeRecord.shop_id); shakeRecord.account = Account.find.byId(userId); shakeRecord.create_time = new Date(); Ebean.save(shakeRecord); Logger.info("save it"); return ok(Json.toJson(shakeRecord)); } catch (Throwable e) { Logger.info("cannot save"); Logger.info(e.getMessage()); return status(ErrDefinition.E_SHAKE_RECORD_CREATE_ERROR, Messages.get("shakerecord.failure")); } }