mirror of
https://github.com/201206030/novel.git
synced 2025-07-04 12:36:37 +00:00
新增加入书架的书籍下次可继续上次阅读记录阅读
This commit is contained in:
@ -28,4 +28,8 @@ public interface UserRefBookMapper {
|
||||
int updateByPrimaryKeySelective(UserRefBook record);
|
||||
|
||||
int updateByPrimaryKey(UserRefBook record);
|
||||
|
||||
void updateNewstIndex(@Param("bookId") Long bookId,@Param("userId") String userId,@Param("indexNum") Integer indexNum);
|
||||
|
||||
Integer queryBookIndexNumber(@Param("userId") String userId,@Param("bookId") Long bookId);
|
||||
}
|
@ -17,10 +17,7 @@ import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import tk.mybatis.orderbyhelper.OrderByHelper;
|
||||
import xyz.zinglizingli.books.constant.CacheKeyConstans;
|
||||
import xyz.zinglizingli.books.mapper.BookContentMapper;
|
||||
import xyz.zinglizingli.books.mapper.BookIndexMapper;
|
||||
import xyz.zinglizingli.books.mapper.BookMapper;
|
||||
import xyz.zinglizingli.books.mapper.ScreenBulletMapper;
|
||||
import xyz.zinglizingli.books.mapper.*;
|
||||
import xyz.zinglizingli.books.po.*;
|
||||
import xyz.zinglizingli.common.cache.CommonCacheUtil;
|
||||
import xyz.zinglizingli.common.utils.RestTemplateUtil;
|
||||
@ -45,6 +42,9 @@ public class BookService {
|
||||
@Autowired
|
||||
private ScreenBulletMapper screenBulletMapper;
|
||||
|
||||
@Autowired
|
||||
private UserRefBookMapper userRefBookMapper;
|
||||
|
||||
@Autowired
|
||||
private CommonCacheUtil cacheUtil;
|
||||
|
||||
@ -330,9 +330,14 @@ public class BookService {
|
||||
return contentBuilder.toString();
|
||||
}
|
||||
|
||||
public void addVisitCount(Long bookId) {
|
||||
public void addVisitCount(Long bookId, String userId, Integer indexNum) {
|
||||
|
||||
bookMapper.addVisitCount(bookId);
|
||||
|
||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(userId)) {
|
||||
userRefBookMapper.updateNewstIndex(bookId, userId, indexNum);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String queryIndexNameByBookIdAndIndexNum(Long bookId, Integer indexNum) {
|
||||
|
@ -83,4 +83,8 @@ public class UserService {
|
||||
addToCollect(bookId, userid);
|
||||
}
|
||||
}
|
||||
|
||||
public Integer queryBookIndexNumber(String userId, Long bookId) {
|
||||
return userRefBookMapper.queryBookIndexNumber(userId,bookId);
|
||||
}
|
||||
}
|
||||
|
@ -176,13 +176,13 @@ public class ApiBookController {
|
||||
return modelMap;
|
||||
}
|
||||
|
||||
@RequestMapping("addVisit")
|
||||
/*@RequestMapping("addVisit")
|
||||
public String addVisit(@RequestParam("bookId") Long bookId) {
|
||||
|
||||
bookService.addVisitCount(bookId);
|
||||
bookService.addVisitCount(bookId, userId, indexNum);
|
||||
|
||||
return "ok";
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import xyz.zinglizingli.books.po.BookContent;
|
||||
import xyz.zinglizingli.books.po.BookIndex;
|
||||
import xyz.zinglizingli.books.po.ScreenBullet;
|
||||
import xyz.zinglizingli.books.service.BookService;
|
||||
import xyz.zinglizingli.books.service.UserService;
|
||||
import xyz.zinglizingli.books.vo.BookVO;
|
||||
import xyz.zinglizingli.common.cache.CommonCacheUtil;
|
||||
|
||||
@ -35,6 +36,9 @@ public class BookController {
|
||||
@Autowired
|
||||
private BookService bookService;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Autowired
|
||||
private CommonCacheUtil commonCacheUtil;
|
||||
|
||||
@ -187,7 +191,16 @@ public class BookController {
|
||||
}
|
||||
|
||||
@RequestMapping("{bookId}.html")
|
||||
public String detail(@PathVariable("bookId") Long bookId, ModelMap modelMap) {
|
||||
public String detail(@PathVariable("bookId") Long bookId, @RequestParam(value = "token",required = false)String token, ModelMap modelMap) {
|
||||
String userId = commonCacheUtil.get(token);
|
||||
if(org.apache.commons.lang3.StringUtils.isNotBlank(userId)){
|
||||
Integer indexNumber = userService.queryBookIndexNumber(userId,bookId);
|
||||
if(indexNumber!=null){
|
||||
return "redirect:/book/"+bookId+"/"+indexNumber+".html";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//查询基本信息
|
||||
Book book = bookService.queryBaseInfo(bookId);
|
||||
//查询最新目录信息
|
||||
@ -260,9 +273,10 @@ public class BookController {
|
||||
|
||||
@RequestMapping("addVisit")
|
||||
@ResponseBody
|
||||
public String addVisit(@RequestParam("bookId") Long bookId) {
|
||||
public String addVisit(@RequestParam("bookId") Long bookId,@RequestParam("indexNum") Integer indexNum,@RequestParam("token") String token) {
|
||||
String userId = commonCacheUtil.get(token);
|
||||
|
||||
bookService.addVisitCount(bookId);
|
||||
bookService.addVisitCount(bookId,userId,indexNum);
|
||||
|
||||
return "ok";
|
||||
}
|
||||
|
Reference in New Issue
Block a user