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

上级 8ee89c69
此差异已折叠。
...@@ -11,6 +11,7 @@ import com.kwan.springbootkwan.entity.pic.PicDataInfo; ...@@ -11,6 +11,7 @@ import com.kwan.springbootkwan.entity.pic.PicDataInfo;
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 lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -89,8 +90,14 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl ...@@ -89,8 +90,14 @@ public class PicInfoServiceImpl extends ServiceImpl<PicInfoMapper, PicInfo> impl
final List<PicDataInfo> data = baiduPic.getData(); final List<PicDataInfo> data = baiduPic.getData();
for (PicDataInfo datum : data) { for (PicDataInfo datum : data) {
final String hoverURL = datum.getHoverURL(); final String hoverURL = datum.getHoverURL();
final String picName = datum.getFromPageTitle().split(".")[0]; final String fromPageTitle = datum.getFromPageTitle();
this.insertPic(hoverURL, picName); 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; return true;
} catch (Exception e) { } catch (Exception e) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册