Skip to content

Commit

Permalink
adds child board meta data
Browse files Browse the repository at this point in the history
  • Loading branch information
MGZero committed Oct 29, 2024
1 parent 6e76745 commit dd9d18f
Show file tree
Hide file tree
Showing 12 changed files with 859 additions and 6 deletions.
Binary file added backend-assets/img/logos/midnight-mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added backend-assets/img/logos/midnight-mobile.psd
Binary file not shown.
3 changes: 2 additions & 1 deletion src/main/java/com/zfgc/zfgbb/ZfgbbApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
@MapperScan("com.zfgc.zfgbb.mappers")
@EnableGlobalMethodSecurity(prePostEnabled = true)
@EnableMethodSecurity(prePostEnabled = true)
public class ZfgbbApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.zfgc.zfgbb.dataprovider.forum;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -15,11 +17,14 @@
import com.zfgc.zfgbb.dbo.BoardPermissionViewDboExample;
import com.zfgc.zfgbb.dbo.BoardSummaryViewDboExample;
import com.zfgc.zfgbb.dbo.CategoryDboExample;
import com.zfgc.zfgbb.dbo.ChildBoardViewDboExample;
import com.zfgc.zfgbb.dbo.ThreadDboExample;
import com.zfgc.zfgbb.mappers.BoardSummaryViewDboMapper;
import com.zfgc.zfgbb.mappers.ChildBoardViewDboMapper;
import com.zfgc.zfgbb.model.forum.Board;
import com.zfgc.zfgbb.model.forum.BoardSummary;
import com.zfgc.zfgbb.model.forum.Category;
import com.zfgc.zfgbb.model.forum.ChildBoard;
import com.zfgc.zfgbb.model.forum.Forum;
import com.zfgc.zfgbb.model.forum.Thread;
import com.zfgc.zfgbb.model.users.Permission;
Expand All @@ -45,6 +50,9 @@ public class ForumDataProvider extends AbstractDataProvider {
@Autowired
private BoardSummaryViewDboMapper boardSummaryMapper;

@Autowired
private ChildBoardViewDboMapper childBoardMapper;

public Board getBoard(Integer boardId, Integer pageNo, Integer threadsPerPage) {
BoardDbo boardDbo = boardDao.get(boardId);
Board board = mapper.map(boardDbo, Board.class);
Expand All @@ -59,12 +67,30 @@ public Board getBoard(Integer boardId, Integer pageNo, Integer threadsPerPage) {
threadEx.createCriteria().andBoardIdEqualTo(boardId).andPinnedFlagEqualTo(false);
Long threadCount = threadDao.getMapper().countByExample(threadEx);
board.setThreadCount(threadCount);

board.setChildBoards(getBoardSummaries(board.getBoardId()));

return board;
}

private List<BoardSummary> getBoardSummaries(Integer parentBoardId){
BoardSummaryViewDboExample bEx = new BoardSummaryViewDboExample();
bEx.createCriteria().andParentBoardIdEqualTo(boardId);
board.setChildBoards(boardSummaryMapper.selectByExample(bEx).stream().map(b -> mapper.map(b, BoardSummary.class)).collect(Collectors.toList()));
bEx.createCriteria().andParentBoardIdEqualTo(parentBoardId);
List<BoardSummary> result = (boardSummaryMapper.selectByExample(bEx).stream().map(b -> mapper.map(b, BoardSummary.class)).collect(Collectors.toList()));

return board;
ChildBoardViewDboExample cEx = new ChildBoardViewDboExample();
cEx.createCriteria().andParentBoardIdEqualTo(parentBoardId);

Map<Integer, List<ChildBoard>> childBoards = childBoardMapper.selectByExample(cEx).stream()
.map(c -> mapper.map(c, ChildBoard.class))
.collect(Collectors.groupingBy(ChildBoard::getParentBoardId));

result.forEach(bs -> {
bs.setChildBoards(childBoards.get(bs.getBoardId()));
});


return result;
}

public Forum getForum() {
Expand Down
74 changes: 74 additions & 0 deletions src/main/java/com/zfgc/zfgbb/dbo/ChildBoardViewDbo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.zfgc.zfgbb.dbo;

public class ChildBoardViewDbo {

/**
* This field was generated by MyBatis Generator. This field corresponds to the database column zfgbb.child_board_view.board_id
* @mbg.generated Mon Oct 14 23:44:38 EDT 2024
*/
private Integer boardId;
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column zfgbb.child_board_view.board_name
* @mbg.generated Mon Oct 14 23:44:38 EDT 2024
*/
private String boardName;
/**
* This field was generated by MyBatis Generator. This field corresponds to the database column zfgbb.child_board_view.parent_board_id
* @mbg.generated Mon Oct 14 23:44:38 EDT 2024
*/
private Integer parentBoardId;

/**
* This method was generated by MyBatis Generator. This method returns the value of the database column zfgbb.child_board_view.board_id
* @return the value of zfgbb.child_board_view.board_id
* @mbg.generated Mon Oct 14 23:44:38 EDT 2024
*/
public Integer getBoardId() {
return boardId;
}

/**
* This method was generated by MyBatis Generator. This method sets the value of the database column zfgbb.child_board_view.board_id
* @param boardId the value for zfgbb.child_board_view.board_id
* @mbg.generated Mon Oct 14 23:44:38 EDT 2024
*/
public void setBoardId(Integer boardId) {
this.boardId = boardId;
}

/**
* This method was generated by MyBatis Generator. This method returns the value of the database column zfgbb.child_board_view.board_name
* @return the value of zfgbb.child_board_view.board_name
* @mbg.generated Mon Oct 14 23:44:38 EDT 2024
*/
public String getBoardName() {
return boardName;
}

/**
* This method was generated by MyBatis Generator. This method sets the value of the database column zfgbb.child_board_view.board_name
* @param boardName the value for zfgbb.child_board_view.board_name
* @mbg.generated Mon Oct 14 23:44:38 EDT 2024
*/
public void setBoardName(String boardName) {
this.boardName = boardName;
}

/**
* This method was generated by MyBatis Generator. This method returns the value of the database column zfgbb.child_board_view.parent_board_id
* @return the value of zfgbb.child_board_view.parent_board_id
* @mbg.generated Mon Oct 14 23:44:38 EDT 2024
*/
public Integer getParentBoardId() {
return parentBoardId;
}

/**
* This method was generated by MyBatis Generator. This method sets the value of the database column zfgbb.child_board_view.parent_board_id
* @param parentBoardId the value for zfgbb.child_board_view.parent_board_id
* @mbg.generated Mon Oct 14 23:44:38 EDT 2024
*/
public void setParentBoardId(Integer parentBoardId) {
this.parentBoardId = parentBoardId;
}
}
Loading

0 comments on commit dd9d18f

Please sign in to comment.