package com.seer.teach.iot.admin.convert;

import com.seer.teach.iot.admin.resp.DeviceDashboardResp;
import com.seer.teach.iot.admin.resp.DeviceDetailResp;
import com.seer.teach.iot.admin.resp.DeviceListResp;
import com.seer.teach.common.entity.CityEntity;
import com.seer.teach.common.entity.ProvinceEntity;
import com.seer.teach.iot.module.entity.DeviceModelsEntity;
import com.seer.teach.iot.module.entity.DevicesEntity;
import com.seer.teach.user.api.dto.LevelDTO;
import com.seer.teach.user.api.dto.UserDeviceDTO;
import com.seer.teach.user.api.dto.UserInfoDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * <p>
 *
 * </p >
 *
 * @author Captain
 * @since 2025-08-13 20:54
 */
@Mapper
public interface AdminsDeviceConvert {
    AdminsDeviceConvert INSTANCE = Mappers.getMapper(AdminsDeviceConvert.class);

    DeviceDashboardResp toDeviceDashboardResp(long onlineDevices, long todayActive, long totalDevices);

    @Mapping(target = "id", source = "data.id")
    @Mapping(target = "device", source = "data.unionId")
    @Mapping(target = "ip", source = "data.ip")
    @Mapping(target = "nickName", source = "user.nickName")
    @Mapping(target = "mobile", source = "user.mobile")
    @Mapping(target = "status", ignore = true)
    DeviceListResp toDeviceListResp(DevicesEntity data, UserDeviceDTO user);

    @Mapping(target = "id", source = "devices.id")
    @Mapping(target = "device", source = "devices.unionId")
    @Mapping(target = "ip", source = "devices.ip")
    @Mapping(target = "model", source = "deviceModel.model")
    @Mapping(target = "nickName", source = "userInfo.nickName")
    @Mapping(target = "mobile", source = "userInfo.mobile")
    @Mapping(target = "level", source = "level.name")
    @Mapping(target = "province", source = "province.province")
    @Mapping(target = "city", source = "city.city")
    @Mapping(target = "grade", source = "grade")
    @Mapping(target = "status", source = "status")
    DeviceDetailResp toDeviceDetailResp(DevicesEntity devices, CityEntity city, ProvinceEntity province, DeviceModelsEntity deviceModel, UserInfoDTO userInfo, LevelDTO level, String grade, Integer status);

}