Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102

This commit is contained in:
陈维伟 2023-09-11 20:35:48 +08:00
commit 908c1104bc

View File

@ -8,6 +8,7 @@ import cn.axzo.tyr.client.model.product.ProductFeatureRelationVO;
import cn.axzo.tyr.server.repository.entity.SaasProductModuleFeatureRelation;
import cn.axzo.tyr.server.repository.service.SaasProductModuleFeatureRelationDao;
import cn.axzo.tyr.server.service.ProductFeatureRelationService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -44,7 +45,10 @@ public class ProductFeatureRelationServiceImpl implements ProductFeatureRelation
@Transactional(rollbackFor = Exception.class)
public ApiResult<Boolean> updateFeatureRelation(List<ProductFeatureRelationUpdateReq> req) {
List<Long> productIds = req.stream().map(ProductFeatureRelationUpdateReq::getProductModuleId).distinct().collect(Collectors.toList());
saasProductModuleFeatureRelationDao.removeByIds(productIds);
if(!CollectionUtils.isEmpty(productIds)) {
saasProductModuleFeatureRelationDao.remove(new LambdaQueryWrapper<SaasProductModuleFeatureRelation>()
.in(SaasProductModuleFeatureRelation::getProductModuleId, productIds));
}
List<SaasProductModuleFeatureRelation> saveList = new ArrayList<>();
req.forEach(i -> i.getFeatureIds().forEach(featureId -> {
SaasProductModuleFeatureRelation relation = new SaasProductModuleFeatureRelation();