Pārlūkot izejas kodu

Springboot 3.22 更新版本

shilin 6 mēneši atpakaļ
vecāks
revīzija
f6bd6d8394

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 487 - 0
log/ota.log


+ 0 - 22
src/main/java/com/gyee/generation/config/mybatis/CustomizedSqlInjector.java

@@ -1,22 +0,0 @@
-package com.gyee.generation.config.mybatis;
-
-import com.baomidou.mybatisplus.core.injector.AbstractMethod;
-import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
-
-import java.util.List;
-
-/**
- * 自定义方法SQL注入器
- */
-public class CustomizedSqlInjector extends DefaultSqlInjector {
-    /**
-     * 如果只需增加方法,保留mybatis plus自带方法,
-     * 可以先获取super.getMethodList(),再添加add
-     */
-    @Override
-    public List<AbstractMethod> getMethodList(Class<?> mapperClass) {
-        List<AbstractMethod> methodList = super.getMethodList(mapperClass);
-        methodList.add(new InsertOrUpdateBath());
-        return methodList;
-    }
-}

+ 0 - 76
src/main/java/com/gyee/generation/config/mybatis/InsertOrUpdateBath.java

@@ -1,76 +0,0 @@
-package com.gyee.generation.config.mybatis;
-
-
-import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.injector.AbstractMethod;
-        import com.baomidou.mybatisplus.core.metadata.TableInfo;
-        import org.apache.ibatis.executor.keygen.NoKeyGenerator;
-        import org.apache.ibatis.mapping.MappedStatement;
-        import org.apache.ibatis.mapping.SqlSource;
-        import org.springframework.util.StringUtils;
-
-public class InsertOrUpdateBath extends AbstractMethod {
-
-    @Override
-    public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
-        final String sql = "<script>insert into %s %s values %s ON DUPLICATE KEY UPDATE %s</script>";
-        final String tableName = tableInfo.getTableName();
-        final String filedSql = prepareFieldSql(tableInfo);
-        final String modelValuesSql = prepareModelValuesSql(tableInfo);
-        final String duplicateKeySql =prepareDuplicateKeySql(tableInfo);
-        final String sqlResult = String.format(sql, tableName, filedSql, modelValuesSql,duplicateKeySql);
-        //System.out.println("savaorupdatesqlsql="+sqlResult);
-        SqlSource sqlSource = languageDriver.createSqlSource(configuration, sqlResult, modelClass);
-        return this.addInsertMappedStatement(mapperClass, modelClass, "mysqlInsertOrUpdateBath", sqlSource, new NoKeyGenerator(), null, null);
-    }
-
-    /**
-     * 准备ON DUPLICATE KEY UPDATE sql
-     * @param tableInfo
-     * @return
-     */
-    private String prepareDuplicateKeySql(TableInfo tableInfo) {
-        final StringBuilder duplicateKeySql = new StringBuilder();
-        if(!StrUtil.isEmpty(tableInfo.getKeyColumn())) {
-            duplicateKeySql.append(tableInfo.getKeyColumn()).append("=values(").append(tableInfo.getKeyColumn()).append("),");
-        }
-
-        tableInfo.getFieldList().forEach(x -> {
-            duplicateKeySql.append(x.getColumn())
-                    .append("=values(")
-                    .append(x.getColumn())
-                    .append("),");
-        });
-        duplicateKeySql.delete(duplicateKeySql.length() - 1, duplicateKeySql.length());
-        return duplicateKeySql.toString();
-    }
-
-    /**
-     * 准备属性名
-     * @param tableInfo
-     * @return
-     */
-    private String prepareFieldSql(TableInfo tableInfo) {
-        StringBuilder fieldSql = new StringBuilder();
-        fieldSql.append(tableInfo.getKeyColumn()).append(",");
-        tableInfo.getFieldList().forEach(x -> {
-            fieldSql.append(x.getColumn()).append(",");
-        });
-        fieldSql.delete(fieldSql.length() - 1, fieldSql.length());
-        fieldSql.insert(0, "(");
-        fieldSql.append(")");
-        return fieldSql.toString();
-    }
-
-    private String prepareModelValuesSql(TableInfo tableInfo){
-        final StringBuilder valueSql = new StringBuilder();
-        valueSql.append("<foreach collection=\"list\" item=\"item\" index=\"index\" open=\"(\" separator=\"),(\" close=\")\">");
-        if(!StringUtils.isEmpty(tableInfo.getKeyProperty())) {
-            valueSql.append("#{item.").append(tableInfo.getKeyProperty()).append("},");
-        }
-        tableInfo.getFieldList().forEach(x -> valueSql.append("#{item.").append(x.getProperty()).append("},"));
-        valueSql.delete(valueSql.length() - 1, valueSql.length());
-        valueSql.append("</foreach>");
-        return valueSql.toString();
-    }
-}

+ 0 - 28
src/main/java/com/gyee/generation/config/mybatis/RootMapper.java

@@ -1,28 +0,0 @@
-package com.gyee.generation.config.mybatis;
-
-import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-
-/**
- * 根Mapper,给表Mapper继承用的,可以自定义通用方法
- * {@link BaseMapper}
- * {@link com.baomidou.mybatisplus.extension.service.IService}
- * {@link com.baomidou.mybatisplus.extension.service.impl.ServiceImpl}
- */
-public interface RootMapper<T> extends BaseMapper<T> {
-
-    /**
-     * 自定义批量插入
-     * 如果要自动填充,@Param(xx) xx参数名必须是 list/collection/array 3个的其中之一
-     */
-    int insertBatch(@Param("list") List<T> list);
-
-    /**
-     * 自定义批量新增或更新
-     * 如果要自动填充,@Param(xx) xx参数名必须是 list/collection/array 3个的其中之一
-     */
-    int insertOrUpdateBath(@Param("list") List<T> list);
-
-}