From cc192e5345ccaeba2d55cd5ecbdd69ec8048ec1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Fri, 11 Aug 2023 21:28:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=B8=8A=E4=BC=A0=E5=9B=BE=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/kwan/springbootkwan/entity/PicInfo.java | 2 +- .../springbootkwan/service/impl/PicInfoServiceImpl.java | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/kwan/springbootkwan/entity/PicInfo.java b/src/main/java/com/kwan/springbootkwan/entity/PicInfo.java index 63d7775..da96509 100644 --- a/src/main/java/com/kwan/springbootkwan/entity/PicInfo.java +++ b/src/main/java/com/kwan/springbootkwan/entity/PicInfo.java @@ -19,7 +19,7 @@ public class PicInfo extends Model { private String picName; //图片地址 private String picUrl; - //图片类型,0:表示宝宝图片 + //图片类型,0:表示宝宝图片,1:学习图片,2:风景,3:美女,99:其他 private Integer type; private Date createTime; private Integer isDelete; diff --git a/src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java b/src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java index 0edf12e..aab08b1 100644 --- a/src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java +++ b/src/main/java/com/kwan/springbootkwan/service/impl/PicInfoServiceImpl.java @@ -48,7 +48,11 @@ public class PicInfoServiceImpl extends ServiceImpl impl if (Files.isRegularFile(filePath)) { final String picNameOrigin = filePath.getFileName().toString(); String picPath = PRE_FIX + picNameOrigin; - final String picName = picNameOrigin.split(".")[0]; + final String[] split = picNameOrigin.split("."); + String picName = picNameOrigin; + if (Objects.nonNull(split) && split.length > 0) { + picName = split[0]; + } this.insertPic(type, picPath, picName); } } -- GitLab