package com.seer.teach.teacher.convert;

import com.seer.teach.common.dto.mq.dto.UserCacheDTO;
import com.seer.teach.iot.api.req.DeviceStatusDTO;
import com.seer.teach.iot.api.resp.DeviceRespDTO;
import com.seer.teach.teacher.common.llm.resp.LlmUserInfoResult;
import com.seer.teach.user.api.dto.UserInfoDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.time.LocalDate;

/**
 * <p>
 *
 * </p >
 *
 * @author Captain
 * @since 2025-08-05 20:29
 */
@Mapper
public interface UserConvert {

    UserConvert INSTANCE = Mappers.getMapper(UserConvert.class);

    @Mapping(target = "userName", source = "userName")
    @Mapping(target = "avatar", source = "avatar")
    @Mapping(target = "nickName", source = "nickName")
    @Mapping(target = "birthDate", source = "birthDate")
    @Mapping(target = "gradeId", source = "gradeId")
    @Mapping(target = "levelId", source = "levelId")
    @Mapping(target = "city", source = "city")
    @Mapping(target = "province", source = "province")
    LlmUserInfoResult toUserInfo(String userName, String avatar, String nickName, LocalDate birthDate, Integer gradeId, Integer levelId, String city, String province);


    @Mappings({
            @Mapping(source = "device.id", target = "deviceId"),
            @Mapping(source = "device.device", target = "device"),
            @Mapping(source = "deviceStatus.isOnline", target = "deviceIsOnLine"),
            @Mapping(source = "deviceStatus.screenStatus", target = "screenStatus"),
            @Mapping(source = "deviceStatus.volumeStatus", target = "volumeStatus"),
            @Mapping(source = "code", target = "roleCode"),
            @Mapping(source = "user.userName", target = "userName"),
            @Mapping(source = "user.password", target = "password"),
            @Mapping(source = "user.avatar", target = "avatar"),
            @Mapping(source = "user.realName", target = "realName"),
            @Mapping(source = "user.gender", target = "gender"),
            @Mapping(source = "user.nickName", target = "nickName"),
            @Mapping(source = "user.mobile", target = "mobile"),
            @Mapping(source = "user.email", target = "email"),
            @Mapping(source = "user.birthDate", target = "birthDate"),
            @Mapping(source = "user.unionId", target = "unionId"),
            @Mapping(source = "user.openId", target = "openId"),
            @Mapping(source = "user.gradeId", target = "gradeId"),
            @Mapping(source = "user.levelId", target = "levelId"),
            @Mapping(source = "user.experience", target = "experience")
    })
    UserCacheDTO toUserCacheDTO(DeviceRespDTO device, DeviceStatusDTO deviceStatus, String code, UserInfoDTO user);

}
