|
@@ -2,13 +2,21 @@ package com.book.server.service.impl;
|
|
|
|
|
|
import com.book.server.common.entity.PageResult;
|
|
|
import com.book.server.dao.entity.Book;
|
|
|
+import com.book.server.dao.entity.ManageBlock;
|
|
|
+import com.book.server.dao.entity.ManageBlockResource;
|
|
|
import com.book.server.dao.entity.example.BookExample;
|
|
|
+import com.book.server.dao.entity.example.ManageBlockExample;
|
|
|
+import com.book.server.dao.entity.example.ManageBlockResourceExample;
|
|
|
import com.book.server.dao.mapper.BookMapper;
|
|
|
+import com.book.server.dao.mapper.ManageBlockMapper;
|
|
|
+import com.book.server.dao.mapper.ManageBlockResourceMapper;
|
|
|
+import com.book.server.model.VO.BlockRes;
|
|
|
import com.book.server.model.VO.QueryVO;
|
|
|
import com.book.server.service.BookService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
@@ -16,6 +24,12 @@ public class BookServiceImpl implements BookService {
|
|
|
@Autowired
|
|
|
private BookMapper bookMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ManageBlockMapper manageBlockMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ManageBlockResourceMapper manageBlockResourceMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public PageResult<Book> query(QueryVO queryVO) {
|
|
|
BookExample example = BookExample.newAndCreateCriteria().example();
|
|
@@ -41,4 +55,32 @@ public class BookServiceImpl implements BookService {
|
|
|
List<Book> books = bookMapper.selectByExample(example);
|
|
|
return new PageResult<>(queryVO.getPage(), queryVO.getSize(), count, books);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<BlockRes> getBlockByPageId(Integer pageId) {
|
|
|
+ ArrayList<BlockRes> list = new ArrayList<>();
|
|
|
+ // 获取板块
|
|
|
+ ManageBlockExample manageBlockExample = ManageBlockExample.newAndCreateCriteria()
|
|
|
+ .andPageIdEqualTo(pageId)
|
|
|
+ .example();
|
|
|
+ manageBlockExample.orderBy(ManageBlock.Column.weigh.desc());
|
|
|
+ List<ManageBlock> manageBlocks = manageBlockMapper.selectByExample(manageBlockExample);
|
|
|
+
|
|
|
+ // 获取板块内部数据
|
|
|
+ for (ManageBlock manageBlock : manageBlocks) {
|
|
|
+ ManageBlockResourceExample manageBlockResourceExample = ManageBlockResourceExample.newAndCreateCriteria()
|
|
|
+ .andBlockIdEqualTo(manageBlock.getId())
|
|
|
+ .example();
|
|
|
+ manageBlockResourceExample.orderBy(ManageBlockResource.Column.weigh.desc());
|
|
|
+ List<ManageBlockResource> manageBlockResources = manageBlockResourceMapper.selectByExample(manageBlockResourceExample);
|
|
|
+ BlockRes blockRes = new BlockRes();
|
|
|
+ blockRes.setName(manageBlock.getName());
|
|
|
+ blockRes.setSecondName(manageBlock.getSecondName());
|
|
|
+ blockRes.setType(manageBlock.getType());
|
|
|
+ blockRes.setResources(manageBlockResources);
|
|
|
+
|
|
|
+ list.add(blockRes);
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
}
|