package com.jojubanking.boot.module.system.convert.auth;

import com.jojubanking.boot.module.system.api.sms.dto.code.SmsCodeSendReqDTO;
import com.jojubanking.boot.module.system.api.sms.dto.code.SmsCodeUseReqDTO;
import com.jojubanking.boot.module.system.api.social.dto.SocialUserBindReqDTO;
import com.jojubanking.boot.module.system.controller.admin.auth.vo.AuthLoginRespVO;
import com.jojubanking.boot.module.system.controller.admin.auth.vo.AuthMenuRespVO;
import com.jojubanking.boot.module.system.controller.admin.auth.vo.AuthSmsLoginReqVO;
import com.jojubanking.boot.module.system.controller.admin.auth.vo.AuthSmsSendReqVO;
import com.jojubanking.boot.module.system.controller.admin.auth.vo.AuthSocialLoginReqVO;
import com.jojubanking.boot.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO;
import com.jojubanking.boot.module.system.dal.dataobject.permission.MenuDO;
import javax.annotation.Generated;

@Generated(
    value = "org.mapstruct.ap.MappingProcessor",
    date = "2025-12-05T11:32:08+0800",
    comments = "version: 1.4.1.Final, compiler: javac, environment: Java 1.8.0_201 (Oracle Corporation)"
)
public class AuthConvertImpl implements AuthConvert {

    @Override
    public AuthLoginRespVO convert(OAuth2AccessTokenDO bean) {
        if ( bean == null ) {
            return null;
        }

        AuthLoginRespVO authLoginRespVO = new AuthLoginRespVO();

        authLoginRespVO.setUserId( bean.getUserId() );
        authLoginRespVO.setAccessToken( bean.getAccessToken() );
        authLoginRespVO.setRefreshToken( bean.getRefreshToken() );
        authLoginRespVO.setExpiresTime( bean.getExpiresTime() );

        return authLoginRespVO;
    }

    @Override
    public AuthMenuRespVO convertTreeNode(MenuDO menu) {
        if ( menu == null ) {
            return null;
        }

        AuthMenuRespVO authMenuRespVO = new AuthMenuRespVO();

        authMenuRespVO.setId( menu.getId() );
        authMenuRespVO.setParentId( menu.getParentId() );
        authMenuRespVO.setName( menu.getName() );
        authMenuRespVO.setPath( menu.getPath() );
        authMenuRespVO.setComponent( menu.getComponent() );
        authMenuRespVO.setIcon( menu.getIcon() );
        authMenuRespVO.setVisible( menu.getVisible() );
        authMenuRespVO.setKeepAlive( menu.getKeepAlive() );

        return authMenuRespVO;
    }

    @Override
    public SocialUserBindReqDTO convert(Long userId, Integer userType, AuthSocialLoginReqVO reqVO) {
        if ( userId == null && userType == null && reqVO == null ) {
            return null;
        }

        SocialUserBindReqDTO socialUserBindReqDTO = new SocialUserBindReqDTO();

        if ( userId != null ) {
            socialUserBindReqDTO.setUserId( userId );
        }
        if ( userType != null ) {
            socialUserBindReqDTO.setUserType( userType );
        }
        if ( reqVO != null ) {
            socialUserBindReqDTO.setType( reqVO.getType() );
            socialUserBindReqDTO.setCode( reqVO.getCode() );
            socialUserBindReqDTO.setState( reqVO.getState() );
        }

        return socialUserBindReqDTO;
    }

    @Override
    public SmsCodeSendReqDTO convert(AuthSmsSendReqVO reqVO) {
        if ( reqVO == null ) {
            return null;
        }

        SmsCodeSendReqDTO smsCodeSendReqDTO = new SmsCodeSendReqDTO();

        smsCodeSendReqDTO.setMobile( reqVO.getMobile() );
        smsCodeSendReqDTO.setScene( reqVO.getScene() );

        return smsCodeSendReqDTO;
    }

    @Override
    public SmsCodeUseReqDTO convert(AuthSmsLoginReqVO reqVO, Integer scene, String usedIp) {
        if ( reqVO == null && scene == null && usedIp == null ) {
            return null;
        }

        SmsCodeUseReqDTO smsCodeUseReqDTO = new SmsCodeUseReqDTO();

        if ( reqVO != null ) {
            smsCodeUseReqDTO.setMobile( reqVO.getMobile() );
            smsCodeUseReqDTO.setCode( reqVO.getCode() );
        }
        if ( scene != null ) {
            smsCodeUseReqDTO.setScene( scene );
        }
        if ( usedIp != null ) {
            smsCodeUseReqDTO.setUsedIp( usedIp );
        }

        return smsCodeUseReqDTO;
    }
}
