diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/repository/CoalWashingDailyAnalysisRepository.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/repository/CoalWashingDailyAnalysisRepository.java index 9d8d06bc..517b05f5 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/repository/CoalWashingDailyAnalysisRepository.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/repository/CoalWashingDailyAnalysisRepository.java @@ -3,8 +3,14 @@ package cn.lihongjie.coal.coalWashingDailyAnalysis.repository; import cn.lihongjie.coal.base.dao.BaseRepository; import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; @Repository public interface CoalWashingDailyAnalysisRepository - extends BaseRepository {} + extends BaseRepository { + @Query("update CoalWashingDailyAnalysisEntity c set c.name = :name where c.product.id = :productId") + @Modifying + void updateNameByProductId(String name, String productId); +} diff --git a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java index 94fe109c..e60d4d1e 100644 --- a/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java +++ b/src/main/java/cn/lihongjie/coal/coalWashingDailyAnalysis/service/CoalWashingDailyAnalysisService.java @@ -17,6 +17,7 @@ import cn.lihongjie.coal.common.Ctx; import cn.lihongjie.coal.common.FreeMakerUtils; import cn.lihongjie.coal.common.JpaUtils; import cn.lihongjie.coal.exception.BizException; +import cn.lihongjie.coal.product.entity.ProductEntity; import cn.lihongjie.coal.product.service.ProductService; import cn.lihongjie.coal.sse.service.SseService; @@ -345,4 +346,9 @@ public class CoalWashingDailyAnalysisService return new PageImpl<>(ans, PageRequest.of(0, request.getPageSize()), count); } + + public void updateName(ProductEntity entity) { + + this.repository.updateNameByProductId(entity.getName(), entity.getId()); + } } diff --git a/src/main/java/cn/lihongjie/coal/product/service/ProductService.java b/src/main/java/cn/lihongjie/coal/product/service/ProductService.java index 2627b753..7596c38f 100644 --- a/src/main/java/cn/lihongjie/coal/product/service/ProductService.java +++ b/src/main/java/cn/lihongjie/coal/product/service/ProductService.java @@ -4,6 +4,7 @@ import cn.lihongjie.coal.base.dto.CommonQuery; import cn.lihongjie.coal.base.dto.IdRequest; import cn.lihongjie.coal.base.service.BaseService; import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity; +import cn.lihongjie.coal.coalWashingDailyAnalysis.service.CoalWashingDailyAnalysisService; import cn.lihongjie.coal.exception.BizException; import cn.lihongjie.coal.product.dto.CreateProductDto; import cn.lihongjie.coal.product.dto.ProductDto; @@ -41,6 +42,9 @@ public class ProductService extends BaseService