yangys
2024-04-02 6bed83e92f67954cd2135071133329f2205efe4f
smart-man-boot/src/main/java/com/qianwen/smartman/modules/notify/websocket/InternalMessageDataJsonMessageHandler.java
@@ -1,19 +1,19 @@
package com.qianwen.smartman.modules.notify.websocket;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.jsonwebtoken.Claims;
import java.lang.invoke.SerializedLambda;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qianwen.core.jwt.JwtUtil;
import com.qianwen.core.secure.utils.AuthUtil;
import com.qianwen.core.websocket.config.WebSocketMessageSender;
import com.qianwen.core.websocket.handler.JsonMessageHandler;
import com.qianwen.smartman.modules.notify.entity.NotifySystem;
import com.qianwen.smartman.modules.notify.service.INotifySystemService;
import org.springframework.stereotype.Component;
import org.springframework.web.socket.WebSocketSession;
import io.jsonwebtoken.Claims;
@Component
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/websocket/InternalMessageDataJsonMessageHandler.class */
@@ -21,41 +21,6 @@
    private static final Logger log = LoggerFactory.getLogger(InternalMessageDataJsonMessageHandler.class);
    private INotifySystemService notifySystemService;
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -1462639958:
                if (implMethodName.equals("getNotifyUser")) {
                    z = false;
                    break;
                }
                break;
            case 803533544:
                if (implMethodName.equals("getStatus")) {
                    z = true;
                    break;
                }
                break;
        }
        switch (z) {
            case false:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/notify/entity/NotifySystem") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getNotifyUser();
                    };
                }
                break;
            case true:
                if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getStatus();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
    public InternalMessageDataJsonMessageHandler(final INotifySystemService notifySystemService) {
        this.notifySystemService = notifySystemService;
@@ -65,11 +30,15 @@
        try {
            String uri = session.getUri().getQuery();
            Claims claims = AuthUtil.parseJWT(JwtUtil.getToken(uri.substring(uri.lastIndexOf("=") + 1)));
            long unNotificationCount = this.notifySystemService.count(Wrappers.<NotifySystem>lambdaQuery()
                    .ne(NotifySystem::getStatus, 1)
                    .eq(NotifySystem::getNotifyUser, claims.get("user_id")));
            /*
            long unNotificationCount = this.notifySystemService.count((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().ne((v0) -> {
                return v0.getStatus();
            }, 1)).eq((v0) -> {
                return v0.getNotifyUser();
            }, claims.get("user_id")));
            }, claims.get("user_id")));*/
            InternalMessageResponseJsonWebSocketMessage internalMessageResponseJsonWebSocketMessage = new InternalMessageResponseJsonWebSocketMessage();
            internalMessageResponseJsonWebSocketMessage.setHaveUnread(unNotificationCount > 0);
            WebSocketMessageSender.send(session, internalMessageResponseJsonWebSocketMessage);