feat(handler): 新增 FastjsonArrayHandler
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user