feat: redis点赞数据同步数据库
This commit is contained in:
@@ -2,8 +2,11 @@ package com.landaiqing.subject.infra.basic.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectLiked;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 题目点赞表 表数据库访问层
|
||||
*
|
||||
@@ -13,5 +16,12 @@ import org.springframework.stereotype.Repository;
|
||||
@Repository
|
||||
public interface SubjectLikedDao extends BaseMapper<SubjectLiked> {
|
||||
|
||||
void insertBatch(@Param("entities") List<SubjectLiked> subjectLikedList);
|
||||
|
||||
int countByCondition(SubjectLiked subjectLiked);
|
||||
|
||||
List<SubjectLiked> queryPage(@Param("entity") SubjectLiked subjectLiked,
|
||||
@Param("start") int start,
|
||||
@Param("pageSize") Integer pageSize);
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,8 @@ package com.landaiqing.subject.infra.basic.service;
|
||||
|
||||
import com.landaiqing.subject.infra.basic.entity.SubjectLiked;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 题目点赞表 表服务接口
|
||||
@@ -48,4 +50,10 @@ public interface SubjectLikedService {
|
||||
*/
|
||||
SubjectLiked queryByCondition(SubjectLiked subjectLiked);
|
||||
|
||||
void batchInsert(List<SubjectLiked> subjectLikedList);
|
||||
|
||||
|
||||
int countByCondition(SubjectLiked subjectLiked);
|
||||
|
||||
List<SubjectLiked> queryPage(SubjectLiked subjectLiked, int start, Integer pageSize);
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import com.landaiqing.subject.infra.basic.service.SubjectLikedService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -90,4 +91,19 @@ public class SubjectLikedServiceImpl implements SubjectLikedService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchInsert(List<SubjectLiked> subjectLikedList) {
|
||||
this.subjectLikedDao.insertBatch(subjectLikedList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countByCondition(SubjectLiked subjectLiked) {
|
||||
return this.subjectLikedDao.countByCondition(subjectLiked);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubjectLiked> queryPage(SubjectLiked subjectLiked, int start, Integer pageSize) {
|
||||
return this.subjectLikedDao.queryPage(subjectLiked, start, pageSize);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -13,5 +13,35 @@
|
||||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
|
||||
</resultMap>
|
||||
<insert id="insertBatch">
|
||||
insert into subject_liked(id, subject_id, like_user_id, status, created_by, created_time, update_by,
|
||||
update_time, is_deleted)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.id},
|
||||
#{entity.subjectId},
|
||||
#{entity.likeUserId},
|
||||
#{entity.status},
|
||||
#{entity.createdBy},
|
||||
#{entity.createdTime},
|
||||
#{entity.updateBy}, #{entity.updateTime}, #{entity.isDeleted})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="countByCondition" resultType="java.lang.Integer">
|
||||
select count(1)
|
||||
from subject_liked
|
||||
where like_user_id = #{likeUserId} and status = 1
|
||||
and is_deleted = 0
|
||||
</select>
|
||||
|
||||
<select id="queryPage" resultType="com.landaiqing.subject.infra.basic.entity.SubjectLiked">
|
||||
select *
|
||||
from subject_liked
|
||||
where like_user_id = #{entity.likeUserId}
|
||||
and is_deleted = 0 and status = 1
|
||||
limit #{start}
|
||||
, #{pageSize}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
Reference in New Issue
Block a user