diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/core/crawl/BiquCrawlSource.java b/novel-front/src/main/java/xyz/zinglizingli/books/core/crawl/BiquCrawlSource.java index 53b84f1..c289f90 100644 --- a/novel-front/src/main/java/xyz/zinglizingli/books/core/crawl/BiquCrawlSource.java +++ b/novel-front/src/main/java/xyz/zinglizingli/books/core/crawl/BiquCrawlSource.java @@ -5,15 +5,12 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import xyz.zinglizingli.books.core.utils.Constants; -import xyz.zinglizingli.books.mapper.BookParseLogMapper; import xyz.zinglizingli.books.po.*; import xyz.zinglizingli.books.service.BookService; import xyz.zinglizingli.books.core.utils.CatUtil; import xyz.zinglizingli.common.cache.CommonCacheUtil; -import xyz.zinglizingli.common.utils.ExcutorUtils; import xyz.zinglizingli.common.utils.RestTemplateUtil; -import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -73,7 +70,7 @@ public class BiquCrawlSource extends BaseHtmlCrawlSource { String bookName = bookNameMatch.group(1); - bookService.addBookParseLog(bookUrl, bookName, score); + bookService.addBookParseLog(bookUrl, bookName, score, (byte) 10); } catch (Exception e) { diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/mapper/BookParseLogMapper.java b/novel-front/src/main/java/xyz/zinglizingli/books/mapper/BookParseLogMapper.java deleted file mode 100644 index 54a15bf..0000000 --- a/novel-front/src/main/java/xyz/zinglizingli/books/mapper/BookParseLogMapper.java +++ /dev/null @@ -1,30 +0,0 @@ -package xyz.zinglizingli.books.mapper; - -import java.util.List; -import org.apache.ibatis.annotations.Param; -import xyz.zinglizingli.books.po.BookParseLog; -import xyz.zinglizingli.books.po.BookParseLogExample; - -public interface BookParseLogMapper { - int countByExample(BookParseLogExample example); - - int deleteByExample(BookParseLogExample example); - - int deleteByPrimaryKey(Long id); - - int insert(BookParseLog record); - - int insertSelective(BookParseLog record); - - List selectByExample(BookParseLogExample example); - - BookParseLog selectByPrimaryKey(Long id); - - int updateByExampleSelective(@Param("record") BookParseLog record, @Param("example") BookParseLogExample example); - - int updateByExample(@Param("record") BookParseLog record, @Param("example") BookParseLogExample example); - - int updateByPrimaryKeySelective(BookParseLog record); - - int updateByPrimaryKey(BookParseLog record); -} \ No newline at end of file diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/po/BookParseLog.java b/novel-front/src/main/java/xyz/zinglizingli/books/po/BookParseLog.java deleted file mode 100644 index 136f344..0000000 --- a/novel-front/src/main/java/xyz/zinglizingli/books/po/BookParseLog.java +++ /dev/null @@ -1,55 +0,0 @@ -package xyz.zinglizingli.books.po; - -import java.util.Date; - -public class BookParseLog { - private Long id; - - private String bookUrl; - - private String bookName; - - private Float score; - - private Date createTime; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getBookUrl() { - return bookUrl; - } - - public void setBookUrl(String bookUrl) { - this.bookUrl = bookUrl == null ? null : bookUrl.trim(); - } - - public String getBookName() { - return bookName; - } - - public void setBookName(String bookName) { - this.bookName = bookName == null ? null : bookName.trim(); - } - - public Float getScore() { - return score; - } - - public void setScore(Float score) { - this.score = score; - } - - public Date getCreateTime() { - return createTime; - } - - public void setCreateTime(Date createTime) { - this.createTime = createTime; - } -} \ No newline at end of file diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/po/BookParseLogExample.java b/novel-front/src/main/java/xyz/zinglizingli/books/po/BookParseLogExample.java deleted file mode 100644 index 487e1b6..0000000 --- a/novel-front/src/main/java/xyz/zinglizingli/books/po/BookParseLogExample.java +++ /dev/null @@ -1,521 +0,0 @@ -package xyz.zinglizingli.books.po; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -public class BookParseLogExample { - protected String orderByClause; - - protected boolean distinct; - - protected List oredCriteria; - - public BookParseLogExample() { - oredCriteria = new ArrayList(); - } - - public void setOrderByClause(String orderByClause) { - this.orderByClause = orderByClause; - } - - public String getOrderByClause() { - return orderByClause; - } - - public void setDistinct(boolean distinct) { - this.distinct = distinct; - } - - public boolean isDistinct() { - return distinct; - } - - public List getOredCriteria() { - return oredCriteria; - } - - public void or(Criteria criteria) { - oredCriteria.add(criteria); - } - - public Criteria or() { - Criteria criteria = createCriteriaInternal(); - oredCriteria.add(criteria); - return criteria; - } - - public Criteria createCriteria() { - Criteria criteria = createCriteriaInternal(); - if (oredCriteria.size() == 0) { - oredCriteria.add(criteria); - } - return criteria; - } - - protected Criteria createCriteriaInternal() { - Criteria criteria = new Criteria(); - return criteria; - } - - public void clear() { - oredCriteria.clear(); - orderByClause = null; - distinct = false; - } - - protected abstract static class GeneratedCriteria { - protected List criteria; - - protected GeneratedCriteria() { - super(); - criteria = new ArrayList(); - } - - public boolean isValid() { - return criteria.size() > 0; - } - - public List getAllCriteria() { - return criteria; - } - - public List getCriteria() { - return criteria; - } - - protected void addCriterion(String condition) { - if (condition == null) { - throw new RuntimeException("Value for condition cannot be null"); - } - criteria.add(new Criterion(condition)); - } - - protected void addCriterion(String condition, Object value, String property) { - if (value == null) { - throw new RuntimeException("Value for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value)); - } - - protected void addCriterion(String condition, Object value1, Object value2, String property) { - if (value1 == null || value2 == null) { - throw new RuntimeException("Between values for " + property + " cannot be null"); - } - criteria.add(new Criterion(condition, value1, value2)); - } - - public Criteria andIdIsNull() { - addCriterion("id is null"); - return (Criteria) this; - } - - public Criteria andIdIsNotNull() { - addCriterion("id is not null"); - return (Criteria) this; - } - - public Criteria andIdEqualTo(Long value) { - addCriterion("id =", value, "id"); - return (Criteria) this; - } - - public Criteria andIdNotEqualTo(Long value) { - addCriterion("id <>", value, "id"); - return (Criteria) this; - } - - public Criteria andIdGreaterThan(Long value) { - addCriterion("id >", value, "id"); - return (Criteria) this; - } - - public Criteria andIdGreaterThanOrEqualTo(Long value) { - addCriterion("id >=", value, "id"); - return (Criteria) this; - } - - public Criteria andIdLessThan(Long value) { - addCriterion("id <", value, "id"); - return (Criteria) this; - } - - public Criteria andIdLessThanOrEqualTo(Long value) { - addCriterion("id <=", value, "id"); - return (Criteria) this; - } - - public Criteria andIdIn(List values) { - addCriterion("id in", values, "id"); - return (Criteria) this; - } - - public Criteria andIdNotIn(List values) { - addCriterion("id not in", values, "id"); - return (Criteria) this; - } - - public Criteria andIdBetween(Long value1, Long value2) { - addCriterion("id between", value1, value2, "id"); - return (Criteria) this; - } - - public Criteria andIdNotBetween(Long value1, Long value2) { - addCriterion("id not between", value1, value2, "id"); - return (Criteria) this; - } - - public Criteria andBookUrlIsNull() { - addCriterion("book_url is null"); - return (Criteria) this; - } - - public Criteria andBookUrlIsNotNull() { - addCriterion("book_url is not null"); - return (Criteria) this; - } - - public Criteria andBookUrlEqualTo(String value) { - addCriterion("book_url =", value, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlNotEqualTo(String value) { - addCriterion("book_url <>", value, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlGreaterThan(String value) { - addCriterion("book_url >", value, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlGreaterThanOrEqualTo(String value) { - addCriterion("book_url >=", value, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlLessThan(String value) { - addCriterion("book_url <", value, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlLessThanOrEqualTo(String value) { - addCriterion("book_url <=", value, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlLike(String value) { - addCriterion("book_url like", value, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlNotLike(String value) { - addCriterion("book_url not like", value, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlIn(List values) { - addCriterion("book_url in", values, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlNotIn(List values) { - addCriterion("book_url not in", values, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlBetween(String value1, String value2) { - addCriterion("book_url between", value1, value2, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookUrlNotBetween(String value1, String value2) { - addCriterion("book_url not between", value1, value2, "bookUrl"); - return (Criteria) this; - } - - public Criteria andBookNameIsNull() { - addCriterion("book_name is null"); - return (Criteria) this; - } - - public Criteria andBookNameIsNotNull() { - addCriterion("book_name is not null"); - return (Criteria) this; - } - - public Criteria andBookNameEqualTo(String value) { - addCriterion("book_name =", value, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameNotEqualTo(String value) { - addCriterion("book_name <>", value, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameGreaterThan(String value) { - addCriterion("book_name >", value, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameGreaterThanOrEqualTo(String value) { - addCriterion("book_name >=", value, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameLessThan(String value) { - addCriterion("book_name <", value, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameLessThanOrEqualTo(String value) { - addCriterion("book_name <=", value, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameLike(String value) { - addCriterion("book_name like", value, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameNotLike(String value) { - addCriterion("book_name not like", value, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameIn(List values) { - addCriterion("book_name in", values, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameNotIn(List values) { - addCriterion("book_name not in", values, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameBetween(String value1, String value2) { - addCriterion("book_name between", value1, value2, "bookName"); - return (Criteria) this; - } - - public Criteria andBookNameNotBetween(String value1, String value2) { - addCriterion("book_name not between", value1, value2, "bookName"); - return (Criteria) this; - } - - public Criteria andScoreIsNull() { - addCriterion("score is null"); - return (Criteria) this; - } - - public Criteria andScoreIsNotNull() { - addCriterion("score is not null"); - return (Criteria) this; - } - - public Criteria andScoreEqualTo(Float value) { - addCriterion("score =", value, "score"); - return (Criteria) this; - } - - public Criteria andScoreNotEqualTo(Float value) { - addCriterion("score <>", value, "score"); - return (Criteria) this; - } - - public Criteria andScoreGreaterThan(Float value) { - addCriterion("score >", value, "score"); - return (Criteria) this; - } - - public Criteria andScoreGreaterThanOrEqualTo(Float value) { - addCriterion("score >=", value, "score"); - return (Criteria) this; - } - - public Criteria andScoreLessThan(Float value) { - addCriterion("score <", value, "score"); - return (Criteria) this; - } - - public Criteria andScoreLessThanOrEqualTo(Float value) { - addCriterion("score <=", value, "score"); - return (Criteria) this; - } - - public Criteria andScoreIn(List values) { - addCriterion("score in", values, "score"); - return (Criteria) this; - } - - public Criteria andScoreNotIn(List values) { - addCriterion("score not in", values, "score"); - return (Criteria) this; - } - - public Criteria andScoreBetween(Float value1, Float value2) { - addCriterion("score between", value1, value2, "score"); - return (Criteria) this; - } - - public Criteria andScoreNotBetween(Float value1, Float value2) { - addCriterion("score not between", value1, value2, "score"); - return (Criteria) this; - } - - public Criteria andCreateTimeIsNull() { - addCriterion("create_time is null"); - return (Criteria) this; - } - - public Criteria andCreateTimeIsNotNull() { - addCriterion("create_time is not null"); - return (Criteria) this; - } - - public Criteria andCreateTimeEqualTo(Date value) { - addCriterion("create_time =", value, "createTime"); - return (Criteria) this; - } - - public Criteria andCreateTimeNotEqualTo(Date value) { - addCriterion("create_time <>", value, "createTime"); - return (Criteria) this; - } - - public Criteria andCreateTimeGreaterThan(Date value) { - addCriterion("create_time >", value, "createTime"); - return (Criteria) this; - } - - public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) { - addCriterion("create_time >=", value, "createTime"); - return (Criteria) this; - } - - public Criteria andCreateTimeLessThan(Date value) { - addCriterion("create_time <", value, "createTime"); - return (Criteria) this; - } - - public Criteria andCreateTimeLessThanOrEqualTo(Date value) { - addCriterion("create_time <=", value, "createTime"); - return (Criteria) this; - } - - public Criteria andCreateTimeIn(List values) { - addCriterion("create_time in", values, "createTime"); - return (Criteria) this; - } - - public Criteria andCreateTimeNotIn(List values) { - addCriterion("create_time not in", values, "createTime"); - return (Criteria) this; - } - - public Criteria andCreateTimeBetween(Date value1, Date value2) { - addCriterion("create_time between", value1, value2, "createTime"); - return (Criteria) this; - } - - public Criteria andCreateTimeNotBetween(Date value1, Date value2) { - addCriterion("create_time not between", value1, value2, "createTime"); - return (Criteria) this; - } - } - - public static class Criteria extends GeneratedCriteria { - - protected Criteria() { - super(); - } - } - - public static class Criterion { - private String condition; - - private Object value; - - private Object secondValue; - - private boolean noValue; - - private boolean singleValue; - - private boolean betweenValue; - - private boolean listValue; - - private String typeHandler; - - public String getCondition() { - return condition; - } - - public Object getValue() { - return value; - } - - public Object getSecondValue() { - return secondValue; - } - - public boolean isNoValue() { - return noValue; - } - - public boolean isSingleValue() { - return singleValue; - } - - public boolean isBetweenValue() { - return betweenValue; - } - - public boolean isListValue() { - return listValue; - } - - public String getTypeHandler() { - return typeHandler; - } - - protected Criterion(String condition) { - super(); - this.condition = condition; - this.typeHandler = null; - this.noValue = true; - } - - protected Criterion(String condition, Object value, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.typeHandler = typeHandler; - if (value instanceof List) { - this.listValue = true; - } else { - this.singleValue = true; - } - } - - protected Criterion(String condition, Object value) { - this(condition, value, null); - } - - protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { - super(); - this.condition = condition; - this.value = value; - this.secondValue = secondValue; - this.typeHandler = typeHandler; - this.betweenValue = true; - } - - protected Criterion(String condition, Object value, Object secondValue) { - this(condition, value, secondValue, null); - } - } -} \ No newline at end of file diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/service/BookService.java b/novel-front/src/main/java/xyz/zinglizingli/books/service/BookService.java index ed0badd..745557c 100644 --- a/novel-front/src/main/java/xyz/zinglizingli/books/service/BookService.java +++ b/novel-front/src/main/java/xyz/zinglizingli/books/service/BookService.java @@ -439,7 +439,7 @@ public class BookService { /** * 添加解析日志 * */ - public void addBookParseLog(String bookUrl, String bookName, Float score) { + public void addBookParseLog(String bookUrl, String bookName, Float score, Byte priority) { BookParseLogExample example = new BookParseLogExample(); example.createCriteria().andBookUrlEqualTo(bookUrl).andCreateTimeGreaterThan(new Date(System.currentTimeMillis()-1000*60*60)); if(bookParseLogMapper.countByExample(example)==0) { @@ -447,6 +447,7 @@ public class BookService { bookParseLog.setBookUrl(bookUrl); bookParseLog.setBookName(bookName); bookParseLog.setScore(score); + bookParseLog.setPriority(priority); bookParseLog.setCreateTime(new Date()); bookParseLogMapper.insertSelective(bookParseLog); } @@ -458,7 +459,7 @@ public class BookService { public List queryBookParseLogs() { PageHelper.startPage(1,100); BookParseLogExample example = new BookParseLogExample(); - example.setOrderByClause("create_time desc"); + example.setOrderByClause("priority asc,create_time desc"); List logs = bookParseLogMapper.selectByExample(example); return logs; } diff --git a/novel-front/src/main/java/xyz/zinglizingli/books/web/BookController.java b/novel-front/src/main/java/xyz/zinglizingli/books/web/BookController.java index 0fa5bf7..eb85b9b 100644 --- a/novel-front/src/main/java/xyz/zinglizingli/books/web/BookController.java +++ b/novel-front/src/main/java/xyz/zinglizingli/books/web/BookController.java @@ -59,7 +59,7 @@ public class BookController { @ResponseBody public Map bookSubmit(String bookUrl, String bookName, Float score){ Map result = new HashMap<>(2); - bookService.addBookParseLog(bookUrl, bookName, score); + bookService.addBookParseLog(bookUrl, bookName, score, (byte) 5); result.put("code", 1); return result; } diff --git a/novel-front/src/main/resources/mybatis/generatorConfig.xml b/novel-front/src/main/resources/mybatis/generatorConfig.xml index 9fb02c4..94d5e2f 100644 --- a/novel-front/src/main/resources/mybatis/generatorConfig.xml +++ b/novel-front/src/main/resources/mybatis/generatorConfig.xml @@ -42,7 +42,7 @@ - +
diff --git a/novel-front/src/main/resources/mybatis/mapping/BookParseLogMapper.xml b/novel-front/src/main/resources/mybatis/mapping/BookParseLogMapper.xml deleted file mode 100644 index 4646615..0000000 --- a/novel-front/src/main/resources/mybatis/mapping/BookParseLogMapper.xml +++ /dev/null @@ -1,211 +0,0 @@ - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - id, book_url, book_name, score, create_time - - - - - delete from book_parse_log - where id = #{id,jdbcType=BIGINT} - - - delete from book_parse_log - - - - - - insert into book_parse_log (id, book_url, book_name, - score, create_time) - values (#{id,jdbcType=BIGINT}, #{bookUrl,jdbcType=VARCHAR}, #{bookName,jdbcType=VARCHAR}, - #{score,jdbcType=REAL}, #{createTime,jdbcType=TIMESTAMP}) - - - insert into book_parse_log - - - id, - - - book_url, - - - book_name, - - - score, - - - create_time, - - - - - #{id,jdbcType=BIGINT}, - - - #{bookUrl,jdbcType=VARCHAR}, - - - #{bookName,jdbcType=VARCHAR}, - - - #{score,jdbcType=REAL}, - - - #{createTime,jdbcType=TIMESTAMP}, - - - - - - update book_parse_log - - - id = #{record.id,jdbcType=BIGINT}, - - - book_url = #{record.bookUrl,jdbcType=VARCHAR}, - - - book_name = #{record.bookName,jdbcType=VARCHAR}, - - - score = #{record.score,jdbcType=REAL}, - - - create_time = #{record.createTime,jdbcType=TIMESTAMP}, - - - - - - - - update book_parse_log - set id = #{record.id,jdbcType=BIGINT}, - book_url = #{record.bookUrl,jdbcType=VARCHAR}, - book_name = #{record.bookName,jdbcType=VARCHAR}, - score = #{record.score,jdbcType=REAL}, - create_time = #{record.createTime,jdbcType=TIMESTAMP} - - - - - - update book_parse_log - - - book_url = #{bookUrl,jdbcType=VARCHAR}, - - - book_name = #{bookName,jdbcType=VARCHAR}, - - - score = #{score,jdbcType=REAL}, - - - create_time = #{createTime,jdbcType=TIMESTAMP}, - - - where id = #{id,jdbcType=BIGINT} - - - update book_parse_log - set book_url = #{bookUrl,jdbcType=VARCHAR}, - book_name = #{bookName,jdbcType=VARCHAR}, - score = #{score,jdbcType=REAL}, - create_time = #{createTime,jdbcType=TIMESTAMP} - where id = #{id,jdbcType=BIGINT} - - \ No newline at end of file diff --git a/sql/books.sql b/sql/books.sql index d319939..d29caf4 100644 --- a/sql/books.sql +++ b/sql/books.sql @@ -1042,3 +1042,5 @@ INSERT INTO `book_update_time_log` VALUES ('6', '6', NOW()); INSERT INTO `book_update_time_log` VALUES ('7', '7', NOW()); ALTER TABLE book_parse_log drop INDEX uq_key_bookurl; + +alter table book_parse_log add column `priority` TINYINT(2) not null default 10 ;