| | 6 | 重构如下代码:[[BR]] |
| | 7 | |
| | 8 | {{{ |
| | 9 | public static String htmlUrl(Object object, int type) { |
| | 10 | boolean isIt = false; |
| | 11 | if (isIt && type != SystemConstant.TYPE_WAP ) { |
| | 12 | return ""; |
| | 13 | } else { |
| | 14 | |
| | 15 | switch (type) { |
| | 16 | case SystemConstant.TYPE_WEB: |
| | 17 | rootUrl = rootUrl; |
| | 18 | break; |
| | 19 | case SystemConstant.TYPE_WAP: |
| | 20 | rootUrl = rootUrl; |
| | 21 | break; |
| | 22 | default: |
| | 23 | break; |
| | 24 | } |
| | 25 | |
| | 26 | if ("".equals(rootUrl) || rootUrl == null) { |
| | 27 | return ""; |
| | 28 | } |
| | 29 | |
| | 30 | if (object instanceof Forum) { |
| | 31 | Forum forum = (Forum) object; |
| | 32 | if (!isEmpty(forum.getRedirectUrl()) && SystemConstant.TYPE_WEB == type) { |
| | 33 | return forum.getRedirectUrl(); |
| | 34 | } else { |
| | 35 | return rootUrl + "/forum-" + forum.getFid() + ".html"; |
| | 36 | } |
| | 37 | } else if (object instanceof Topic) { |
| | 38 | //销售配合,此帖子跳转到指定链接 |
| | 39 | if(SystemConstant.AUTO_APP_NAME.equals(appName) && ((Topic) object).getTid() == 4018911){ |
| | 40 | return "http://ad.doubleclick.net/clk;275446626;102403463;a?http://bbs.pcauto.com.cn/topic-4018911.html"; |
| | 41 | } |
| | 42 | if(SystemConstant.AUTO_APP_NAME.equals(appName) && ((Topic) object).getTid() == 4027940){ |
| | 43 | return "http://ad.doubleclick.net/clk;275446638;102403466;g?http://bbs.pcauto.com.cn/topic-4027940.html"; |
| | 44 | } |
| | 45 | if(SystemConstant.AUTO_APP_NAME.equals(appName) && ((Topic) object).getTid() == 4040395){ |
| | 46 | return "http://ad.doubleclick.net/clk;275446642;102403468;d?http://bbs.pcauto.com.cn/topic-4040395.html"; |
| | 47 | } |
| | 48 | return rootUrl + "/topic-" + ((Topic) object).getTid() + ".html"; |
| | 49 | } else if (object instanceof Post) { |
| | 50 | return rootUrl + "/post-" + ((Post) object).getTid() + '_' + ((Post) object).getPid() + ".html"; |
| | 51 | } else if (object instanceof String) { |
| | 52 | return (String) object; |
| | 53 | } else if (object instanceof User) { |
| | 54 | return "/" + ((User) object).getUid(); |
| | 55 | } else if (object instanceof ftree.Forum) { |
| | 56 | ftree.Forum forum = (ftree.Forum) object; |
| | 57 | return rootUrl + "/forum-" + forum.getFid() + ".html"; |
| | 58 | } else { |
| | 59 | return ""; |
| | 60 | } |
| | 61 | } |
| | 62 | } |
| | 63 | |
| | 64 | public static boolean isEmpty(String text){ |
| | 65 | return (null == text || "".equals(text)); |
| | 66 | } |
| | 67 | }}}[[BR]] |
| | 68 | |
| | 69 | |
| | 70 | 活动开始前,咱们组的陈阳童鞋一马当先,只管抢占键盘,是的,他只用键盘,就已经将需要重构的方法提炼出来,完全忽略鼠标,看得我眼睛一眨一眨的,暗下决定要学好vi的使用。 |
| | 71 | |
| | 72 | |
| | 73 | |
| | 74 | |
| | 75 | |
| | 76 | |
| | 77 | |
| | 78 | |
| | 79 | |
| | 80 | |
| | 81 | |
| | 82 | |
| | 83 | |
| | 84 | |
| | 85 | |
| | 86 | |
| | 87 | |