mirror of
https://gitee.com/best_handsome/mybatis-plus-join
synced 2025-07-11 00:02:22 +08:00
This commit is contained in:
parent
c6b781fc72
commit
a3340741f1
@ -1,9 +1,15 @@
|
||||
package com.github.yulichang.adapter.base;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.IJsonTypeHandler;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
|
||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.core.toolkit.MybatisUtils;
|
||||
import com.github.yulichang.adapter.base.metadata.OrderFieldInfo;
|
||||
import com.github.yulichang.adapter.jsqlparser.JSqlParserHelper;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.type.TypeHandler;
|
||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||
import org.apache.ibatis.type.UnknownTypeHandler;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
@ -50,5 +56,23 @@ public interface IAdapter {
|
||||
new OrderFieldInfo(f.getColumn(), f.getType(), f.getSort())).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
void parserColum(String alias, String from, String selectSql, Consumer<String> columConsumer);
|
||||
default void parserColum(String alias, String from, String selectSql, Consumer<String> columConsumer) {
|
||||
JSqlParserHelper.parserColum(alias, from, selectSql, columConsumer);
|
||||
}
|
||||
|
||||
default TypeHandler<?> getTypeHandler(Configuration configuration, Class<?> propertyType, Class<? extends TypeHandler<?>> typeHandlerClass, Field field) {
|
||||
TypeHandlerRegistry registry = configuration.getTypeHandlerRegistry();
|
||||
TypeHandler<?> typeHandler = registry.getMappingTypeHandler(typeHandlerClass);
|
||||
if (typeHandlerClass != null && typeHandlerClass != UnknownTypeHandler.class) {
|
||||
if (IJsonTypeHandler.class.isAssignableFrom(typeHandlerClass)) {
|
||||
// 保证每次实例化
|
||||
typeHandler = MybatisUtils.newJsonTypeHandler(typeHandlerClass, propertyType, field);
|
||||
} else {
|
||||
if (typeHandler == null) {
|
||||
typeHandler = registry.getInstance(propertyType, typeHandlerClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ import com.github.yulichang.adapter.base.metadata.OrderFieldInfo;
|
||||
import com.github.yulichang.adapter.base.tookit.VersionUtils;
|
||||
import com.github.yulichang.adapter.jsqlparser.v46.JSqlParserHelperV46;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.type.TypeHandler;
|
||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
@ -21,7 +23,7 @@ import java.util.function.Supplier;
|
||||
* @author yulichang
|
||||
* @since 1.4.3
|
||||
*/
|
||||
public class AdapterV33x implements IAdapter {
|
||||
public class Adapter33x implements IAdapter {
|
||||
|
||||
private static final boolean is330 = VersionUtils.compare(MybatisPlusVersion.getVersion(), "3.3.0") == 0;
|
||||
|
||||
@ -75,4 +77,14 @@ public class AdapterV33x implements IAdapter {
|
||||
public void parserColum(String alias, String from, String selectSql, Consumer<String> columConsumer) {
|
||||
JSqlParserHelperV46.parserColum(alias, from, selectSql, columConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeHandler<?> getTypeHandler(Configuration configuration, Class<?> propertyType, Class<? extends TypeHandler<?>> typeHandlerClass, Field field) {
|
||||
TypeHandlerRegistry registry = configuration.getTypeHandlerRegistry();
|
||||
TypeHandler<?> typeHandler = registry.getMappingTypeHandler(typeHandlerClass);
|
||||
if (typeHandler == null) {
|
||||
typeHandler = registry.getInstance(propertyType, typeHandlerClass);
|
||||
}
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
@ -10,7 +10,11 @@ import com.github.yulichang.adapter.base.metadata.OrderFieldInfo;
|
||||
import com.github.yulichang.adapter.base.tookit.VersionUtils;
|
||||
import com.github.yulichang.adapter.jsqlparser.v46.JSqlParserHelperV46;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.type.TypeHandler;
|
||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
@ -46,4 +50,14 @@ public class Adapter3431 implements IAdapter {
|
||||
public void parserColum(String alias, String from, String selectSql, Consumer<String> columConsumer) {
|
||||
JSqlParserHelperV46.parserColum(alias, from, selectSql, columConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeHandler<?> getTypeHandler(Configuration configuration, Class<?> propertyType, Class<? extends TypeHandler<?>> typeHandlerClass, Field field) {
|
||||
TypeHandlerRegistry registry = configuration.getTypeHandlerRegistry();
|
||||
TypeHandler<?> typeHandler = registry.getMappingTypeHandler(typeHandlerClass);
|
||||
if (typeHandler == null) {
|
||||
typeHandler = registry.getInstance(propertyType, typeHandlerClass);
|
||||
}
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,11 @@ package com.github.yulichang.adapter.v355;
|
||||
|
||||
import com.github.yulichang.adapter.base.IAdapter;
|
||||
import com.github.yulichang.adapter.jsqlparser.v46.JSqlParserHelperV46;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.type.TypeHandler;
|
||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@ -15,4 +19,14 @@ public class Adapter355 implements IAdapter {
|
||||
public void parserColum(String alias, String from, String selectSql, Consumer<String> columConsumer) {
|
||||
JSqlParserHelperV46.parserColum(alias, from, selectSql, columConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeHandler<?> getTypeHandler(Configuration configuration, Class<?> propertyType, Class<? extends TypeHandler<?>> typeHandlerClass, Field field) {
|
||||
TypeHandlerRegistry registry = configuration.getTypeHandlerRegistry();
|
||||
TypeHandler<?> typeHandler = registry.getMappingTypeHandler(typeHandlerClass);
|
||||
if (typeHandler == null) {
|
||||
typeHandler = registry.getInstance(propertyType, typeHandlerClass);
|
||||
}
|
||||
return typeHandler;
|
||||
}
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
package com.github.yulichang.adapter;
|
||||
|
||||
import com.github.yulichang.adapter.base.IAdapter;
|
||||
import com.github.yulichang.adapter.jsqlparser.JSqlParserHelper;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* @author yulichang
|
||||
@ -11,8 +8,4 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
public class Adapter implements IAdapter {
|
||||
|
||||
@Override
|
||||
public void parserColum(String alias, String from, String selectSql, Consumer<String> columConsumer) {
|
||||
JSqlParserHelper.parserColum(alias, from, selectSql, columConsumer);
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.MybatisPlusVersion;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
|
||||
import com.github.yulichang.adapter.base.IAdapter;
|
||||
import com.github.yulichang.adapter.base.tookit.VersionUtils;
|
||||
import com.github.yulichang.adapter.v33x.AdapterV33x;
|
||||
import com.github.yulichang.adapter.v33x.Adapter33x;
|
||||
import com.github.yulichang.adapter.v3431.Adapter3431;
|
||||
import com.github.yulichang.adapter.v355.Adapter355;
|
||||
import lombok.Getter;
|
||||
@ -32,7 +32,7 @@ public class AdapterHelper {
|
||||
} else if (VersionUtils.compare(version, "3.4.0") >= 0) {
|
||||
adapter = new Adapter3431();
|
||||
} else if (VersionUtils.compare(version, "3.3.0") >= 0) {
|
||||
adapter = new AdapterV33x();
|
||||
adapter = new Adapter33x();
|
||||
} else {
|
||||
throw ExceptionUtils.mpe("MPJ需要MP版本3.3.0+,当前MP版本%s", version);
|
||||
}
|
||||
|
@ -7,17 +7,18 @@ import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.github.yulichang.adapter.AdapterHelper;
|
||||
import com.github.yulichang.apt.BaseColumn;
|
||||
import com.github.yulichang.apt.Column;
|
||||
import com.github.yulichang.config.ConfigProperties;
|
||||
import com.github.yulichang.config.enums.LogicDelTypeEnum;
|
||||
import com.github.yulichang.extension.apt.interfaces.QueryJoin;
|
||||
import com.github.yulichang.toolkit.Constant;
|
||||
import com.github.yulichang.toolkit.LogicInfoUtils;
|
||||
import com.github.yulichang.toolkit.TableHelper;
|
||||
import com.github.yulichang.toolkit.TableMap;
|
||||
import com.github.yulichang.toolkit.support.ColumnCache;
|
||||
import com.github.yulichang.extension.apt.interfaces.QueryJoin;
|
||||
import com.github.yulichang.wrapper.interfaces.MFunction;
|
||||
import com.github.yulichang.wrapper.segments.SelectCache;
|
||||
import lombok.Getter;
|
||||
@ -27,7 +28,6 @@ import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.baomidou.mybatisplus.core.enums.WrapperKeyword.APPLY;
|
||||
@ -73,7 +73,7 @@ public abstract class AptAbstractWrapper<T, Children extends AptAbstractWrapper<
|
||||
/**
|
||||
* 主表 表名处理方法
|
||||
*/
|
||||
protected Function<String, String> tableFunc;
|
||||
protected SFunction<String, String> tableFunc;
|
||||
|
||||
/**
|
||||
* 逻辑删除位置
|
||||
@ -140,7 +140,7 @@ public abstract class AptAbstractWrapper<T, Children extends AptAbstractWrapper<
|
||||
*
|
||||
* @return 自定义表别名
|
||||
*/
|
||||
public Children setTableName(Function<String, String> tableFunc) {
|
||||
public Children setTableName(SFunction<String, String> tableFunc) {
|
||||
if (isMain) {
|
||||
if (tableFunc != null) {
|
||||
this.dynamicTableName = true;
|
||||
|
@ -8,15 +8,17 @@ import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.github.yulichang.apt.BaseColumn;
|
||||
import com.github.yulichang.apt.Column;
|
||||
import com.github.yulichang.config.ConfigProperties;
|
||||
import com.github.yulichang.extension.apt.toolkit.AptWrapperUtils;
|
||||
import com.github.yulichang.extension.apt.toolkit.AptWrappers;
|
||||
import com.github.yulichang.toolkit.LambdaUtils;
|
||||
import com.github.yulichang.toolkit.*;
|
||||
import com.github.yulichang.toolkit.support.ColumnCache;
|
||||
import com.github.yulichang.extension.apt.interfaces.Query;
|
||||
import com.github.yulichang.extension.apt.interfaces.QueryLabel;
|
||||
import com.github.yulichang.extension.apt.toolkit.AptWrapperUtils;
|
||||
import com.github.yulichang.extension.apt.toolkit.AptWrappers;
|
||||
import com.github.yulichang.toolkit.Constant;
|
||||
import com.github.yulichang.toolkit.LambdaUtils;
|
||||
import com.github.yulichang.toolkit.TableMap;
|
||||
import com.github.yulichang.toolkit.support.ColumnCache;
|
||||
import com.github.yulichang.wrapper.enums.IfExistsSqlKeyWordEnum;
|
||||
import com.github.yulichang.wrapper.interfaces.Chain;
|
||||
import com.github.yulichang.wrapper.interfaces.MBiPredicate;
|
||||
import com.github.yulichang.wrapper.interfaces.SelectWrapper;
|
||||
import com.github.yulichang.wrapper.resultmap.Label;
|
||||
import com.github.yulichang.wrapper.segments.Select;
|
||||
@ -27,7 +29,6 @@ import lombok.Getter;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -97,7 +98,7 @@ public class AptQueryWrapper<T> extends AptAbstractWrapper<T, AptQueryWrapper<T>
|
||||
Map<String, Object> paramNameValuePairs, MergeSegments mergeSegments, SharedString paramAlias,
|
||||
SharedString lastSql, SharedString sqlComment, SharedString sqlFirst,
|
||||
TableMap aptIndex, Integer index, String keyWord, Class<?> joinClass, String tableName,
|
||||
BiPredicate<Object, IfExistsSqlKeyWordEnum> IfExists) {
|
||||
MBiPredicate<Object, IfExistsSqlKeyWordEnum> IfExists) {
|
||||
super(baseColumn);
|
||||
super.setEntity(entity);
|
||||
super.setEntityClass(baseColumn.getColumnClass());
|
||||
|
@ -22,10 +22,7 @@ import com.github.yulichang.extension.apt.interfaces.CompareIfExists;
|
||||
import com.github.yulichang.extension.apt.interfaces.Func;
|
||||
import com.github.yulichang.extension.apt.interfaces.OnCompare;
|
||||
import com.github.yulichang.wrapper.enums.IfExistsSqlKeyWordEnum;
|
||||
import com.github.yulichang.wrapper.interfaces.CompareStrIfExists;
|
||||
import com.github.yulichang.wrapper.interfaces.DoSomething;
|
||||
import com.github.yulichang.wrapper.interfaces.FuncStr;
|
||||
import com.github.yulichang.wrapper.interfaces.Join;
|
||||
import com.github.yulichang.wrapper.interfaces.*;
|
||||
import com.github.yulichang.wrapper.segments.AptConsumer;
|
||||
import lombok.Getter;
|
||||
|
||||
@ -113,7 +110,7 @@ public abstract class JoinAbstractWrapper<T, Children extends JoinAbstractWrappe
|
||||
* IfExists 策略
|
||||
*/
|
||||
@Getter
|
||||
protected BiPredicate<Object, IfExistsSqlKeyWordEnum> ifExists = ConfigProperties.ifExists;
|
||||
protected MBiPredicate<Object, IfExistsSqlKeyWordEnum> ifExists = ConfigProperties.ifExists;
|
||||
|
||||
@Override
|
||||
public T getEntity() {
|
||||
@ -163,7 +160,7 @@ public abstract class JoinAbstractWrapper<T, Children extends JoinAbstractWrappe
|
||||
return typedThis;
|
||||
}
|
||||
|
||||
public Children setIfExists(BiPredicate<Object, IfExistsSqlKeyWordEnum> IfExists) {
|
||||
public Children setIfExists(MBiPredicate<Object, IfExistsSqlKeyWordEnum> IfExists) {
|
||||
this.ifExists = IfExists;
|
||||
return typedThis;
|
||||
}
|
||||
@ -283,12 +280,12 @@ public abstract class JoinAbstractWrapper<T, Children extends JoinAbstractWrappe
|
||||
() -> formatSqlMaybeWithParam(applySql, null, values)));
|
||||
}
|
||||
|
||||
public Children applyFunc(String applySql, Function<AptConsumer, Column[]> consumerFunction, Object... values) {
|
||||
public Children applyFunc(String applySql, SFunction<AptConsumer, Column[]> consumerFunction, Object... values) {
|
||||
return applyFunc(true, applySql, consumerFunction, values);
|
||||
}
|
||||
|
||||
public Children applyFunc(boolean condition, String applySql,
|
||||
Function<AptConsumer, Column[]> consumerFunction, Object... values) {
|
||||
SFunction<AptConsumer, Column[]> consumerFunction, Object... values) {
|
||||
return maybeDo(condition, () -> appendSqlSegments(APPLY,
|
||||
() -> formatSqlMaybeWithParam(String.format(applySql,
|
||||
Arrays.stream(consumerFunction.apply(AptConsumer.func)).map(this::columnToString).toArray()), null, values)));
|
||||
|
@ -190,8 +190,13 @@ public class MPJInterceptor implements Interceptor {
|
||||
}
|
||||
|
||||
private ResultMapping selectToResult(Class<?> entity, Select select, Class<?> type, ResultMapping.Builder builder) {
|
||||
if (select.hasTypeHandle() && select.getPropertyType().isAssignableFrom(type)) {
|
||||
builder.typeHandler(select.getTypeHandle());
|
||||
if (select.hasTypeHandle()) {
|
||||
if (select.getPropertyType().isAssignableFrom(type)) {
|
||||
builder.typeHandler(select.getTypeHandle());
|
||||
} else {
|
||||
throw new ClassCastException(String.format("%s not cast to %s [%s]",
|
||||
select.getPropertyType().getSimpleName(), type.getSimpleName(), entity.getName() + "." + select.getColumProperty()));
|
||||
}
|
||||
}
|
||||
if (select.isPk() && entity == select.getClazz()) {
|
||||
builder.flags(Collections.singletonList(ResultFlag.ID));
|
||||
|
@ -2,6 +2,8 @@ package com.github.yulichang.wrapper.segments;
|
||||
|
||||
import com.github.yulichang.apt.Column;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 用于selectFunc 和 applyFunc中的参数填充
|
||||
* 从原来的 {@link SelectFunc} 里的内部类中提取出来
|
||||
@ -9,7 +11,7 @@ import com.github.yulichang.apt.Column;
|
||||
* @author yulichang
|
||||
* @since 1.4.13
|
||||
*/
|
||||
public class AptConsumer {
|
||||
public class AptConsumer implements Serializable {
|
||||
|
||||
public static final AptConsumer func = new AptConsumer();
|
||||
|
||||
|
@ -5,15 +5,15 @@ import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.github.yulichang.adapter.AdapterHelper;
|
||||
import com.github.yulichang.toolkit.MPJStringUtils;
|
||||
import com.github.yulichang.toolkit.ReflectionKit;
|
||||
import com.github.yulichang.toolkit.TableHelper;
|
||||
import lombok.Getter;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.apache.ibatis.type.JdbcType;
|
||||
import org.apache.ibatis.type.TypeHandler;
|
||||
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||
import org.apache.ibatis.type.UnknownTypeHandler;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@ -99,31 +99,25 @@ public class SelectCache implements Serializable {
|
||||
|
||||
public TypeHandler<?> getTypeHandler() {
|
||||
if (this.hasTypeHandle) {
|
||||
return Cache.getTypeHandlerCache(this.clazz, this.typeHandlerClass, this.propertyType);
|
||||
return Cache.getTypeHandlerCache(this.clazz, this.typeHandlerClass, this.propertyType, this.columProperty);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static TypeHandler<?> getTypeHandler(Configuration configuration, Class<?> propertyType, Class<? extends TypeHandler<?>> typeHandlerClass) {
|
||||
TypeHandlerRegistry registry = configuration.getTypeHandlerRegistry();
|
||||
TypeHandler<?> typeHandler = registry.getMappingTypeHandler(typeHandlerClass);
|
||||
if (typeHandler == null) {
|
||||
typeHandler = registry.getInstance(propertyType, typeHandlerClass);
|
||||
}
|
||||
return typeHandler;
|
||||
}
|
||||
|
||||
public static class Cache {
|
||||
private static final Map<Class<?>, Map<Class<?>, TypeHandler<?>>> CACHE = new ConcurrentHashMap<>();
|
||||
|
||||
public static TypeHandler<?> getTypeHandlerCache(Class<?> table, Class<? extends TypeHandler<?>> typeHandler, Class<?> propertyType) {
|
||||
public static TypeHandler<?> getTypeHandlerCache(Class<?> table, Class<? extends TypeHandler<?>> typeHandler, Class<?> propertyType, String columProperty) {
|
||||
if (table == null || typeHandler == null) {
|
||||
return null;
|
||||
}
|
||||
Map<Class<?>, TypeHandler<?>> map = CACHE.computeIfAbsent(table, k -> new ConcurrentHashMap<>());
|
||||
return map.computeIfAbsent(typeHandler, k -> {
|
||||
TableInfo info = TableHelper.getAssert(table);
|
||||
return getTypeHandler(AdapterHelper.getAdapter().mpjGetConfiguration(info), propertyType, typeHandler);
|
||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||
TableFieldInfo fieldInfo = info.getFieldList().stream().filter(f -> f.getProperty().equals(columProperty)).findFirst().get();
|
||||
Field field = AdapterHelper.getAdapter().mpjGetField(fieldInfo, () -> ReflectionKit.getFieldMap(table).get(columProperty));
|
||||
return AdapterHelper.getAdapter().getTypeHandler(AdapterHelper.getAdapter().mpjGetConfiguration(info), propertyType, typeHandler, field);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class UserDTO {
|
||||
/** user */
|
||||
private String PName;
|
||||
/** user */
|
||||
private Map<String,String> json;
|
||||
private List<UserJson> json;
|
||||
/** user */
|
||||
private Sex sex;
|
||||
/** user */
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.github.yulichang.test.join.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class UserJson implements Serializable {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
}
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import com.github.yulichang.annotation.DynamicTableName;
|
||||
import com.github.yulichang.annotation.Table;
|
||||
import com.github.yulichang.test.join.dto.UserJson;
|
||||
import com.github.yulichang.test.join.enums.Sex;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -16,7 +17,6 @@ import lombok.experimental.FieldNameConstants;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Table
|
||||
@Data
|
||||
@ -34,7 +34,7 @@ public class UserDO extends ID<Integer> implements Serializable {
|
||||
private String name;
|
||||
|
||||
@TableField(value = "`json`", typeHandler = JacksonTypeHandler.class)
|
||||
private Map<String, String> json;
|
||||
private List<UserJson> json;
|
||||
|
||||
private Sex sex;
|
||||
|
||||
|
@ -30,28 +30,28 @@ INSERT INTO area (id, province, city, area, postcode, del) VALUES (10022, '北
|
||||
DELETE FROM `user`;
|
||||
|
||||
INSERT INTO `user` (id, pid, `name`, `json`, `address_id`, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES
|
||||
( 1, 1, '张三 1', '{"id": 1,"name":"张三 1"}', 1, 2, 1, 'https://url-01', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 2, 1, '张三 2', '{"id": 2,"name":"张三 2"}', 1, 2, 0, 'https://url-02', '2022-01-01 12:00:00', 2, 3, false),
|
||||
( 3, 1, '张三 3', '{"id": 3,"name":"张三 3"}', 1, 2, 0, 'https://url-03', '2022-01-01 12:00:00', 3, 2, false),
|
||||
( 4, 1, '张三 4', '{"id": 4,"name":"张三 4"}', 1, 2, 0, 'https://url-04', '2022-01-01 12:00:00', 9, 2, false),
|
||||
( 5, 1, '张三 5', '{"id": 5,"name":"张三 5"}', 1, 2, 0, 'https://url-05', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 6, 1, '张三 6', '{"id": 6,"name":"张三 6"}', 1, 2, 0, 'https://url-06', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 7, 1, '张三 7', '{"id": 7,"name":"张三 7"}', 1, 2, 0, 'https://url-07', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 8, 1, '张三 8', '{"id": 8,"name":"张三 8"}', 1, 2, 0, 'https://url-08', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 9, 1, '张三 9', '{"id": 9,"name":"张三 9"}', 1, 2, 0, 'https://url-09', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(10, 1, '张三10', '{"id":10,"name":"张三10"}', 1, 2, 0, 'https://url-10', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(11, 1, '张三11', '{"id":11,"name":"张三11"}', 1, 2, 0, 'https://url-11', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(12, 1, '张三12', '{"id":12,"name":"张三12"}', 1, 2, 0, 'https://url-12', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(13, 1, '张三13', '{"id":13,"name":"张三13"}', 1, 2, 0, 'https://url-13', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(14, 2, '张三14', '{"id":14,"name":"张三14"}', 1, 2, 0, 'https://url-14', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(15, 2, '张三15', '{"id":15,"name":"张三15"}', 1, 2, 0, 'https://url-15', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(16, 2, '张三16', '{"id":16,"name":"张三16"}', 1, 2, 0, 'https://url-16', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(17, 2, '张三17', '{"id":17,"name":"张三17"}', 1, 2, 0, 'https://url-17', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(18, 2, '张三18', '{"id":18,"name":"张三18"}', 1, 2, 0, 'https://url-18', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(19, 2, '张三19', '{"id":19,"name":"张三19"}', 1, 2, 0, 'https://url-19', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(20, 2, '张三20', '{"id":20,"name":"张三20"}', 1, 2, 0, 'https://url-20', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(21, 2, '张三21', '{"id":21,"name":"张三21"}', 1, 2, 0, 'https://url-21', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(22, 2, '张三22', '{"id":22,"name":"张三22"}', 1, 2, 0, 'https://url-22', '2022-01-01 12:00:00', 1, 2, true );
|
||||
( 1, 1, '张三 1', '[{"id": 1,"name":"张三 1"}]', 1, 2, 1, 'https://url-01', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 2, 1, '张三 2', '[{"id": 2,"name":"张三 2"}]', 1, 2, 0, 'https://url-02', '2022-01-01 12:00:00', 2, 3, false),
|
||||
( 3, 1, '张三 3', '[{"id": 3,"name":"张三 3"}]', 1, 2, 0, 'https://url-03', '2022-01-01 12:00:00', 3, 2, false),
|
||||
( 4, 1, '张三 4', '[{"id": 4,"name":"张三 4"}]', 1, 2, 0, 'https://url-04', '2022-01-01 12:00:00', 9, 2, false),
|
||||
( 5, 1, '张三 5', '[{"id": 5,"name":"张三 5"}]', 1, 2, 0, 'https://url-05', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 6, 1, '张三 6', '[{"id": 6,"name":"张三 6"}]', 1, 2, 0, 'https://url-06', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 7, 1, '张三 7', '[{"id": 7,"name":"张三 7"}]', 1, 2, 0, 'https://url-07', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 8, 1, '张三 8', '[{"id": 8,"name":"张三 8"}]', 1, 2, 0, 'https://url-08', '2022-01-01 12:00:00', 1, 2, false),
|
||||
( 9, 1, '张三 9', '[{"id": 9,"name":"张三 9"}]', 1, 2, 0, 'https://url-09', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(10, 1, '张三10', '[{"id":10,"name":"张三10"}]', 1, 2, 0, 'https://url-10', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(11, 1, '张三11', '[{"id":11,"name":"张三11"}]', 1, 2, 0, 'https://url-11', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(12, 1, '张三12', '[{"id":12,"name":"张三12"}]', 1, 2, 0, 'https://url-12', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(13, 1, '张三13', '[{"id":13,"name":"张三13"}]', 1, 2, 0, 'https://url-13', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(14, 2, '张三14', '[{"id":14,"name":"张三14"}]', 1, 2, 0, 'https://url-14', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(15, 2, '张三15', '[{"id":15,"name":"张三15"}]', 1, 2, 0, 'https://url-15', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(16, 2, '张三16', '[{"id":16,"name":"张三16"}]', 1, 2, 0, 'https://url-16', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(17, 2, '张三17', '[{"id":17,"name":"张三17"}]', 1, 2, 0, 'https://url-17', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(18, 2, '张三18', '[{"id":18,"name":"张三18"}]', 1, 2, 0, 'https://url-18', '2022-01-01 12:00:00', 1, 2, false),
|
||||
(19, 2, '张三19', '[{"id":19,"name":"张三19"}]', 1, 2, 0, 'https://url-19', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(20, 2, '张三20', '[{"id":20,"name":"张三20"}]', 1, 2, 0, 'https://url-20', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(21, 2, '张三21', '[{"id":21,"name":"张三21"}]', 1, 2, 0, 'https://url-21', '2022-01-01 12:00:00', 1, 2, true ),
|
||||
(22, 2, '张三22', '[{"id":22,"name":"张三22"}]', 1, 2, 0, 'https://url-22', '2022-01-01 12:00:00', 1, 2, true );
|
||||
|
||||
|
||||
DELETE FROM address;
|
||||
|
@ -29,28 +29,28 @@ INSERT INTO area (id, province, city, area, postcode, del) VALUES (10022, '北
|
||||
|
||||
DELETE FROM "user";
|
||||
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 1, 1, '张三 1', '{"id": 1,"name":"张三 1"}', 1, 2, 1, 'https://url-01', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 2, 1, '张三 2', '{"id": 2,"name":"张三 2"}', 1, 2, 0, 'https://url-02', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 2, 3, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 3, 1, '张三 3', '{"id": 3,"name":"张三 3"}', 1, 2, 0, 'https://url-03', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 3, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 4, 1, '张三 4', '{"id": 4,"name":"张三 4"}', 1, 2, 0, 'https://url-04', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 9, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 5, 1, '张三 5', '{"id": 5,"name":"张三 5"}', 1, 2, 0, 'https://url-05', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 6, 1, '张三 6', '{"id": 6,"name":"张三 6"}', 1, 2, 0, 'https://url-06', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 7, 1, '张三 7', '{"id": 7,"name":"张三 7"}', 1, 2, 0, 'https://url-07', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 8, 1, '张三 8', '{"id": 8,"name":"张三 8"}', 1, 2, 0, 'https://url-08', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 9, 1, '张三 9', '{"id": 9,"name":"张三 9"}', 1, 2, 0, 'https://url-09', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (10, 1, '张三10', '{"id":10,"name":"张三10"}', 1, 2, 0, 'https://url-10', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (11, 1, '张三11', '{"id":11,"name":"张三11"}', 1, 2, 0, 'https://url-11', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (12, 1, '张三12', '{"id":12,"name":"张三12"}', 1, 2, 0, 'https://url-12', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (13, 1, '张三13', '{"id":13,"name":"张三13"}', 1, 2, 0, 'https://url-13', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (14, 2, '张三14', '{"id":14,"name":"张三14"}', 1, 2, 0, 'https://url-14', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (15, 2, '张三15', '{"id":15,"name":"张三15"}', 1, 2, 0, 'https://url-15', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (16, 2, '张三16', '{"id":16,"name":"张三16"}', 1, 2, 0, 'https://url-16', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (17, 2, '张三17', '{"id":17,"name":"张三17"}', 1, 2, 0, 'https://url-17', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (18, 2, '张三18', '{"id":18,"name":"张三18"}', 1, 2, 0, 'https://url-18', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (19, 2, '张三19', '{"id":19,"name":"张三19"}', 1, 2, 0, 'https://url-19', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (20, 2, '张三20', '{"id":20,"name":"张三20"}', 1, 2, 0, 'https://url-20', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (21, 2, '张三21', '{"id":21,"name":"张三21"}', 1, 2, 0, 'https://url-21', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (22, 2, '张三22', '{"id":22,"name":"张三22"}', 1, 2, 0, 'https://url-22', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 1, 1, '张三 1', '[{"id": 1,"name":"张三 1"}]', 1, 2, 1, 'https://url-01', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 2, 1, '张三 2', '[{"id": 2,"name":"张三 2"}]', 1, 2, 0, 'https://url-02', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 2, 3, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 3, 1, '张三 3', '[{"id": 3,"name":"张三 3"}]', 1, 2, 0, 'https://url-03', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 3, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 4, 1, '张三 4', '[{"id": 4,"name":"张三 4"}]', 1, 2, 0, 'https://url-04', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 9, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 5, 1, '张三 5', '[{"id": 5,"name":"张三 5"}]', 1, 2, 0, 'https://url-05', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 6, 1, '张三 6', '[{"id": 6,"name":"张三 6"}]', 1, 2, 0, 'https://url-06', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 7, 1, '张三 7', '[{"id": 7,"name":"张三 7"}]', 1, 2, 0, 'https://url-07', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 8, 1, '张三 8', '[{"id": 8,"name":"张三 8"}]', 1, 2, 0, 'https://url-08', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES ( 9, 1, '张三 9', '[{"id": 9,"name":"张三 9"}]', 1, 2, 0, 'https://url-09', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (10, 1, '张三10', '[{"id":10,"name":"张三10"}]', 1, 2, 0, 'https://url-10', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (11, 1, '张三11', '[{"id":11,"name":"张三11"}]', 1, 2, 0, 'https://url-11', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (12, 1, '张三12', '[{"id":12,"name":"张三12"}]', 1, 2, 0, 'https://url-12', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (13, 1, '张三13', '[{"id":13,"name":"张三13"}]', 1, 2, 0, 'https://url-13', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (14, 2, '张三14', '[{"id":14,"name":"张三14"}]', 1, 2, 0, 'https://url-14', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (15, 2, '张三15', '[{"id":15,"name":"张三15"}]', 1, 2, 0, 'https://url-15', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (16, 2, '张三16', '[{"id":16,"name":"张三16"}]', 1, 2, 0, 'https://url-16', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (17, 2, '张三17', '[{"id":17,"name":"张三17"}]', 1, 2, 0, 'https://url-17', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (18, 2, '张三18', '[{"id":18,"name":"张三18"}]', 1, 2, 0, 'https://url-18', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, false);
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (19, 2, '张三19', '[{"id":19,"name":"张三19"}]', 1, 2, 0, 'https://url-19', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (20, 2, '张三20', '[{"id":20,"name":"张三20"}]', 1, 2, 0, 'https://url-20', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (21, 2, '张三21', '[{"id":21,"name":"张三21"}]', 1, 2, 0, 'https://url-21', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
INSERT INTO "user" (id, pid, "name", "json", address_id, address_id2 , sex, head_img, create_time, create_by, update_by, del) VALUES (22, 2, '张三22', '[{"id":22,"name":"张三22"}]', 1, 2, 0, 'https://url-22', TO_TIMESTAMP('2022-01-01 12:00:00', 'YYYY-MM-DD HH24:MI:SS'), 1, 2, true );
|
||||
|
||||
|
||||
DELETE FROM address;
|
||||
|
@ -29,28 +29,28 @@ INSERT INTO area (id, province, city, area, postcode, del) VALUES (10022, '北
|
||||
|
||||
DELETE FROM "user";
|
||||
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 1, 1, '张三 1', '{"id": 1,"name":"张三 1"}', 1, 2, 1, 'https://url-01', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 2, 1, '张三 2', '{"id": 2,"name":"张三 2"}', 1, 2, 0, 'https://url-02', '2022-01-01 12:00:00', 2, 3, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 3, 1, '张三 3', '{"id": 3,"name":"张三 3"}', 1, 2, 0, 'https://url-03', '2022-01-01 12:00:00', 3, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 4, 1, '张三 4', '{"id": 4,"name":"张三 4"}', 1, 2, 0, 'https://url-04', '2022-01-01 12:00:00', 9, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 5, 1, '张三 5', '{"id": 5,"name":"张三 5"}', 1, 2, 0, 'https://url-05', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 6, 1, '张三 6', '{"id": 6,"name":"张三 6"}', 1, 2, 0, 'https://url-06', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 7, 1, '张三 7', '{"id": 7,"name":"张三 7"}', 1, 2, 0, 'https://url-07', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 8, 1, '张三 8', '{"id": 8,"name":"张三 8"}', 1, 2, 0, 'https://url-08', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 9, 1, '张三 9', '{"id": 9,"name":"张三 9"}', 1, 2, 0, 'https://url-09', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (10, 1, '张三10', '{"id":10,"name":"张三10"}', 1, 2, 0, 'https://url-10', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (11, 1, '张三11', '{"id":11,"name":"张三11"}', 1, 2, 0, 'https://url-11', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (12, 1, '张三12', '{"id":12,"name":"张三12"}', 1, 2, 0, 'https://url-12', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (13, 1, '张三13', '{"id":13,"name":"张三13"}', 1, 2, 0, 'https://url-13', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (14, 2, '张三14', '{"id":14,"name":"张三14"}', 1, 2, 0, 'https://url-14', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (15, 2, '张三15', '{"id":15,"name":"张三15"}', 1, 2, 0, 'https://url-15', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (16, 2, '张三16', '{"id":16,"name":"张三16"}', 1, 2, 0, 'https://url-16', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (17, 2, '张三17', '{"id":17,"name":"张三17"}', 1, 2, 0, 'https://url-17', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (18, 2, '张三18', '{"id":18,"name":"张三18"}', 1, 2, 0, 'https://url-18', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (19, 2, '张三19', '{"id":19,"name":"张三19"}', 1, 2, 0, 'https://url-19', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (20, 2, '张三20', '{"id":20,"name":"张三20"}', 1, 2, 0, 'https://url-20', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (21, 2, '张三21', '{"id":21,"name":"张三21"}', 1, 2, 0, 'https://url-21', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (22, 2, '张三22', '{"id":22,"name":"张三22"}', 1, 2, 0, 'https://url-22', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 1, 1, '张三 1', '[{"id": 1,"name":"张三 1"}]', 1, 2, 1, 'https://url-01', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 2, 1, '张三 2', '[{"id": 2,"name":"张三 2"}]', 1, 2, 0, 'https://url-02', '2022-01-01 12:00:00', 2, 3, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 3, 1, '张三 3', '[{"id": 3,"name":"张三 3"}]', 1, 2, 0, 'https://url-03', '2022-01-01 12:00:00', 3, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 4, 1, '张三 4', '[{"id": 4,"name":"张三 4"}]', 1, 2, 0, 'https://url-04', '2022-01-01 12:00:00', 9, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 5, 1, '张三 5', '[{"id": 5,"name":"张三 5"}]', 1, 2, 0, 'https://url-05', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 6, 1, '张三 6', '[{"id": 6,"name":"张三 6"}]', 1, 2, 0, 'https://url-06', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 7, 1, '张三 7', '[{"id": 7,"name":"张三 7"}]', 1, 2, 0, 'https://url-07', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 8, 1, '张三 8', '[{"id": 8,"name":"张三 8"}]', 1, 2, 0, 'https://url-08', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES ( 9, 1, '张三 9', '[{"id": 9,"name":"张三 9"}]', 1, 2, 0, 'https://url-09', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (10, 1, '张三10', '[{"id":10,"name":"张三10"}]', 1, 2, 0, 'https://url-10', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (11, 1, '张三11', '[{"id":11,"name":"张三11"}]', 1, 2, 0, 'https://url-11', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (12, 1, '张三12', '[{"id":12,"name":"张三12"}]', 1, 2, 0, 'https://url-12', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (13, 1, '张三13', '[{"id":13,"name":"张三13"}]', 1, 2, 0, 'https://url-13', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (14, 2, '张三14', '[{"id":14,"name":"张三14"}]', 1, 2, 0, 'https://url-14', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (15, 2, '张三15', '[{"id":15,"name":"张三15"}]', 1, 2, 0, 'https://url-15', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (16, 2, '张三16', '[{"id":16,"name":"张三16"}]', 1, 2, 0, 'https://url-16', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (17, 2, '张三17', '[{"id":17,"name":"张三17"}]', 1, 2, 0, 'https://url-17', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (18, 2, '张三18', '[{"id":18,"name":"张三18"}]', 1, 2, 0, 'https://url-18', '2022-01-01 12:00:00', 1, 2, false);
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (19, 2, '张三19', '[{"id":19,"name":"张三19"}]', 1, 2, 0, 'https://url-19', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (20, 2, '张三20', '[{"id":20,"name":"张三20"}]', 1, 2, 0, 'https://url-20', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (21, 2, '张三21', '[{"id":21,"name":"张三21"}]', 1, 2, 0, 'https://url-21', '2022-01-01 12:00:00', 1, 2, true );
|
||||
INSERT INTO "user" (id, "pid", "name", "json", "address_id", "address_id2" , sex, head_img, create_time, create_by, update_by, del) VALUES (22, 2, '张三22', '[{"id":22,"name":"张三22"}]', 1, 2, 0, 'https://url-22', '2022-01-01 12:00:00', 1, 2, true );
|
||||
|
||||
|
||||
DELETE FROM address;
|
||||
|
@ -37,6 +37,7 @@ public class ApplyFuncTest {
|
||||
.leftJoin(addr, addr.userId, u.id)
|
||||
.applyFunc("concat(%s,%s,{0}) is not null", arg -> arg.accept(u.id, addr.userId), "12")
|
||||
.applyFunc("concat(%s,%s,{0}) is not null", arg -> arg.accept(u.id, addr.userId), "12")
|
||||
.clone()
|
||||
.list();
|
||||
|
||||
list.forEach(System.out::println);
|
||||
@ -55,6 +56,7 @@ public class ApplyFuncTest {
|
||||
.leftJoin(addr1, addr1.userId, u1.id)
|
||||
.applyFunc("concat(%s,%s,{0}) is not null", arg -> arg.accept(u1.id, addr1.userId), "12")
|
||||
.applyFunc("concat(%s,%s,{0}) is not null", arg -> arg.accept(u1.id,addr1.userId), "12")
|
||||
.clone()
|
||||
.list();
|
||||
|
||||
list1.forEach(System.out::println);
|
||||
|
@ -2,6 +2,7 @@ package com.github.yulichang.test.join.mysql;
|
||||
|
||||
import com.baomidou.mybatisplus.core.plugins.IgnoreStrategy;
|
||||
import com.baomidou.mybatisplus.core.plugins.InterceptorIgnoreHelper;
|
||||
import com.github.yulichang.test.join.dto.UserJson;
|
||||
import com.github.yulichang.test.join.entity.AddressDO;
|
||||
import com.github.yulichang.test.join.entity.OrderDO;
|
||||
import com.github.yulichang.test.join.entity.UserDO;
|
||||
@ -17,8 +18,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.EnabledIf;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 连表更新没有同意语法语法,不同数据库差别较大
|
||||
@ -60,11 +62,15 @@ public class UpdateJoinTest {
|
||||
|
||||
@Test
|
||||
void updateInc2() {
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("aaa", "bbb");
|
||||
UserJson json = new UserJson();
|
||||
json.setId(1111L);
|
||||
json.setName("11111111111");
|
||||
|
||||
List<UserJson> jsonList = new ArrayList<>();
|
||||
jsonList.add(json);
|
||||
|
||||
UserDO userDO = new UserDO();
|
||||
userDO.setJson(map);
|
||||
userDO.setJson(jsonList);
|
||||
|
||||
InterceptorIgnoreHelper.handle(IgnoreStrategy.builder().tenantLine(true).build());
|
||||
|
||||
@ -78,7 +84,7 @@ public class UpdateJoinTest {
|
||||
List<UserDO> list = JoinWrappers.lambda(UserDO.class).list();
|
||||
list.forEach(System.out::println);
|
||||
list.forEach(c -> {
|
||||
assert c.getJson().get("aaa").equals("bbb");
|
||||
assert Objects.equals(c.getJson().get(0).getName(), "11111111111");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,31 @@
|
||||
package com.github.yulichang.test.join.unit;
|
||||
|
||||
import com.github.yulichang.test.join.entity.UserDO;
|
||||
import com.github.yulichang.test.util.Reset;
|
||||
import com.github.yulichang.toolkit.JoinWrappers;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
public class TypeHandlerTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
Reset.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
void typeHandler(){
|
||||
MPJLambdaWrapper<UserDO> wrapper = JoinWrappers.lambda(UserDO.class);
|
||||
|
||||
List<UserDO> list = wrapper.list();
|
||||
|
||||
System.out.println(list.get(0).getJson().get(0).getClass().getName());
|
||||
|
||||
list.forEach(System.out::println);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user