mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
feat: 新增小说点击量增加接口
This commit is contained in:
parent
960b9124d5
commit
63bfacccb7
@ -8,10 +8,7 @@ import io.github.xxyopen.novel.dto.resp.BookInfoRespDto;
|
||||
import io.github.xxyopen.novel.dto.resp.BookRankRespDto;
|
||||
import io.github.xxyopen.novel.service.BookService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
@ -37,6 +34,14 @@ public class BookController {
|
||||
return bookService.getBookById(bookId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加小说点击量接口
|
||||
* */
|
||||
@PostMapping("visit")
|
||||
public RestResp<Void> addVisitCount(Long bookId){
|
||||
return bookService.addVisitCount(bookId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 小说最新章节相关信息查询接口
|
||||
* */
|
||||
|
@ -2,6 +2,7 @@ package io.github.xxyopen.novel.dao.mapper;
|
||||
|
||||
import io.github.xxyopen.novel.dao.entity.BookInfo;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -13,4 +14,10 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
*/
|
||||
public interface BookInfoMapper extends BaseMapper<BookInfo> {
|
||||
|
||||
/**
|
||||
* 增加小说点击量
|
||||
*
|
||||
* @param bookId 小说ID
|
||||
*/
|
||||
void addVisitCount(@Param("bookId") Long bookId);
|
||||
}
|
||||
|
@ -51,4 +51,9 @@ public interface BookService {
|
||||
* 小说推荐列表查询
|
||||
* */
|
||||
RestResp<List<BookInfoRespDto>> listRecBooks(Long bookId) throws NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* 增加小说点击量
|
||||
* */
|
||||
RestResp<Void> addVisitCount(Long bookId);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.github.xxyopen.novel.core.common.resp.RestResp;
|
||||
import io.github.xxyopen.novel.dao.entity.BookChapter;
|
||||
import io.github.xxyopen.novel.dao.mapper.BookChapterMapper;
|
||||
import io.github.xxyopen.novel.dao.mapper.BookInfoMapper;
|
||||
import io.github.xxyopen.novel.dto.resp.*;
|
||||
import io.github.xxyopen.novel.manager.BookChapterCacheManager;
|
||||
import io.github.xxyopen.novel.manager.BookContentCacheManager;
|
||||
@ -39,6 +40,8 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
private final BookContentCacheManager bookContentCacheManager;
|
||||
|
||||
private final BookInfoMapper bookInfoMapper;
|
||||
|
||||
private final BookChapterMapper bookChapterMapper;
|
||||
|
||||
private static final Integer REC_BOOK_COUNT = 4;
|
||||
@ -108,6 +111,12 @@ public class BookServiceImpl implements BookService {
|
||||
return RestResp.ok(respDtoList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResp<Void> addVisitCount(Long bookId) {
|
||||
bookInfoMapper.addVisitCount(bookId);
|
||||
return RestResp.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResp<BookContentAboutRespDto> getBookContentAbout(Long chapterId) {
|
||||
// 查询章节信息
|
||||
|
@ -2,4 +2,10 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="io.github.xxyopen.novel.dao.mapper.BookInfoMapper">
|
||||
|
||||
<update id="addVisitCount">
|
||||
update book_info
|
||||
set visit_count = visit_count + 1
|
||||
where id = #{bookId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user