提交 034da93b authored 作者: ww1xhqc's avatar ww1xhqc

[数据模型] 稳定版修改integer和double的错误

上级 c7b4b059
...@@ -13,6 +13,7 @@ import java.util.Objects; ...@@ -13,6 +13,7 @@ import java.util.Objects;
public interface FourComsumer<T, Y, U, I> { public interface FourComsumer<T, Y, U, I> {
/** /**
* accept
* @param t * @param t
* @param y * @param y
* @param u * @param u
...@@ -20,6 +21,11 @@ public interface FourComsumer<T, Y, U, I> { ...@@ -20,6 +21,11 @@ public interface FourComsumer<T, Y, U, I> {
*/ */
void accept(T t, Y y, U u, I i); void accept(T t, Y y, U u, I i);
/**
* andThen
* @param after
* @return
*/
default FourComsumer<T, Y, U, I> andThen(FourComsumer<? super T, ? super Y, ? super U, ? super I> after) { default FourComsumer<T, Y, U, I> andThen(FourComsumer<? super T, ? super Y, ? super U, ? super I> after) {
Objects.requireNonNull(after); Objects.requireNonNull(after);
......
...@@ -669,7 +669,7 @@ public class ModelImpl implements ModelService { ...@@ -669,7 +669,7 @@ public class ModelImpl implements ModelService {
//引用校验 //引用校验
if (!isNull(quoteDao.findAllByColumnId(columnInfo.getId()))) { if (!isNull(quoteDao.findAllByColumnId(columnInfo.getId()))) {
List<String> quotes = quoteDao.findAllByColumnId(columnInfo.getId()).stream().map(Quote::getValue).collect(Collectors.toList()); List<String> quotes = quoteDao.findAllByColumnId(columnInfo.getId()).stream().map(Quote::getValue).collect(Collectors.toList());
if (!validationQuote(quotes, (String) value)) { if (!validationQuote(quotes, value)) {
throw new ApiException("引用校验不通过!"); throw new ApiException("引用校验不通过!");
} }
} }
......
package com.tykj.datawarehouse.model.utils; package com.tykj.datawarehouse.model.utils;
import com.tykj.datawarehouse.base.result.ApiException; import com.tykj.datawarehouse.base.result.ApiException;
import lombok.val;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.List; import java.util.List;
...@@ -36,15 +37,28 @@ public class CheckUtils { ...@@ -36,15 +37,28 @@ public class CheckUtils {
throw new ApiException("校验不通过!"); throw new ApiException("校验不通过!");
} }
public static Boolean validationQuote(List<String> quotes, String val) { public static Boolean validationQuote(List<String> quotes, Object val) {
//如果没有引用就通过 //如果没有引用就通过
if (quotes.size() == 0) { if (quotes.size() == 0) {
return true; return true;
} }
//如果引用存在则通过 //如果引用存在则通过
if (quotes.contains(val)) { if (val instanceof String){
return true; if (quotes.contains(val)) {
return true;
}
}
if (val instanceof Integer){
if (quotes.contains(val)) {
return true;
}
} }
if (val instanceof Double){
if (quotes.contains(val)) {
return true;
}
}
throw new ApiException("引用不通过!"); throw new ApiException("引用不通过!");
} }
......
...@@ -50,7 +50,7 @@ public class SqlUtil { ...@@ -50,7 +50,7 @@ public class SqlUtil {
//基本部分 //基本部分
result.append(String.format("ALTER TABLE %s ADD COLUMN %s %s", table, name, type)); result.append(String.format("ALTER TABLE %s ADD COLUMN %s %s", table, name, type));
//字段长度 //字段长度
if (nonNull(length)) { if (nonNull(length) && type.equals("java.lang.String")) {
result.append(String.format("(%s)", length)); result.append(String.format("(%s)", length));
} }
result.append(";"); result.append(";");
...@@ -77,12 +77,12 @@ public class SqlUtil { ...@@ -77,12 +77,12 @@ public class SqlUtil {
&& nonNull(newType); && nonNull(newType);
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
if (hasValue) { if (hasValue) {
if (needLengthColumn(newType)){ if (needLengthColumn(newType)) {
result.append(String.format("ALTER TABLE %s MODIFY %s %s (%s) ;", table, name, newType,newLength)); result.append(String.format("ALTER TABLE %s MODIFY %s %s (%s) ;", table, name, newType, newLength));
}else { } else {
result.append(String.format("ALTER TABLE %s MODIFY %s %s ;", table, name, newType)); result.append(String.format("ALTER TABLE %s MODIFY %s %s ;", table, name, newType));
} }
if (isNull(newName)){ if (isNull(newName)) {
result.append(String.format("ALTER TABLE %s RENAME COLUMN %s TO %s ;", table, name, newName)); result.append(String.format("ALTER TABLE %s RENAME COLUMN %s TO %s ;", table, name, newName));
} }
} else { } else {
...@@ -94,16 +94,16 @@ public class SqlUtil { ...@@ -94,16 +94,16 @@ public class SqlUtil {
/** /**
* 修改表的单个字段的SQL语句 * 修改表的单个字段的SQL语句
* *
* @param table 表名 * @param table 表名
* @param name 旧字段名 * @param name 旧字段名
* @param newName 新字段名 * @param newName 新字段名
* @return SQL语句 * @return SQL语句
*/ */
public static String updateColumnName(String table, String name, String newName) { public static String updateColumnName(String table, String name, String newName) {
boolean hasValue = !Strings.isNullOrEmpty(table); boolean hasValue = !Strings.isNullOrEmpty(table);
StringBuilder result = new StringBuilder(); StringBuilder result = new StringBuilder();
if (hasValue) { if (hasValue) {
if (!isNull(newName)){ if (!isNull(newName)) {
result.append(String.format("ALTER TABLE %s RENAME COLUMN %s TO %s ;", table, name, newName)); result.append(String.format("ALTER TABLE %s RENAME COLUMN %s TO %s ;", table, name, newName));
} }
} else { } else {
...@@ -123,8 +123,8 @@ public class SqlUtil { ...@@ -123,8 +123,8 @@ public class SqlUtil {
return String.format("ALTER TABLE %s DROP %s;", table, name); return String.format("ALTER TABLE %s DROP %s;", table, name);
} }
private static boolean needLengthColumn(String type){ private static boolean needLengthColumn(String type) {
switch (type){ switch (type) {
case "varchar": case "varchar":
return true; return true;
default: default:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论