Skip to content

Commit

Permalink
添加瞅一瞅功能
Browse files Browse the repository at this point in the history
首页添加瞅一瞅功能,可以浏览网站内部公开的收藏内容。
  • Loading branch information
ityouknow committed Jul 13, 2018
1 parent 351dbc4 commit d0f11a3
Show file tree
Hide file tree
Showing 27 changed files with 215 additions and 730 deletions.
5 changes: 5 additions & 0 deletions app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
<artifactId>jsoup</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>

<build>
Expand Down
16 changes: 5 additions & 11 deletions app/src/main/java/com/favorites/comm/filter/SecurityFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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 = "<script type=\"text/javascript\">window.location.href=\"_BP_login\"</script>";
}else{
html = "<script type=\"text/javascript\">window.location.href=\"_BP_index\"</script>";
Expand All @@ -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 = "<script type=\"text/javascript\">window.location.href=\"_BP_login\"</script>";
}else{
html = "<script type=\"text/javascript\">window.location.href=\"_BP_index\"</script>";
Expand Down Expand Up @@ -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;
Expand Down
37 changes: 16 additions & 21 deletions app/src/main/java/com/favorites/domain/Comment.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ public class Comment extends Entitys implements Serializable {
@Transient
private String profilePicture;

public Comment() {
super();
}

public Long getId() {
return id;
}
Expand All @@ -48,7 +44,7 @@ public void setId(Long id) {
this.id = id;
}

public long getCollectId() {
public Long getCollectId() {
return collectId;
}

Expand All @@ -64,15 +60,15 @@ public void setContent(String content) {
this.content = content;
}

public long getUserId() {
public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}

public long getReplyUserId() {
public Long getReplyUserId() {
return replyUserId;
}

Expand All @@ -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;
}
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface CollectRepository extends JpaRepository<Collect, Long> {
+ "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'";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Collect> list = collectRepository.findByFavoritesIdAndUrlAndUserIdAndIsDelete(collect.getFavoritesId(), collect.getUrl(), collect.getUserId(),IsDelete.NO);
Expand Down
18 changes: 10 additions & 8 deletions app/src/main/java/com/favorites/web/CollectController.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,16 @@ public List<CollectSummary> standard(@RequestParam(value = "page", defaultValue
}
return collects;
}


@RequestMapping(value="/lookAround")
@LoggerManage(description="查看更多lookAround")
public List<CollectSummary> 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<CollectSummary> collects =lookAroundService.queryCollectExplore(pageable, getUserId(),null);
return collects;
}

/**
* @author neo
Expand Down Expand Up @@ -265,7 +274,6 @@ public Response delete(@PathVariable("id") long id) {
return result();
}


/**
* @author neo
* @date 2016年8月24日
Expand Down Expand Up @@ -352,9 +360,6 @@ public void export(String favoritesId,HttpServletResponse response){
}





@RequestMapping(value="/searchMy/{key}")
public List<CollectSummary> searchMy(Model model,@RequestParam(value = "page", defaultValue = "0") Integer page,
@RequestParam(value = "size", defaultValue = "20") Integer size, @PathVariable("key") String key) {
Expand All @@ -366,8 +371,6 @@ public List<CollectSummary> searchMy(Model model,@RequestParam(value = "page", d
return myCollects;
}



@RequestMapping(value="/searchOther/{key}")
public List<CollectSummary> searchOther(Model model,@RequestParam(value = "page", defaultValue = "0") Integer page,
@RequestParam(value = "size", defaultValue = "20") Integer size, @PathVariable("key") String key) {
Expand All @@ -391,5 +394,4 @@ public Map<String,Object> getPraiseStatus(Model model,@PathVariable("collectId")
return maps;
}


}
10 changes: 5 additions & 5 deletions app/src/main/java/com/favorites/web/CommentController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down Expand Up @@ -113,13 +113,13 @@ public Response delete(@PathVariable("id") long id) {
*/
private List<Comment> convertComment(List<Comment> 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;
Expand Down
20 changes: 5 additions & 15 deletions app/src/main/java/com/favorites/web/IndexController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<CollectSummary> collects = null;
List<CollectSummary> fivecollects = lookAroundService.scrollFiveCollect();
List<UserIsFollow> fiveUsers = lookAroundService.queryFiveUser(this.getUserId());
collects =lookAroundService.queryCollectExplore(pageable,getUserId(),category);
List<CollectSummary> 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
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ file.backgroundpictures.url=backgroundpictures/
#\u90AE\u4EF6\u914D\u7F6E
spring.mail.host=smtp.126.com
spring.mail.username=[email protected]
spring.mail.password=
spring.mail.password=ritesxxx123
spring.mail.port=465

#\u767B\u5F55\u670D\u52A1\u5668\u662F\u5426\u9700\u8981\u8BA4\u8BC1
Expand All @@ -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:<br /><a href='{0}'>\u91CD\u7F6E\u5BC6\u7801</a>
##### mail setting end #####
##### mail setting end #####

spring.thymeleaf.cache=false
5 changes: 4 additions & 1 deletion app/src/main/resources/application-docker.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:<br /><a href='{0}'>\u91CD\u7F6E\u5BC6\u7801</a>
##### mail setting end #####
##### mail setting end #####

spring.thymeleaf.cache=true
3 changes: 2 additions & 1 deletion app/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
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 ######


static.url = /usr/local/static
file.profilepictures.url = file/profilepictures/
file.backgroundpictures.url = file/backgroundpictures/

spring.thymeleaf.cache=true
spring.profiles.active=dev


Expand Down
Loading

0 comments on commit d0f11a3

Please sign in to comment.