mirror of
https://github.com/201206030/novel-cloud.git
synced 2025-06-24 14:06:39 +00:00
集成阿里云OSS,增加文件微服务
This commit is contained in:
@ -70,4 +70,23 @@ public interface BookApi {
|
||||
* */
|
||||
@GetMapping("api/book/listUserCommentByPage")
|
||||
List<BookComment> listUserCommentByPage(@RequestParam("userId") Long userId,@RequestParam("page") int page, @RequestParam("pageSize") int pageSize);
|
||||
|
||||
/**
|
||||
* 查询网络图片的小说
|
||||
*
|
||||
* @param localPicPrefix
|
||||
* @param limit 查询条数
|
||||
* @return 返回小说集合
|
||||
* */
|
||||
@GetMapping("api/book/queryNetworkPicBooks")
|
||||
List<Book> queryNetworkPicBooks(@RequestParam("localPicPrefix") String localPicPrefix,@RequestParam("limit") int limit);
|
||||
|
||||
|
||||
/**
|
||||
* 更新图片路径
|
||||
* @param picUrl 图片路径
|
||||
* @param bookId 小说ID
|
||||
*/
|
||||
@PostMapping("api/book/updateBookPic")
|
||||
void updateBookPic(@RequestParam("picUrl") String picUrl,@RequestParam("bookId") Long bookId);
|
||||
}
|
||||
|
@ -91,4 +91,27 @@ public class BookApi {
|
||||
List<BookComment> listUserCommentByPage(@RequestParam("userId") Long userId,@RequestParam("page") int page, @RequestParam("pageSize") int pageSize){
|
||||
return bookService.listUserCommentByPage(userId,page,pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询网络图片的小说
|
||||
*
|
||||
* @param localPicPrefix
|
||||
* @param limit 查询条数
|
||||
* @return 返回小说集合
|
||||
* */
|
||||
@GetMapping("queryNetworkPicBooks")
|
||||
List<Book> queryNetworkPicBooks(@RequestParam("localPicPrefix") String localPicPrefix,@RequestParam("limit") int limit){
|
||||
return bookService.queryNetworkPicBooks(localPicPrefix,limit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新图片路径
|
||||
* @param picUrl 图片路径
|
||||
* @param bookId 小说ID
|
||||
*/
|
||||
@PostMapping("updateBookPic")
|
||||
void updateBookPic(@RequestParam("picUrl") String picUrl,@RequestParam("bookId") Long bookId){
|
||||
bookService.updateBookPic(picUrl,bookId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,10 @@ import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @author 11797
|
||||
* 消息监听器
|
||||
* @author xiongxiaoyang
|
||||
* @version 1.0
|
||||
* @since 2020/6/2
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
|
@ -136,4 +136,21 @@ public interface BookService {
|
||||
* @return 评论数据
|
||||
* */
|
||||
List<BookComment> listUserCommentByPage(Long userId, int page, int pageSize);
|
||||
|
||||
/**
|
||||
* 查询网络图片的小说
|
||||
*
|
||||
* @param localPicPrefix
|
||||
* @param limit 查询条数
|
||||
* @return 返回小说集合
|
||||
* */
|
||||
List<Book> queryNetworkPicBooks(String localPicPrefix, Integer limit);
|
||||
|
||||
|
||||
/**
|
||||
* 更新图片路径
|
||||
* @param picUrl 图片路径
|
||||
* @param bookId 小说ID
|
||||
*/
|
||||
void updateBookPic(String picUrl, Long bookId);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import static org.mybatis.dynamic.sql.select.SelectDSL.select;
|
||||
|
||||
/**
|
||||
* 小说服务接口实现
|
||||
*
|
||||
* @author xiongxiaoyang
|
||||
* @version 1.0
|
||||
* @since 2020/5/28
|
||||
@ -63,14 +64,14 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
@Override
|
||||
public List<Book> queryBookByIds(List<Long> ids) {
|
||||
return bookMapper.selectMany(select(BookDynamicSqlSupport.id,BookDynamicSqlSupport.catId,BookDynamicSqlSupport.catName,
|
||||
BookDynamicSqlSupport.bookName,BookDynamicSqlSupport.authorName,
|
||||
BookDynamicSqlSupport.lastIndexId,BookDynamicSqlSupport.lastIndexName,BookDynamicSqlSupport.lastIndexUpdateTime,
|
||||
BookDynamicSqlSupport.picUrl,BookDynamicSqlSupport.bookDesc,BookDynamicSqlSupport.score)
|
||||
return bookMapper.selectMany(select(BookDynamicSqlSupport.id, BookDynamicSqlSupport.catId, BookDynamicSqlSupport.catName,
|
||||
BookDynamicSqlSupport.bookName, BookDynamicSqlSupport.authorName,
|
||||
BookDynamicSqlSupport.lastIndexId, BookDynamicSqlSupport.lastIndexName, BookDynamicSqlSupport.lastIndexUpdateTime,
|
||||
BookDynamicSqlSupport.picUrl, BookDynamicSqlSupport.bookDesc, BookDynamicSqlSupport.score)
|
||||
.from(book)
|
||||
.where(BookDynamicSqlSupport.id,isIn(ids))
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3)
|
||||
.where(BookDynamicSqlSupport.id, isIn(ids))
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3)
|
||||
);
|
||||
}
|
||||
|
||||
@ -104,12 +105,12 @@ public class BookServiceImpl implements BookService {
|
||||
BookDynamicSqlSupport.authorId, BookDynamicSqlSupport.authorName,
|
||||
BookDynamicSqlSupport.picUrl, BookDynamicSqlSupport.bookDesc,
|
||||
BookDynamicSqlSupport.wordCount, BookDynamicSqlSupport.lastIndexUpdateTime)
|
||||
.from(book)
|
||||
.where(BookDynamicSqlSupport.wordCount, isGreaterThan(0))
|
||||
.orderBy(sortSpecification)
|
||||
.limit(limit)
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
.from(book)
|
||||
.where(BookDynamicSqlSupport.wordCount, isGreaterThan(0))
|
||||
.orderBy(sortSpecification)
|
||||
.limit(limit)
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
return bookMapper.selectMany(selectStatement);
|
||||
}
|
||||
|
||||
@ -132,12 +133,12 @@ public class BookServiceImpl implements BookService {
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
List<Book> books = bookMapper.selectMany(selectStatement);
|
||||
return books.size() >0 ? books.get(0) : null;
|
||||
return books.size() > 0 ? books.get(0) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVisitCount(Long bookId, int addCount) {
|
||||
bookMapper.addVisitCount(bookId,addCount);
|
||||
bookMapper.addVisitCount(bookId, addCount);
|
||||
|
||||
}
|
||||
|
||||
@ -173,12 +174,12 @@ public class BookServiceImpl implements BookService {
|
||||
//分页查询小说评论数据
|
||||
PageHelper.startPage(page, pageSize);
|
||||
List<BookComment> bookCommentList = bookCommentMapper.selectMany(
|
||||
select(BookCommentDynamicSqlSupport.id,BookCommentDynamicSqlSupport.bookId,
|
||||
select(BookCommentDynamicSqlSupport.id, BookCommentDynamicSqlSupport.bookId,
|
||||
BookCommentDynamicSqlSupport.createUserId,
|
||||
BookCommentDynamicSqlSupport.commentContent,BookCommentDynamicSqlSupport.replyCount,
|
||||
BookCommentDynamicSqlSupport.commentContent, BookCommentDynamicSqlSupport.replyCount,
|
||||
BookCommentDynamicSqlSupport.createTime)
|
||||
.from(BookCommentDynamicSqlSupport.bookComment)
|
||||
.where(BookCommentDynamicSqlSupport.bookId,isEqualTo(bookId))
|
||||
.where(BookCommentDynamicSqlSupport.bookId, isEqualTo(bookId))
|
||||
.orderBy(BookCommentDynamicSqlSupport.createTime.descending())
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
@ -190,11 +191,11 @@ public class BookServiceImpl implements BookService {
|
||||
|
||||
//将评论数据和评论人数据关联起来
|
||||
List<BookCommentVO> resultList = new ArrayList<>(bookCommentList.size());
|
||||
for(BookComment bookComment : bookCommentList){
|
||||
for (BookComment bookComment : bookCommentList) {
|
||||
BookCommentVO bookCommentVO = new BookCommentVO();
|
||||
BeanUtils.copyProperties(bookComment,bookCommentVO);
|
||||
BeanUtils.copyProperties(bookComment, bookCommentVO);
|
||||
User user = userMap.get(bookComment.getCreateUserId());
|
||||
if(user != null){
|
||||
if (user != null) {
|
||||
bookCommentVO.setCreateUserName(user.getUsername());
|
||||
bookCommentVO.setCreateUserPhoto(user.getUserPhoto());
|
||||
}
|
||||
@ -260,9 +261,9 @@ public class BookServiceImpl implements BookService {
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
List<BookIndex> list = bookIndexMapper.selectMany(selectStatement);
|
||||
if (list.size() == 0) {
|
||||
result.put("preBookIndexId",0L);
|
||||
result.put("preBookIndexId", 0L);
|
||||
} else {
|
||||
result.put("preBookIndexId",list.get(0).getId());
|
||||
result.put("preBookIndexId", list.get(0).getId());
|
||||
}
|
||||
|
||||
selectStatement = select(BookIndexDynamicSqlSupport.id)
|
||||
@ -275,9 +276,9 @@ public class BookServiceImpl implements BookService {
|
||||
.render(RenderingStrategies.MYBATIS3);
|
||||
list = bookIndexMapper.selectMany(selectStatement);
|
||||
if (list.size() == 0) {
|
||||
result.put("nextBookIndexId",0L);
|
||||
result.put("nextBookIndexId", 0L);
|
||||
} else {
|
||||
result.put("nextBookIndexId",list.get(0).getId());
|
||||
result.put("nextBookIndexId", list.get(0).getId());
|
||||
}
|
||||
|
||||
|
||||
@ -310,14 +311,44 @@ public class BookServiceImpl implements BookService {
|
||||
public List<BookComment> listUserCommentByPage(Long userId, int page, int pageSize) {
|
||||
PageHelper.startPage(page, pageSize);
|
||||
return bookCommentMapper.selectMany(
|
||||
select(BookCommentDynamicSqlSupport.id,BookCommentDynamicSqlSupport.bookId,
|
||||
select(BookCommentDynamicSqlSupport.id, BookCommentDynamicSqlSupport.bookId,
|
||||
BookCommentDynamicSqlSupport.createUserId,
|
||||
BookCommentDynamicSqlSupport.commentContent,BookCommentDynamicSqlSupport.replyCount,
|
||||
BookCommentDynamicSqlSupport.commentContent, BookCommentDynamicSqlSupport.replyCount,
|
||||
BookCommentDynamicSqlSupport.createTime)
|
||||
.from(BookCommentDynamicSqlSupport.bookComment)
|
||||
.where(BookCommentDynamicSqlSupport.createUserId,isEqualTo(userId))
|
||||
.where(BookCommentDynamicSqlSupport.createUserId, isEqualTo(userId))
|
||||
.orderBy(BookCommentDynamicSqlSupport.createTime.descending())
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Book> queryNetworkPicBooks(String localPicPrefix, Integer limit) {
|
||||
|
||||
|
||||
return bookMapper.selectMany(
|
||||
select(BookDynamicSqlSupport.id, BookDynamicSqlSupport.picUrl)
|
||||
.from(book)
|
||||
.where(BookDynamicSqlSupport.picUrl, isLike("http%"))
|
||||
.and(BookDynamicSqlSupport.picUrl, isNotLike(localPicPrefix))
|
||||
.limit(limit)
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBookPic(String picUrl, Long bookId) {
|
||||
|
||||
bookMapper.update(update(book)
|
||||
.set(BookDynamicSqlSupport.picUrl)
|
||||
.equalTo(picUrl)
|
||||
.set(BookDynamicSqlSupport.updateTime)
|
||||
.equalTo(new Date())
|
||||
.where(BookDynamicSqlSupport.id, isEqualTo(bookId))
|
||||
.build()
|
||||
.render(RenderingStrategies.MYBATIS3));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user