chat sub list
This commit is contained in:
@@ -7,7 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||||||
import com.peanut.common.utils.PageUtils;
|
import com.peanut.common.utils.PageUtils;
|
||||||
import com.peanut.common.utils.R;
|
import com.peanut.common.utils.R;
|
||||||
import com.peanut.modules.book.entity.BookClockEntryEntity;
|
import com.peanut.modules.book.entity.BookClockEntryEntity;
|
||||||
import com.peanut.modules.book.entity.BookClockEntryChatEntity;
|
import com.peanut.modules.book.entity.BookClockEntryChat;
|
||||||
import com.peanut.modules.book.entity.MyUserEntity;
|
import com.peanut.modules.book.entity.MyUserEntity;
|
||||||
import com.peanut.modules.book.service.BookClockEntryChatService;
|
import com.peanut.modules.book.service.BookClockEntryChatService;
|
||||||
import com.peanut.modules.book.service.BookClockEntryService;
|
import com.peanut.modules.book.service.BookClockEntryService;
|
||||||
@@ -64,13 +64,12 @@ public class BookClockForumController {
|
|||||||
* @param entryId
|
* @param entryId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(path = "/getChatList", method = RequestMethod.POST)
|
@RequestMapping(path = "/getChatList", method = RequestMethod.GET)
|
||||||
public R getChatList(@RequestParam("entryId") Integer entryId,
|
public R getChatList(@RequestParam("entryId") Integer entryId,
|
||||||
@RequestParam(value = "userId", required = false) Integer userId,
|
@RequestParam(value = "userId", required = false) Integer userId,
|
||||||
@RequestParam(value = "pageSize") Integer pageSize,
|
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||||
@RequestParam("currentPage") Integer currentPage,
|
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
|
||||||
@RequestBody Map<Integer, Integer> subPage) {
|
QueryWrapper<BookClockEntryChat> queryWrapper = new QueryWrapper<>();
|
||||||
QueryWrapper<BookClockEntryChatEntity> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("entry_id", entryId);
|
queryWrapper.eq("entry_id", entryId);
|
||||||
queryWrapper.eq("fid", 0);
|
queryWrapper.eq("fid", 0);
|
||||||
if (userId != null) {
|
if (userId != null) {
|
||||||
@@ -78,8 +77,8 @@ public class BookClockForumController {
|
|||||||
}
|
}
|
||||||
queryWrapper.orderByAsc("fid", "create_time");
|
queryWrapper.orderByAsc("fid", "create_time");
|
||||||
List<ClockInCommentVo> resultList = new ArrayList<>();
|
List<ClockInCommentVo> resultList = new ArrayList<>();
|
||||||
List<BookClockEntryChatEntity> chatEntityList = bookClockEntryChatService.list(queryWrapper);
|
List<BookClockEntryChat> chatEntityList = bookClockEntryChatService.list(queryWrapper);
|
||||||
for (BookClockEntryChatEntity entity : chatEntityList) {
|
for (BookClockEntryChat entity : chatEntityList) {
|
||||||
List<String> imageList = JSON.parseObject(entity.getImages(), new TypeReference<List<String>>() {
|
List<String> imageList = JSON.parseObject(entity.getImages(), new TypeReference<List<String>>() {
|
||||||
});
|
});
|
||||||
entity.setImageList(imageList);
|
entity.setImageList(imageList);
|
||||||
@@ -88,12 +87,29 @@ public class BookClockForumController {
|
|||||||
MyUserEntity user = userService.getById(entity.getUserId());
|
MyUserEntity user = userService.getById(entity.getUserId());
|
||||||
vo.setNickName(user.getNickname());
|
vo.setNickName(user.getNickname());
|
||||||
vo.setAvatar(user.getAvatar());
|
vo.setAvatar(user.getAvatar());
|
||||||
QueryWrapper<BookClockEntryChatEntity> subQueryWrapper = new QueryWrapper<>();
|
resultList.add(vo);
|
||||||
subQueryWrapper.eq("fid", entity.getId());
|
}
|
||||||
List<BookClockEntryChatEntity> subClockInChatList = bookClockEntryChatService.list(subQueryWrapper);
|
PageUtils page = new PageUtils(resultList, resultList.size(), pageSize, currentPage);
|
||||||
|
return R.ok().put("result", page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取子评论
|
||||||
|
*
|
||||||
|
* @param fid 父评论 ID
|
||||||
|
* @param pageSize 页大小
|
||||||
|
* @param currentPage 当前页
|
||||||
|
* @return R
|
||||||
|
*/
|
||||||
|
@RequestMapping(path = "/getSubChatList", method = RequestMethod.GET)
|
||||||
|
public R getSubChatList(@RequestParam("fid") Integer fid,
|
||||||
|
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||||
|
@RequestParam(value = "currentPage", defaultValue = "1") Integer currentPage) {
|
||||||
|
QueryWrapper<BookClockEntryChat> subQueryWrapper = new QueryWrapper<>();
|
||||||
|
subQueryWrapper.eq("fid", fid);
|
||||||
|
List<BookClockEntryChat> subClockInChatList = bookClockEntryChatService.list(subQueryWrapper);
|
||||||
List<ClockInCommentVo> subCommentList = new ArrayList<>();
|
List<ClockInCommentVo> subCommentList = new ArrayList<>();
|
||||||
List<PageUtils> subCommentPages = new ArrayList<>();
|
for (BookClockEntryChat subChat : subClockInChatList) {
|
||||||
for (BookClockEntryChatEntity subChat : subClockInChatList) {
|
|
||||||
ClockInCommentVo subVo = new ClockInCommentVo();
|
ClockInCommentVo subVo = new ClockInCommentVo();
|
||||||
BeanUtil.copyProperties(subChat, subVo);
|
BeanUtil.copyProperties(subChat, subVo);
|
||||||
MyUserEntity subChatUser = userService.getById(subChat.getUserId());
|
MyUserEntity subChatUser = userService.getById(subChat.getUserId());
|
||||||
@@ -103,17 +119,9 @@ public class BookClockForumController {
|
|||||||
subVo.setAvatar(subChatUser.getAvatar());
|
subVo.setAvatar(subChatUser.getAvatar());
|
||||||
subVo.setNickName(subChatUser.getNickname());
|
subVo.setNickName(subChatUser.getNickname());
|
||||||
subCommentList.add(subVo);
|
subCommentList.add(subVo);
|
||||||
Integer currentCommentId = subPage.get(entity.getId());
|
|
||||||
PageUtils subCommentPage = new PageUtils(subCommentList, subCommentList.size(), 5, subPage.get(currentCommentId));
|
|
||||||
subCommentPages.add(subCommentPage);
|
|
||||||
}
|
}
|
||||||
vo.setSubCommentList(subCommentPages);
|
PageUtils subChatPage = new PageUtils(subCommentList, subCommentList.size(), pageSize, currentPage);
|
||||||
resultList.add(vo);
|
return R.ok().put("result", subChatPage);
|
||||||
}
|
|
||||||
PageUtils page = new PageUtils(resultList, resultList.size(), 5, currentPage);
|
|
||||||
Map<String, Object> result = new HashMap<>();
|
|
||||||
result.put("chatList", page);
|
|
||||||
return R.ok(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,7 +131,7 @@ public class BookClockForumController {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(path = "/addChat", method = RequestMethod.POST)
|
@RequestMapping(path = "/addChat", method = RequestMethod.POST)
|
||||||
public R addChat(@RequestBody BookClockEntryChatEntity chat) {
|
public R addChat(@RequestBody BookClockEntryChat chat) {
|
||||||
List<String> imageList = chat.getImageList();
|
List<String> imageList = chat.getImageList();
|
||||||
if (imageList != null) {
|
if (imageList != null) {
|
||||||
String images = JSON.toJSON(imageList).toString();
|
String images = JSON.toJSON(imageList).toString();
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.peanut.modules.book.dao;
|
package com.peanut.modules.book.dao;
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
import com.github.yulichang.base.MPJBaseMapper;
|
||||||
import com.peanut.modules.book.entity.BookClockEntryChatEntity;
|
import com.peanut.modules.book.entity.BookClockEntryChat;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface BookClockEntryChatDao extends MPJBaseMapper<BookClockEntryChatEntity> {
|
public interface BookClockEntryChatDao extends MPJBaseMapper<BookClockEntryChat> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import java.util.List;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("book_clock_entry_chat")
|
@TableName("book_clock_entry_chat")
|
||||||
public class BookClockEntryChatEntity implements Serializable {
|
public class BookClockEntryChat implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@TableId
|
@TableId
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.peanut.modules.book.service;
|
package com.peanut.modules.book.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.peanut.modules.book.entity.BookClockEntryChatEntity;
|
import com.peanut.modules.book.entity.BookClockEntryChat;
|
||||||
|
|
||||||
public interface BookClockEntryChatService extends IService<BookClockEntryChatEntity> {
|
public interface BookClockEntryChatService extends IService<BookClockEntryChat> {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package com.peanut.modules.book.service.impl;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.peanut.modules.book.dao.BookClockEntryChatDao;
|
import com.peanut.modules.book.dao.BookClockEntryChatDao;
|
||||||
import com.peanut.modules.book.entity.BookClockEntryChatEntity;
|
import com.peanut.modules.book.entity.BookClockEntryChat;
|
||||||
import com.peanut.modules.book.service.BookClockEntryChatService;
|
import com.peanut.modules.book.service.BookClockEntryChatService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service("bookClockEntryChatService")
|
@Service("bookClockEntryChatService")
|
||||||
public class BookClockEntryChatImpl extends ServiceImpl<BookClockEntryChatDao, BookClockEntryChatEntity> implements BookClockEntryChatService {
|
public class BookClockEntryChatImpl extends ServiceImpl<BookClockEntryChatDao, BookClockEntryChat> implements BookClockEntryChatService {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ connection-timeout: 6000000ms
|
|||||||
spring:
|
spring:
|
||||||
# 环境 dev|test|prod
|
# 环境 dev|test|prod
|
||||||
profiles:
|
profiles:
|
||||||
active: prod
|
active: dev-wcl
|
||||||
# jackson时间格式化
|
# jackson时间格式化
|
||||||
jackson:
|
jackson:
|
||||||
time-zone: GMT+8
|
time-zone: GMT+8
|
||||||
|
|||||||
Reference in New Issue
Block a user