1.分配策略页面提交
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package org.nl.common.domain.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.Feature;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Assert;
|
||||
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.MappedJdbcTypes;
|
||||
import org.apache.ibatis.type.MappedTypes;
|
||||
|
||||
@Slf4j
|
||||
@MappedTypes({Object.class})
|
||||
@MappedJdbcTypes(JdbcType.VARCHAR)
|
||||
public class FastjsonSortTypeHandler extends AbstractJsonTypeHandler<Object> {
|
||||
private Class<?> type;
|
||||
|
||||
public FastjsonSortTypeHandler(Class<?> type) {
|
||||
if (log.isTraceEnabled()) {
|
||||
log.trace("FastjsonSortTypeHandler(" + type + ")");
|
||||
}
|
||||
Assert.notNull(type, "Type argument cannot be null");
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object parse(String json) {
|
||||
return JSON.parseObject(json, type, Feature.OrderedField);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String toJson(Object obj) {
|
||||
return JSON.toJSONString(obj,SerializerFeature.WriteMapNullValue,
|
||||
SerializerFeature.WriteNullListAsEmpty, SerializerFeature.WriteNullStringAsEmpty,SerializerFeature.SortField);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.nl.common.domain.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import org.apache.ibatis.type.BaseTypeHandler;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
*
|
||||
* @author <a href="mailto:qinghehe@qq.com">gongmanman</a>
|
||||
* @Date Create on 2020/3/19/0019 18:30
|
||||
* @since version1.0 Copyright 2020 CLKJ All Rights Reserved.
|
||||
*/
|
||||
public class ListTypeHandler extends BaseTypeHandler<Object> {
|
||||
@Override
|
||||
public void setNonNullParameter(PreparedStatement ps, int i, Object parameter, JdbcType jdbcType) throws SQLException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNullableResult(ResultSet rs, String columnName) throws SQLException {
|
||||
return jsonTrans(rs.getString(columnName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
|
||||
return jsonTrans(rs.getString(columnIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
|
||||
return jsonTrans(cs.getString(columnIndex));
|
||||
}
|
||||
|
||||
private Object jsonTrans(String s) {
|
||||
if(s == null){
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
return JSONArray.parseArray(s,String.class);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user