mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
refactor(coal): 更新产品名称同步到洗煤日报
- 在 CoalWashingDailyAnalysisRepository 中添加 updateNameByProductId 方法 - 在 CoalWashingDailyAnalysisService 中实现 updateName 方法 - 在 ProductService 中,创建产品后调用 updateName 方法同步产品名称到洗煤日报
This commit is contained in:
@@ -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<CoalWashingDailyAnalysisEntity> {}
|
||||
extends BaseRepository<CoalWashingDailyAnalysisEntity> {
|
||||
@Query("update CoalWashingDailyAnalysisEntity c set c.name = :name where c.product.id = :productId")
|
||||
@Modifying
|
||||
void updateNameByProductId(String name, String productId);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<ProductEntity, ProductRepository
|
||||
|
||||
@Autowired private ConversionService conversionService;
|
||||
|
||||
@Autowired
|
||||
CoalWashingDailyAnalysisService coalWashingDailyAnalysisService;
|
||||
|
||||
public ProductDto create(CreateProductDto request) {
|
||||
ProductEntity entity = mapper.toEntity(request);
|
||||
|
||||
@@ -54,6 +58,8 @@ public class ProductService extends BaseService<ProductEntity, ProductRepository
|
||||
|
||||
this.repository.save(entity);
|
||||
|
||||
this.coalWashingDailyAnalysisService.updateName(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user