Commit 58eae9bc by HlQ

[feat] 新增集团默认配置同步新增mall的指标配置

1 parent 2c66ff06
...@@ -45,6 +45,7 @@ public class MyBatisPlusConfig implements MetaObjectHandler { ...@@ -45,6 +45,7 @@ public class MyBatisPlusConfig implements MetaObjectHandler {
var vo = (UserVO) StpUtil.getTokenSession().get("curLoginUser"); var vo = (UserVO) StpUtil.getTokenSession().get("curLoginUser");
this.fillHasGetter(metaObject, "updater", vo.getUserid()); this.fillHasGetter(metaObject, "updater", vo.getUserid());
this.fillHasGetter(metaObject, "updateBy", vo.getId()); this.fillHasGetter(metaObject, "updateBy", vo.getId());
this.fillHasGetter(metaObject, "updateUser", vo.getId());
} catch (Exception ignored) { } catch (Exception ignored) {
} }
} }
......
package vion.service.impl.monitor; package vion.service.impl.monitor;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.bean.BeanUtil;
import org.dromara.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.monitor.MAccountMapper; import vion.mapper.monitor.MAccountMapper;
import vion.model.monitor.MAccount; import vion.model.monitor.*;
import vion.model.monitor.RAccountEvent;
import vion.model.monitor.RUserAccount;
import vion.service.monitor.IMAccountService; import vion.service.monitor.IMAccountService;
import vion.service.monitor.IRAccountEventService; import vion.service.monitor.IRAccountEventService;
import vion.service.monitor.IRAgentEventService;
import vion.service.monitor.IRUserAccountService; import vion.service.monitor.IRUserAccountService;
import java.util.List; import java.util.List;
...@@ -22,6 +24,7 @@ import java.util.List; ...@@ -22,6 +24,7 @@ import java.util.List;
public class MAccountServiceImpl extends MPJBaseServiceImpl<MAccountMapper, MAccount> implements IMAccountService { public class MAccountServiceImpl extends MPJBaseServiceImpl<MAccountMapper, MAccount> implements IMAccountService {
private final IRAccountEventService accountEventService; private final IRAccountEventService accountEventService;
private final IRAgentEventService agentEventService;
private final IRUserAccountService userAccountService; private final IRUserAccountService userAccountService;
@Override @Override
...@@ -33,7 +36,31 @@ public class MAccountServiceImpl extends MPJBaseServiceImpl<MAccountMapper, MAcc ...@@ -33,7 +36,31 @@ public class MAccountServiceImpl extends MPJBaseServiceImpl<MAccountMapper, MAcc
public String saveEvent(String agentUid, String uid, RAccountEvent event) { public String saveEvent(String agentUid, String uid, RAccountEvent event) {
event.setAgentUid(agentUid); event.setAgentUid(agentUid);
event.setAccountUid(uid); event.setAccountUid(uid);
return accountEventService.save(event) ? "成功" : "失败"; var save = accountEventService.save(event);
if (save) {
var mallList = Db.lambdaQuery(Mall.class).eq(Mall::getAccountUid, uid).list();
var mallUidList = mallList.stream().map(Mall::getUid).toList();
var eventList = agentEventService.lambdaQuery()
.eq(RAgentEvent::getAccountUid, uid)
.eq(RAgentEvent::getEventUid, event.getEventUid())
.list();
var existMallUidList = eventList.stream().map(RAgentEvent::getMallUid).toList();
if (CollUtil.isNotEmpty(mallUidList) && CollUtil.isNotEmpty(existMallUidList)) {
// 把 existMallUidList 从 mallUidList 中移除
mallUidList.removeAll(existMallUidList);
var saveList = mallUidList.stream().map(mUid -> {
var rAgentEvent = BeanUtil.copyProperties(event, RAgentEvent.class);
rAgentEvent.setMallUid(mUid);
return rAgentEvent;
}).toList();
var res = agentEventService.saveBatch(saveList);
if (!res) {
throw new RuntimeException();
}
}
}
return save ? "成功" : "失败";
} }
@Override @Override
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!