Procházet zdrojové kódy

新增会话批量删除

udream-cxs před 4 roky
rodič
revize
06d5e5a163

+ 9 - 5
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/controller/ChatSessionController.java

@@ -6,14 +6,11 @@ import cn.com.ty.lift.ud.common.BaseController;
 
 import java.time.LocalDateTime;
 
+import cn.com.ty.lift.ud.common.DelReq;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 
@@ -79,4 +76,11 @@ public class ChatSessionController extends BaseController<ChatSessionEntity, Cha
     public RestResponse createPrivateChatRoom(@RequestBody ChatSessionQuery req) {
         return chatSessionService.createPrivateChatRoom(req);
     }
+
+    //根据id删除
+    @Override
+    public RestResponse deleteBath(DelReq req) {
+
+        return chatSessionService.batchDelete(req.getIds());
+    }
 }

+ 4 - 0
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/service/IChatSessionService.java

@@ -5,6 +5,7 @@ import cn.com.ty.lift.ud.chat.controller.query.ChatSessionQuery;
 import cn.com.ty.lift.ud.chat.mapper.entity.ChatSessionEntity;
 import cn.com.xwy.boot.web.dto.RestResponse;
 
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.ibatis.annotations.Param;
@@ -76,4 +77,7 @@ public interface IChatSessionService extends IService<ChatSessionEntity> {
     
     RestResponse createPrivateChatRoom(ChatSessionQuery request);
 
+
+    RestResponse batchDelete(Collection ids);
+
 }

+ 29 - 11
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/service/impl/ChatSessionServiceImpl.java

@@ -6,7 +6,9 @@ import cn.com.ty.lift.ud.chat.controller.model.ChatSessionReq;
 import cn.com.ty.lift.ud.chat.controller.model.ChatSessionVo;
 import cn.com.ty.lift.ud.chat.controller.query.ChatSessionQuery;
 import cn.com.ty.lift.ud.chat.mapper.ChatSessionMapper;
+import cn.com.ty.lift.ud.chat.mapper.entity.ChatMsgEntity;
 import cn.com.ty.lift.ud.chat.mapper.entity.ChatSessionEntity;
+import cn.com.ty.lift.ud.chat.service.IChatMsgService;
 import cn.com.ty.lift.ud.chat.service.IChatSessionService;
 import cn.com.ty.lift.ud.neety.task.RoomInfo;
 import cn.com.ty.lift.ud.neety.task.UserInfo;
@@ -26,13 +28,12 @@ import org.springframework.jms.core.JmsMessagingTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.lang.reflect.Array;
 import java.time.LocalDateTime;
 import java.time.ZoneOffset;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
-import java.util.Set;
 
 /**
  * 会话 -ServiceImpl
@@ -42,8 +43,7 @@ import java.util.Set;
  */
 @Service
 @Transactional
