Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Kwan的解忧杂货铺@新空间代码工作室
SpringBoot-kwan
提交
2be8fde4
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看板
提交
2be8fde4
编写于
8月 09, 2023
作者:
Kwan的解忧杂货铺@新空间代码工作室
🐭
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix:插入图片
上级
0e4d0ff7
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
383 addition
and
1 deletion
+383
-1
logs/SpringBoot-kwan.log
logs/SpringBoot-kwan.log
+325
-0
src/main/java/com/kwan/springbootkwan/controller/PicInfoController.java
...com/kwan/springbootkwan/controller/PicInfoController.java
+14
-1
src/main/java/com/kwan/springbootkwan/service/PicInfoService.java
.../java/com/kwan/springbootkwan/service/PicInfoService.java
+1
-0
src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java
.../kwan/springbootkwan/service/impl/PicInfoServiceImpl.java
+43
-0
未找到文件。
logs/SpringBoot-kwan.log
浏览文件 @
2be8fde4
此差异已折叠。
点击以展开。
src/main/java/com/kwan/springbootkwan/controller/PicInfoController.java
浏览文件 @
2be8fde4
...
@@ -42,7 +42,7 @@ public class PicInfoController {
...
@@ -42,7 +42,7 @@ public class PicInfoController {
/**
/**
* 分页查询
所有数据
* 分页查询
图片
*
*
* @return 所有数据
* @return 所有数据
*/
*/
...
@@ -91,6 +91,19 @@ public class PicInfoController {
...
@@ -91,6 +91,19 @@ public class PicInfoController {
return
Result
.
ok
(
this
.
picInfoService
.
save
(
picInfo
));
return
Result
.
ok
(
this
.
picInfoService
.
save
(
picInfo
));
}
}
/**
* 新增图片
*
* @param path
* @return
*/
@PostMapping
(
value
=
"/insertByPath"
)
public
Result
insertByPath
(
@RequestParam
String
path
)
{
return
Result
.
ok
(
this
.
picInfoService
.
insertByPath
(
path
));
}
/**
/**
* 修改数据
* 修改数据
*
*
...
...
src/main/java/com/kwan/springbootkwan/service/PicInfoService.java
浏览文件 @
2be8fde4
...
@@ -11,5 +11,6 @@ import com.kwan.springbootkwan.entity.PicInfo;
...
@@ -11,5 +11,6 @@ import com.kwan.springbootkwan.entity.PicInfo;
*/
*/
public
interface
PicInfoService
extends
IService
<
PicInfo
>
{
public
interface
PicInfoService
extends
IService
<
PicInfo
>
{
boolean
insertByPath
(
String
path
);
}
}
src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java
浏览文件 @
2be8fde4
package
com.kwan.springbootkwan.service.impl
;
package
com.kwan.springbootkwan.service.impl
;
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.kwan.springbootkwan.entity.PicInfo
;
import
com.kwan.springbootkwan.entity.PicInfo
;
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
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.io.IOException
;
import
java.nio.file.DirectoryStream
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.util.Objects
;
/**
/**
* 图片信息表(PicInfo)表服务实现类
* 图片信息表(PicInfo)表服务实现类
*
*
...
@@ -15,5 +24,39 @@ import org.springframework.stereotype.Service;
...
@@ -15,5 +24,39 @@ import org.springframework.stereotype.Service;
@Service
(
"picInfoService"
)
@Service
(
"picInfoService"
)
public
class
PicInfoServiceImpl
extends
ServiceImpl
<
PicInfoMapper
,
PicInfo
>
implements
PicInfoService
{
public
class
PicInfoServiceImpl
extends
ServiceImpl
<
PicInfoMapper
,
PicInfo
>
implements
PicInfoService
{
@Autowired
private
PicInfoMapper
picInfoMapper
;
/**
* 图片路径前缀
*/
private
static
final
String
PRE_FIX
=
"https://gitcode.net/qyj19920704/baby-images/-/raw/main/"
;
@Override
public
boolean
insertByPath
(
String
path
)
{
Path
directoryPath
=
Paths
.
get
(
path
);
try
(
DirectoryStream
<
Path
>
directoryStream
=
Files
.
newDirectoryStream
(
directoryPath
))
{
for
(
Path
filePath
:
directoryStream
)
{
if
(
Files
.
isRegularFile
(
filePath
))
{
final
String
picName
=
filePath
.
getFileName
().
toString
();
String
picPath
=
PRE_FIX
+
picName
;
QueryWrapper
<
PicInfo
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
eq
(
"pic_url"
,
picPath
);
wrapper
.
eq
(
"is_delete"
,
0
);
final
PicInfo
pic
=
picInfoMapper
.
selectOne
(
wrapper
);
if
(
Objects
.
nonNull
(
pic
)){
continue
;
}
PicInfo
picInfo
=
new
PicInfo
();
picInfo
.
setPicName
(
picName
);
picInfo
.
setPicUrl
(
picPath
);
picInfoMapper
.
insert
(
picInfo
);
}
}
return
true
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
false
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录