fix sql
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.cool.store.service;
|
||||
|
||||
import com.cool.store.dto.StoreDTO;
|
||||
import com.cool.store.response.MiniShopsResponse;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -21,4 +22,6 @@ public interface StoreService {
|
||||
*/
|
||||
PageInfo<StoreDTO> getStoreExtendFieldInfo(Integer pageSize,Integer pageNum);
|
||||
|
||||
List<MiniShopsResponse> getStoreListByMobile(String mobile);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,21 @@
|
||||
package com.cool.store.service.impl;
|
||||
|
||||
import com.cool.store.dao.EnterpriseUserDAO;
|
||||
import com.cool.store.dao.EnterpriseUserRoleDao;
|
||||
import com.cool.store.dao.StoreDao;
|
||||
import com.cool.store.dao.SysRoleDao;
|
||||
import com.cool.store.dto.StoreDTO;
|
||||
import com.cool.store.entity.EnterpriseUserDO;
|
||||
import com.cool.store.entity.StoreDO;
|
||||
import com.cool.store.entity.SysRoleDO;
|
||||
import com.cool.store.entity.UserAuthMappingDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.ExtendFieldTypeEnum;
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import com.cool.store.mapper.RegionMapper;
|
||||
import com.cool.store.response.MiniShopsResponse;
|
||||
import com.cool.store.service.StoreService;
|
||||
import com.cool.store.service.UserAuthMappingService;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.github.pagehelper.Page;
|
||||
@@ -19,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -34,6 +44,16 @@ public class StoreServiceImpl implements StoreService {
|
||||
|
||||
@Resource
|
||||
StoreDao storeDao;
|
||||
@Resource
|
||||
private EnterpriseUserDAO enterpriseUserDAO;
|
||||
@Resource
|
||||
private EnterpriseUserRoleDao enterpriseUserRoleDao;
|
||||
@Resource
|
||||
private SysRoleDao sysRoleDao;
|
||||
@Resource
|
||||
private UserAuthMappingService userAuthMappingService;
|
||||
@Resource
|
||||
private RegionMapper regionMapper;
|
||||
|
||||
@Override
|
||||
public PageInfo<StoreDTO> getStoreExtendFieldInfo(Integer pageSize, Integer pageNum) {
|
||||
@@ -51,6 +71,38 @@ public class StoreServiceImpl implements StoreService {
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MiniShopsResponse> getStoreListByMobile(String mobile) {
|
||||
//根据手机号查询 标品userId
|
||||
EnterpriseUserDO enterpriseUserDO = enterpriseUserDAO.selectByMobile(mobile);
|
||||
if (enterpriseUserDO == null){
|
||||
throw new ServiceException(ErrorCodeEnum.USER_NOT_EXIST);
|
||||
}
|
||||
//获取用户职位
|
||||
List<Long> userRoleIds = enterpriseUserRoleDao.getUserRoleIds(enterpriseUserDO.getUserId());
|
||||
if (CollectionUtils.isEmpty(userRoleIds)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//查询职位详情,筛选掉店外职位
|
||||
List<SysRoleDO> roleIds = sysRoleDao.selectRoleByRoleIds(userRoleIds);
|
||||
List<SysRoleDO> sysRoleDOS = roleIds.stream().filter(role -> "store_inside".equals(role.getPositionType())).collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(sysRoleDOS)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
//获取用户管辖门店
|
||||
List<UserAuthMappingDO> userAuthMapping = userAuthMappingService.listUserAuthMappingByUserId(enterpriseUserDO.getUserId());
|
||||
if(CollectionUtils.isEmpty(userAuthMapping)){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<String> regionIds = userAuthMapping.stream().map(UserAuthMappingDO::getMappingId).collect(Collectors.toList());
|
||||
List<String> subRegionIds = regionMapper.getStoreIdsByRegionIds(regionIds);
|
||||
if (CollectionUtils.isNotEmpty(subRegionIds)) {
|
||||
regionIds.addAll(subRegionIds);
|
||||
}
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
public static List<StoreDTO> processStores(List<StoreDO> stores) {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Reference in New Issue
Block a user