mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 15:55:18 +08:00
feat(coal-washing-daily-analysis): 新增编辑功能
- 添加了更新煤洗日常分析的接口和实现 - 新增 updateKfItems 和 updateMain 方法分别处理不同类型的更新请求 - 优化了数据验证和保存逻辑
This commit is contained in:
@@ -51,6 +51,21 @@ public class CoalWashingDailyAnalysisController extends BaseController {
|
||||
return this.service.update(dto);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updateKfItems")
|
||||
@SysLog(action = "编辑")
|
||||
public CoalWashingDailyAnalysisDto updateKfItems(@RequestBody UpdateCoalWashingDailyAnalysisDto dto) {
|
||||
return this.service.updateKfItems(dto);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PostMapping("/updateMain")
|
||||
@SysLog(action = "编辑")
|
||||
public CoalWashingDailyAnalysisDto updateMain(@RequestBody UpdateCoalWashingDailyAnalysisDto dto) {
|
||||
return this.service.updateKfItems(dto);
|
||||
}
|
||||
|
||||
@PostMapping("/delete")
|
||||
@SysLog(action = "删除")
|
||||
public Object delete(@RequestBody IdRequest dto) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CoalWashingDailyAnalysisDt
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.CreateCoalWashingDailyAnalysisDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.dto.UpdateCoalWashingDailyAnalysisDto;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisEntity;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.entity.CoalWashingDailyAnalysisKFItemVo;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.mapper.CoalWashingDailyAnalysisMapper;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.mapper.RoundMapper;
|
||||
import cn.lihongjie.coal.coalWashingDailyAnalysis.repository.CoalWashingDailyAnalysisRepository;
|
||||
@@ -124,6 +125,71 @@ public class CoalWashingDailyAnalysisService
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public CoalWashingDailyAnalysisDto updateKfItems(UpdateCoalWashingDailyAnalysisDto request) {
|
||||
|
||||
CoalWashingDailyAnalysisEntity entity = this.repository.get(request.getId());
|
||||
|
||||
if (this.repository.containArchived(request.getId())) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
|
||||
|
||||
|
||||
entity.setKfItems(request.getKfItems());
|
||||
|
||||
entity.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
|
||||
validate(entity);
|
||||
if (entity.getProduct() != null) {
|
||||
|
||||
entity.setName(productService.get(entity.getProduct().getId()).getName());
|
||||
}
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public CoalWashingDailyAnalysisDto updateMain(UpdateCoalWashingDailyAnalysisDto request) {
|
||||
|
||||
CoalWashingDailyAnalysisEntity entity = this.repository.get(request.getId());
|
||||
List<CoalWashingDailyAnalysisKFItemVo> kfItems = entity.getKfItems();
|
||||
|
||||
if (this.repository.containArchived(request.getId())) {
|
||||
throw new BizException("部分数据已归档,无法编辑或删除");
|
||||
}
|
||||
this.mapper.updateEntity(entity, request);
|
||||
|
||||
|
||||
entity.setKfItems(kfItems);
|
||||
|
||||
entity.setOrganizationId(Ctx.currentUser().getOrganizationId());
|
||||
|
||||
validate(entity);
|
||||
if (entity.getProduct() != null) {
|
||||
|
||||
entity.setName(productService.get(entity.getProduct().getId()).getName());
|
||||
}
|
||||
this.repository.save(entity);
|
||||
|
||||
return getById(entity.getId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void delete(IdRequest request) {
|
||||
|
||||
if (this.repository.containArchived(request)) {
|
||||
|
||||
Reference in New Issue
Block a user