feat(handler): 新增 FastjsonArrayHandler

This commit is contained in:
han0
2023-11-23 18:33:34 +08:00
parent 2662b4a31c
commit 0261835833

View File

@@ -0,0 +1,22 @@
package mjkf.xinke.main.common.serializer;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;
@MappedTypes({Object.class})
@MappedJdbcTypes({JdbcType.VARCHAR})
public class FastjsonArrayHandler<T> extends AbstractJsonTypeHandler<T> {
public String toJson(Object obj) {
return JSON.toJSONString(obj);
}
public T parse(String json) {
return (T) JSON.parseArray(json);
}
}