|
@@ -10,6 +10,7 @@ import com.book.dao.cpsshard.entity.Recharge;
|
|
|
import com.book.dao.cpsshard.entity.UserRecentlyRead;
|
|
|
import com.book.dao.cpsshard.mapper.ConsumeMapper;
|
|
|
import com.book.dao.cpsshard.mapper.RechargeMapper;
|
|
|
+import com.book.dao.cpsshard.mapper.UserRecentlyRead2Mapper;
|
|
|
import com.book.dao.cpsshard.mapper.UserRecentlyReadMapper;
|
|
|
import com.book.dao.cpsshard.pojo.example.ConsumeExample;
|
|
|
import com.book.dao.cpsshard.pojo.example.RechargeExample;
|
|
@@ -475,17 +476,41 @@ public class BookServiceImpl implements BookService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<UserRecentlyRead> getRecentReadByUserId(UserRecentReadVO userRecentlyRead) {
|
|
|
+ public List<UserRecentlyReadRes> getRecentReadByUserId(UserRecentReadVO vo) {
|
|
|
+ ArrayList<UserRecentlyReadRes> res = new ArrayList<>();
|
|
|
UserRecentlyReadExample example = UserRecentlyReadExample.newAndCreateCriteria()
|
|
|
- .andUserIdEqualTo(userRecentlyRead.getUserId())
|
|
|
+ .andUserIdEqualTo(vo.getUserId())
|
|
|
.example();
|
|
|
example.orderBy(UserRecentlyRead.Column.updatetime.desc());
|
|
|
- example.page(userRecentlyRead.getPage(), userRecentlyRead.getSize());
|
|
|
+ example.page(vo.getPage(), vo.getSize());
|
|
|
List<UserRecentlyRead> userRecentlyReads = userRecentlyReadMapper.selectByExample(example);
|
|
|
+
|
|
|
if (userRecentlyReads == null) {
|
|
|
- userRecentlyReads = new ArrayList<>();
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取 bookId 和 cover
|
|
|
+ List<Long> bookIds = userRecentlyReads.stream().map(x -> x.getBookId()).collect(Collectors.toList());
|
|
|
+ List<Book> books = bookMapper.selectByExampleSelective(
|
|
|
+ BookExample.newAndCreateCriteria()
|
|
|
+ .andIdIn(bookIds).example()
|
|
|
+ , Book.Column.id, Book.Column.name, Book.Column.image
|
|
|
+ );
|
|
|
+ HashMap<Long, Book> map = new HashMap<>();
|
|
|
+ for (Book book : books) {
|
|
|
+ map.put(book.getId(), book);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 填充 res
|
|
|
+ for (UserRecentlyRead userRecentlyRead : userRecentlyReads) {
|
|
|
+ UserRecentlyReadRes recentlyReadRes = new UserRecentlyReadRes();
|
|
|
+ BeanUtils.copyProperties(userRecentlyRead, recentlyReadRes);
|
|
|
+ recentlyReadRes.setBookName(map.get(userRecentlyRead.getBookId()).getName());
|
|
|
+ recentlyReadRes.setImage(map.get(userRecentlyRead.getBookId()).getImage());
|
|
|
+ res.add(recentlyReadRes);
|
|
|
}
|
|
|
- return userRecentlyReads;
|
|
|
+
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
@Override
|