mirror of
https://github.com/201206030/novel.git
synced 2025-04-27 07:30:50 +00:00
feat: 增加书架状态查询接口
This commit is contained in:
parent
cb8f347ccc
commit
0ff6c56f27
@ -80,4 +80,14 @@ public class UserController {
|
||||
return bookService.saveComment(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询书架状态接口
|
||||
* 0-不在书架
|
||||
* 1-已在书架
|
||||
* */
|
||||
@GetMapping("bookshelf_status")
|
||||
public RestResp<Integer> getBookshelfStatus(@RequestBody String bookId) {
|
||||
return userService.getBookshelfStatus(UserHolder.getUserId(),bookId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,6 +37,21 @@ public class DatabaseConsts {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户书架表
|
||||
*/
|
||||
public static class UserBookshelfTable {
|
||||
|
||||
private UserBookshelfTable() {
|
||||
throw new IllegalStateException(SystemConfigConsts.CONST_INSTANCE_EXCEPTION_MSG);
|
||||
}
|
||||
|
||||
public static final String COLUMN_USER_ID = "user_id";
|
||||
|
||||
public static final String COLUMN_BOOK_ID = "book_id";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 作家信息表
|
||||
*/
|
||||
|
@ -19,96 +19,111 @@ public interface BookService {
|
||||
|
||||
/**
|
||||
* 小说搜索
|
||||
*
|
||||
* @param condition 搜索条件
|
||||
* @return 搜索结果
|
||||
* */
|
||||
*/
|
||||
RestResp<PageRespDto<BookInfoRespDto>> searchBooks(BookSearchReqDto condition);
|
||||
|
||||
/**
|
||||
* 小说点击榜查询
|
||||
*
|
||||
* @return 小说点击排行列表
|
||||
* */
|
||||
*/
|
||||
RestResp<List<BookRankRespDto>> listVisitRankBooks();
|
||||
|
||||
/**
|
||||
* 小说新书榜查询
|
||||
*
|
||||
* @return 小说新书排行列表
|
||||
* */
|
||||
*/
|
||||
RestResp<List<BookRankRespDto>> listNewestRankBooks();
|
||||
|
||||
/**
|
||||
* 小说更新榜查询
|
||||
*
|
||||
* @return 小说更新排行列表
|
||||
* */
|
||||
*/
|
||||
RestResp<List<BookRankRespDto>> listUpdateRankBooks();
|
||||
|
||||
/**
|
||||
* 小说信息查询
|
||||
*
|
||||
* @param bookId 小说ID
|
||||
* @return 小说信息
|
||||
* */
|
||||
*/
|
||||
RestResp<BookInfoRespDto> getBookById(Long bookId);
|
||||
|
||||
/**
|
||||
* 小说内容相关信息查询
|
||||
*
|
||||
* @param chapterId 章节ID
|
||||
* @return 内容相关联的信息
|
||||
* */
|
||||
*/
|
||||
RestResp<BookContentAboutRespDto> getBookContentAbout(Long chapterId);
|
||||
|
||||
/**
|
||||
* 小说最新章节相关信息查询
|
||||
*
|
||||
* @param bookId 小说ID
|
||||
* @return 章节相关联的信息
|
||||
* */
|
||||
*/
|
||||
RestResp<BookChapterAboutRespDto> getLastChapterAbout(Long bookId);
|
||||
|
||||
/**
|
||||
* 小说推荐列表查询
|
||||
*
|
||||
* @param bookId 小说ID
|
||||
* @return 小说信息列表
|
||||
* */
|
||||
*/
|
||||
RestResp<List<BookInfoRespDto>> listRecBooks(Long bookId) throws NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* 增加小说点击量
|
||||
*
|
||||
* @param bookId 小说ID
|
||||
* @return 成功状态
|
||||
* */
|
||||
*/
|
||||
RestResp<Void> addVisitCount(Long bookId);
|
||||
|
||||
/**
|
||||
* 获取上一章节ID
|
||||
*
|
||||
* @param chapterId 章节ID
|
||||
* @return 上一章节ID
|
||||
* */
|
||||
*/
|
||||
RestResp<Long> getPreChapterId(Long chapterId);
|
||||
|
||||
/**
|
||||
* 获取下一章节ID
|
||||
*
|
||||
* @param chapterId 章节ID
|
||||
* @return 下一章节ID
|
||||
* */
|
||||
*/
|
||||
RestResp<Long> nextChapterId(Long chapterId);
|
||||
|
||||
/**
|
||||
* 小说章节列表查询
|
||||
*
|
||||
* @param bookId 小说ID
|
||||
* @return 小说章节列表
|
||||
* */
|
||||
*/
|
||||
RestResp<List<BookChapterRespDto>> listChapters(Long bookId);
|
||||
|
||||
/**
|
||||
* 小说分类列表查询
|
||||
*
|
||||
* @param workDirection 作品方向;0-男频 1-女频
|
||||
* @return 分类列表
|
||||
* */
|
||||
*/
|
||||
RestResp<List<BookCategoryRespDto>> listCategory(Integer workDirection);
|
||||
|
||||
/**
|
||||
* 发表评论
|
||||
*
|
||||
* @param dto 评论相关 DTO
|
||||
* @return void
|
||||
* */
|
||||
*/
|
||||
RestResp<Void> saveComment(UserCommentReqDto dto);
|
||||
|
||||
}
|
||||
|
@ -18,12 +18,13 @@ public interface HomeService {
|
||||
* 查询首页小说推荐列表
|
||||
*
|
||||
* @return 首页小说推荐列表的 rest 响应结果
|
||||
* */
|
||||
*/
|
||||
RestResp<List<HomeBookRespDto>> listHomeBooks();
|
||||
|
||||
/**
|
||||
* 首页友情链接列表查询
|
||||
*
|
||||
* @return 友情链接列表
|
||||
* */
|
||||
*/
|
||||
RestResp<List<HomeFriendLinkRespDto>> listHomeFriendLinks();
|
||||
}
|
||||
|
@ -15,14 +15,16 @@ public interface NewsService {
|
||||
|
||||
/**
|
||||
* 最新新闻列表查询
|
||||
*
|
||||
* @return 新闻列表
|
||||
* */
|
||||
*/
|
||||
RestResp<List<NewsInfoRespDto>> listLatestNews();
|
||||
|
||||
/**
|
||||
* 新闻信息查询
|
||||
*
|
||||
* @param id 新闻ID
|
||||
* @return 新闻信息
|
||||
* */
|
||||
*/
|
||||
RestResp<NewsInfoRespDto> getNews(Long id);
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ public interface ResourceService {
|
||||
|
||||
/**
|
||||
* 获取图片验证码
|
||||
*
|
||||
* @return Base64编码的图片
|
||||
* */
|
||||
*/
|
||||
RestResp<ImgVerifyCodeRespDto> getImgVerifyCode() throws IOException;
|
||||
}
|
||||
|
@ -16,38 +16,52 @@ public interface UserService {
|
||||
|
||||
/**
|
||||
* 用户注册
|
||||
*
|
||||
* @param dto 注册参数
|
||||
* @return JWT
|
||||
* */
|
||||
*/
|
||||
RestResp<String> register(UserRegisterReqDto dto);
|
||||
|
||||
/**
|
||||
* 用户登录
|
||||
*
|
||||
* @param dto 登录参数
|
||||
* @return JWT + 昵称
|
||||
* */
|
||||
*/
|
||||
RestResp<UserLoginRespDto> login(UserLoginReqDto dto);
|
||||
|
||||
/**
|
||||
* 用户反馈
|
||||
* @param userId 反馈用户ID
|
||||
*
|
||||
* @param userId 反馈用户ID
|
||||
* @param content 反馈内容
|
||||
* @return void
|
||||
* */
|
||||
*/
|
||||
RestResp<Void> saveFeedback(Long userId, String content);
|
||||
|
||||
/**
|
||||
* 用户信息修改
|
||||
*
|
||||
* @param dto 用户信息
|
||||
* @return void
|
||||
* */
|
||||
*/
|
||||
RestResp<Void> updateUserInfo(UserInfoUptReqDto dto);
|
||||
|
||||
/**
|
||||
* 用户反馈删除
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param id 反馈ID
|
||||
* @param id 反馈ID
|
||||
* @return void
|
||||
* */
|
||||
*/
|
||||
RestResp<Void> deleteFeedback(Long userId, Long id);
|
||||
|
||||
/**
|
||||
* 查询书架状态接口
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param bookId 小说ID
|
||||
* @return 0-不在书架 1-已在书架
|
||||
*/
|
||||
RestResp<Integer> getBookshelfStatus(Long userId, String bookId);
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
package io.github.xxyopen.novel.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.github.xxyopen.novel.core.common.constant.CommonConsts;
|
||||
import io.github.xxyopen.novel.core.common.constant.ErrorCodeEnum;
|
||||
import io.github.xxyopen.novel.core.common.exception.BusinessException;
|
||||
import io.github.xxyopen.novel.core.common.resp.RestResp;
|
||||
import io.github.xxyopen.novel.core.constant.DatabaseConsts;
|
||||
import io.github.xxyopen.novel.core.constant.SystemConfigConsts;
|
||||
import io.github.xxyopen.novel.core.util.JwtUtils;
|
||||
import io.github.xxyopen.novel.dao.entity.UserBookshelf;
|
||||
import io.github.xxyopen.novel.dao.entity.UserFeedback;
|
||||
import io.github.xxyopen.novel.dao.entity.UserInfo;
|
||||
import io.github.xxyopen.novel.dao.mapper.UserBookshelfMapper;
|
||||
import io.github.xxyopen.novel.dao.mapper.UserFeedbackMapper;
|
||||
import io.github.xxyopen.novel.dao.mapper.UserInfoMapper;
|
||||
import io.github.xxyopen.novel.dto.req.UserInfoUptReqDto;
|
||||
@ -41,6 +44,8 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
private final UserFeedbackMapper userFeedbackMapper;
|
||||
|
||||
private final UserBookshelfMapper userBookshelfMapper;
|
||||
|
||||
private final JwtUtils jwtUtils;
|
||||
|
||||
@Override
|
||||
@ -128,8 +133,20 @@ public class UserServiceImpl implements UserService {
|
||||
public RestResp<Void> deleteFeedback(Long userId, Long id) {
|
||||
QueryWrapper<UserFeedback> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(DatabaseConsts.CommonColumnEnum.ID.getName(), id)
|
||||
.eq(DatabaseConsts.UserFeedBackTable.COLUMN_USER_ID,userId);
|
||||
.eq(DatabaseConsts.UserFeedBackTable.COLUMN_USER_ID, userId);
|
||||
userFeedbackMapper.delete(queryWrapper);
|
||||
return RestResp.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestResp<Integer> getBookshelfStatus(Long userId, String bookId) {
|
||||
QueryWrapper<UserBookshelf> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(DatabaseConsts.UserBookshelfTable.COLUMN_USER_ID, userId)
|
||||
.eq(DatabaseConsts.UserBookshelfTable.COLUMN_BOOK_ID, bookId);
|
||||
return RestResp.ok(
|
||||
userBookshelfMapper.selectCount(queryWrapper) > 0
|
||||
? CommonConsts.YES
|
||||
: CommonConsts.NO
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user