package com.example.removetolocal.config;

import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;

/**
 * @author zjm
 * @version 1.0.0
 * @ClassName BeanHelper.java
 * @Description TODO
 * @createTime 2020年08月11日 11:18:00
 */
@Service
public class BeanHelper {
    private static ModelMapper mapper = new ModelMapper();

    static {
        mapper.getConfiguration().setAmbiguityIgnored(true);
        //设置为严格匹配
        mapper.getConfiguration().setFullTypeMatchingRequired(true);
        mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);

    }

    public static ModelMapper getUserMapper() {
        return mapper;
    }

    @Bean
    public ModelMapper initModelMapper() {
        return mapper;
    }

    @Bean
    public BCryptPasswordEncoder bCryptPasswordEncoder() {
        return new BCryptPasswordEncoder();
    }

//    @Bean
//    public ObjectMapper objectMapper() {
//        return new ObjectMapper().disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
//    }

}
