package com.seer.teach.netty.im.handler.mq.impl.commonand;

import cn.hutool.core.convert.Convert;
import com.seer.teach.common.dto.mq.IntegerDTO;
import com.seer.teach.common.enums.im.CommandTopicTagEnum;
import com.seer.teach.common.enums.MessagePushStatusEnums;
import com.seer.teach.netty.common.proto.MessageType;
import com.seer.teach.netty.im.handler.mq.ImCommandHandler;
import com.seer.teach.netty.im.utils.ImUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.HashMap;

/**
 *
 * <p>
 *
 * </p >
 *
 * @author Captain
 * @since 2025-10-28 18:36
 */
@Slf4j
@Component
public class QuickAccessModuleHandler implements ImCommandHandler<IntegerDTO> {

    @Override
    public void handle(IntegerDTO messageBody, String device) {
        Integer index = Convert.toInt(messageBody.getData());
        HashMap<String, Integer> result = new HashMap<>();
        result.put("id", index);
        ImUtils.pushSingleChatToDeviceWithAck(
                device,
                MessagePushStatusEnums.SUCCESS.getCode(),
                MessageType.MessageContentType.QUICK_ACCESS_MODULE.getMsgContentType(),
                result
        );
        log.info("QuickAccessModuleHandler: {}", index);
    }

    @Override
    public Class<IntegerDTO> getType() {
        return IntegerDTO.class;
    }

    @Override
    public String getTag() {
        return CommandTopicTagEnum.QUICK_ACCESS_MODULE.getTag();
    }
}