-public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatSessionEntity>
-    implements IChatSessionService {
+public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatSessionEntity> implements IChatSessionService {
     @Autowired
     private ChatSessionMapper sessionMapper;
     @Autowired
@@ -52,6 +52,8 @@ public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatS
     private UserInfoMapper userInfoMapper;
     @Autowired
     private RedisUtils redis;
+    @Autowired
+    private IChatMsgService msgService;
 
     @Autowired
     private JmsMessagingTemplate jmsMessagingTemplate;
@@ -117,9 +119,12 @@ public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatS
 
     @Override
     public RestResponse findOneByLiftCase(ChatSessionQuery req) {
-        QueryWrapper<ChatSessionEntity> queryWrapper = new QueryWrapper<ChatSessionEntity>();
+        /*QueryWrapper<ChatSessionEntity> queryWrapper = new QueryWrapper<ChatSessionEntity>();
         queryWrapper.eq("data_id", req.getDataId());
-        queryWrapper.eq("user_id", req.getUserId());
+        queryWrapper.eq("user_id", req.getUserId());*/
+        QueryWrapper<ChatSessionEntity> queryWrapper = new QueryWrapper<ChatSessionEntity>()
+                .eq("data_id", req.getDataId())
+                .last("find_in_set(" + req.getUserId() + ",user_id)");
         ChatSessionEntity data = sessionMapper.selectOne(queryWrapper);
 
         return RestResponse.success(data, "success");
@@ -149,20 +154,20 @@ public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatS
         });*/
         for (int i = 0; i < list.size(); i++) {
             ChatSessionEntity entity = list.get(i);
-            RoomInfo roomInfo = JSONObject.parseObject(redis.get("ROOM:" + entity.getSessionid()),RoomInfo.class);
+            RoomInfo roomInfo = JSONObject.parseObject(redis.get("ROOM:" + entity.getSessionid()), RoomInfo.class);
             if (null != roomInfo) {
                 entity.setLastMsg(roomInfo.getLastChat());
                 entity.setLastTime(roomInfo.getLastTime());
 
                 roomInfo.getUserLIst().forEach(userInfo -> {
-                    if (userInfo.getUserId().equals(query.getUserId())){
+                    if (userInfo.getUserId().equals(query.getUserId())) {
                         roomInfo.setIsRed(userInfo.getIsRed());
                     }
                 });
             }
         }
         Collections.sort(list, (ent1, ent2) -> {
-            if (ent1.getLastTime() == null || ent2.getLastTime() == null){
+            if (ent1.getLastTime() == null || ent2.getLastTime() == null) {
                 return -1;
             }
 
@@ -186,13 +191,13 @@ public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatS
         ChatSessionVo vo = new ChatSessionVo();
         // 使用我的用户id和将要聊天的用户id正反去数据库查询房间号是否存在
         String sessionId =
-            sessionMapper.findOneByUserIdAndCreateUserIdAndDateTable(request.getUserId(), request.getCreateUserId(), 3);
+                sessionMapper.findOneByUserIdAndCreateUserIdAndDateTable(request.getUserId(), request.getCreateUserId(), 3);
 
         if (StringUtils.isBlank(sessionId)) {
             ChatSessionEntity record = new ChatSessionEntity();
             // 添加自己到房间
             sessionId = UUIDUtil.getUuidByTime9();
-            record.setUserId(request.getUserId()+","+request.getCreateUserId());
+            record.setUserId(request.getUserId() + "," + request.getCreateUserId());
             record.setCreateUserId(request.getCreateUserId());
             record.setSessionid(sessionId);
             record.setDataTable(3);
@@ -251,4 +256,17 @@ public class ChatSessionServiceImpl extends ServiceImpl<ChatSessionMapper, ChatS
 
         return list;
     }
+
+    @Override
+    public RestResponse batchDelete(Collection ids) {
+        boolean deleteFlag = removeByIds(ids);
+
+        if (deleteFlag){
+            msgService.remove(new QueryWrapper<ChatMsgEntity>().in("session_id",ids));
+            return RestResponse.success(null, "Deleted successfully");
+        } else {
+            return RestResponse.fail("Deleted unsuccessfully");
+        }
+
+    }
 }

+ 2 - 4
lift-ud-service/src/main/java/cn/com/ty/lift/ud/chat/service/impl/LiftCaseServiceImpl.java

@@ -636,8 +636,7 @@ public class LiftCaseServiceImpl extends ServiceImpl<LiftCaseMapper, LiftCaseEnt
             caseMapper.updateById(selectById);
         }
 
-        PushUserInfo pushUserInfo =
-                iUserAccountService.getPushUserInfoByUserId(selectById.getCreateUserId().toString());
+        PushUserInfo pushUserInfo = iUserAccountService.getPushUserInfoByUserId(selectById.getCreateUserId().toString());
         PushMessage pushMessage = PushMessage.orderChargeStatus("专家已确认");
         pushMessage.sendTokenOnPlatform(jmsMessagingTemplate, pushUserInfo);
         return RestResponse.success("success");
@@ -649,8 +648,7 @@ public class LiftCaseServiceImpl extends ServiceImpl<LiftCaseMapper, LiftCaseEnt
             caseMapper.userToClock(liftCaseEntity.getId(), liftCaseEntity.getBeforeRepair());
             return RestResponse.success("打卡成功");
         }
-        Long chargeToClock =
-                caseMapper.chargeToClock(liftCaseEntity.getId(), liftCaseEntity.getLat(), liftCaseEntity.getLng());
+        Long chargeToClock = caseMapper.chargeToClock(liftCaseEntity.getId(), liftCaseEntity.getLat(), liftCaseEntity.getLng());
         liftCaseEntity.setArrivedFlag(1);
         OtherSettingEntity latestVersion = otherSettingMapper.getLatestVersion();
         if (chargeToClock >= latestVersion.getClockInArea()) {

+ 1 - 2
lift-ud-service/src/main/java/cn/com/ty/lift/ud/expertPunish/controller/ExpertsPunishmentController.java

@@ -88,8 +88,7 @@ public class ExpertsPunishmentController extends BaseController<ExpertsPunishmen
             return RestResponse.fail("请选择惩罚记录");
         }
         //修改余额
-        RestResponse addUserBalance =
-                userInfoService.addUserBalance(req.getIds());
+        RestResponse addUserBalance = userInfoService.addUserBalance(req.getIds());
         if (addUserBalance.getStatusCode().equals("1")) {
             return RestResponse.success(null, "撤销成功");
         }else{

+ 1 - 2
lift-ud-service/src/main/java/cn/com/ty/lift/ud/userInfo/service/impl/UserInfoServiceImpl.java

@@ -1018,8 +1018,7 @@ public class UserInfoServiceImpl extends ServiceImpl<UserInfoMapper, UserInfoEnt
             ExpertsPunishment expertsPunishment = iExpertsPunishmentService.getById(id);
 
             //余额增加,冻结余额减少
-            int updateUserBalance = userInfoMapper.addExpertBalance(expertsPunishment.getChargeId(),
-                    expertsPunishment.getPunishAmount());
+            int updateUserBalance = userInfoMapper.addExpertBalance(expertsPunishment.getChargeId(), expertsPunishment.getPunishAmount());
             UserInfoEntity selectById = userInfoMapper.getByUserId(expertsPunishment.getChargeId());
             if (updateUserBalance > 0) {
                 //流水记录