anwena / MongoPlus

🔥🔥🔥使用MyBatisPlus的方式,优雅的操作MongoDB
Apache License 2.0
112 stars 12 forks source link

类型转换比较弱智 #2

Open juqkai opened 11 months ago

juqkai commented 11 months ago

数值默认会是double,如果使用Integer, Long来接收,会出错。

我临时把nutz的类型转换嫁接了过来

status{
        ConversionService.getAllConversion().clear();
        ConversionService.getAllConversion().put(Object.class, new NutzConversionStrategy());
}
public class NutzConversionStrategy implements ConversionStrategy {
    @Override
    public Object convertValue(Field field, Object obj, Object fieldValue) throws IllegalAccessException {
        return Castors.me().castTo(fieldValue, field.getType());
    }
}
anwena commented 11 months ago

anwena commented 11 months ago

没明白你的问题,什么比较弱智,换新版本去吧,而且,double类型,用Integer和Long来接收,我的转换只是“尝试”进行转换,明显不能这样去用啊

juqkai commented 11 months ago

不是能不能的问题,是因为mongdb对数值默认就是double,但是这个值是希望是int或者Long。这个时候就会转换出错

Groos-dev commented 3 months ago

@juqkai why are you hostile, your quality needs to be improved, Cloud you please respect open source ?