TASK:获取affiliate的用户名和id;BUGFIX:模特无法保存
This commit is contained in:
@@ -439,5 +439,10 @@ public class AffiliateServiceImpl extends ServiceImpl<AffiliateMapper, Affiliate
|
||||
redisUtil.addToString(RedisUtil.PAYMENT_INFO_LAST_SCAN_TIME, currentTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getAllAffiliateUsername(){
|
||||
return baseMapper.selectAllAffiliateUsername();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -2555,47 +2555,62 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
}
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(moduleSaveDTO.getMannequin())) {
|
||||
// 目前已有的模特
|
||||
List<CollectionElementRelModel> collectionElementRelModels = collectionElementMapper.selectByProject(projectId);
|
||||
// 入参中的模特
|
||||
List<MannequinDTO> mannequin = moduleSaveDTO.getMannequin();
|
||||
List<Long> inputMannequinId = mannequin.stream().map(MannequinDTO::getCollectionElementId).collect(Collectors.toList());
|
||||
|
||||
// 新增的模特只有id,没有collectionElementId
|
||||
List<Long> inputMannequinIds = mannequin.stream().map(MannequinDTO::getId).collect(Collectors.toList());
|
||||
// 既有id又有collectionElementId的,为保持原状的模特(都没有的且又存在于数据库的,即为被删除的模特)
|
||||
List<Long> inputCollectionElementIds = mannequin.stream().map(MannequinDTO::getCollectionElementId).collect(Collectors.toList());
|
||||
|
||||
// 创建relationId到Model的映射
|
||||
Map<Long, CollectionElementRelModel> relationIdToModelMap = collectionElementRelModels.stream()
|
||||
.collect(Collectors.toMap(
|
||||
CollectionElementRelModel::getRelationId,
|
||||
java.util.function.Function.identity(),
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
// 创建collectionElementId到Model的映射
|
||||
Map<Long, CollectionElementRelModel> collectionElementToModelMap = collectionElementRelModels.stream()
|
||||
.collect(Collectors.toMap(
|
||||
CollectionElementRelModel::getCollectionElementId,
|
||||
java.util.function.Function.identity(),
|
||||
(existing, replacement) -> existing
|
||||
));
|
||||
List<Long> newReletionIds = new ArrayList<>();
|
||||
List<Long> toBeDeletedRelationIds = new ArrayList<>();
|
||||
List<Long> toBeDeletedCollectionElementIds = new ArrayList<>();
|
||||
|
||||
if (collectionElementRelModels.isEmpty()) {
|
||||
// 如果原本没有记录,所有输入的Mannequin都是新的
|
||||
newReletionIds = inputMannequinId;
|
||||
newReletionIds = inputMannequinIds;
|
||||
} else {
|
||||
// 获取所有已有的relationId集合
|
||||
// 获取db中所有的relationId集合
|
||||
Set<Long> relationIds = relationIdToModelMap.keySet();
|
||||
// 获取db中所有的collectionElementId集合
|
||||
Set<Long> collectionElementIds = collectionElementToModelMap.keySet();
|
||||
|
||||
// 1. 找出需要删除的:relationIds中有但inputMannequinId中没有的
|
||||
toBeDeletedRelationIds = relationIds.stream()
|
||||
.filter(id -> !inputMannequinId.contains(id))
|
||||
// 1. 找出需要删除的:collectionElementIds中有但inputCollectionElementIds中没有的
|
||||
toBeDeletedCollectionElementIds = collectionElementIds.stream()
|
||||
.filter(id -> !inputCollectionElementIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 找出新增的:inputMannequinId中有但relationIds中没有的
|
||||
newReletionIds = inputMannequinId.stream()
|
||||
// 2. 找出新增的:inputMannequinId中有但relationIds中没有的(一定程度避免重复)
|
||||
newReletionIds = inputMannequinIds.stream()
|
||||
.filter(id -> !relationIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if (!toBeDeletedRelationIds.isEmpty()){
|
||||
Set<Long> toBeDeletedElementIdList = toBeDeletedRelationIds.stream()
|
||||
if (!toBeDeletedCollectionElementIds.isEmpty()){
|
||||
/*Set<Long> toBeDeletedElementIdList = toBeDeletedCollectionElementIds.stream()
|
||||
.map(relationIdToModelMap::get) // 获取对应的Model
|
||||
.filter(Objects::nonNull) // 过滤掉可能为null的情况
|
||||
.map(CollectionElementRelModel::getCollectionElementId) // 提取collectionElementId
|
||||
.collect(Collectors.toSet());
|
||||
collectionElementMapper.deleteBatchIds(toBeDeletedElementIdList);
|
||||
.collect(Collectors.toSet());*/
|
||||
collectionElementMapper.deleteBatchIds(toBeDeletedCollectionElementIds);
|
||||
// 删除关联关系
|
||||
deleteByCollectionElementIdList(toBeDeletedElementIdList);
|
||||
deleteByCollectionElementIdList(toBeDeletedCollectionElementIds);
|
||||
}
|
||||
|
||||
for (MannequinDTO dto : mannequin) {
|
||||
@@ -2678,7 +2693,7 @@ public class UserLikeGroupServiceImpl extends ServiceImpl<UserLikeGroupMapper, U
|
||||
return result;
|
||||
}
|
||||
|
||||
private void deleteByCollectionElementIdList(Set<Long> old) {
|
||||
private void deleteByCollectionElementIdList(java.util.Collection<Long> old) {
|
||||
QueryWrapper<CollectionElementRelModel> qw = new QueryWrapper<>();
|
||||
qw.lambda().in(CollectionElementRelModel::getCollectionElementId, old);
|
||||
collectionElementRelModelMapper.delete(qw);
|
||||
|
||||
Reference in New Issue
Block a user