fix:根据百度搜索后的结果插入图片

上级 8ee89c69
因为 它太大了无法显示 source diff 。你可以改为 查看blob
......@@ -11,6 +11,7 @@ import com.kwan.springbootkwan.entity.pic.PicDataInfo;
import com.kwan.springbootkwan.mapper.PicInfoMapper;
import com.kwan.springbootkwan.service.PicInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -89,8 +90,14 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
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);
final String fromPageTitle = datum.getFromPageTitle();
if (StringUtils.isNotEmpty(fromPageTitle)) {
String[] split = fromPageTitle.split(".");
if (Objects.isNull(split) || split.length == 0) {
split = fromPageTitle.split(",");
}
this.insertPic(hoverURL, Objects.isNull(split) || split.length == 0 ? fromPageTitle : split[0]);
}
}
return true;
} catch (Exception e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册