/** * 获取下一篇文章ID,使用select for update 保证id自增 * * @return */ @Transactional public String getNextPostid() { String currentid = optionsService.getOptionValueForUpdate(OptionConstants.POSTID); int id = NumberUtils.toInteger(currentid, PostConstants.INIT_POST_ID); id++; optionsService.updateOptionValue(OptionConstants.POSTID, id + ""); return id + ""; }
public PostOption getPostOption() { PostOption option = new PostOption(); option.setMaxshow( NumberUtils.toInteger(optionsService.getOptionValue(OptionConstants.MAXSHOW), 10)); option.setAllowComment( Boolean.parseBoolean(optionsService.getOptionValue(OptionConstants.ALLOW_COMMENT))); option.setDefaultCategory(optionsService.getOptionValue(OptionConstants.DEFAULT_CATEGORY_ID)); return option; }