|
@@ -1,6 +1,8 @@
|
|
|
package com.fjhx.jushuitan.service.shop.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.jushuitan.entity.shop.dto.ShopInfoDto;
|
|
@@ -9,10 +11,18 @@ import com.fjhx.jushuitan.entity.shop.po.ShopInfo;
|
|
|
import com.fjhx.jushuitan.entity.shop.vo.ShopInfoVo;
|
|
|
import com.fjhx.jushuitan.mapper.shop.ShopInfoMapper;
|
|
|
import com.fjhx.jushuitan.service.shop.ShopInfoService;
|
|
|
+import com.ruoyi.common.core.domain.entity.SysDept;
|
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
-import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
+import com.ruoyi.framework.mybatis.holder.TenantHolder;
|
|
|
+import com.ruoyi.system.service.ISysDeptService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
|
|
|
|
|
|
* <p>
|
|
@@ -25,19 +35,51 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> implements ShopInfoService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<ShopInfoVo> getPage(ShopInfoSelectDto dto) {
|
|
|
IWrapper<ShopInfo> wrapper = getWrapper();
|
|
|
|
|
|
|
|
|
- wrapper.keyword(dto.getKeyword(),
|
|
|
- new SqlField(ShopInfo::getCode),
|
|
|
- new SqlField(ShopInfo::getCode),
|
|
|
- new SqlField("de", ShopInfoVo::getDeptName)
|
|
|
- );
|
|
|
+ if (ObjectUtil.isNotEmpty(dto.getKeyword())) {
|
|
|
+ TenantHolder.setIgnore(true);
|
|
|
+ List<SysDept> deptList = deptService.list(Wrappers.<SysDept>query()
|
|
|
+ .like("dept_name", dto.getKeyword())
|
|
|
+ );
|
|
|
+ TenantHolder.clear();
|
|
|
+ List<Long> deptIds = deptList.stream().map(SysDept::getDeptId).collect(Collectors.toList());
|
|
|
+ wrapper.and(q -> q
|
|
|
+ .like(ShopInfo::getCode, dto.getKeyword())
|
|
|
+ .or().like(ShopInfo::getName, dto.getKeyword())
|
|
|
+ .or().in(ShopInfo::getDeptId, deptIds)
|
|
|
+ );
|
|
|
+ }
|
|
|
|
|
|
wrapper.orderByDesc("si", ShopInfo::getId);
|
|
|
Page<ShopInfoVo> page = this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(page)) {
|
|
|
+ return page;
|
|
|
+ }
|
|
|
+ List<ShopInfoVo> records = page.getRecords();
|
|
|
+
|
|
|
+ List<Long> deptIds = records.stream().map(ShopInfo::getDeptId).collect(Collectors.toList());
|
|
|
+
|
|
|
+ TenantHolder.setIgnore(true);
|
|
|
+ Map<Long, String> deptMap = new HashMap<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(deptIds)) {
|
|
|
+ List<SysDept> deptList = deptService.list(Wrappers.<SysDept>query().in("dept_id", deptIds));
|
|
|
+ deptMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptId, SysDept::getDeptName));
|
|
|
+ }
|
|
|
+ TenantHolder.clear();
|
|
|
+
|
|
|
+ for (ShopInfoVo record : records) {
|
|
|
+
|
|
|
+ record.setDeptName(deptMap.get(record.getDeptId()));
|
|
|
+ }
|
|
|
+
|
|
|
return page;
|
|
|
}
|
|
|
|