diff --git a/src/main/java/com/kwan/springbootkwan/entity/PicInfo.java b/src/main/java/com/kwan/springbootkwan/entity/PicInfo.java index 63d7775f3d585783743e2beea21a65ff27697294..da9650937cfa8d8769821cfc648f8d2cf9071a42 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 0edf12e61fe162e4e54ccc3b3e0cb7379be1d586..aab08b10c7a183800ba1352b310aa4ca635cc197 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); } }