|
@@ -2,12 +2,16 @@ package com.ljq.house.im.service;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.ljq.house.biz.dao.TmHouseDao;
|
|
|
+import com.ljq.house.biz.model.TmHouse;
|
|
|
import com.ljq.house.im.entity.*;
|
|
|
import com.ljq.house.im.entity.dto.ImUserDTO;
|
|
|
import com.ljq.house.im.enums.ImMessageReadStatus;
|
|
|
import com.ljq.house.im.mapper.*;
|
|
|
+import jdk.nashorn.internal.runtime.ECMAException;
|
|
|
import lombok.extern.log4j.Log4j2;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -43,6 +47,9 @@ public class ImService {
|
|
|
@Autowired
|
|
|
private ImCategoryMapper imCategoryMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TmHouseDao tmHouseDao;
|
|
|
+
|
|
|
public Res<List<ImGroup>> getPublicGroup() {
|
|
|
return Res.ok(this.imGroupMapper.selectList(new LambdaQueryWrapper<ImGroup>().eq(ImGroup::getType, "public")), "获取公共群成功!");
|
|
|
}
|
|
@@ -75,6 +82,27 @@ public class ImService {
|
|
|
String limitSql = "limit " + limitStarter + ",10";
|
|
|
queryWrapper.orderByDesc("send_time").last(limitSql);
|
|
|
List<ImMessage> messageList = imMessageMapper.selectList(queryWrapper);
|
|
|
+
|
|
|
+ if(messageList!=null && messageList.size()>0){
|
|
|
+ for (ImMessage im:messageList){
|
|
|
+ if(im.getContent()!=null){
|
|
|
+ try {
|
|
|
+ JSONObject object = JSONObject.parseObject(im.getContent());
|
|
|
+ if(object.containsKey("house_id")){
|
|
|
+ String houseId = (String) object.get("house_id");
|
|
|
+ TmHouse tmHouse = tmHouseDao.selectHouseById(houseId);
|
|
|
+ if(tmHouse == null){
|
|
|
+ im.setEnable(0);
|
|
|
+ }else{
|
|
|
+ im.setEnable(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return messageList;
|
|
|
}
|
|
|
|