Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
caf854d7
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看板
提交
caf854d7
编写于
8月 09, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:宝宝图片
上级
a130797f
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
549 addition
and
15 deletion
+549
-15
logs/SpringBoot-kwan.log
logs/SpringBoot-kwan.log
+530
-0
src/main/java/com/kwan/springbootkwan/controller/PicInfoController.java
...com/kwan/springbootkwan/controller/PicInfoController.java
+9
-8
src/main/java/com/kwan/springbootkwan/service/PicInfoService.java
.../java/com/kwan/springbootkwan/service/PicInfoService.java
+4
-2
src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java
.../kwan/springbootkwan/service/impl/PicInfoServiceImpl.java
+6
-5
未找到文件。
logs/SpringBoot-kwan.log
浏览文件 @
caf854d7
此差异已折叠。
点击以展开。
src/main/java/com/kwan/springbootkwan/controller/PicInfoController.java
浏览文件 @
caf854d7
...
@@ -40,20 +40,21 @@ public class PicInfoController {
...
@@ -40,20 +40,21 @@ public class PicInfoController {
return
Result
.
ok
(
this
.
picInfoService
.
list
());
return
Result
.
ok
(
this
.
picInfoService
.
list
());
}
}
/**
/**
* 分页查询图片
* 分页查询图片
*
*
* @return 所有数据
* @return 所有数据
*/
*/
@GetMapping
(
"/page"
)
@GetMapping
(
"/page"
)
public
Result
selectAll
(
@RequestParam
Integer
page
,
@RequestParam
Integer
pageSize
)
{
public
Result
selectAll
(
@RequestParam
Integer
page
,
@RequestParam
Integer
pageSize
,
@RequestParam
Integer
picType
)
{
Page
<
PicInfo
>
pageParm
=
new
Page
<>();
Page
<
PicInfo
>
pageParm
=
new
Page
<>();
pageParm
.
setCurrent
(
page
);
pageParm
.
setCurrent
(
page
);
pageParm
.
setSize
(
pageSize
);
pageParm
.
setSize
(
pageSize
);
QueryWrapper
<
PicInfo
>
wrapper
=
new
QueryWrapper
<>();
QueryWrapper
<
PicInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
orderByDesc
(
"id"
);
// 按照 id 字段降序排列
wrapper
.
orderByDesc
(
"id"
);
wrapper
.
eq
(
"is_delete"
,
0
);
// 按照 id 字段降序排列
wrapper
.
eq
(
"is_delete"
,
0
);
wrapper
.
eq
(
"type"
,
picType
);
return
Result
.
ok
(
this
.
picInfoService
.
page
(
pageParm
,
wrapper
));
return
Result
.
ok
(
this
.
picInfoService
.
page
(
pageParm
,
wrapper
));
}
}
...
@@ -99,8 +100,8 @@ public class PicInfoController {
...
@@ -99,8 +100,8 @@ public class PicInfoController {
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/insertByPath"
)
@PostMapping
(
value
=
"/insertByPath"
)
public
Result
insertByPath
(
@RequestParam
String
path
)
{
public
Result
insertByPath
(
@RequestParam
String
path
,
@RequestParam
Integer
type
)
{
return
Result
.
ok
(
this
.
picInfoService
.
insertByPath
(
path
));
return
Result
.
ok
(
this
.
picInfoService
.
insertByPath
(
path
,
type
));
}
}
...
@@ -111,8 +112,8 @@ public class PicInfoController {
...
@@ -111,8 +112,8 @@ public class PicInfoController {
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/insertByBaiduUrl"
)
@PostMapping
(
value
=
"/insertByBaiduUrl"
)
public
Result
insertByBaiduUrl
(
@RequestParam
String
url
)
{
public
Result
insertByBaiduUrl
(
@RequestParam
String
url
,
@RequestParam
Integer
type
)
{
return
Result
.
ok
(
this
.
picInfoService
.
insertByBaiduUrl
(
url
));
return
Result
.
ok
(
this
.
picInfoService
.
insertByBaiduUrl
(
url
,
type
));
}
}
...
...
src/main/java/com/kwan/springbootkwan/service/PicInfoService.java
浏览文件 @
caf854d7
...
@@ -15,16 +15,18 @@ public interface PicInfoService extends IService<PicInfo> {
...
@@ -15,16 +15,18 @@ public interface PicInfoService extends IService<PicInfo> {
* 根据目录插入图片
* 根据目录插入图片
*
*
* @param path
* @param path
* @param type
* @return
* @return
*/
*/
boolean
insertByPath
(
String
path
);
boolean
insertByPath
(
String
path
,
Integer
type
);
/**
/**
* 根据百度图片路径获取图片
* 根据百度图片路径获取图片
*
*
* @param url
* @param url
* @param type
* @return
* @return
*/
*/
boolean
insertByBaiduUrl
(
String
url
);
boolean
insertByBaiduUrl
(
String
url
,
Integer
type
);
}
}
src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java
浏览文件 @
caf854d7
...
@@ -41,7 +41,7 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
...
@@ -41,7 +41,7 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
private
static
final
String
PRE_FIX
=
"https://gitcode.net/qyj19920704/baby-images/-/raw/main/"
;
private
static
final
String
PRE_FIX
=
"https://gitcode.net/qyj19920704/baby-images/-/raw/main/"
;
@Override
@Override
public
boolean
insertByPath
(
String
path
)
{
public
boolean
insertByPath
(
String
path
,
Integer
type
)
{
Path
directoryPath
=
Paths
.
get
(
path
);
Path
directoryPath
=
Paths
.
get
(
path
);
try
(
DirectoryStream
<
Path
>
directoryStream
=
Files
.
newDirectoryStream
(
directoryPath
))
{
try
(
DirectoryStream
<
Path
>
directoryStream
=
Files
.
newDirectoryStream
(
directoryPath
))
{
for
(
Path
filePath
:
directoryStream
)
{
for
(
Path
filePath
:
directoryStream
)
{
...
@@ -49,7 +49,7 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
...
@@ -49,7 +49,7 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
final
String
picNameOrigin
=
filePath
.
getFileName
().
toString
();
final
String
picNameOrigin
=
filePath
.
getFileName
().
toString
();
String
picPath
=
PRE_FIX
+
picNameOrigin
;
String
picPath
=
PRE_FIX
+
picNameOrigin
;
final
String
picName
=
picNameOrigin
.
split
(
"."
)[
0
];
final
String
picName
=
picNameOrigin
.
split
(
"."
)[
0
];
this
.
insertPic
(
picPath
,
picName
);
this
.
insertPic
(
type
,
picPath
,
picName
);
}
}
}
}
return
true
;
return
true
;
...
@@ -65,7 +65,7 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
...
@@ -65,7 +65,7 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
* @param picPath
* @param picPath
* @param picName
* @param picName
*/
*/
private
void
insertPic
(
String
picPath
,
String
picName
)
{
private
void
insertPic
(
Integer
type
,
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
);
...
@@ -76,11 +76,12 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
...
@@ -76,11 +76,12 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
PicInfo
picInfo
=
new
PicInfo
();
PicInfo
picInfo
=
new
PicInfo
();
picInfo
.
setPicName
(
picName
);
picInfo
.
setPicName
(
picName
);
picInfo
.
setPicUrl
(
picPath
);
picInfo
.
setPicUrl
(
picPath
);
picInfo
.
setType
(
type
);
picInfoMapper
.
insert
(
picInfo
);
picInfoMapper
.
insert
(
picInfo
);
}
}
@Override
@Override
public
boolean
insertByBaiduUrl
(
String
url
)
{
public
boolean
insertByBaiduUrl
(
String
url
,
Integer
type
)
{
HttpResponse
response
;
HttpResponse
response
;
try
{
try
{
response
=
HttpUtil
.
createGet
(
url
).
execute
();
response
=
HttpUtil
.
createGet
(
url
).
execute
();
...
@@ -96,7 +97,7 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
...
@@ -96,7 +97,7 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
if
(
Objects
.
isNull
(
split
)
||
split
.
length
==
0
)
{
if
(
Objects
.
isNull
(
split
)
||
split
.
length
==
0
)
{
split
=
fromPageTitle
.
split
(
","
);
split
=
fromPageTitle
.
split
(
","
);
}
}
this
.
insertPic
(
hoverURL
,
Objects
.
isNull
(
split
)
||
split
.
length
==
0
?
fromPageTitle
:
split
[
0
]);
this
.
insertPic
(
type
,
hoverURL
,
Objects
.
isNull
(
split
)
||
split
.
length
==
0
?
fromPageTitle
:
split
[
0
]);
}
}
}
}
return
true
;
return
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录