|
@@ -220,10 +220,13 @@ public class BookServiceImpl implements BookService {
|
|
|
}
|
|
|
JsonParser parser = new JsonParser();
|
|
|
JsonArray jsonArray = parser.parse(result).getAsJsonArray();
|
|
|
+ Book book = bookMapper.selectByPrimaryKey(Long.parseLong(bookId));
|
|
|
+ Integer freeChapterNum = book.getFreeChapterNum();
|
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
JsonObject jsonObject = jsonArray.get(i).getAsJsonObject();
|
|
|
Chapter chapter = new Chapter();
|
|
|
+ chapter.setReadAble("1");
|
|
|
chapter.setBookId(jsonObject.get("book_id").getAsString());
|
|
|
chapter.setContentId(jsonObject.get("content_id").getAsString());
|
|
|
chapter.setIsPay(jsonObject.get("ispay").getAsString());
|
|
@@ -233,6 +236,9 @@ public class BookServiceImpl implements BookService {
|
|
|
chapter.setVolumeId(jsonObject.get("volume_id").getAsString());
|
|
|
chapter.setWords(jsonObject.get("words").getAsString());
|
|
|
list.add(chapter);
|
|
|
+ if (i+1 == freeChapterNum){
|
|
|
+ chapter.setReadAble("0");
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage());
|
|
@@ -266,6 +272,32 @@ public class BookServiceImpl implements BookService {
|
|
|
return bookRes;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ 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)){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ BookContent content =null;
|
|
|
+ try {
|
|
|
+ content = new BookContent();
|
|
|
+ String url = String.format(contentUrl, bookId, contentId);
|
|
|
+ String result = HttpTool.sendGet(url, "");
|
|
|
+ JsonObject jsonObject = JsonUtils.getObject(result, JsonObject.class);
|
|
|
+
|
|
|
+ content.setContent(jsonObject.get("content").getAsString());
|
|
|
+ content.setBookId(jsonObject.get("book_id").getAsString());
|
|
|
+ content.setChapterId(jsonObject.get("CONTENT_ID").getAsString());
|
|
|
+ content.setIsPay(jsonObject.get("ispay").getAsString());
|
|
|
+ }catch (Exception e){
|
|
|
+ logger.info(e.getMessage());
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return content;
|
|
|
+ }
|
|
|
+
|
|
|
private List<BookRes> getRandom(List<BookRes> bookRes) {
|
|
|
if (bookRes.size() <= 4) {
|
|
|
return bookRes;
|