package com.kym.service.miniapp.impl;

import com.kym.entity.miniapp.DeviceRelation;
import com.kym.mapper.miniapp.DeviceRelationMapper;
import com.kym.service.cache.KymCache;
import com.kym.service.miniapp.DeviceRelationService;
import com.kym.service.mybatisplus.MyBaseServiceImpl;
import jakarta.annotation.PostConstruct;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author skyline
 * @since 2024-11-11
 */
@Service
public class DeviceRelationServiceImpl extends MyBaseServiceImpl<DeviceRelationMapper, DeviceRelation> implements DeviceRelationService {

    @PostConstruct
    private void init() {
        list().forEach(item -> {
            // 初始化短编号和设备信息的关联
            KymCache.INSTANCE.putWashShortId2ProductKeyAndDeviceName(Map.of(item.getShortId(), item.getProductKey() + "," + item.getDeviceName()));
        });
    }

}
