|
|
@@ -1,5 +1,7 @@
|
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.apache.seata.spring.annotation.GlobalTransactional;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
@@ -9,6 +11,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.dromara.service.api.RemoteStoreServiceService;
|
|
|
+import org.dromara.service.api.domain.bo.RemoteStoreServiceBo;
|
|
|
+import org.dromara.system.domain.vo.SysStoreStatusVo;
|
|
|
+import org.dromara.system.enums.SysStoreStatusEnum;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.system.domain.bo.SysStoreBo;
|
|
|
import org.dromara.system.domain.vo.SysStoreVo;
|
|
|
@@ -16,6 +22,7 @@ import org.dromara.system.domain.SysStore;
|
|
|
import org.dromara.system.mapper.SysStoreMapper;
|
|
|
import org.dromara.system.service.ISysStoreService;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Collection;
|
|
|
@@ -33,6 +40,9 @@ public class SysStoreServiceImpl implements ISysStoreService {
|
|
|
|
|
|
private final SysStoreMapper baseMapper;
|
|
|
|
|
|
+ @DubboReference
|
|
|
+ private final RemoteStoreServiceService storeServiceService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询门店管理
|
|
|
*
|
|
|
@@ -55,6 +65,11 @@ public class SysStoreServiceImpl implements ISysStoreService {
|
|
|
public TableDataInfo<SysStoreVo> queryPageList(SysStoreBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<SysStore> lqw = buildQueryWrapper(bo);
|
|
|
Page<SysStoreVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+
|
|
|
+ List<Long> storeIds = new ArrayList<>();
|
|
|
+ result.getRecords().forEach(e -> storeIds.add(e.getId()));
|
|
|
+ Map<Long, List<Long>> map = storeServiceService.getByIds(storeIds);
|
|
|
+ result.getRecords().forEach(e -> e.setServices(map.get(e.getId())));
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
|
|
|
@@ -90,6 +105,7 @@ public class SysStoreServiceImpl implements ISysStoreService {
|
|
|
* @param bo 门店管理
|
|
|
* @return 是否新增成功
|
|
|
*/
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public Boolean insertByBo(SysStoreBo bo) {
|
|
|
SysStore add = MapstructUtils.convert(bo, SysStore.class);
|
|
|
@@ -98,7 +114,20 @@ public class SysStoreServiceImpl implements ISysStoreService {
|
|
|
if (flag) {
|
|
|
bo.setId(add.getId());
|
|
|
}
|
|
|
- return flag;
|
|
|
+
|
|
|
+ boolean storeServiceFlag = storeServiceService.insertBatch(
|
|
|
+ bo.getServices().stream().map(e -> {
|
|
|
+ RemoteStoreServiceBo storeService = new RemoteStoreServiceBo();
|
|
|
+ storeService.setStoreId(bo.getId());
|
|
|
+ storeService.setServiceId(e);
|
|
|
+ return storeService;
|
|
|
+ }).toList()
|
|
|
+ );
|
|
|
+ if (!storeServiceFlag) {
|
|
|
+ throw new RuntimeException("批量插入关系失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -135,4 +164,17 @@ public class SysStoreServiceImpl implements ISysStoreService {
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SysStoreStatusVo> listStatus() {
|
|
|
+ return SysStoreStatusEnum.list().stream()
|
|
|
+ .map(e -> {
|
|
|
+ SysStoreStatusVo vo = new SysStoreStatusVo();
|
|
|
+ vo.setValue(e.getValue());
|
|
|
+ vo.setLabel(e.getLabel());
|
|
|
+ vo.setStyle(e.getStyle());
|
|
|
+ return vo;
|
|
|
+ })
|
|
|
+ .toList();
|
|
|
+ }
|
|
|
}
|