|
|
@ -4,6 +4,7 @@ import cc.hiver.mall.shoprelations.entity.ShopRelations; |
|
|
import cc.hiver.mall.shoprelations.mapper.ShopRelationsMapper; |
|
|
import cc.hiver.mall.shoprelations.mapper.ShopRelationsMapper; |
|
|
import cc.hiver.mall.shoprelations.service.ShopRelationsService; |
|
|
import cc.hiver.mall.shoprelations.service.ShopRelationsService; |
|
|
import cc.hiver.mall.shoprelations.vo.ShopRelationsVo; |
|
|
import cc.hiver.mall.shoprelations.vo.ShopRelationsVo; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
@ -16,26 +17,101 @@ public class ShopRelationsServiceImpl implements ShopRelationsService { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ShopRelationsMapper shopRelationsMapper; |
|
|
private ShopRelationsMapper shopRelationsMapper; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 新增店铺关联信息 |
|
|
|
|
|
* |
|
|
|
|
|
* @param shopRelations |
|
|
|
|
|
* @author 王富康 |
|
|
|
|
|
* @date 2024/8/4 |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public void addShopRelations(ShopRelations shopRelations) { |
|
|
public void addShopRelations(ShopRelations shopRelations) { |
|
|
shopRelationsMapper.insert(shopRelations); |
|
|
shopRelationsMapper.insert(shopRelations); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据店铺id获取关联的店铺信息 |
|
|
|
|
|
* |
|
|
|
|
|
* @param shopId |
|
|
|
|
|
* @return List<ShopRelationsVo> |
|
|
|
|
|
* @author 王富康 |
|
|
|
|
|
* @date 2024/8/4 |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public List<ShopRelationsVo> getShopRelations(String shopId) { |
|
|
public List<ShopRelationsVo> getShopRelations(String shopId) { |
|
|
List<ShopRelations> shopRelations = shopRelationsMapper.getShopRelations(shopId); |
|
|
// 查询出来包含当前店铺的分组信息
|
|
|
List<ShopRelationsVo> shopRelationsVo = new ArrayList<>(); |
|
|
final List<ShopRelations> shopRelations = shopRelationsMapper.getShopRelations(shopId); |
|
|
if(shopRelations != null && !shopRelations.isEmpty()){ |
|
|
// 需要返回的跟当前店铺有关联的店铺信息
|
|
|
|
|
|
final List<ShopRelationsVo> shopRelationsVo = new ArrayList<>(); |
|
|
|
|
|
// 存放已经添加过的店铺id,用于去重
|
|
|
|
|
|
final List<String> shopIds = new ArrayList<>(); |
|
|
|
|
|
if (shopRelations != null && !shopRelations.isEmpty()) { |
|
|
for (ShopRelations shopRelation : shopRelations) { |
|
|
for (ShopRelations shopRelation : shopRelations) { |
|
|
String groupShopId = shopRelation.getShopId(); |
|
|
final String groupShopId = shopRelation.getShopId(); |
|
|
String shopName = shopRelation.getShopName(); |
|
|
final String shopName = shopRelation.getShopName(); |
|
|
|
|
|
if (StringUtils.isEmpty(groupShopId)) { |
|
|
|
|
|
// 根据都好分隔
|
|
|
|
|
|
final String[] groupShopIdArray = groupShopId.split(","); |
|
|
|
|
|
final String[] groupshopNameArray = shopName.split(","); |
|
|
|
|
|
for (int i = 0; i < groupShopIdArray.length; i++) { |
|
|
|
|
|
// 判断是否已经添加过
|
|
|
|
|
|
if (!shopIds.contains(groupShopIdArray[i])) { |
|
|
|
|
|
// 没有添加过,放进集合
|
|
|
|
|
|
shopIds.add(groupShopIdArray[i]); |
|
|
|
|
|
// 没有添加过,放回返回集合
|
|
|
|
|
|
final ShopRelationsVo relationsVo = new ShopRelationsVo(); |
|
|
|
|
|
relationsVo.setShopId(groupShopIdArray[i]); |
|
|
|
|
|
relationsVo.setShopName(groupshopNameArray[i]); |
|
|
|
|
|
shopRelationsVo.add(relationsVo); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return shopRelationsVo; |
|
|
return shopRelationsVo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 删除店铺关联信息 |
|
|
|
|
|
* |
|
|
|
|
|
* @param id |
|
|
|
|
|
* @author 王富康 |
|
|
|
|
|
* @date 2024/8/4 |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public void deleteShopRelations(String id) { |
|
|
public void deleteShopRelations(String id) { |
|
|
shopRelationsMapper.deleteById(id); |
|
|
shopRelationsMapper.deleteById(id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 根据店主id查询分组 |
|
|
|
|
|
* |
|
|
|
|
|
* @param shopOwnerId |
|
|
|
|
|
* @return List<ShopRelations> |
|
|
|
|
|
* @author 王富康 |
|
|
|
|
|
* @date 2024/8/4 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public List<ShopRelations> getShopRelationsByShopOwnerId(String shopOwnerId) { |
|
|
|
|
|
return shopRelationsMapper.getShopRelationsByShopOwnerId(shopOwnerId); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 修改分组店铺信息 |
|
|
|
|
|
* |
|
|
|
|
|
* @param shopRelations |
|
|
|
|
|
* @author 王富康 |
|
|
|
|
|
* @date 2024/8/4 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public void updateShopRelations(ShopRelations shopRelations) { |
|
|
|
|
|
// 只能修改分组名称及店铺信息,这里不要动其他数据
|
|
|
|
|
|
// 获取到之前的数据
|
|
|
|
|
|
final ShopRelations oldShopRelations = shopRelationsMapper.selectById(shopRelations.getId()); |
|
|
|
|
|
oldShopRelations.setGroupName(shopRelations.getGroupName()); |
|
|
|
|
|
oldShopRelations.setShopId(shopRelations.getShopId()); |
|
|
|
|
|
oldShopRelations.setShopName(shopRelations.getShopName()); |
|
|
|
|
|
// 更新
|
|
|
|
|
|
shopRelationsMapper.updateById(oldShopRelations); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|