package com.seer.teach.user.app.convert;

import com.seer.teach.common.dto.mq.dto.UserCacheDTO;
import com.seer.teach.user.app.user.controller.req.UserRegisterReq;
import com.seer.teach.user.entity.UserEntity;
import com.seer.teach.user.entity.UserExtendEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

@Mapper
public interface UserAuthConvert {

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

    UserEntity convertOneToEntity(UserRegisterReq userRegisterReq);

    @Mappings({
            @Mapping(source = "deviceId", target = "deviceId"),
            @Mapping(source = "device", target = "device"),
            @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 = "userExtendEntity.gradeId", target = "gradeId"),
            @Mapping(source = "userExtendEntity.levelId", target = "levelId"),
            @Mapping(source = "userExtendEntity.experience", target = "experience")
    })
    UserCacheDTO toUserCacheDTO(Integer deviceId, String device, UserEntity user, UserExtendEntity userExtendEntity, String code);
}