修改通用Serive,update返回类型
This commit is contained in:
@@ -66,13 +66,13 @@ public class TableController {
|
|||||||
|
|
||||||
@ApiOperation(value = "更新接口")
|
@ApiOperation(value = "更新接口")
|
||||||
@PutMapping({"/{typeName}/{version}", "/{typeName}"})
|
@PutMapping({"/{typeName}/{version}", "/{typeName}"})
|
||||||
public ResultVO<Integer> update(@PathVariable String typeName, @RequestParam Map<String, Object> map, @PathVariable(required = false) Integer version) {
|
public ResultVO<Map<String,Object>> update(@PathVariable String typeName, @RequestParam Map<String, Object> map, @PathVariable(required = false) Integer version) {
|
||||||
return tableService.update(tableNameUtil.getTableName(typeName), map, version);
|
return tableService.update(tableNameUtil.getTableName(typeName), map, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "更新接口(带更改日期)")
|
@ApiOperation(value = "更新接口(带更改日期)")
|
||||||
@PutMapping({"/{typeName}/{version}/date", "/{typeName}/date"})
|
@PutMapping({"/{typeName}/{version}/date", "/{typeName}/date"})
|
||||||
public ResultVO<Integer> updateWithDate(@PathVariable String typeName, @RequestParam Map<String, Object> map, @PathVariable(required = false) Integer version) {
|
public ResultVO<Map<String,Object>> updateWithDate(@PathVariable String typeName, @RequestParam Map<String, Object> map, @PathVariable(required = false) Integer version) {
|
||||||
return tableService.updateWithDate(tableNameUtil.getTableName(typeName), map, version);
|
return tableService.updateWithDate(tableNameUtil.getTableName(typeName), map, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ public interface TableService {
|
|||||||
|
|
||||||
ResultVO<Map<String, Object>> saveWithDate(OsSysTable osSysTable, Map<String, Object> map);
|
ResultVO<Map<String, Object>> saveWithDate(OsSysTable osSysTable, Map<String, Object> map);
|
||||||
|
|
||||||
ResultVO<Integer> update(OsSysTable osSysTable, Map<String, Object> map, Integer version);
|
ResultVO<Map<String,Object>> update(OsSysTable osSysTable, Map<String, Object> map, Integer version);
|
||||||
|
|
||||||
ResultVO<Integer> updateWithDate(OsSysTable tableName, Map<String, Object> map, Integer version);
|
ResultVO<Map<String,Object>> updateWithDate(OsSysTable tableName, Map<String, Object> map, Integer version);
|
||||||
|
|
||||||
ResultVO<Integer> delete(OsSysTable tableName, String ids);
|
ResultVO<Integer> delete(OsSysTable tableName, String ids);
|
||||||
|
|
||||||
|
|||||||
@@ -67,14 +67,14 @@ public class TableServiceImpl implements TableService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultVO<Integer> update(OsSysTable osSysTable, Map<String, Object> map, Integer version) {
|
public ResultVO<Map<String,Object>> update(OsSysTable osSysTable, Map<String, Object> map, Integer version) {
|
||||||
Object pk = map.get(osSysTable.getTablePk());
|
Object pk = map.get(osSysTable.getTablePk());
|
||||||
map.remove(osSysTable.getTablePk());
|
map.remove(osSysTable.getTablePk());
|
||||||
return versionValid(osSysTable, map, version, pk);
|
return versionValid(osSysTable, map, version, pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResultVO<Integer> updateWithDate(OsSysTable osSysTable, Map<String, Object> map, Integer version) {
|
public ResultVO<Map<String,Object>> updateWithDate(OsSysTable osSysTable, Map<String, Object> map, Integer version) {
|
||||||
Object pk = map.get(osSysTable.getTablePk());
|
Object pk = map.get(osSysTable.getTablePk());
|
||||||
map.put(FieldConstants.UPDATE_TIME.toString(), new Date());
|
map.put(FieldConstants.UPDATE_TIME.toString(), new Date());
|
||||||
map.remove(osSysTable.getTablePk());
|
map.remove(osSysTable.getTablePk());
|
||||||
@@ -82,7 +82,7 @@ public class TableServiceImpl implements TableService {
|
|||||||
return versionValid(osSysTable, map, version, pk);
|
return versionValid(osSysTable, map, version, pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultVO<Integer> versionValid(OsSysTable osSysTable, Map<String, Object> map, Integer version, Object pk) {
|
private ResultVO<Map<String,Object>> versionValid(OsSysTable osSysTable, Map<String, Object> map, Integer version, Object pk) {
|
||||||
if (!StringUtils.isEmpty(version)) {
|
if (!StringUtils.isEmpty(version)) {
|
||||||
DataMap dataMap = DataMap.builder().sysOsTable(osSysTable).pkValue(pk).data(map).build();
|
DataMap dataMap = DataMap.builder().sysOsTable(osSysTable).pkValue(pk).data(map).build();
|
||||||
Map<String, Object> data = baseMapper.selectByPk(dataMap);
|
Map<String, Object> data = baseMapper.selectByPk(dataMap);
|
||||||
@@ -96,7 +96,7 @@ public class TableServiceImpl implements TableService {
|
|||||||
return updateByPk(osSysTable, map, pk);
|
return updateByPk(osSysTable, map, pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResultVO<Integer> updateByPk(OsSysTable osSysTable, Map<String, Object> map, Object pk) {
|
private ResultVO<Map<String,Object>> updateByPk(OsSysTable osSysTable, Map<String, Object> map, Object pk) {
|
||||||
map.remove("ROW_ID");
|
map.remove("ROW_ID");
|
||||||
// 设置更新项
|
// 设置更新项
|
||||||
DataMap dataMap = DataMap.builder()
|
DataMap dataMap = DataMap.builder()
|
||||||
@@ -106,7 +106,8 @@ public class TableServiceImpl implements TableService {
|
|||||||
.build();
|
.build();
|
||||||
int i = baseMapper.updateByPk(dataMap);
|
int i = baseMapper.updateByPk(dataMap);
|
||||||
SqlException.operation(i, "更新失败");
|
SqlException.operation(i, "更新失败");
|
||||||
return ResultVO.getSuccess(i);
|
Map<String,Object> result = baseMapper.selectByPk(osSysTable,pk);
|
||||||
|
return ResultVO.getSuccess(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user