diff --git a/mallchat-common/src/main/java/com/abin/mallchat/common/common/utils/AssertUtil.java b/mallchat-common/src/main/java/com/abin/mallchat/common/common/utils/AssertUtil.java index 2182707..4c28bcb 100644 --- a/mallchat-common/src/main/java/com/abin/mallchat/common/common/utils/AssertUtil.java +++ b/mallchat-common/src/main/java/com/abin/mallchat/common/common/utils/AssertUtil.java @@ -47,6 +47,13 @@ public class AssertUtil { } } + //如果不是非空对象,则抛异常 + public static void isNotEmpty(Object obj, ErrorEnum errorEnum, Object... args) { + if (isEmpty(obj)) { + throwException(errorEnum, args); + } + } + //如果不是非空对象,则抛异常 public static void isEmpty(Object obj, String msg) { if (!isEmpty(obj)) { diff --git a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/impl/ChatServiceImpl.java b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/impl/ChatServiceImpl.java index d003217..9ecec66 100644 --- a/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/impl/ChatServiceImpl.java +++ b/mallchat-custom-server/src/main/java/com/abin/mallchat/custom/chat/service/impl/ChatServiceImpl.java @@ -152,12 +152,13 @@ public class ChatServiceImpl implements ChatService { @Override public CursorPageBaseResp getRoomPage(CursorPageBaseReq request, Long uid) { CursorPageBaseResp cursorPage = roomDao.getCursorPage(request); + ArrayList rooms = new ArrayList<>(cursorPage.getList()); if (request.isFirstPage()) { //第一页插入置顶的大群聊 Room group = roomDao.getById(ROOM_GROUP_ID); - cursorPage.getList().add(0, group); + rooms.add(0, group); } - return CursorPageBaseResp.init(cursorPage, RoomAdapter.buildResp(cursorPage.getList())); + return CursorPageBaseResp.init(cursorPage, RoomAdapter.buildResp(rooms)); } @Override