提交 3700df1e authored 作者: 1239068511@qq.com's avatar 1239068511@qq.com

[数据模型] 修改了一个修改表结构时的BUG

上级 f794900b
...@@ -124,10 +124,10 @@ public class ModelController { ...@@ -124,10 +124,10 @@ public class ModelController {
public ResponseEntity addModel(@RequestBody TableVO tableVO) { public ResponseEntity addModel(@RequestBody TableVO tableVO) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
modelService.newTable(tableVO); TableInfo tableInfo = modelService.newTable(tableVO);
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
log.warn("创建总用时为:{}秒", (end - start) / 1000.0); log.warn("创建总用时为:{}秒", (end - start) / 1000.0);
return ResultUtil.success("", "新建成功!"); return ResultUtil.success(tableInfo, "新建成功!");
} }
/** /**
...@@ -203,9 +203,10 @@ public class ModelController { ...@@ -203,9 +203,10 @@ public class ModelController {
@ApiOperation("编辑操作") @ApiOperation("编辑操作")
@PutMapping("/update") @PutMapping("/update")
public ResponseEntity updateTable(@RequestBody UpdateTableInfoVO updateTableInfoVO) { public ResponseEntity updateTable(@RequestBody UpdateTableInfoVO updateTableInfoVO) {
return modelService.updateTable(updateTableInfoVO); sessionUtil.addXml(modelService.updateTable(updateTableInfoVO));
// return
// if (i == 1) { // if (i == 1) {
// return ResultUtil.success("", "修改成功!"); return ResultUtil.success("", "修改成功!");
// } // }
// return ResultUtil.failed("业务不支持修改!"); // return ResultUtil.failed("业务不支持修改!");
} }
......
...@@ -122,7 +122,7 @@ public interface ModelService { ...@@ -122,7 +122,7 @@ public interface ModelService {
* @param updateTableInfoVO * @param updateTableInfoVO
* @return * @return
*/ */
ResponseEntity updateTable(UpdateTableInfoVO updateTableInfoVO); String updateTable(UpdateTableInfoVO updateTableInfoVO);
/** /**
......
...@@ -383,7 +383,7 @@ public class ModelImpl implements ModelService { ...@@ -383,7 +383,7 @@ public class ModelImpl implements ModelService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public ResponseEntity updateTable(UpdateTableInfoVO updateTableInfoVO) { public String updateTable(UpdateTableInfoVO updateTableInfoVO) {
//tableInfo和columnInfo变化 //tableInfo和columnInfo变化
//查询到TableInfo和ColumnInfo //查询到TableInfo和ColumnInfo
TableVO tableVO = updateTableInfoVO.getTableVO(); TableVO tableVO = updateTableInfoVO.getTableVO();
...@@ -413,6 +413,7 @@ public class ModelImpl implements ModelService { ...@@ -413,6 +413,7 @@ public class ModelImpl implements ModelService {
} catch (Exception exception) { } catch (Exception exception) {
//todo //todo
exception.printStackTrace();
throw new ApiException("出错"); throw new ApiException("出错");
// if (exception instanceof OSQLException) { // if (exception instanceof OSQLException) {
// String error = exception.getMessage(); // String error = exception.getMessage();
...@@ -444,9 +445,8 @@ public class ModelImpl implements ModelService { ...@@ -444,9 +445,8 @@ public class ModelImpl implements ModelService {
tableInfo.setXml(xml); tableInfo.setXml(xml);
tableInfoDao.save(tableInfo); tableInfoDao.save(tableInfo);
sessionUtil.deleteTableInMeteData(tableInfo.getModelName()); sessionUtil.deleteTableInMeteData(tableInfo.getModelName());
sessionUtil.addXml(xml);
return ResultUtil.success("修改成功!"); return xml;
} }
......
...@@ -11,6 +11,7 @@ import com.tykj.model.entity.Quote; ...@@ -11,6 +11,7 @@ import com.tykj.model.entity.Quote;
import com.tykj.model.entity.vo.SearchQuoteVO; import com.tykj.model.entity.vo.SearchQuoteVO;
import com.tykj.model.entity.vo.UpdateQuoteVO; import com.tykj.model.entity.vo.UpdateQuoteVO;
import com.tykj.model.service.QuoteService; import com.tykj.model.service.QuoteService;
import com.tykj.model.utils.SessionUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -67,6 +68,7 @@ public class QuoteServiceImpl implements QuoteService { ...@@ -67,6 +68,7 @@ public class QuoteServiceImpl implements QuoteService {
@Override @Override
public Quote saveQuote(Quote quote) { public Quote saveQuote(Quote quote) {
if (existValue(quote.getColumnId(), quote.getValue())) { if (existValue(quote.getColumnId(), quote.getValue())) {
return quoteDao.save(quote); return quoteDao.save(quote);
} }
......
...@@ -69,11 +69,11 @@ public class CreateTableUtil { ...@@ -69,11 +69,11 @@ public class CreateTableUtil {
for (ColumnVO columnVO : dataList) { for (ColumnVO columnVO : dataList) {
try { try {
//由于ID属于自动建立的列 不允许用户自己建立 //由于ID属于自动建立的列 不允许用户自己建立
if (!columnVO.getFieldName().toUpperCase(Locale.ROOT).equals("ID")){ // if (!columnVO.getFieldName().toUpperCase(Locale.ROOT).equals("ID")){
xmlMapping += xmlMapping +=
"\n <property type=\"" + columnVO.getFieldType() + "\" name=\"" + columnVO.getFieldName().toUpperCase() + "\" length=\"" + columnVO.getFieldLength() + "\n <property type=\"" + columnVO.getFieldType() + "\" name=\"" + columnVO.getFieldName().toUpperCase() + "\" length=\"" + columnVO.getFieldLength() +
"\" column=\"" + columnVO.getFieldName().toUpperCase() + "\"/>\n"; "\" column=\"" + columnVO.getFieldName().toUpperCase() + "\"/>\n";
} // }
} catch (Exception e) { } catch (Exception e) {
throw new ApiException("名称不合法!"); throw new ApiException("名称不合法!");
} }
......
...@@ -3,7 +3,7 @@ spring: ...@@ -3,7 +3,7 @@ spring:
date-format: yyyy-MM-dd HH:mm:ss date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8 time-zone: GMT+8
datasource: datasource:
username: ANNUAL_PERFORMANCE_EVALUATION_INDEX_SYSTEM username: PUNISH
password: 123456 password: 123456
url: jdbc:oscar://192.168.102.200:2003/OSRDB url: jdbc:oscar://192.168.102.200:2003/OSRDB
driver-class-name: com.oscar.Driver driver-class-name: com.oscar.Driver
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论