|
@@ -5,6 +5,7 @@ import com.boman.gen.domain.GenTableColumn;
|
|
import com.boman.web.core.constant.FormDataConstant;
|
|
import com.boman.web.core.constant.FormDataConstant;
|
|
import com.boman.web.core.domain.RowResult;
|
|
import com.boman.web.core.domain.RowResult;
|
|
import com.boman.web.core.mapper.StandardlyMapper;
|
|
import com.boman.web.core.mapper.StandardlyMapper;
|
|
|
|
+import com.boman.web.core.utils.ColumnUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -39,28 +40,9 @@ public class BaseSaveServiceImpl implements IBaseSaveService {
|
|
@Override
|
|
@Override
|
|
public RowResult insertRow(String tableName, String pkName, Long maxId, JSONObject commitData, List<GenTableColumn> columns) {
|
|
public RowResult insertRow(String tableName, String pkName, Long maxId, JSONObject commitData, List<GenTableColumn> columns) {
|
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
- for (GenTableColumn column : columns) {
|
|
|
|
- // 判断是否有修改人、修改时间
|
|
|
|
- if (FormDataConstant.UPDATE_BY.equalsIgnoreCase(column.getColumnName())) {
|
|
|
|
- commitData.put(FormDataConstant.UPDATE_BY, "张三");
|
|
|
|
- }
|
|
|
|
- if (FormDataConstant.UPDATE_TIME.equalsIgnoreCase(column.getColumnName())) {
|
|
|
|
- commitData.put(FormDataConstant.UPDATE_TIME, currentTime);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 如果某一列是datetime类型,需要把类型转成datetime,否则数据库会报错
|
|
|
|
- if (FormDataConstant.DATETIME.equalsIgnoreCase(column.getColumnType())) {
|
|
|
|
- String columnName = column.getColumnName().toUpperCase();
|
|
|
|
- commitData.put(columnName, commitData.getTimestamp(columnName));
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 新增
|
|
|
|
-// if (row.getId() > 0) {
|
|
|
|
- commitData.put(FormDataConstant.CREATE_TIME.toUpperCase(), currentTime);
|
|
|
|
- commitData.put(FormDataConstant.CREATE_BY.toUpperCase(), "张三");
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
|
|
+ ColumnUtils.packUpdateByAndTime(columns, commitData, currentTime);
|
|
|
|
+ commitData.put(FormDataConstant.CREATE_TIME.toUpperCase(), currentTime);
|
|
|
|
+ commitData.put(FormDataConstant.CREATE_BY.toUpperCase(), "张三");
|
|
commitData.put(pkName.toUpperCase(), maxId);
|
|
commitData.put(pkName.toUpperCase(), maxId);
|
|
int ret = mapper.insert(tableName, commitData);
|
|
int ret = mapper.insert(tableName, commitData);
|
|
if (ret > 0) {
|
|
if (ret > 0) {
|