diff --git a/app/pom.xml b/app/pom.xml index e42421e7..6a8ae779 100644 --- a/app/pom.xml +++ b/app/pom.xml @@ -75,6 +75,11 @@ jsoup 1.9.2 + + org.webjars + jquery + 2.0.0 + diff --git a/app/src/main/java/com/favorites/comm/filter/SecurityFilter.java b/app/src/main/java/com/favorites/comm/filter/SecurityFilter.java index e009d807..bf20c784 100644 --- a/app/src/main/java/com/favorites/comm/filter/SecurityFilter.java +++ b/app/src/main/java/com/favorites/comm/filter/SecurityFilter.java @@ -76,8 +76,7 @@ public void doFilter(ServletRequest srequest, ServletResponse sresponse, FilterC logger.info("userId :" + user.getId()); request.getSession().setAttribute(Const.LOGIN_SESSION_KEY, user); String referer = this.getRef(request); - if(referer.indexOf("/collect?") >= 0 || referer.indexOf("/lookAround/standard/") >= 0 - || referer.indexOf("/lookAround/simple/") >= 0){ + if(referer.indexOf("/collect?") >= 0 || referer.indexOf("/lookAround") >= 0){ filterChain.doFilter(srequest, sresponse); return; }else{ @@ -97,8 +96,7 @@ public void doFilter(ServletRequest srequest, ServletResponse sresponse, FilterC String referer = this.getRef(request); logger.debug("security filter, deney, " + request.getRequestURI()); String html = ""; - if(referer.contains("/collect?") || referer.contains("/lookAround/standard/") - || referer.contains("/lookAround/simple/")){ + if(referer.contains("/collect?") || referer.contains("/lookAround")){ html = ""; }else{ html = ""; @@ -111,8 +109,7 @@ public void doFilter(ServletRequest srequest, ServletResponse sresponse, FilterC String referer = this.getRef(request); logger.debug("security filter, deney, " + request.getRequestURI()); String html = ""; - if(referer.contains("/collect?") || referer.contains("/lookAround/standard/") - || referer.contains("/lookAround/simple/")){ + if(referer.contains("/collect?") || referer.contains("/lookAround")){ html = ""; }else{ html = ""; @@ -171,13 +168,10 @@ private boolean containsKey(String url) { || (url.contains("/collector") && !url.contains("/collect/detail/")) || url.contains("/collect/standard/")||url.contains("/collect/simple/") || url.contains("/user")||url.contains("/favorites")||url.contains("/comment") - || url.startsWith("/lookAround/standard/") - || url.startsWith("/lookAround/simple/") + || url.contains("/lookAround") || url.startsWith("/user/") || url.startsWith("/feedback") - || url.startsWith("/standard/") - || url.startsWith("/collect/standard/lookAround/") - || url.startsWith("/collect/simple/lookAround/")) { + || url.startsWith("/standard/")) { return true; } else { return false; diff --git a/app/src/main/java/com/favorites/domain/Comment.java b/app/src/main/java/com/favorites/domain/Comment.java index e972eeb8..f78b7f04 100644 --- a/app/src/main/java/com/favorites/domain/Comment.java +++ b/app/src/main/java/com/favorites/domain/Comment.java @@ -36,10 +36,6 @@ public class Comment extends Entitys implements Serializable { @Transient private String profilePicture; - public Comment() { - super(); - } - public Long getId() { return id; } @@ -48,7 +44,7 @@ public void setId(Long id) { this.id = id; } - public long getCollectId() { + public Long getCollectId() { return collectId; } @@ -64,7 +60,7 @@ public void setContent(String content) { this.content = content; } - public long getUserId() { + public Long getUserId() { return userId; } @@ -72,7 +68,7 @@ public void setUserId(Long userId) { this.userId = userId; } - public long getReplyUserId() { + public Long getReplyUserId() { return replyUserId; } @@ -84,14 +80,6 @@ public Long getCreateTime() { return createTime; } - public String getProfilePicture() { - return profilePicture; - } - - public void setProfilePicture(String profilePicture) { - this.profilePicture = profilePicture; - } - public void setCreateTime(Long createTime) { this.createTime = createTime; } @@ -112,12 +100,19 @@ public void setUserName(String userName) { this.userName = userName; } - public String getReplyUserName() { - return replyUserName; - } + public String getReplyUserName() { + return replyUserName; + } - public void setReplyUserName(String replyUserName) { - this.replyUserName = replyUserName; - } + public void setReplyUserName(String replyUserName) { + this.replyUserName = replyUserName; + } + public String getProfilePicture() { + return profilePicture; + } + + public void setProfilePicture(String profilePicture) { + this.profilePicture = profilePicture; + } } \ No newline at end of file diff --git a/app/src/main/java/com/favorites/domain/view/CollectSummary.java b/app/src/main/java/com/favorites/domain/view/CollectSummary.java index ae80eef3..95efcde4 100644 --- a/app/src/main/java/com/favorites/domain/view/CollectSummary.java +++ b/app/src/main/java/com/favorites/domain/view/CollectSummary.java @@ -33,6 +33,7 @@ public CollectSummary(CollectView view) { this.userId = view.getUserId(); this.profilePicture = view.getProfilePicture(); this.favoritesId = view.getFavoritesId(); + this.favoriteName=view.getFavoriteName(); this.url = view.getUrl(); this.title = view.getTitle(); this.description = view.getDescription(); diff --git a/app/src/main/java/com/favorites/repository/CollectRepository.java b/app/src/main/java/com/favorites/repository/CollectRepository.java index fd36d056..ecb6cfb0 100644 --- a/app/src/main/java/com/favorites/repository/CollectRepository.java +++ b/app/src/main/java/com/favorites/repository/CollectRepository.java @@ -23,7 +23,7 @@ public interface CollectRepository extends JpaRepository { + "from Collect c,User u,Favorites f WHERE c.userId=u.id and c.favoritesId=f.id and c.isDelete='NO'"; public String isDeleteBaseSql="select c.id as id,c.title as title, c.type as type,c.url as url,c.logoUrl as logoUrl,c.userId as userId, " - + "c.remark as remark,c.description as description,c.lastModifyTime as lastModifyTime, " + + "c.remark as remark,c.description as description,c.lastModifyTime as lastModifyTime,c.createTime as createTime, " + "u.userName as userName,u.profilePicture as profilePicture,f.id as favoritesId,f.name as favoriteName " + "from Collect c,User u,Favorites f WHERE c.userId=u.id and c.favoritesId=f.id and c.isDelete='YES'"; diff --git a/app/src/main/java/com/favorites/service/impl/CollectServiceImpl.java b/app/src/main/java/com/favorites/service/impl/CollectServiceImpl.java index 50b71089..f5d5d87f 100644 --- a/app/src/main/java/com/favorites/service/impl/CollectServiceImpl.java +++ b/app/src/main/java/com/favorites/service/impl/CollectServiceImpl.java @@ -271,7 +271,7 @@ public boolean checkCollect(Collect collect){ }else{ if(collect.getId() != null){ Collect c = collectRepository.findById(collect.getId().longValue()); - if(c.getFavoritesId().longValue() == collect.getFavoritesId().longValue()){ + if(c.getFavoritesId().equals(collect.getFavoritesId())){ return true; }else{ List list = collectRepository.findByFavoritesIdAndUrlAndUserIdAndIsDelete(collect.getFavoritesId(), collect.getUrl(), collect.getUserId(),IsDelete.NO); diff --git a/app/src/main/java/com/favorites/web/CollectController.java b/app/src/main/java/com/favorites/web/CollectController.java index b3613b91..3e937650 100644 --- a/app/src/main/java/com/favorites/web/CollectController.java +++ b/app/src/main/java/com/favorites/web/CollectController.java @@ -177,7 +177,16 @@ public List standard(@RequestParam(value = "page", defaultValue } return collects; } - + + @RequestMapping(value="/lookAround") + @LoggerManage(description="查看更多lookAround") + public List lookAround(@RequestParam(value = "page", defaultValue = "0") Integer page, + @RequestParam(value = "size", defaultValue = "15") Integer size) { + Sort sort = new Sort(Direction.DESC, "id"); + Pageable pageable = PageRequest.of(page, size, sort); + List collects =lookAroundService.queryCollectExplore(pageable, getUserId(),null); + return collects; + } /** * @author neo @@ -265,7 +274,6 @@ public Response delete(@PathVariable("id") long id) { return result(); } - /** * @author neo * @date 2016年8月24日 @@ -352,9 +360,6 @@ public void export(String favoritesId,HttpServletResponse response){ } - - - @RequestMapping(value="/searchMy/{key}") public List searchMy(Model model,@RequestParam(value = "page", defaultValue = "0") Integer page, @RequestParam(value = "size", defaultValue = "20") Integer size, @PathVariable("key") String key) { @@ -366,8 +371,6 @@ public List searchMy(Model model,@RequestParam(value = "page", d return myCollects; } - - @RequestMapping(value="/searchOther/{key}") public List searchOther(Model model,@RequestParam(value = "page", defaultValue = "0") Integer page, @RequestParam(value = "size", defaultValue = "20") Integer size, @PathVariable("key") String key) { @@ -391,5 +394,4 @@ public Map getPraiseStatus(Model model,@PathVariable("collectId") return maps; } - } \ No newline at end of file diff --git a/app/src/main/java/com/favorites/web/CommentController.java b/app/src/main/java/com/favorites/web/CommentController.java index 94fb685a..f14910c1 100644 --- a/app/src/main/java/com/favorites/web/CommentController.java +++ b/app/src/main/java/com/favorites/web/CommentController.java @@ -68,7 +68,7 @@ public Response add(Comment comment) { noticeService.saveNotice(String.valueOf(comment.getCollectId()), "comment", user.getId(), String.valueOf(comment.getId())); }else{ // 保存消息通知(直接评论) - Collect collect = colloectRepository.findById(comment.getCollectId()); + Collect collect = colloectRepository.findById((long)comment.getCollectId()); if(null != collect){ noticeService.saveNotice(String.valueOf(comment.getCollectId()), "comment", collect.getUserId(), String.valueOf(comment.getId())); } @@ -113,13 +113,13 @@ public Response delete(@PathVariable("id") long id) { */ private List convertComment(List comments) { for (Comment comment : comments) { - User user = userRepository.findById(comment.getUserId()); + User user = userRepository.findById((long)comment.getUserId()); comment.setCommentTime(DateUtils.getTimeFormatText(comment.getCreateTime())); comment.setUserName(user.getUserName()); comment.setProfilePicture(user.getProfilePicture()); - if(comment.getReplyUserId()!=0){ - User replyUser = userRepository.findById(comment.getReplyUserId()); - comment.setReplyUserName(replyUser.getUserName()); + if(comment.getReplyUserId()!=null && comment.getReplyUserId()!=0){ + User replyUser = userRepository.findById((long)comment.getReplyUserId()); + comment.setReplyUserName(replyUser.getUserName()); } } return comments; diff --git a/app/src/main/java/com/favorites/web/IndexController.java b/app/src/main/java/com/favorites/web/IndexController.java index 31e02bed..83e3dd7f 100644 --- a/app/src/main/java/com/favorites/web/IndexController.java +++ b/app/src/main/java/com/favorites/web/IndexController.java @@ -87,37 +87,27 @@ public String home(Model model) { } /** - * 随便看看 标准模式显示 added by chenzhimin 暂时去掉,以后优化更新 + * 随便看看 标准模式显示 * @return */ - /*@RequestMapping(value="/lookAround/standard/{category}") + @RequestMapping(value="/lookAround") @LoggerManage(description="随便看看页面") public String lookAroundStandard(Model model,@RequestParam(value = "page", defaultValue = "0") Integer page, - @RequestParam(value = "size", defaultValue = "15") Integer size, - @PathVariable("category") String category) { + @RequestParam(value = "size", defaultValue = "15") Integer size) { Sort sort = new Sort(Sort.Direction.DESC, "id"); Pageable pageable = PageRequest.of(page, size,sort); - model.addAttribute("category", category); model.addAttribute("type", "lookAround"); - Favorites favorites = new Favorites(); - List collects = null; - List fivecollects = lookAroundService.scrollFiveCollect(); - List fiveUsers = lookAroundService.queryFiveUser(this.getUserId()); - - collects =lookAroundService.queryCollectExplore(pageable,getUserId(),category); + List collects =lookAroundService.queryCollectExplore(pageable,getUserId(),null); User user = super.getUser(); if(null != user){ model.addAttribute("user",user); } - model.addAttribute("fiveCollects", fivecollects); - model.addAttribute("fiveUsers", fiveUsers); model.addAttribute("collects", collects); - model.addAttribute("favorites", favorites); model.addAttribute("userId", getUserId()); model.addAttribute("size", collects.size()); return "lookAround/standard"; - }*/ + } /** * 随便看看 简单模式显示 added by chenzhimin diff --git a/app/src/main/resources/application-dev.properties b/app/src/main/resources/application-dev.properties index 59fc95a9..e6ca51fe 100644 --- a/app/src/main/resources/application-dev.properties +++ b/app/src/main/resources/application-dev.properties @@ -30,7 +30,7 @@ file.backgroundpictures.url=backgroundpictures/ #\u90AE\u4EF6\u914D\u7F6E spring.mail.host=smtp.126.com spring.mail.username=cloudfavorites@126.com -spring.mail.password= +spring.mail.password=ritesxxx123 spring.mail.port=465 #\u767B\u5F55\u670D\u52A1\u5668\u662F\u5426\u9700\u8981\u8BA4\u8BC1 @@ -45,4 +45,6 @@ spring.mail.self.username=\u4E91\u6536\u85CF mail.subject.forgotpassword=\u5BC6\u7801\u91CD\u7F6E\u90AE\u4EF6 mail.content.forgotpassword=\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u5730\u5740:\u91CD\u7F6E\u5BC6\u7801 -##### mail setting end ##### \ No newline at end of file +##### mail setting end ##### + +spring.thymeleaf.cache=false \ No newline at end of file diff --git a/app/src/main/resources/application-docker.properties b/app/src/main/resources/application-docker.properties index 35450f26..6426bb73 100644 --- a/app/src/main/resources/application-docker.properties +++ b/app/src/main/resources/application-docker.properties @@ -3,6 +3,7 @@ spring.datasource.url=jdbc:mysql://mysql:3306/favorites?useUnicode=true&characte spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-class-name=com.mysql.jdbc.Driver +spring.datasource.hikari.connectionInitSql=SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci; spring.datasource.max-active=20 spring.datasource.max-idle=30 spring.datasource.min-idle=6 @@ -44,4 +45,6 @@ spring.mail.self.username=\u4E91\u6536\u85CF mail.subject.forgotpassword=\u5BC6\u7801\u91CD\u7F6E\u90AE\u4EF6 mail.content.forgotpassword=\u8BF7\u70B9\u51FB\u4EE5\u4E0B\u5730\u5740:\u91CD\u7F6E\u5BC6\u7801 -##### mail setting end ##### \ No newline at end of file +##### mail setting end ##### + +spring.thymeleaf.cache=true \ No newline at end of file diff --git a/app/src/main/resources/application.properties b/app/src/main/resources/application.properties index bf407507..71ee08c8 100644 --- a/app/src/main/resources/application.properties +++ b/app/src/main/resources/application.properties @@ -2,6 +2,8 @@ spring.jpa.properties.hibernate.hbm2ddl.auto=update spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect spring.jpa.show-sql= true +spring.datasource.hikari.connectionInitSql=SET NAMES utf8mb4 COLLATE utf8mb4_unicode_ci; + ###### data config end ###### @@ -9,7 +11,6 @@ static.url = /usr/local/static file.profilepictures.url = file/profilepictures/ file.backgroundpictures.url = file/backgroundpictures/ -spring.thymeleaf.cache=true spring.profiles.active=dev diff --git a/app/src/main/resources/static/js/collect.js b/app/src/main/resources/static/js/collect.js index c0d58f89..08a8e02c 100644 --- a/app/src/main/resources/static/js/collect.js +++ b/app/src/main/resources/static/js/collect.js @@ -1,3 +1,5 @@ + + $(function(){ $("#changeModel1").click(function(){ $("#show2").show(); @@ -503,8 +505,6 @@ function loadStandardMore(){ }, success: function(collects){ if(collects.length==0){ - /*$("#loadStandardNoMore").show();*/ - /*$("#loadStandardMore").hide();*/ $("#loadStandardMore").text('没有更多了'); } if($("#userContent").val()== 'usercontent'){ @@ -518,6 +518,29 @@ function loadStandardMore(){ } +function lookAroundMore(){ + $.ajax({ + async: false, + type: 'POST', + dataType: 'json', + data:'page='+page, + url:'/collect/lookAround', + error : function(XMLHttpRequest, textStatus, errorThrown) { + console.log(XMLHttpRequest); + console.log(textStatus); + console.log(errorThrown); + }, + success: function(collects){ + if(collects.length==0){ + $("#loadStandardMore").text('没有更多了'); + $("#loadStandardMore").show(); + } + listStandardCollect(collects,'collectStandardList',''); + page++; + } + }); +} + function loadMyMore(){ $('#loadMyMore').hide(); $('#loadingMy').show(); @@ -700,9 +723,15 @@ function listStandardCollect(collects,listId,user){ " "+ " "+ " "+ - " "+ - " "+ - " "+collects[i].favoriteName+""+ + " " + + if($('#lookAround').length >= 1){ + item=item+" " + }else{ + item=item+" "+ + " "+collects[i].favoriteName+"" + } + item=item+ " "+ " "+ " "+ @@ -857,18 +886,30 @@ $(function() { $(window).scroll(function() { if ($(window).scrollTop() == $(document).height() - $(window).height()) { - if ($('#standard').length >= 1 && $('#simple').length >= 1) { - if ($('#standard').is(':visible')) { - if ($('#loadStandardMore').text() == '加载更多') { - if (loadingFlag) { - loadingFlag = false; - $('#loadingStandard').show(); - loadStandardMore(); - $('#loadingStandard').hide(); - loadingFlag = true; + if ($('#lookAround').length >= 1) { + if ($('#standard').is(':visible')) { + if ($('#loadStandardMore').text() == '加载更多') { + if (loadingFlag) { + loadingFlag = false; + $('#loadingStandard').show(); + lookAroundMore(); + $('#loadingStandard').hide(); + loadingFlag = true; + } + } + } + } else if ($('#standard').length >= 1 && $('#simple').length >= 1) { + if ($('#standard').is(':visible')) { + if ($('#loadStandardMore').text() == '加载更多') { + if (loadingFlag) { + loadingFlag = false; + $('#loadingStandard').show(); + loadStandardMore(); + $('#loadingStandard').hide(); + loadingFlag = true; + } } - } - } else if ($('#simple').is(':visible')) { + } else if ($('#simple').is(':visible')) { if ($('#loadSimpleMore').text() == '加载更多') { if (loadingFlag) { loadingFlag = false; @@ -904,17 +945,4 @@ $(function() { }); }); -function lookAroundInit(category){ - - var categoryArr = ['ALL','TRAVEL','FOOD','EXERCISE','PHOTOGRAPH','MUSIC','REARING', - 'LOVE','BUSINESS','ART','MANAGER','MARKET','RUNNING']; - $("#category"+category).addClass('active'); - for(var i = 0; i < categoryArr.length; i++){ - if(categoryArr[i] != category){ - $("#category"+categoryArr[i]).removeClass('active'); - } - } - loadConfig(); - loadFavorites(); -} diff --git a/app/src/main/resources/static/js/comm.js b/app/src/main/resources/static/js/comm.js index 5ad97781..b26af0cb 100644 --- a/app/src/main/resources/static/js/comm.js +++ b/app/src/main/resources/static/js/comm.js @@ -145,6 +145,9 @@ function handleServerResponse() { } function smartFavoritesFun(title,description,selectLabelName){ + if ($('#userId').val() == "" || $('#userId').val() == 0) { + return; + } $.ajax({ type: "POST", url:"/collect/getFavoriteResult", diff --git a/app/src/main/resources/static/js/lookAround.js b/app/src/main/resources/static/js/lookAround.js index c7ef4db9..3377375e 100644 --- a/app/src/main/resources/static/js/lookAround.js +++ b/app/src/main/resources/static/js/lookAround.js @@ -130,4 +130,11 @@ function initFavorites(favorites){ $("#favoritesSelect").append("" + name + ""); $("#layoutFavoritesName").append("" + name + ""); } +} + +function lookAroundInit(){ + if ($('#userId').val() != "" && $('#userId').val() != 0) { + loadConfig(); + loadFavorites(); + } } \ No newline at end of file diff --git a/app/src/main/resources/templates/collect.html b/app/src/main/resources/templates/collect.html index 83459b16..60b7df7d 100644 --- a/app/src/main/resources/templates/collect.html +++ b/app/src/main/resources/templates/collect.html @@ -134,7 +134,7 @@ - - 未读列表中的内容将从收集当日起30天后自动进入回收站,赶紧给收藏分类吧~ - - - 未读列表是空的 - 您的收藏都整洁有序,恭喜您! - (在未读列表中的收藏,30天后自动进入右上角的回收站) - - - - 您和您的好友,暂未收藏 - 第一次使用,需要安装网页收集工具 - 点击下面按钮,进行安装。 - - 去安装 - - - - - - (8) - (8) - - - - - 删除 - - - - 回收站 - 未读列表中的收藏30天后会自动被清理到这里。 - 您可以将该收藏重新换个收藏夹,就能从回收站中移出。 - - - - - 此收藏夹为空 - - - - - - - - - - - - - - - - - - - - - - - - - - - 修改收藏 - - 修改收藏的各种属性 - - - - - - - - - - 删除 - - 该分享会永久删除 - - - - - - - - - user name - - - - - - 6天前 - - - - - - - - - title - - title - - description - - - - - - 文件加名称 - - - - - - | - - - - - - - | - - - 评论(0) - - | - - 收藏 - - - - - - - - - - - - 发送 - - - - - - - - - - - @@ -402,17 +219,12 @@ - - - - - @@ -422,21 +234,12 @@
您的收藏都整洁有序,恭喜您!
(在未读列表中的收藏,30天后自动进入右上角的回收站)
第一次使用,需要安装网页收集工具
点击下面按钮,进行安装。
- 去安装 -
未读列表中的收藏30天后会自动被清理到这里。
您可以将该收藏重新换个收藏夹,就能从回收站中移出。
修改收藏
- 修改收藏的各种属性 -
删除
- 该分享会永久删除 -
description