2019-04-02 17:41:53 +08:00
|
|
|
package com.novelbook.android.db;
|
|
|
|
|
|
|
|
|
2019-04-08 23:16:20 +08:00
|
|
|
import org.litepal.LitePal;
|
2019-04-02 17:41:53 +08:00
|
|
|
import org.litepal.crud.LitePalSupport;
|
|
|
|
|
2019-04-03 23:29:58 +08:00
|
|
|
import java.io.Serializable;
|
2019-04-08 23:16:20 +08:00
|
|
|
import java.util.List;
|
2019-04-02 17:41:53 +08:00
|
|
|
|
2019-04-03 23:29:58 +08:00
|
|
|
|
|
|
|
public class Chapter extends LitePalSupport implements Serializable {
|
2019-04-02 17:41:53 +08:00
|
|
|
private int id;
|
2019-04-05 23:59:31 +08:00
|
|
|
private int novelId;//本地小说id
|
|
|
|
private String novelPath; //离线导入小说文件地址
|
2019-04-02 17:41:53 +08:00
|
|
|
private String chapterName;
|
2019-04-03 16:21:00 +08:00
|
|
|
private long novelChapterStartPos;
|
2019-04-02 17:41:53 +08:00
|
|
|
private String chapterUrl;
|
|
|
|
private int length;
|
2019-04-05 23:59:31 +08:00
|
|
|
private String chapterPath; //缓存地址
|
|
|
|
private String domain; //目标 site
|
2019-04-08 23:16:20 +08:00
|
|
|
private int index;//第几章
|
|
|
|
|
2019-05-03 00:30:48 +08:00
|
|
|
public static Chapter getChapter(int id, String domain, int chapId) {
|
|
|
|
// Chapter chapter =(Chapter)
|
|
|
|
|
|
|
|
List<Chapter> lst = LitePal.where("novelId=? and domain = ? and index = ?", id + "", domain, chapId + "").limit(1).find(Chapter.class);
|
|
|
|
if (lst.size() > 0) {
|
|
|
|
return lst.get(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Chapter chapter = new Chapter();
|
|
|
|
chapter.setDomain(domain);
|
|
|
|
chapter.setIndex(chapId);
|
|
|
|
chapter.setNovelId(id);
|
|
|
|
chapter.setChapterName("");
|
|
|
|
chapter.setChapterUrl("");
|
|
|
|
chapter.setChapterPath("");
|
|
|
|
return chapter;
|
|
|
|
}
|
|
|
|
|
2019-04-08 23:16:20 +08:00
|
|
|
public int getIndex() {
|
|
|
|
return index;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setIndex(int index) {
|
|
|
|
this.index = index;
|
|
|
|
}
|
2019-04-02 17:41:53 +08:00
|
|
|
|
2019-04-05 23:59:31 +08:00
|
|
|
public String getDomain() {
|
|
|
|
return domain;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDomain(String domain) {
|
|
|
|
this.domain = domain;
|
|
|
|
}
|
2019-04-03 18:09:00 +08:00
|
|
|
|
2019-04-02 17:41:53 +08:00
|
|
|
public int getId() {
|
|
|
|
return id;
|
|
|
|
}
|
2019-04-03 16:21:00 +08:00
|
|
|
|
2019-04-02 17:41:53 +08:00
|
|
|
public void setId(int id) {
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
2019-04-03 16:21:00 +08:00
|
|
|
public int getNovelId() {
|
|
|
|
return novelId;
|
2019-04-02 17:41:53 +08:00
|
|
|
}
|
|
|
|
|
2019-04-03 16:21:00 +08:00
|
|
|
public void setNovelId(int novelId) {
|
|
|
|
this.novelId = novelId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getNovelPath() {
|
|
|
|
return novelPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setNovelPath(String novelPath) {
|
|
|
|
this.novelPath = novelPath;
|
2019-04-02 17:41:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getChapterName() {
|
|
|
|
return chapterName;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setChapterName(String chapterName) {
|
|
|
|
this.chapterName = chapterName;
|
|
|
|
}
|
|
|
|
|
2019-04-03 16:21:00 +08:00
|
|
|
public long getNovelChapterStartPos() {
|
|
|
|
return novelChapterStartPos;
|
2019-04-02 17:41:53 +08:00
|
|
|
}
|
|
|
|
|
2019-04-03 16:21:00 +08:00
|
|
|
public void setNovelChapterStartPos(long novelChapterStartPos) {
|
|
|
|
this.novelChapterStartPos = novelChapterStartPos;
|
2019-04-02 17:41:53 +08:00
|
|
|
}
|
2019-04-03 16:21:00 +08:00
|
|
|
|
|
|
|
public String getChapterUrl() {
|
|
|
|
return chapterUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setChapterUrl(String chapterUrl) {
|
|
|
|
this.chapterUrl = chapterUrl;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLength() {
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLength(int length) {
|
|
|
|
this.length = length;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getChapterPath() {
|
|
|
|
return chapterPath;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setChapterPath(String chapterPath) {
|
|
|
|
this.chapterPath = chapterPath;
|
|
|
|
}
|
|
|
|
|
2019-04-08 23:16:20 +08:00
|
|
|
public static List<Chapter> getUnCachedChapters(int noveId,String domain ){
|
2019-04-10 22:19:06 +08:00
|
|
|
// return LitePal.where("novelId = ? and domain = ? and chapterPath = null" ,noveId+"",domain ) .find(Chapter.class);
|
|
|
|
|
|
|
|
return LitePal.where("novelId = ? and domain = ? " ,noveId+"",domain).find(Chapter.class);
|
2019-04-08 23:16:20 +08:00
|
|
|
|
|
|
|
}
|
2019-04-03 16:21:00 +08:00
|
|
|
|
2019-04-02 17:41:53 +08:00
|
|
|
}
|
|
|
|
|