本文整理汇总了Java中com.avaje.ebean.Ebean.update方法的典型用法代码示例。如果您正苦于以下问题:Java Ebean.update方法的具体用法?Java Ebean.update怎么用?Java Ebean.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.avaje.ebean.Ebean
的用法示例。
在下文中一共展示了Ebean.update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: useCoupon
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
public Result useCoupon(String couponId) {
try {
CouponRecord couponRecord = CouponRecord.find.where()
.eq("coupon_id", couponId).findUnique();
if (null != couponRecord) {
couponRecord.is_used = true;
Set<String> updateProps = new HashSet<String>();
updateProps.add("is_used");
Ebean.update(couponRecord, updateProps);
return ok(Json.toJson(couponRecord));
}
}
catch (Throwable e) {
Logger.info("error:" + e.getMessage());
}
return ok();
}
示例2: update
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
@AccessLevel(level=2)
public Result update() {
Form<ProgramContent> contentForm =
Form.form(ProgramContent.class).bindFromRequest();
if (contentForm.hasErrors()) {
return status(ErrDefinition.E_PROGRAM_CONTENT_FORM_HASERROR,
Messages.get("programcontent.failure"));
}
try {
ProgramContent content = contentForm.get();
Ebean.update(content);
return ok(Json.toJson(content));
}
catch (Throwable e) {
return status(ErrDefinition.E_PROGRAM_CONTENT_UPDATE_FAILED,
Messages.get("programcontent.failure"));
}
}
示例3: collectionGet
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
public Result collectionGet(int pageNumber, int sizePerPage) {
try {
List<Collections> listConnections = Collections.find.where()
.eq("user_id", session("userId"))
.setFirstRow(pageNumber*sizePerPage)
.setMaxRows(sizePerPage)
.findList();
for(Collections itera:listConnections) {
if (itera.article_name == null) {
itera.article_name = Article.find.where().eq("article_id", itera.article_id).findUnique().article_name;
Ebean.update(itera);
}
}
return ok(Json.toJson(listConnections));
}
catch (Throwable e) {
System.err.println(e.toString());
return status(ErrDefinition.E_COLLECTIONS_GET_ERROR,
Messages.get("collectionsget.failure"));
}
}
示例4: update
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
public Result update() {
Form<UserAddress> addressForm =
Form.form(UserAddress.class).bindFromRequest();
if (addressForm.hasErrors()) {
return status(ErrDefinition.E_USER_ADDRESS_FORM_ERROR);
}
try {
UserAddress address = addressForm.get();
address.id = new AccountAppId(session("userId"), session("appId"));
Ebean.update(address);
return ok(Json.toJson(address));
}
catch (Throwable e) {
return status(ErrDefinition.E_USER_ADDRESS_UPDATE_ERROR);
}
}
示例5: update
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
@AccessLevel(level=2)
public Result update() {
Form<Application> appForm =
Form.form(Application.class).bindFromRequest();
if (appForm.hasErrors()) {
return status(ErrDefinition.E_APP_FORM_HASERROR,
Messages.get("application.actionfailed"));
}
try {
Application app = appForm.get();
Ebean.update(app);
}
catch (Throwable e) {
return status(ErrDefinition.E_APP_EXCEPTION_FOUND,
Messages.get("application.actionfailed"));
}
return ok();
}
示例6: updateFcwm
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
public Result updateFcwm() {
Form<Activity> activityForm =
Form.form(Activity.class).bindFromRequest();
if (activityForm.hasErrors()) {
return status(ErrDefinition.E_ACTIVITY_FORM_HASERROR,
Messages.get("activity.failure"));
}
try {
Activity activity = activityForm.get();
activity.app_id=session("appId");
Ebean.update(activity);
return ok(Json.toJson(activity));
}
catch (Exception e) {
return status(ErrDefinition.E_ACTIVITY_UPDATE_FAILED,
Messages.get("activity.failure"));
}
}
示例7: update
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
public Result update() {
Form<Gift> gift =
Form.form(Gift.class).bindFromRequest();
if (gift.hasErrors()) {
return status (ErrDefinition.E_GIFT_READ_FAILED,
Messages.get("giftUpdate.failure"));
}
try{
String appId=session("appId");
Gift gif = gift.get();
gif.app_id=appId;
Ebean.update(gif);
}
catch (Throwable e) {
return status(ErrDefinition.E_GIFT_READ_FAILED,
Messages.get("giftUpdate.failure"));
}
return ok();
}
示例8: update
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
@AccessLevel(level=2)
public Result update() {
Form<Program> programForm =
Form.form(Program.class).bindFromRequest();
if (programForm.hasErrors()) {
return status(ErrDefinition.E_PROGRAM_FORM_HASERROR,
Messages.get("program.failure"));
}
try {
Program program = programForm.get();
Ebean.update(program);
return ok(Json.toJson(program));
}
catch (Throwable e) {
return status(ErrDefinition.E_PROGRAM_UPDATE_FAILED,
Messages.get("program.failure"));
}
}
示例9: update
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
@AccessLevel(level=2)
public Result update() {
Form<Shop> shopForm =
Form.form(Shop.class).bindFromRequest();
if (shopForm.hasErrors()) {
return status(ErrDefinition.E_SHOP_FORM_ERROR,
Messages.get("shop.failure"));
}
try {
Shop shop = shopForm.get();
Shop shopToUpdate = Shop.find.byId(shop.id);
shop.app = shopToUpdate.app;
Ebean.update(shop);
return ok(Json.toJson(shop));
}
catch (Throwable e) {
Logger.info(e.getMessage());
return status(ErrDefinition.E_SHOP_UPDATE_ERROR,
Messages.get("shop.failure"));
}
}
示例10: onHandleQuit
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
private void onHandleQuit(ChatRoom.Quit quit) {
if(m_members.containsKey(quit.userId)){
m_members.remove(quit.userId);
}
else {
return;
}
if (quit.userId.compareToIgnoreCase(m_hostId) == 0) {
onHostQuit(quit);
}
else {
onGuestQuit(quit);
}
try {
ChatRoomTime joinTime = ChatRoomTime.find.where()
.eq("account_id", quit.userId)
.findUnique();
if (joinTime != null) {
joinTime.action = "exit";
joinTime.action_time = new Date();
joinTime.room_id = m_hostId;
joinTime.send_gift_number = CharmValue.find.where()
.eq("sender_id", quit.userId).findRowCount();
Ebean.update(joinTime);
}
}
catch (Throwable e) {
Logger.info(e.getMessage());
}
}
示例11: update
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
public Result update() {
Form<Article> ArticleForm =
Form.form(Article.class).bindFromRequest();
if (ArticleForm.hasErrors()) {
return status(ErrDefinition.E_ARTICLE_FORM_ERROR,
Messages.get("article.failure"));
}
try {
Article updateArticle = ArticleForm.get();
// Check the updated article is done by author
Article originArticle = Article.find.where()
.eq("article_id", updateArticle.article_id )
.findUnique();
AccountAppId id = new AccountAppId(session("userId"), session("appId"));
// if (Account.find.where().eq("id", (session("userId"))).findUnique().role==2) { // administrator may update the article
// updateArticle.author = originArticle.author;
// } else
if (AppProfile.find.byId(id).name != originArticle.author_name && Account.find.where().eq("id", (session("userId"))).findUnique().role!=2) {
return status(ErrDefinition.E_ARTICLE_UPDATE_ERROR,
Messages.get("articleupdate.failure"));
}
Date updateTime = new Date();
updateArticle.update_time = updateTime;
Ebean.update(updateArticle);
return ok(Json.toJson(updateArticle));
}
catch (Throwable e) {
return status(ErrDefinition.E_ARTICLE_UPDATE_ERROR,
Messages.get("articleupdate.failure"));
}
}
示例12: onHandleJoin
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
private void onHandleJoin(ChatRoom.Join join) {
//add the member
if (!m_members.containsKey(join.userId)) {
m_members.put(join.userId, join.channel);
}
else {
return;
}
for (History history : recordList) {
sendHistoryMessage(join.channel, history);
}
if (join.userId.compareToIgnoreCase(m_hostId) == 0) {
onHostJoin(join);
}
else {
onGuestJoin(join);
}
try {
ChatRoomTime joinTime = ChatRoomTime.find.where()
.eq("account_id", join.userId)
.findUnique();
if (joinTime == null) {
joinTime = new ChatRoomTime();
joinTime.id = CodeGenerator.GenerateUUId();
joinTime.room_id = m_hostId;
joinTime.action = "join";
joinTime.action_time = new Date();
joinTime.account = Account.find.byId(join.userId);
//joinTime.send_gift_number = CharmValue.find.where()
// .eq("sender_id", join.userId).findRowCount();
Ebean.save(joinTime);
} else {
joinTime.action = "join";
joinTime.action_time = new Date();
joinTime.room_id = m_hostId;
//joinTime.send_gift_number = CharmValue.find.where()
// .eq("sender_id", join.userId).findRowCount();
Ebean.update(joinTime);
}
}
catch (Throwable e) {
Logger.info(e.getMessage());
}
}
示例13: post
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
public Result post() {
Form<Comments> CommentForm =
Form.form(Comments.class).bindFromRequest();
if (CommentForm.hasErrors()) {
return status(ErrDefinition.E_COMMENT_FORM_ERROR,
Messages.get("comment.failure"));
}
try {
Comments comment = CommentForm.get();
AccountAppId id = new AccountAppId(session("userId"), session("appId"));
Article article = Article.find.where()
.eq("article_id", comment.article_id)
.findUnique();
if (article == null) {
return status(ErrDefinition.E_COMMENT_POST_ERROR,
Messages.get("commentcreate.failure"));
} else {
article.last_reply = new Date();
if (article.last_reply.getTime() > article.update_time.getTime())
article.is_new_comments = true;
if (article.comments_number == null)
article.comments_number = 1;
else
article.comments_number += 1;
Ebean.update(article);
}
comment.id = CodeGenerator.GenerateUUId();
comment.comments = CodeGenerator.GenerateUUId();
comment.author = Account.find.byId(session("userId"));
comment.user_id = session("userId");
comment.author_name = AppProfile.find.byId(id).name;
comment.author_image = AppProfile.find.byId(id).head_image;
Date createTime = new Date();
comment.create_time = createTime;
comment.update_time = createTime;
comment.last_reply = createTime;
comment.is_top = false;
comment.is_hidden = false;
Ebean.save(comment);
if(session("appId").equals("34536418-d6b2-451f-a400-4f0e284c9497")){
Sign signItem = Sign.find.where().eq("account_id", session("userId")).eq("app_id", session("appId")).findUnique();
if(signItem==null){
signItem = new Sign();
signItem.id = CodeGenerator.GenerateUUId();
signItem.application = Application.find.where().eq("id", session("appId")).findUnique();
signItem.user = Account.find.where().eq("id", session("userId")).findUnique();
signItem.last_visit = new Date();
signItem.sign_charm = 1;
Ebean.save(signItem);
}
else {
signItem.sign_charm += 1;
Ebean.update(signItem);
}
}
return ok(Json.toJson(comment));
}
catch (Throwable e) {
return status(ErrDefinition.E_COMMENT_POST_ERROR,
Messages.get("commentcreate.failure"));
}
}
示例14: post
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
public Result post() {
Form<CommentsLevel2> CommentForm =
Form.form(CommentsLevel2.class).bindFromRequest();
if (CommentForm.hasErrors()) {
return status(ErrDefinition.E_COMMENT_FORM_ERROR,
Messages.get("comment.failure"));
}
try {
CommentsLevel2 comment = CommentForm.get();
AccountAppId id = new AccountAppId(session("userId"), session("appId"));
Comments comments = Comments.find.where()
.eq("comments", comment.comments)
.findUnique();
if (comments == null) {
return status(ErrDefinition.E_COMMENT_POST_ERROR,
Messages.get("commentcreate.failure"));
}
Article article = Article.find.where()
.eq("article_id", comments.article_id)
.findUnique();
if (article == null) {
return status(ErrDefinition.E_COMMENT_POST_ERROR,
Messages.get("commentcreate.failure"));
} else {
article.last_reply = new Date();
if (article.last_reply.getTime() > article.update_time.getTime())
article.is_new_comments = true;
if (article.comments_number == null)
article.comments_number = 1;
else
article.comments_number += 1;
Ebean.update(article);
}
comment.id = CodeGenerator.GenerateUUId();
comment.comments = comments.comments;
comment.author = Account.find.byId(session("userId"));
comment.user_id = session("userId");
comment.author_name = AppProfile.find.byId(id).name;
comment.author_image = AppProfile.find.byId(id).head_image;
Date createTime = new Date();
comment.create_time = createTime;
comment.update_time = createTime;
comment.last_reply = createTime;
comment.is_top = false;
comment.is_hidden = false;
if(session("appId").equals("34536418-d6b2-451f-a400-4f0e284c9497")){
Sign signItem = Sign.find.where().eq("account_id", session("userId")).eq("app_id", session("appId")).findUnique();
if(signItem==null){
signItem = new Sign();
signItem.id = CodeGenerator.GenerateUUId();
signItem.application = Application.find.where().eq("id", session("appId")).findUnique();
signItem.user = Account.find.where().eq("id", session("userId")).findUnique();
signItem.last_visit = new Date();
signItem.sign_charm = 1;
Ebean.save(signItem);
}
else {
signItem.sign_charm += 1;
Ebean.update(signItem);
}
}
Ebean.save(comment);
return ok(Json.toJson(comment));
}
catch (Throwable e) {
return status(ErrDefinition.E_COMMENT_POST_ERROR,
Messages.get("commentcreate.failure"));
}
}
示例15: post
import com.avaje.ebean.Ebean; //导入方法依赖的package包/类
public Result post() {
Form<Article> ArticleForm =
Form.form(Article.class).bindFromRequest();
if (ArticleForm.hasErrors()) {
return status(ErrDefinition.E_ARTICLE_FORM_ERROR,
Messages.get("article.failure"));
}
try {
Article article = ArticleForm.get();
if(article.theme_id == null) article.theme_id = "stockDefault";
Theme theme = Theme.find.where()
.eq("id", article.theme_id)
.findUnique();
if (theme==null) {
return status(ErrDefinition.E_ARTICLE_NO_THEME_ERROR,
Messages.get("articlepost.failure"));
}
AccountAppId id = new AccountAppId(session("userId"), session("appId"));
AppProfile appProfile = AppProfile.find.byId(id);
if(session("appId").equals("34536418-d6b2-451f-a400-4f0e284c9497")){
Sign signItem = Sign.find.where().eq("account_id", session("userId")).eq("app_id", session("appId")).findUnique();
signItem.sign_charm += 1;
Ebean.update(signItem);
}
article.id = CodeGenerator.GenerateUUId();
article.article_id = CodeGenerator.GenerateUUId();
article.author = Account.find.where().eq("id", (session("userId"))).findUnique();
article.user_id = session("userId");
article.application = Application.find.where().eq("id", (session("appId"))).findUnique();
article.author_name = appProfile.name;
article.author_image = appProfile.head_image;
// article.author_image_base64 = appProfile.head_imgbase64;
article.is_verified = appProfile.is_verified;
Date createTime = new Date();
article.create_time = createTime;
article.update_time = createTime;
article.last_reply = createTime;
article.theme_name = theme.theme_name;
article.theme_image = theme.theme_image;
article.theme_class = theme.theme_class;
article.is_top = false;
article.is_elite = false;
article.is_public = false;
article.is_new_comments = false;
article.isSpecial = false;
article.thumbs_number = 0;
article.thumbs_number2 = 0;
article.comments_number = 0;
theme.last_update = new Date(); //update theme latest time
// Only administrator can send is_top flag
// UserGroup authorGroup = UserGroup.find.where()
// .eq("account_id", article.author)
// .findUnique();
// if (authorGroup != null) {
// if (authorGroup.group_name == "admin") {
// }
// else {
// article.is_top = false;
// }
// } else {
// article.is_top = false;
// }
Ebean.save(article);
return ok(Json.toJson(article));
}
catch (Throwable e) {
return status(ErrDefinition.E_ARTICLE_POST_ERROR,
Messages.get("articlepost.failure"));
}
}