TASK:获取affiliate的用户名和id;BUGFIX:模特无法保存
This commit is contained in:
@@ -22,6 +22,7 @@ import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@@ -100,7 +101,7 @@ public class AffiliateController {
|
||||
return Response.success(affiliateService.getEachAffiliateGeneratedRevenue(affiliateQueryDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取所有的referral")
|
||||
@ApiOperation(value = "分页获取所有的referral")
|
||||
@PostMapping("/getReferrals")
|
||||
public Response<IPage<ReferralPageQueryVO>> getReferrals(@RequestBody ReferralPageQueryDTO referralPageQueryDTO) {
|
||||
return Response.success(referralService.queryByPage(referralPageQueryDTO));
|
||||
@@ -120,5 +121,11 @@ public class AffiliateController {
|
||||
return Response.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取所有affiliate用户名")
|
||||
@GetMapping("/getAllAffiliateUsername")
|
||||
public Response<List<Map<String, Object>>> getAllAffiliateUsername() {
|
||||
return Response.success(affiliateService.getAllAffiliateUsername());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -16,4 +16,6 @@ public interface AffiliateMapper extends BaseMapper<Affiliate> {
|
||||
|
||||
int queryAffiliateTotalCount(String status, String startTime, String endTime, Long affiliateId);
|
||||
|
||||
List<Map<String, Object>> selectAllAffiliateUsername();
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface AffiliateService extends IService<Affiliate> {
|
||||
|
||||
@@ -37,4 +39,6 @@ public interface AffiliateService extends IService<Affiliate> {
|
||||
void commissionCalculation(Integer year, Integer month);
|
||||
|
||||
void calcCouponsCommission();
|
||||
|
||||
List<Map<String, Object>> getAllAffiliateUsername();
|
||||
}
|
||||
|
||||
@@ -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