Skip to content

Commit c6895e8

Browse files
committed
feat: update code
1 parent 5e369a4 commit c6895e8

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

base/src/main/java/com/tinyengine/it/mcp/tools/GitFileReaderService.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.springframework.ai.tool.annotation.Tool;
2424
import org.springframework.beans.factory.annotation.Autowired;
2525
import org.springframework.stereotype.Service;
26+
import org.springframework.transaction.annotation.Transactional;
2627

2728
import java.io.ByteArrayOutputStream;
2829
import java.io.IOException;
@@ -152,7 +153,7 @@ public String readFileFromRepo(String url) {
152153
return JsonUtils.mapper().writeValueAsString(fileResult);
153154
} catch (Exception e) {
154155
e.printStackTrace();
155-
log.error("从Raw GitHub URL {} 中读取文件 '{}' 失败: {}", url, "bundle.json", e.getMessage());
156+
log.error(" URL {} 中读取文件 '{}' 失败: {}", url, "bundle.json", e.getMessage());
156157
return "Error: " + e.getMessage();
157158
}
158159

@@ -344,6 +345,7 @@ private List<Component> buildComponentList(BundleDto bundleDto, List<Map<String,
344345
* @param bundleDto The BundleDto containing the materials to be parsed.
345346
* @return A Result object containing the BundleResultDto with the parsed components and packages, or an error if parsing fails.
346347
*/
348+
@Transactional(rollbackFor = Exception.class)
347349
public Result<BundleResultDto> parseBundle(BundleDto bundleDto) {
348350

349351
List<Map<String, Object>> components = bundleDto.getMaterials().getComponents();
@@ -378,6 +380,7 @@ public Result<BundleResultDto> parseBundle(BundleDto bundleDto) {
378380
* @param componentList The list of components to be processed for creation or update.
379381
* @return A FileResult object containing the count of inserted and updated records.
380382
*/
383+
@Transactional(rollbackFor = Exception.class)
381384
public FileResult bulkCreate(List<Component> componentList) {
382385
int addNum = 0;
383386
int updateNum = 0;
@@ -416,11 +419,17 @@ public FileResult bulkCreate(List<Component> componentList) {
416419
MaterialComponent materialComponent = new MaterialComponent();
417420
materialComponent.setMaterialId(1);
418421
materialComponent.setComponentId(component.getId());
419-
baseMapper.createMaterialComponent(materialComponent);
422+
Integer materialComponent1 = baseMapper.createMaterialComponent(materialComponent);
423+
if(materialComponent1 != 1) {
424+
throw new IllegalStateException("createMaterialComponent failed: " + materialComponent1);
425+
}
420426
MaterialHistoryComponent materialHistoryComponent = new MaterialHistoryComponent();
421427
materialHistoryComponent.setComponentId(component.getId());
422428
materialHistoryComponent.setMaterialHistoryId(1);
423-
baseMapper.createMaterialHistoryComponent(materialHistoryComponent);
429+
Integer materialHistoryComponent1 = baseMapper.createMaterialHistoryComponent(materialHistoryComponent);
430+
if(materialHistoryComponent1 != 1) {
431+
throw new IllegalStateException("createMaterialHistoryComponent failed: " + materialHistoryComponent1);
432+
}
424433
addNum = addNum + 1;
425434
} else {
426435
// 更新记录

0 commit comments

Comments
 (0)