public static UserVo convert(User user) { UserVo userVo = new UserVo(); if (user == null) { return userVo; } userVo.setUserId(user.getUserId()); userVo.setUsername(user.getUsername()); userVo.setFbId(user.getFbId()); userVo.setContact(user.getContact()); userVo.setMobilePhone(user.getMobilePhone()); userVo.setEmail(user.getEmail()); userVo.setIsEnable(user.getIsEnable()); userVo.setPhone(user.getPhone()); userVo.setIndustry(user.getIndustry()); userVo.setInvoiceAddr(user.getInvoiceAddr()); userVo.setIsNew(user.getIsNew()); userVo.setUrl(user.getUrl()); userVo.setCompanyInfo(user.getCompanyInfo()); userVo.setFounderInfo(user.getFounderInfo()); userVo.setIndustryOther(user.getIndustryOther()); userVo.setCompany(user.getCompany()); userVo.setUserNo(user.getUserNo()); userVo.setUpdateTime(DateUtil.yyyyMMddHHmmss(user.getUpdateTime())); userVo.setCreateTime(DateUtil.yyyyMMddHHmmss(user.getCreateTime())); return userVo; }
public static ArticleVo convert(Article article) { ArticleVo articleVo = new ArticleVo(); articleVo.setId(article.getId()); articleVo.setAuthor(article.getAuthor()); articleVo.setTopic(article.getTopic()); // articleVo.setContent(StringEscapeUtils.escapeHtml(article.getContent())); articleVo.setContent(article.getContent()); articleVo.setKeywords(article.getKeywords()); articleVo.setCreateTime(DateUtil.yyyyMMddHHmmss(article.getCreateTime())); articleVo.setModifyTime(DateUtil.yyyyMMddHHmmss(article.getModifyTime())); articleVo.setIsEnable(Boolean.TRUE); if (article.getArticleStatus() == ArticleStatusEnums.DISABLE) { articleVo.setIsEnable(Boolean.FALSE); } articleVo.setArticleStatus(article.getArticleStatus()); articleVo.setPopularIndex(article.getPopularIndex()); articleVo.setYoutubeUrl(article.getYoutubeUrl()); articleVo.setYoutubeUrl2(article.getYoutubeUrl2()); articleVo.setYoutubeUrl3(article.getYoutubeUrl3()); articleVo.setEfficiency(article.getEfficiency()); articleVo.setArticleTypeEnums(article.getArticleType()); articleVo.setRemark(article.getRemark()); return articleVo; }
public static PrVo convert(Pr pr) { User user = pr.getUser(); PrVo prVo = new PrVo(); prVo.setPrId(pr.getPrId()); List<PrContent> prContentGrp = pr.getPrContentGrp(); Hibernate.initialize(prContentGrp); if (prContentGrp != null) { for (PrContent prContent : prContentGrp) { prVo.getPrContentVoGrp().add(convert(prContent)); } } Set<Article> successCaseGrp = pr.getSuccessCaseGrp(); Hibernate.initialize(successCaseGrp); if (successCaseGrp != null) { for (Article article : successCaseGrp) { prVo.getArticleVoGrp().add(convert(article)); if (StringUtil.isBlank(prVo.getCoverYoutubeUrl())) { prVo.setCoverYoutubeUrl(article.getYoutubeUrl()); } } } prVo.setAuthorUsername(user.getUsername()); prVo.setCompany(user.getCompany()); prVo.setPhoneNumber(user.getPhone()); prVo.setCompanyUrl(user.getUrl()); prVo.setPrNo(pr.getPrNo()); prVo.setEmail(user.getEmail()); prVo.setTitle(pr.getTitle()); prVo.setTitleSuggestion(pr.getTitleSuggestion()); prVo.setImageSuggetion(pr.getImageSuggestion()); prVo.setPrStatus(pr.getPrStatus()); prVo.setAuthor(user.getContact()); prVo.setCreateTime(DateUtil.yyyyMMddHHmmss(pr.getCreateTime())); prVo.setMonth(pr.getCreateTime().getMonth() + 1); prVo.setDay(pr.getCreateTime().getDate()); prVo.setSeqNo(user.getUserNo()); prVo.setAllowRemodel(pr.getAllowRemodel()); prVo.setCompanyInfo(user.getCompanyInfo()); prVo.setFounderInfo(user.getFounderInfo()); prVo.setQuote(pr.getQuote()); for (PrPhoto prPhoto : pr.getPrPhotoGrp()) { PrPhotoVo prPhotoVo = new PrPhotoVo(); prPhotoVo.setPrPhotoId(prPhoto.getId()); prPhotoVo.setFilePath(prPhoto.getFilePath()); prVo.getPrPhotoVoGrp().add(prPhotoVo); } prVo.setUpdateTime(DateUtil.yyyyMMddHHmmss(pr.getUpdateTime())); prVo.setReleaseDay(DateUtil.yyyyMMdd(pr.getUpdateTime())); return prVo; }
public static OperatorVo convert(Operator operator) { OperatorVo operatorVo = new OperatorVo(); operatorVo.setAccount(operator.getAccount()); operatorVo.setCreateTime(DateUtil.yyyyMMddHHmmss(operator.getCreateTime())); operatorVo.setId(operator.getId()); operatorVo.setIsEnable(operator.getIsEnable()); operatorVo.setModifyTime(DateUtil.yyyyMMddHHmmss(operator.getModifyTime())); operatorVo.setRemark(operator.getRemark()); operatorVo.setOperatorRole(operator.getOperatorRole()); operatorVo.setOperatorRoleStr(operator.getOperatorRole().getText()); operatorVo.setEmail(operator.getEmail()); operatorVo.setFinalLoginTime(DateUtil.yyyyMMddHHmmss(operator.getFinalLoginTime())); operatorVo.setPwd(operator.getPwd()); return operatorVo; }
public static ArticleBriefVo convert2ArticleBrief(Article article) { ArticleBriefVo articleBriefVo = new ArticleBriefVo(); articleBriefVo.setId(article.getId()); articleBriefVo.setAuthor(article.getNicname()); articleBriefVo.setTopic(article.getTopic()); articleBriefVo.setEfficiency(article.getEfficiency()); articleBriefVo.setYoutubeUrl(article.getYoutubeUrl()); String content = article.getContent(); if (StringUtil.isNotBlank(content)) { content = Jsoup.parse(content).text(); articleBriefVo.setContent(StringUtil.summary(content, 100)); } Timestamp createTime = article.getCreateTime(); articleBriefVo.setCreateTime(DateUtil.dateDiff(createTime)); articleBriefVo.setPopularIndex(article.getPopularIndex()); List<String> keywordGrp = new ArrayList<String>(); String keywords = article.getKeywords(); if (StringUtil.isNotEmpty(keywords)) { for (String t : keywords.split(",")) { keywordGrp.add(t); } } articleBriefVo.setKeywordsGrp(keywordGrp); return articleBriefVo; }
public static PlatformVo convert(Platform platform) { PlatformVo platformVo = new PlatformVo(); platformVo.setId(platform.getId()); platformVo.setName(platform.getName()); platformVo.setAccount(platform.getAccount()); platformVo.setCreateTime(DateUtil.yyyyMMddHHmmss(platform.getCreateTime())); platformVo.setIsEnable(platform.getIsEnable()); platformVo.setModifyTime(DateUtil.yyyyMMddHHmmss(platform.getModifyTime())); platformVo.setPlatformEnum(platform.getPlatformEnum()); platformVo.setPlatform(platform.getPlatformEnum().getText()); platformVo.setRemark(platform.getRemark()); String url = platform.getUrl(); if (StringUtil.isNotBlank(url)) { url = url.replaceAll("\\\\", "/"); // 在firefox,要把斜線換成反斜線才能運作 platformVo.setUrl(url); } return platformVo; }