Commit f3f884de by guojuxing

门店选择器操作日志方案调整

parent 2ab6cb74
package com.gic.plug.web.utils; package com.gic.plug.web.utils;
import com.gic.store.dto.StoreWidgetLogDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -14,6 +16,10 @@ import com.gic.store.dto.StoreWidgetLogSaveDTO; ...@@ -14,6 +16,10 @@ import com.gic.store.dto.StoreWidgetLogSaveDTO;
import com.gic.store.service.StoreWidgetApiService; import com.gic.store.service.StoreWidgetApiService;
import com.gic.store.service.StoreWidgetLogApiService; import com.gic.store.service.StoreWidgetLogApiService;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* 门店选择器操作日志工具类 * 门店选择器操作日志工具类
* @ClassName: * @ClassName:
...@@ -44,8 +50,9 @@ public class StoreWidgetLogUtils { ...@@ -44,8 +50,9 @@ public class StoreWidgetLogUtils {
if (oldStoreWidget == null) { if (oldStoreWidget == null) {
logSaveDTO = buildStoreWidgetLogWhenCreate(storeWidgetQO, newStoreWidgetId); logSaveDTO = buildStoreWidgetLogWhenCreate(storeWidgetQO, newStoreWidgetId);
} else { } else {
//需要更新日志关联关系 //copy旧门店选择器ID上挂载的日志到新的ID上面
storeWidgetLogApiService.tmpUpdateByStoreWidgetId(storeWidgetId, newStoreWidgetId); copyStoreWidgetLog(storeWidgetId, newStoreWidgetId);
//新门店选择器ID上新增新的日志
logSaveDTO = buildStoreWidgetLogWhenUpdate(oldStoreWidget, storeWidgetQO, newStoreWidgetId); logSaveDTO = buildStoreWidgetLogWhenUpdate(oldStoreWidget, storeWidgetQO, newStoreWidgetId);
} }
//写日志 //写日志
...@@ -85,6 +92,27 @@ public class StoreWidgetLogUtils { ...@@ -85,6 +92,27 @@ public class StoreWidgetLogUtils {
} }
} }
/**
* copy旧门店选择器ID上挂载的日志到新的ID上面
* @param oldStoreWidgetId
* @param newStoreWidgetId
*/
private void copyStoreWidgetLog(Integer oldStoreWidgetId, Integer newStoreWidgetId) {
//查询旧uuid上面挂载的日志数据
ServiceResponse<List<StoreWidgetLogDTO>> response = storeWidgetLogApiService.listStoreWidgetLog(oldStoreWidgetId);
if (response.isSuccess()) {
List<StoreWidgetLogDTO> list = response.getResult();
if (CollectionUtils.isNotEmpty(list)) {
//复制数据到新uuid上面
List<StoreWidgetLogDTO> copyList = list.stream().map(e ->
e.setStoreWidgetId(newStoreWidgetId)
.setStoreWidgetLogId(null)).collect(Collectors.toList());
//
storeWidgetLogApiService.tmpInsert(copyList);
}
}
}
private StoreWidgetDTO getOldStoreWidget(Integer storeWidgetId) { private StoreWidgetDTO getOldStoreWidget(Integer storeWidgetId) {
if (storeWidgetId == null) { if (storeWidgetId == null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment