|
@@ -1,10 +1,11 @@
|
|
|
package com.boman.system.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.boman.common.core.utils.SecurityUtils;
|
|
|
import com.boman.system.common.MainTableRecord;
|
|
|
import com.boman.system.common.RowResult;
|
|
|
-import com.boman.system.common.TableServiceContext;
|
|
|
import com.boman.system.mapper.StandardlyMapper;
|
|
|
+import com.boman.system.service.IBaseSaveService;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -18,35 +19,34 @@ import java.sql.Timestamp;
|
|
|
* @date 2021年03月22日 11:25
|
|
|
**/
|
|
|
@Component
|
|
|
-public class BaseSaveService {
|
|
|
+public class BaseSaveServiceImpl implements IBaseSaveService {
|
|
|
|
|
|
- private static final Logger LOGGER = LoggerFactory.getLogger(BaseSaveService.class);
|
|
|
+ private static final Logger LOGGER = LoggerFactory.getLogger(BaseSaveServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
private StandardlyMapper mapper;
|
|
|
|
|
|
- public RowResult insertRow(TableServiceContext context, MainTableRecord row, Timestamp currentTime) {
|
|
|
- JSONObject commitData = row.getMainData().getCommitData();
|
|
|
- commitData.put("CREATE_TIME", currentTime);
|
|
|
- commitData.put("CREATE_BY", "张三");
|
|
|
- commitData.put("UPDATE_BY", "张三");
|
|
|
- commitData.put("UPDATE_TIME", currentTime);
|
|
|
- int ret = mapper.insert(context.getRealTableName(), commitData);
|
|
|
- if (ret > 0) {
|
|
|
- commitData.put("successCnt", ret);
|
|
|
- return RowResult.ok("保存成功", commitData);
|
|
|
- }
|
|
|
-
|
|
|
- return RowResult.error("失败");
|
|
|
- }
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 功能描述: 保存一行
|
|
|
+ *
|
|
|
+ * @param tableName tableName
|
|
|
+ * @param pkName 主键名称
|
|
|
+ * @param maxId 最大的SEQ
|
|
|
+ * @param row 要保存的数据
|
|
|
+ * @return com.boman.system.common.RowResult
|
|
|
+ */
|
|
|
+ @Override
|
|
|
public RowResult insertRow(String tableName, String pkName, Long maxId, MainTableRecord row) {
|
|
|
JSONObject commitData = row.getMainData().getCommitData();
|
|
|
Timestamp currentTime = new Timestamp(System.currentTimeMillis());
|
|
|
- commitData.put("CREATE_TIME", currentTime);
|
|
|
- commitData.put("CREATE_BY", "张三");
|
|
|
- commitData.put("UPDATE_BY", "张三");
|
|
|
+ commitData.put("UPDATE_BY", SecurityUtils.getUserId());
|
|
|
commitData.put("UPDATE_TIME", currentTime);
|
|
|
+ // 新增
|
|
|
+ if (row.getId() > 0) {
|
|
|
+ commitData.put("CREATE_TIME", currentTime);
|
|
|
+ commitData.put("CREATE_BY", SecurityUtils.getUserId());
|
|
|
+ }
|
|
|
+
|
|
|
commitData.put(pkName.toUpperCase(), maxId);
|
|
|
int ret = mapper.insert(tableName, commitData);
|
|
|
if (ret > 0) {
|