Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
ityouknow committed May 22, 2018
1 parent 0cfdf8e commit 34ab3e9
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 28 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/com/favorites/cache/CacheService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public String getMap(String key){


public void addMaps(String key){
if(key.contains("?")){
key=key.substring(0,key.indexOf("?"));
}
String logoUrl = HtmlUtil.getImge(key);
maps.put(key,logoUrl);
UrlLibrary urlLibrary = new UrlLibrary();
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/favorites/comm/aop/LoggerAdvice.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void addAfterThrowingLogger(JoinPoint joinPoint, LoggerManage loggerManag
}

private String parseParames(Object[] parames) {
if (null == parames || parames.length <= 0) {
if (null == parames || parames.length <= 0 || parames.length >10240) {
return "";
}
StringBuffer param = new StringBuffer("传入参数[{}] ");
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/favorites/domain/Collect.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Collect implements Serializable {
private Long userId;
@Column(nullable = false)
private Long favoritesId;
@Column(nullable = false, columnDefinition = "varchar(500)")
@Column(nullable = false, columnDefinition = "varchar(600)")
private String url;
@Column(nullable = false)
private String title;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/favorites/domain/UrlLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ public class UrlLibrary extends Entitys implements Serializable{
@Id
@GeneratedValue(strategy= GenerationType.IDENTITY)
private Long id;
@Column(nullable = false)
@Column(nullable = false, columnDefinition = "varchar(600)")
private String url;
@Column(nullable = true)
@Column(nullable = true,columnDefinition = "varchar(300)")
private String logoUrl;
@Column(columnDefinition="INT default 0")
private int count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ public void saveCollect(Collect collect) {
if(StringUtils.isBlank(collect.getDescription())){
collect.setDescription(collect.getTitle());
}
if(collect.getUrl().contains("?")){
collect.setUrl(collect.getUrl().substring(0,collect.getUrl().indexOf("?")));
}
collect.setIsDelete(IsDelete.NO);
collect.setCreateTime(DateUtils.getCurrentTime());
collect.setLastModifyTime(DateUtils.getCurrentTime());
Expand Down
38 changes: 20 additions & 18 deletions app/src/main/java/com/favorites/utils/HtmlUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class HtmlUtil {
public static String getImge(String url){
String logo="";
logo=getPageImg(url);
if(StringUtils.isBlank(logo)){
if(StringUtils.isBlank(logo) || logo.length()>300){
logo=Const.BASE_PATH + Const.default_logo;
}
return logo;
Expand Down Expand Up @@ -60,27 +60,29 @@ public static String getPageImg(String url){
}
// 判断图片大小
String fileUrl = download(imgUrl);
File picture = new File(fileUrl);
FileInputStream in = new FileInputStream(picture);
BufferedImage sourceImg = ImageIO.read(in);
String weight = String.format("%.1f",picture.length()/1024.0);
int width = sourceImg.getWidth();
int height = sourceImg.getHeight();
// 删除临时文件
if(picture.exists()){
in.close();
picture.delete();
}
if(Double.parseDouble(weight) <= 0 || width <=0 || height <= 0){
logger.info("当前图片大小为0,继续获取图片链接");
imgUrl="";
}else{
break;
if(fileUrl!=null){
File picture = new File(fileUrl);
FileInputStream in = new FileInputStream(picture);
BufferedImage sourceImg = ImageIO.read(in);
String weight = String.format("%.1f",picture.length()/1024.0);
int width = sourceImg.getWidth();
int height = sourceImg.getHeight();
// 删除临时文件
if(picture.exists()){
in.close();
picture.delete();
}
if(Double.parseDouble(weight) <= 0 || width <=0 || height <= 0){
logger.info("当前图片大小为0,继续获取图片链接");
imgUrl="";
}else{
break;
}
}
}
} catch (Exception e) {
// TODO: handle exception
logger.error("getPageImg失败,url:"+url,e);
logger.warn("getPageImg 失败,url:"+url,e.getMessage());
}
return imgUrl;
}
Expand Down
16 changes: 10 additions & 6 deletions app/src/main/resources/templates/tool.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
<section layout:fragment="content">
<div class="content-wrapper">
<h3>网页收集工具</h3>
<!--<p><span>1.chrome浏览器插件</span>-->
<!--<a target="_blank" href="https://chrome.google.com/webstore/detail/%E4%BA%91%E6%94%B6%E8%97%8F/gnidnmkcdgfiemdaeijncglpgldflhbb?hl=zh-CN" class="btn btn-primary">下载</a></p>-->
<!--<p></p>-->
<span>网页收集小工具</span>
<a th:href="@{${path}}" onclick="alert('请把这个按钮拖到您的浏览器书签栏'); return false;" class="btn btn-primary">云收藏</a>
<span>(将该按钮拖动至浏览器书签栏,如下图)</span>
<div>
<h5>1、使用浏览器扩展收藏网页</h5>
支持:Chrome/360极速/QQ/UC/百度浏览器
<a target="_blank" href="https://chrome.google.com/webstore/detail/%E4%BA%91%E6%94%B6%E8%97%8F/gnidnmkcdgfiemdaeijncglpgldflhbb?hl=zh-CN" class="btn btn-primary">下载</a>
</div>
<div>
<h5>2、网页收集小工具</h5>
<a th:href="@{${path}}" onclick="alert('请把这个按钮拖到您的浏览器书签栏'); return false;" class="btn btn-primary">云收藏</a>
<span>(将该按钮拖动至浏览器书签栏,如下图)</span>
</div>
</div>
<div class="text-center">
<img th:src="@{/img/useTool.gif}" alt=""/>
Expand Down

0 comments on commit 34ab3e9

Please sign in to comment.