mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
优化
This commit is contained in:
parent
d7e3dee2af
commit
8aa724bd69
@ -7,12 +7,14 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
|
|||||||
import org.springframework.cache.annotation.EnableCaching;
|
import org.springframework.cache.annotation.EnableCaching;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.scheduling.TaskScheduler;
|
import org.springframework.scheduling.TaskScheduler;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@EnableScheduling
|
@EnableScheduling
|
||||||
|
@EnableAsync
|
||||||
@MapperScan({"xyz.zinglizingli.*.mapper"})
|
@MapperScan({"xyz.zinglizingli.*.mapper"})
|
||||||
@ServletComponentScan
|
@ServletComponentScan
|
||||||
public class BookApplication {
|
public class BookApplication {
|
||||||
|
@ -27,4 +27,15 @@ public interface BookParseLogMapper {
|
|||||||
int updateByPrimaryKeySelective(BookParseLog record);
|
int updateByPrimaryKeySelective(BookParseLog record);
|
||||||
|
|
||||||
int updateByPrimaryKey(BookParseLog record);
|
int updateByPrimaryKey(BookParseLog record);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加小说更新次数
|
||||||
|
*
|
||||||
|
* @param logs*/
|
||||||
|
void addBookUpdateCount(List<BookParseLog> logs);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询解析日志
|
||||||
|
* */
|
||||||
|
List<BookParseLog> queryBookParseLogs();
|
||||||
}
|
}
|
@ -15,6 +15,8 @@ public class BookParseLog {
|
|||||||
|
|
||||||
private Byte priority;
|
private Byte priority;
|
||||||
|
|
||||||
|
private Byte updateCount;
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -62,4 +64,12 @@ public class BookParseLog {
|
|||||||
public void setPriority(Byte priority) {
|
public void setPriority(Byte priority) {
|
||||||
this.priority = priority;
|
this.priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Byte getUpdateCount() {
|
||||||
|
return updateCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateCount(Byte updateCount) {
|
||||||
|
this.updateCount = updateCount;
|
||||||
|
}
|
||||||
}
|
}
|
@ -484,6 +484,66 @@ public class BookParseLogExample {
|
|||||||
addCriterion("priority not between", value1, value2, "priority");
|
addCriterion("priority not between", value1, value2, "priority");
|
||||||
return (Criteria) this;
|
return (Criteria) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountIsNull() {
|
||||||
|
addCriterion("update_count is null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountIsNotNull() {
|
||||||
|
addCriterion("update_count is not null");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountEqualTo(Byte value) {
|
||||||
|
addCriterion("update_count =", value, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountNotEqualTo(Byte value) {
|
||||||
|
addCriterion("update_count <>", value, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountGreaterThan(Byte value) {
|
||||||
|
addCriterion("update_count >", value, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountGreaterThanOrEqualTo(Byte value) {
|
||||||
|
addCriterion("update_count >=", value, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountLessThan(Byte value) {
|
||||||
|
addCriterion("update_count <", value, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountLessThanOrEqualTo(Byte value) {
|
||||||
|
addCriterion("update_count <=", value, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountIn(List<Byte> values) {
|
||||||
|
addCriterion("update_count in", values, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountNotIn(List<Byte> values) {
|
||||||
|
addCriterion("update_count not in", values, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountBetween(Byte value1, Byte value2) {
|
||||||
|
addCriterion("update_count between", value1, value2, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Criteria andUpdateCountNotBetween(Byte value1, Byte value2) {
|
||||||
|
addCriterion("update_count not between", value1, value2, "updateCount");
|
||||||
|
return (Criteria) this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Criteria extends GeneratedCriteria {
|
public static class Criteria extends GeneratedCriteria {
|
||||||
|
@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import tk.mybatis.orderbyhelper.OrderByHelper;
|
import tk.mybatis.orderbyhelper.OrderByHelper;
|
||||||
@ -457,13 +458,19 @@ public class BookService {
|
|||||||
* 查询解析日志
|
* 查询解析日志
|
||||||
* */
|
* */
|
||||||
public List<BookParseLog> queryBookParseLogs() {
|
public List<BookParseLog> queryBookParseLogs() {
|
||||||
PageHelper.startPage(1,100);
|
List<BookParseLog> logs = bookParseLogMapper.queryBookParseLogs();
|
||||||
BookParseLogExample example = new BookParseLogExample();
|
SpringUtil.getBean(BookService.class).addBookUpdateCount(logs);
|
||||||
example.setOrderByClause("priority asc,create_time desc");
|
|
||||||
List<BookParseLog> logs = bookParseLogMapper.selectByExample(example);
|
|
||||||
return logs;
|
return logs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 增加小说更新次数
|
||||||
|
* */
|
||||||
|
@Async
|
||||||
|
public void addBookUpdateCount(List<BookParseLog> logs) {
|
||||||
|
bookParseLogMapper.addBookUpdateCount(logs);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除已经成功更新的解析日志
|
* 删除已经成功更新的解析日志
|
||||||
* */
|
* */
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<result column="score" property="score" jdbcType="REAL"/>
|
<result column="score" property="score" jdbcType="REAL"/>
|
||||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||||
<result column="priority" property="priority" jdbcType="TINYINT"/>
|
<result column="priority" property="priority" jdbcType="TINYINT"/>
|
||||||
|
<result column="update_count" property="updateCount" jdbcType="TINYINT"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Example_Where_Clause">
|
<sql id="Example_Where_Clause">
|
||||||
<where>
|
<where>
|
||||||
@ -27,7 +28,8 @@
|
|||||||
</when>
|
</when>
|
||||||
<when test="criterion.listValue">
|
<when test="criterion.listValue">
|
||||||
and ${criterion.condition}
|
and ${criterion.condition}
|
||||||
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
|
<foreach collection="criterion.value" item="listItem" open="(" close=")"
|
||||||
|
separator=",">
|
||||||
#{listItem}
|
#{listItem}
|
||||||
</foreach>
|
</foreach>
|
||||||
</when>
|
</when>
|
||||||
@ -56,7 +58,8 @@
|
|||||||
</when>
|
</when>
|
||||||
<when test="criterion.listValue">
|
<when test="criterion.listValue">
|
||||||
and ${criterion.condition}
|
and ${criterion.condition}
|
||||||
<foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
|
<foreach collection="criterion.value" item="listItem" open="(" close=")"
|
||||||
|
separator=",">
|
||||||
#{listItem}
|
#{listItem}
|
||||||
</foreach>
|
</foreach>
|
||||||
</when>
|
</when>
|
||||||
@ -68,9 +71,10 @@
|
|||||||
</where>
|
</where>
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, book_url, book_name, score, create_time, priority
|
id, book_url, book_name, score, create_time, priority, update_count
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByExample" resultMap="BaseResultMap" parameterType="xyz.zinglizingli.books.po.BookParseLogExample" >
|
<select id="selectByExample" resultMap="BaseResultMap"
|
||||||
|
parameterType="xyz.zinglizingli.books.po.BookParseLogExample">
|
||||||
select
|
select
|
||||||
<if test="distinct">
|
<if test="distinct">
|
||||||
distinct
|
distinct
|
||||||
@ -102,11 +106,11 @@
|
|||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="xyz.zinglizingli.books.po.BookParseLog">
|
<insert id="insert" parameterType="xyz.zinglizingli.books.po.BookParseLog">
|
||||||
insert into book_parse_log (id, book_url, book_name,
|
insert into book_parse_log (id, book_url, book_name,
|
||||||
score, create_time, priority
|
score, create_time, priority,
|
||||||
)
|
update_count)
|
||||||
values (#{id,jdbcType=BIGINT}, #{bookUrl,jdbcType=VARCHAR}, #{bookName,jdbcType=VARCHAR},
|
values (#{id,jdbcType=BIGINT}, #{bookUrl,jdbcType=VARCHAR}, #{bookName,jdbcType=VARCHAR},
|
||||||
#{score,jdbcType=REAL}, #{createTime,jdbcType=TIMESTAMP}, #{priority,jdbcType=TINYINT}
|
#{score,jdbcType=REAL}, #{createTime,jdbcType=TIMESTAMP}, #{priority,jdbcType=TINYINT},
|
||||||
)
|
#{updateCount,jdbcType=TINYINT})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="xyz.zinglizingli.books.po.BookParseLog">
|
<insert id="insertSelective" parameterType="xyz.zinglizingli.books.po.BookParseLog">
|
||||||
insert into book_parse_log
|
insert into book_parse_log
|
||||||
@ -129,6 +133,9 @@
|
|||||||
<if test="priority != null">
|
<if test="priority != null">
|
||||||
priority,
|
priority,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="updateCount != null">
|
||||||
|
update_count,
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
@ -149,9 +156,13 @@
|
|||||||
<if test="priority != null">
|
<if test="priority != null">
|
||||||
#{priority,jdbcType=TINYINT},
|
#{priority,jdbcType=TINYINT},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="updateCount != null">
|
||||||
|
#{updateCount,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<select id="countByExample" parameterType="xyz.zinglizingli.books.po.BookParseLogExample" resultType="java.lang.Integer" >
|
<select id="countByExample" parameterType="xyz.zinglizingli.books.po.BookParseLogExample"
|
||||||
|
resultType="java.lang.Integer">
|
||||||
select count(*) from book_parse_log
|
select count(*) from book_parse_log
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Example_Where_Clause"/>
|
<include refid="Example_Where_Clause"/>
|
||||||
@ -178,6 +189,9 @@
|
|||||||
<if test="record.priority != null">
|
<if test="record.priority != null">
|
||||||
priority = #{record.priority,jdbcType=TINYINT},
|
priority = #{record.priority,jdbcType=TINYINT},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="record.updateCount != null">
|
||||||
|
update_count = #{record.updateCount,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
</set>
|
</set>
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause"/>
|
<include refid="Update_By_Example_Where_Clause"/>
|
||||||
@ -190,7 +204,8 @@
|
|||||||
book_name = #{record.bookName,jdbcType=VARCHAR},
|
book_name = #{record.bookName,jdbcType=VARCHAR},
|
||||||
score = #{record.score,jdbcType=REAL},
|
score = #{record.score,jdbcType=REAL},
|
||||||
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
||||||
priority = #{record.priority,jdbcType=TINYINT}
|
priority = #{record.priority,jdbcType=TINYINT},
|
||||||
|
update_count = #{record.updateCount,jdbcType=TINYINT}
|
||||||
<if test="_parameter != null">
|
<if test="_parameter != null">
|
||||||
<include refid="Update_By_Example_Where_Clause"/>
|
<include refid="Update_By_Example_Where_Clause"/>
|
||||||
</if>
|
</if>
|
||||||
@ -213,6 +228,9 @@
|
|||||||
<if test="priority != null">
|
<if test="priority != null">
|
||||||
priority = #{priority,jdbcType=TINYINT},
|
priority = #{priority,jdbcType=TINYINT},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="updateCount != null">
|
||||||
|
update_count = #{updateCount,jdbcType=TINYINT},
|
||||||
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=BIGINT}
|
where id = #{id,jdbcType=BIGINT}
|
||||||
</update>
|
</update>
|
||||||
@ -222,7 +240,29 @@
|
|||||||
book_name = #{bookName,jdbcType=VARCHAR},
|
book_name = #{bookName,jdbcType=VARCHAR},
|
||||||
score = #{score,jdbcType=REAL},
|
score = #{score,jdbcType=REAL},
|
||||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||||
priority = #{priority,jdbcType=TINYINT}
|
priority = #{priority,jdbcType=TINYINT},
|
||||||
|
update_count = #{updateCount,jdbcType=TINYINT}
|
||||||
where id = #{id,jdbcType=BIGINT}
|
where id = #{id,jdbcType=BIGINT}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="addBookUpdateCount">
|
||||||
|
|
||||||
|
update book_parse_log set update_count = update_count + 1
|
||||||
|
where id in
|
||||||
|
<foreach collection="list" item="log" separator="," open="(" close=")">
|
||||||
|
#{log.id}
|
||||||
|
</foreach>
|
||||||
|
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="queryBookParseLogs" resultMap="BaseResultMap">
|
||||||
|
select
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
from book_parse_log
|
||||||
|
where update_count <![CDATA[ < ]]> 5
|
||||||
|
order by priority asc,create_time desc
|
||||||
|
limit 100
|
||||||
|
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
1
sql/2020-04-22.sql
Normal file
1
sql/2020-04-22.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
alter table book_parse_log add column `update_count` TINYINT(2) not null default 0 ;
|
Loading…
x
Reference in New Issue
Block a user