|
@@ -209,7 +209,7 @@ public class BookServiceImpl implements BookService {
|
|
|
@Override
|
|
|
public List<Chapter> getChaptersByBookId(String bookId) {
|
|
|
List<Chapter> list = new ArrayList<>();
|
|
|
- try {
|
|
|
+
|
|
|
if (StringUtils.isEmpty(bookId)) {
|
|
|
throw new IllegalArgumentException("bookId cannot be null or empty");
|
|
|
}
|
|
@@ -221,8 +221,14 @@ public class BookServiceImpl implements BookService {
|
|
|
JsonParser parser = new JsonParser();
|
|
|
JsonArray jsonArray = parser.parse(result).getAsJsonArray();
|
|
|
Book book = bookMapper.selectByPrimaryKey(Long.parseLong(bookId));
|
|
|
+ if (book == null) {
|
|
|
+ return list;
|
|
|
+ }
|
|
|
Integer freeChapterNum = book.getFreeChapterNum();
|
|
|
|
|
|
+ if (freeChapterNum==null){
|
|
|
+ freeChapterNum = 20;
|
|
|
+ }
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JsonObject jsonObject = jsonArray.get(i).getAsJsonObject();
|
|
|
Chapter chapter = new Chapter();
|
|
@@ -235,17 +241,11 @@ public class BookServiceImpl implements BookService {
|
|
|
chapter.setType(jsonObject.get("type").getAsString());
|
|
|
chapter.setVolumeId(jsonObject.get("volume_id").getAsString());
|
|
|
chapter.setWords(jsonObject.get("words").getAsString());
|
|
|
- list.add(chapter);
|
|
|
- if (i+1 == freeChapterNum){
|
|
|
+ if (i + 1 == freeChapterNum) {
|
|
|
chapter.setReadAble("0");
|
|
|
}
|
|
|
+ list.add(chapter);
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- logger.error(e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
-
|
|
|
- return list;
|
|
|
- }
|
|
|
|
|
|
return list;
|
|
|
}
|
|
@@ -273,12 +273,12 @@ public class BookServiceImpl implements BookService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public BookContent getContentByContentId(String bookId,String contentId) {
|
|
|
+ public BookContent getContentByContentId(String bookId, String contentId) {
|
|
|
String contentUrl = "http://new.emeixs.com/index.php/Home/Interface/content/bid/%s/cid/%s";
|
|
|
- if (StringUtils.isEmpty(bookId) || StringUtils.isEmpty(contentId)){
|
|
|
+ if (StringUtils.isEmpty(bookId) || StringUtils.isEmpty(contentId)) {
|
|
|
return null;
|
|
|
}
|
|
|
- BookContent content =null;
|
|
|
+ BookContent content = null;
|
|
|
try {
|
|
|
content = new BookContent();
|
|
|
String url = String.format(contentUrl, bookId, contentId);
|
|
@@ -287,9 +287,10 @@ public class BookServiceImpl implements BookService {
|
|
|
|
|
|
content.setContent(jsonObject.get("content").getAsString());
|
|
|
content.setBookId(jsonObject.get("book_id").getAsString());
|
|
|
+ content.setName(jsonObject.get("name").getAsString());
|
|
|
content.setChapterId(jsonObject.get("CONTENT_ID").getAsString());
|
|
|
content.setIsPay(jsonObject.get("ispay").getAsString());
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
logger.info(e.getMessage());
|
|
|
return null;
|
|
|
}
|