|
@@ -11,6 +11,7 @@ import com.boman.domain.constant.FormDataConstant;
|
|
import com.boman.domain.GenTable;
|
|
import com.boman.domain.GenTable;
|
|
import com.boman.domain.GenTableColumn;
|
|
import com.boman.domain.GenTableColumn;
|
|
import com.boman.domain.TableSql;
|
|
import com.boman.domain.TableSql;
|
|
|
|
+import com.boman.gen.api.RemoteGenTableService;
|
|
import com.boman.gen.mapper.GenTableColumnMapper;
|
|
import com.boman.gen.mapper.GenTableColumnMapper;
|
|
import com.boman.gen.mapper.GenTableMapper;
|
|
import com.boman.gen.mapper.GenTableMapper;
|
|
import com.boman.gen.mapper.TableSqlMapper;
|
|
import com.boman.gen.mapper.TableSqlMapper;
|
|
@@ -35,6 +36,8 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
|
private GenTableMapper genTableMapper;
|
|
private GenTableMapper genTableMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private TableSqlMapper tableSqlMapper;
|
|
private TableSqlMapper tableSqlMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private RemoteGenTableService remoteGenTableService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询业务字段列表
|
|
* 查询业务字段列表
|
|
@@ -64,8 +67,9 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- /**
|
|
|
|
|
|
+ * /**
|
|
* 根据字段编号获取字段详细信息, 把此外键对应的名称返回给前台
|
|
* 根据字段编号获取字段详细信息, 把此外键对应的名称返回给前台
|
|
|
|
+ *
|
|
* @param columnId pk
|
|
* @param columnId pk
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@@ -110,6 +114,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
|
int i = genTableColumnMapper.insertGenTableColumn(genTableColumn);
|
|
int i = genTableColumnMapper.insertGenTableColumn(genTableColumn);
|
|
isAk(genTableColumn);
|
|
isAk(genTableColumn);
|
|
insertCreateLog(genTableColumn, BusinessType.INSERT);
|
|
insertCreateLog(genTableColumn, BusinessType.INSERT);
|
|
|
|
+ remoteGenTableService.loadTable(new GenTable());
|
|
return i;
|
|
return i;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -123,7 +128,9 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
|
public int updateGenTableColumn(GenTableColumn genTableColumn) {
|
|
public int updateGenTableColumn(GenTableColumn genTableColumn) {
|
|
isAk(genTableColumn);
|
|
isAk(genTableColumn);
|
|
insertCreateLog(genTableColumn, BusinessType.UPDATE);
|
|
insertCreateLog(genTableColumn, BusinessType.UPDATE);
|
|
- return genTableColumnMapper.updateGenTableColumn(genTableColumn);
|
|
|
|
|
|
+ int i = genTableColumnMapper.updateGenTableColumn(genTableColumn);
|
|
|
|
+ remoteGenTableService.loadTable(new GenTable());
|
|
|
|
+ return i;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -137,13 +144,13 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
|
StringBuffer sb = new StringBuffer(createLog);
|
|
StringBuffer sb = new StringBuffer(createLog);
|
|
//ALTER TABLE table_name ADD COLUMN column_name VARCHAR(100) DEFAULT NULL COMMENT '新加字段';
|
|
//ALTER TABLE table_name ADD COLUMN column_name VARCHAR(100) DEFAULT NULL COMMENT '新加字段';
|
|
sb.append("\r\n").append(DateUtils.getTime()).append(" ").append(SecurityUtils.getUsername()).append(" ALTER TABLE ").append(genTable.getTableName());
|
|
sb.append("\r\n").append(DateUtils.getTime()).append(" ").append(SecurityUtils.getUsername()).append(" ALTER TABLE ").append(genTable.getTableName());
|
|
- if (BusinessType.INSERT.equals(type)){
|
|
|
|
|
|
+ if (BusinessType.INSERT.equals(type)) {
|
|
sb.append(" ADD COLUMN ").append(genTableColumn.getColumnName()).append(" ").append(genTableColumn.getColumnType());
|
|
sb.append(" ADD COLUMN ").append(genTableColumn.getColumnName()).append(" ").append(genTableColumn.getColumnType());
|
|
sb = genTableColumn.getDefaultValue() == null ? sb.append(" DEFAULT NULL COMMENT ") : sb.append(" DEFAULT '").append(genTableColumn.getDefaultValue()).append("' COMMENT '");
|
|
sb = genTableColumn.getDefaultValue() == null ? sb.append(" DEFAULT NULL COMMENT ") : sb.append(" DEFAULT '").append(genTableColumn.getDefaultValue()).append("' COMMENT '");
|
|
sb.append(genTableColumn.getColumnComment()).append("';");
|
|
sb.append(genTableColumn.getColumnComment()).append("';");
|
|
- }else if(BusinessType.UPDATE.equals(type)){
|
|
|
|
|
|
+ } else if (BusinessType.UPDATE.equals(type)) {
|
|
sb.append(" MODIFY ").append(genTableColumn.getColumnName()).append(" ").append(genTableColumn.getColumnType()).append(";");
|
|
sb.append(" MODIFY ").append(genTableColumn.getColumnName()).append(" ").append(genTableColumn.getColumnType()).append(";");
|
|
- }else if(BusinessType.DELETE.equals(type)){
|
|
|
|
|
|
+ } else if (BusinessType.DELETE.equals(type)) {
|
|
sb.append(" DROP ").append(genTableColumn.getColumnName()).append(";");
|
|
sb.append(" DROP ").append(genTableColumn.getColumnName()).append(";");
|
|
}
|
|
}
|
|
tableSql.setCreateLog(sb.toString());
|
|
tableSql.setCreateLog(sb.toString());
|
|
@@ -165,7 +172,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
|
if (UserConstants.YES.equals(isIn)) {
|
|
if (UserConstants.YES.equals(isIn)) {
|
|
//判断是否已经存在输入字段且不是同一个字段
|
|
//判断是否已经存在输入字段且不是同一个字段
|
|
for (GenTableColumn tableColumn : genTableColumns) {
|
|
for (GenTableColumn tableColumn : genTableColumns) {
|
|
- if (UserConstants.YES.equals(tableColumn.getIsIn()) && !tableColumn.getColumnId().equals(genTableColumn.getColumnId())){
|
|
|
|
|
|
+ if (UserConstants.YES.equals(tableColumn.getIsIn()) && !tableColumn.getColumnId().equals(genTableColumn.getColumnId())) {
|
|
tableColumn.setIsIn("N");
|
|
tableColumn.setIsIn("N");
|
|
genTableColumnMapper.updateGenTableColumn(tableColumn);
|
|
genTableColumnMapper.updateGenTableColumn(tableColumn);
|
|
break;
|
|
break;
|
|
@@ -177,7 +184,7 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
|
if (UserConstants.YES.equals(isOut)) {
|
|
if (UserConstants.YES.equals(isOut)) {
|
|
//判断是否已经存在显示字段且不是同一个字段
|
|
//判断是否已经存在显示字段且不是同一个字段
|
|
for (GenTableColumn tableColumn : genTableColumns) {
|
|
for (GenTableColumn tableColumn : genTableColumns) {
|
|
- if (UserConstants.YES.equals(tableColumn.getIsOut()) && !tableColumn.getColumnId().equals(genTableColumn.getColumnId())){
|
|
|
|
|
|
+ if (UserConstants.YES.equals(tableColumn.getIsOut()) && !tableColumn.getColumnId().equals(genTableColumn.getColumnId())) {
|
|
tableColumn.setIsOut("N");
|
|
tableColumn.setIsOut("N");
|
|
genTableColumnMapper.updateGenTableColumn(tableColumn);
|
|
genTableColumnMapper.updateGenTableColumn(tableColumn);
|
|
break;
|
|
break;
|
|
@@ -200,7 +207,9 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public int deleteGenTableColumnByIds(String ids) {
|
|
public int deleteGenTableColumnByIds(String ids) {
|
|
- return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
|
|
|
|
|
|
+ int i = genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
|
|
|
|
+ remoteGenTableService.loadTable(new GenTable());
|
|
|
|
+ return i;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -214,9 +223,11 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService {
|
|
Long[] longs = Convert.toLongArray(ids);
|
|
Long[] longs = Convert.toLongArray(ids);
|
|
for (Long aLong : longs) {
|
|
for (Long aLong : longs) {
|
|
GenTableColumn genTableColumn = genTableColumnMapper.selectGenTableColumnByColumnId(aLong);
|
|
GenTableColumn genTableColumn = genTableColumnMapper.selectGenTableColumnByColumnId(aLong);
|
|
- insertCreateLog(genTableColumn,BusinessType.DELETE);
|
|
|
|
|
|
+ insertCreateLog(genTableColumn, BusinessType.DELETE);
|
|
}
|
|
}
|
|
- return genTableColumnMapper.deleteGenTableColumnByColumnIds(Convert.toLongArray(ids));
|
|
|
|
|
|
+ int i = genTableColumnMapper.deleteGenTableColumnByColumnIds(Convert.toLongArray(ids));
|
|
|
|
+ remoteGenTableService.loadTable(new GenTable());
|
|
|
|
+ return i;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|