Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
8ee89c69
S
SpringBoot-kwan
项目概览
Kwan的解忧杂货铺@新空间代码工作室
/
SpringBoot-kwan
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SpringBoot-kwan
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8ee89c69
编写于
8月 09, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:图片插入
上级
7c6122d8
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
2477 addition
and
13 deletion
+2477
-13
logs/SpringBoot-kwan.log
logs/SpringBoot-kwan.log
+2313
-0
src/main/java/com/kwan/springbootkwan/controller/PicInfoController.java
...com/kwan/springbootkwan/controller/PicInfoController.java
+12
-0
src/main/java/com/kwan/springbootkwan/entity/pic/BaiduPic.java
...ain/java/com/kwan/springbootkwan/entity/pic/BaiduPic.java
+20
-0
src/main/java/com/kwan/springbootkwan/entity/pic/PicDataInfo.java
.../java/com/kwan/springbootkwan/entity/pic/PicDataInfo.java
+65
-0
src/main/java/com/kwan/springbootkwan/service/PicInfoService.java
.../java/com/kwan/springbootkwan/service/PicInfoService.java
+14
-0
src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java
.../kwan/springbootkwan/service/impl/PicInfoServiceImpl.java
+53
-13
未找到文件。
logs/SpringBoot-kwan.log
浏览文件 @
8ee89c69
因为 它太大了无法显示 source diff 。你可以改为
查看blob
。
src/main/java/com/kwan/springbootkwan/controller/PicInfoController.java
浏览文件 @
8ee89c69
...
@@ -104,6 +104,18 @@ public class PicInfoController {
...
@@ -104,6 +104,18 @@ public class PicInfoController {
}
}
/**
* 通过url新增图片
*
* @param url
* @return
*/
@PostMapping
(
value
=
"/insertByBaiduUrl"
)
public
Result
insertByBaiduUrl
(
@RequestParam
String
url
)
{
return
Result
.
ok
(
this
.
picInfoService
.
insertByBaiduUrl
(
url
));
}
/**
/**
* 修改数据
* 修改数据
*
*
...
...
src/main/java/com/kwan/springbootkwan/entity/pic/BaiduPic.java
0 → 100644
浏览文件 @
8ee89c69
package
com.kwan.springbootkwan.entity.pic
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
@Data
public
class
BaiduPic
implements
Serializable
{
private
Integer
listNum
;
private
String
gsm
;
private
Integer
isNeedAsyncRequest
;
private
List
<
PicDataInfo
>
data
;
private
String
queryEnc
;
private
String
bdSearchTime
;
private
Integer
displayNum
;
private
String
queryExt
;
private
String
bdFmtDispNum
;
private
String
bdIsClustered
;
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/entity/pic/PicDataInfo.java
0 → 100644
浏览文件 @
8ee89c69
package
com.kwan.springbootkwan.entity.pic
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.lang.Integer
;
import
java.lang.Object
;
import
java.lang.String
;
import
java.util.List
;
@Data
public
class
PicDataInfo
implements
Serializable
{
private
Integer
is_gif
;
private
String
di
;
private
Integer
isCommodity
;
private
String
imgCollectionWord
;
private
String
largeTnImageUrl
;
private
String
type
;
private
String
currentIndex
;
private
Integer
hasLarge
;
private
String
strategyAssessment
;
private
String
adPicId
;
private
String
fromJumpUrl
;
private
Integer
height
;
private
String
hasAspData
;
private
String
middleURL
;
private
String
is
;
private
String
source_type
;
private
Integer
spn
;
private
Integer
isAspDianjing
;
private
Object
face_info
;
private
String
shituToken
;
private
String
bdFromPageTitlePrefix
;
private
String
simid
;
private
String
fromPageTitleEnc
;
private
String
fromURLHost
;
private
Integer
isCopyright
;
private
String
fromPageTitle
;
private
String
filesize
;
private
Object
resourceInfo
;
private
String
bdSourceName
;
private
String
personalized
;
private
String
adType
;
private
String
hasThumbData
;
private
String
thumbURL
;
private
Object
commodityInfo
;
private
String
imgType
;
private
String
os
;
private
String
bdSrcType
;
private
String
bdImgnewsDate
;
private
Integer
pageNum
;
private
Object
xiangshi_info
;
private
String
token
;
private
String
cs
;
private
Integer
bdSetImgNum
;
private
Object
simid_info
;
private
String
fromURL
;
private
String
objURL
;
private
Integer
width
;
private
String
pi
;
private
Integer
partnerId
;
private
String
hoverURL
;
private
List
<
Object
>
replaceUrl
;
}
\ No newline at end of file
src/main/java/com/kwan/springbootkwan/service/PicInfoService.java
浏览文件 @
8ee89c69
...
@@ -11,6 +11,20 @@ import com.kwan.springbootkwan.entity.PicInfo;
...
@@ -11,6 +11,20 @@ import com.kwan.springbootkwan.entity.PicInfo;
*/
*/
public
interface
PicInfoService
extends
IService
<
PicInfo
>
{
public
interface
PicInfoService
extends
IService
<
PicInfo
>
{
/**
* 根据目录插入图片
*
* @param path
* @return
*/
boolean
insertByPath
(
String
path
);
boolean
insertByPath
(
String
path
);
/**
* 根据百度图片路径获取图片
*
* @param url
* @return
*/
boolean
insertByBaiduUrl
(
String
url
);
}
}
src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java
浏览文件 @
8ee89c69
package
com.kwan.springbootkwan.service.impl
;
package
com.kwan.springbootkwan.service.impl
;
import
cn.hutool.http.HttpResponse
;
import
cn.hutool.http.HttpUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.kwan.springbootkwan.entity.PicInfo
;
import
com.kwan.springbootkwan.entity.PicInfo
;
import
com.kwan.springbootkwan.entity.pic.BaiduPic
;
import
com.kwan.springbootkwan.entity.pic.PicDataInfo
;
import
com.kwan.springbootkwan.mapper.PicInfoMapper
;
import
com.kwan.springbootkwan.mapper.PicInfoMapper
;
import
com.kwan.springbootkwan.service.PicInfoService
;
import
com.kwan.springbootkwan.service.PicInfoService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -13,6 +19,7 @@ import java.nio.file.DirectoryStream;
...
@@ -13,6 +19,7 @@ import java.nio.file.DirectoryStream;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.Paths
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
/**
/**
...
@@ -21,6 +28,7 @@ import java.util.Objects;
...
@@ -21,6 +28,7 @@ import java.util.Objects;
* @author makejava
* @author makejava
* @since 2023-08-09 12:44:03
* @since 2023-08-09 12:44:03
*/
*/
@Slf4j
@Service
(
"picInfoService"
)
@Service
(
"picInfoService"
)
public
class
PicInfoServiceImpl
extends
ServiceImpl
<
PicInfoMapper
,
PicInfo
>
implements
PicInfoService
{
public
class
PicInfoServiceImpl
extends
ServiceImpl
<
PicInfoMapper
,
PicInfo
>
implements
PicInfoService
{
...
@@ -37,23 +45,55 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
...
@@ -37,23 +45,55 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
try
(
DirectoryStream
<
Path
>
directoryStream
=
Files
.
newDirectoryStream
(
directoryPath
))
{
try
(
DirectoryStream
<
Path
>
directoryStream
=
Files
.
newDirectoryStream
(
directoryPath
))
{
for
(
Path
filePath
:
directoryStream
)
{
for
(
Path
filePath
:
directoryStream
)
{
if
(
Files
.
isRegularFile
(
filePath
))
{
if
(
Files
.
isRegularFile
(
filePath
))
{
final
String
picName
=
filePath
.
getFileName
().
toString
();
final
String
picNameOrigin
=
filePath
.
getFileName
().
toString
();
String
picPath
=
PRE_FIX
+
picName
;
String
picPath
=
PRE_FIX
+
picNameOrigin
;
final
String
picName
=
picNameOrigin
.
split
(
"."
)[
0
];
this
.
insertPic
(
picPath
,
picName
);
}
}
return
true
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
/**
* 插入图片
*
* @param picPath
* @param picName
*/
private
void
insertPic
(
String
picPath
,
String
picName
)
{
QueryWrapper
<
PicInfo
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
PicInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"pic_url"
,
picPath
);
wrapper
.
eq
(
"pic_url"
,
picPath
);
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
PicInfo
pic
=
picInfoMapper
.
selectOne
(
wrapper
);
final
PicInfo
pic
=
picInfoMapper
.
selectOne
(
wrapper
);
if
(
Objects
.
nonNull
(
pic
))
{
if
(
Objects
.
nonNull
(
pic
))
{
continue
;
return
;
}
}
PicInfo
picInfo
=
new
PicInfo
();
PicInfo
picInfo
=
new
PicInfo
();
picInfo
.
setPicName
(
picName
.
split
(
"."
)[
0
]
);
picInfo
.
setPicName
(
picName
);
picInfo
.
setPicUrl
(
picPath
);
picInfo
.
setPicUrl
(
picPath
);
picInfoMapper
.
insert
(
picInfo
);
picInfoMapper
.
insert
(
picInfo
);
}
}
@Override
public
boolean
insertByBaiduUrl
(
String
url
)
{
HttpResponse
response
;
try
{
response
=
HttpUtil
.
createGet
(
url
).
execute
();
String
responseBody
=
response
.
body
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
BaiduPic
baiduPic
=
objectMapper
.
readValue
(
responseBody
,
BaiduPic
.
class
);
final
List
<
PicDataInfo
>
data
=
baiduPic
.
getData
();
for
(
PicDataInfo
datum
:
data
)
{
final
String
hoverURL
=
datum
.
getHoverURL
();
final
String
picName
=
datum
.
getFromPageTitle
().
split
(
"."
)[
0
];
this
.
insertPic
(
hoverURL
,
picName
);
}
}
return
true
;
return
true
;
}
catch
(
IO
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
return
false
;
return
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录