Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b97583e
fix: update page history bug
lu-yg Dec 26, 2024
d30877c
fix: format code and fix style issue
lu-yg Jan 7, 2025
33316bf
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 7, 2025
7fc6507
fix: modify page histiry entity
lu-yg Jan 7, 2025
64be7b4
Merge branch 'opentiny:develop' into develop
lu-yg Jan 9, 2025
24474b8
feat: add code submission rules
lu-yg Jan 9, 2025
9745b66
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 9, 2025
239c624
Merge branch 'opentiny:develop' into develop
lu-yg Jan 9, 2025
b77f2f4
fix: modify app schema for test
lu-yg Jan 9, 2025
feeb8f7
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 9, 2025
7d52937
fix: modify block group
lu-yg Jan 22, 2025
6559bec
fix: modify t_i18n_entry u_idx_i18n_entity
lu-yg Jan 22, 2025
2a7fc44
Merge branch 'opentiny:develop' into develop
lu-yg Jan 22, 2025
656a4a1
fix: modify t_i18n_entry u_idx_i18n_entity
lu-yg Jan 22, 2025
9de10c5
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 22, 2025
e9aa592
fix: modify block update api
lu-yg Jan 23, 2025
aff95bb
Merge branch 'opentiny:develop' into develop
lu-yg Jan 23, 2025
02607e4
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 23, 2025
ed7483d
fix: Modify code format
lu-yg Jan 23, 2025
48267d6
fix: Modify code format
lu-yg Jan 23, 2025
cabb309
fix: Modify code format
lu-yg Jan 23, 2025
83cb48a
fix: Modify code format
lu-yg Jan 24, 2025
486944b
fix: Modify code format
lu-yg Jan 24, 2025
751f331
Merge branch 'opentiny:develop' into develop
lu-yg Jan 26, 2025
48645e1
fix: modify block group api
lu-yg Jan 26, 2025
d2f2406
fix: modify block group mapper
lu-yg Jan 26, 2025
e24d0ec
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Jan 26, 2025
ee8219f
fix: modify workflows
lu-yg Jan 26, 2025
efad29b
fix: Update checkstyle.yml
lu-yg Jan 26, 2025
6868add
fix: modify workflows
lu-yg Jan 26, 2025
2e131ff
fix: Modify block create and update api
lu-yg Jan 27, 2025
9c1225a
Merge branch 'opentiny:develop' into develop
lu-yg Jan 27, 2025
8cc8ca5
fix: Modify code format
lu-yg Jan 27, 2025
4ba0818
fix: Modify code format
lu-yg Jan 27, 2025
6d978f1
fix: Modify block group
lu-yg Feb 6, 2025
b3f35a0
fix: Modify block group
lu-yg Feb 6, 2025
9717200
fix: Modify block group
lu-yg Feb 6, 2025
e757b29
fix: Modify block group
lu-yg Feb 6, 2025
7d90c86
fix: Modify block group api
lu-yg Feb 13, 2025
d6856ba
Merge branch 'opentiny:develop' into develop
lu-yg Feb 13, 2025
8a89475
Merge branch 'develop' of github.com:lu-yg/tiny-engine-backend-java i…
lu-yg Feb 13, 2025
baa4eeb
fix: Modify block group api
lu-yg Feb 13, 2025
654da8b
fix: Modify block group api
lu-yg Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/checkstyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
# 安装依赖并运行 Checkstyle(如果是 Maven 项目)
- name: Install dependencies and run Checkstyle
run: |
mvn checkstyle:check
mvn clean package

# 查看 Checkstyle 检查报告
- name: Upload Checkstyle report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

package com.tinyengine.it.common.base;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
Expand All @@ -24,7 +25,8 @@
@Getter
@Setter
public class HistoryEntity extends BaseEntity {
@Schema(name = "refId", description = "关联主表id")
@Schema(name = "block_id", description = "关联主表id")
@JsonProperty("block_id")
private Integer refId;

@Schema(name = "version", description = "版本")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Collections;
import java.util.List;

import javax.validation.Valid;
Expand Down Expand Up @@ -111,7 +112,7 @@ public Result<List<BlockGroup>> getAllBlockGroups(
)
@SystemControllerLog(description = "创建区块分组")
@PostMapping("/block-groups/create")
public Result<List<BlockGroupDto>> createBlockGroups(@Valid @RequestBody BlockGroup blockGroup) {
public Result<List<BlockGroup>> createBlockGroups(@Valid @RequestBody BlockGroup blockGroup) {
blockGroup.setPlatformId(1);
return blockGroupService.createBlockGroup(blockGroup);
}
Expand All @@ -137,13 +138,13 @@ public Result<List<BlockGroupDto>> createBlockGroups(@Valid @RequestBody BlockGr
)
@SystemControllerLog(description = "修改区块分组")
@PostMapping("/block-groups/update/{id}")
public Result<List<BlockGroupDto>> updateBlockGroups(@Valid @PathVariable Integer id,
@RequestBody BlockGroup blockGroup) {
public Result<List<BlockGroup>> updateBlockGroups(@Valid @PathVariable Integer id,
@RequestBody BlockGroup blockGroup) {
blockGroup.setId(id);
blockGroupService.updateBlockGroupById(blockGroup);
// 页面返回数据显示
List<BlockGroupDto> blockGroupsListResult = blockGroupMapper.getBlockGroupsById(blockGroup.getId());
return Result.success(blockGroupsListResult);
BlockGroup blockGroupResult = blockGroupService.findBlockGroupById(id);
return Result.success(Collections.singletonList(blockGroupResult));
}

/**
Expand All @@ -166,14 +167,14 @@ public Result<List<BlockGroupDto>> updateBlockGroups(@Valid @PathVariable Intege
)
@SystemControllerLog(description = "根据id删除区块分组")
@GetMapping("/block-groups/delete/{id}")
public Result<List<BlockGroupDto>> deleteBlockGroups(@PathVariable Integer id) throws ServiceException {
BlockGroup blockGroups = blockGroupService.findBlockGroupById(id);
if (blockGroups == null) {
public Result<List<BlockGroup>> deleteBlockGroups(@PathVariable Integer id) throws ServiceException {
BlockGroup blockGroup = blockGroupService.findBlockGroupById(id);
if (blockGroup == null) {
return Result.failed(ExceptionEnum.CM009);
}
// 页面返回数据显示
List<BlockGroupDto> blockGroupsListResult = blockGroupMapper.getBlockGroupsById(blockGroups.getId());
blockGroupService.deleteBlockGroupById(id);
return Result.success(blockGroupsListResult);
return Result.success(Collections.singletonList(blockGroup));

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public interface BlockGroupService {
* @param blockGroup the block group
* @return the result
*/
Result<List<BlockGroupDto>> createBlockGroup(BlockGroup blockGroup);
Result<List<BlockGroup>> createBlockGroup(BlockGroup blockGroup);

/**
* 根据ids或者appId获取区块信息
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -50,6 +51,7 @@ public class BlockGroupServiceImpl implements BlockGroupService {
@Autowired
private BlockGroupBlockMapper blockGroupBlockMapper;

private static final String DEFAULT_USER_ID = "1";
/**
* 查询表t_block_group所有数据
*
Expand All @@ -68,7 +70,24 @@ public List<BlockGroup> findAllBlockGroup() {
*/
@Override
public BlockGroup findBlockGroupById(@Param("id") Integer id) {
return blockGroupMapper.queryBlockGroupById(id);
BlockGroup blockGroupResult = blockGroupMapper.queryBlockGroupAndBlockById(id, null, DEFAULT_USER_ID);
// 对查询的结果的区块赋值current_version
if (blockGroupResult == null || blockGroupResult.getBlocks().isEmpty()) {
return blockGroupResult;
}
for (Block block : blockGroupResult.getBlocks()) {
BlockCarriersRelation queryParam = new BlockCarriersRelation();
queryParam.setBlockId(block.getId());
queryParam.setHostId(id);
queryParam.setHostType(Enums.BlockGroup.BLOCK_GROUP.getValue());
List<BlockCarriersRelation> blockCarriersRelations = blockCarriersRelationMapper.queryBlockCarriersRelationByCondition(queryParam);
if (blockCarriersRelations.isEmpty()) {
continue;
}
String version = blockCarriersRelations.get(0).getVersion();
block.setCurrentVersion(version);
}
return blockGroupResult;
}

/**
Expand Down Expand Up @@ -142,16 +161,16 @@ public Integer updateBlockGroupById(BlockGroup blockGroup) {
* @return insert number
*/
@Override
public Result<List<BlockGroupDto>> createBlockGroup(BlockGroup blockGroup) {
public Result<List<BlockGroup>> createBlockGroup(BlockGroup blockGroup) {
List<BlockGroupDto> blockGroupsList = blockGroupMapper.queryBlockGroupByCondition(blockGroup);
if (blockGroupsList.isEmpty()) {
blockGroupMapper.createBlockGroup(blockGroup);
} else {
return Result.failed(ExceptionEnum.CM003);
}
// 页面返回数据显示
List<BlockGroupDto> blockGroupsListResult = blockGroupMapper.getBlockGroupsById(blockGroup.getId());
return Result.success(blockGroupsListResult);
BlockGroup blockGroupResult = findBlockGroupById(blockGroup.getId());
return Result.success(Collections.singletonList(blockGroupResult));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import com.tinyengine.it.common.base.Result;
import com.tinyengine.it.mapper.BlockGroupMapper;
import com.tinyengine.it.model.dto.BlockGroupDto;
import com.tinyengine.it.model.entity.BlockGroup;
import com.tinyengine.it.service.material.BlockGroupService;

Expand All @@ -30,6 +29,7 @@
import org.mockito.MockitoAnnotations;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
Expand Down Expand Up @@ -64,21 +64,21 @@ void testGetAllBlockGroups() {

@Test
void testCreateBlockGroups() {
when(blockGroupService.createBlockGroup(any(BlockGroup.class))).thenReturn(new Result<List<BlockGroupDto>>());
when(blockGroupService.createBlockGroup(any(BlockGroup.class))).thenReturn(new Result<List<BlockGroup>>());

Result<List<BlockGroupDto>> result = blockGroupController.createBlockGroups(new BlockGroup());
Assertions.assertEquals(new Result<List<BlockGroupDto>>(), result);
Result<List<BlockGroup>> result = blockGroupController.createBlockGroups(new BlockGroup());
Assertions.assertEquals(new Result<List<BlockGroup>>(), result);
}

@Test
void testUpdateBlockGroups() {
when(blockGroupService.updateBlockGroupById(any(BlockGroup.class))).thenReturn(Integer.valueOf(0));
BlockGroupDto blockGroupDto = new BlockGroupDto();
when(blockGroupMapper.getBlockGroupsById(anyInt())).thenReturn(Arrays.<BlockGroupDto>asList(blockGroupDto));
when(blockGroupService.updateBlockGroupById(any(BlockGroup.class))).thenReturn(1);
BlockGroup blockGroup = new BlockGroup();
when(blockGroupService.findBlockGroupById(1)).thenReturn(blockGroup);

Result<List<BlockGroupDto>> result =
blockGroupController.updateBlockGroups(Integer.valueOf(0), new BlockGroup());
Assertions.assertEquals(blockGroupDto, result.getData().get(0));
Result<List<BlockGroup>> result =
blockGroupController.updateBlockGroups(1, new BlockGroup());
Assertions.assertEquals("200", result.getCode());
}

@Test
Expand All @@ -87,10 +87,8 @@ void testDeleteBlockGroups() {
mockData.setId(1);
when(blockGroupService.findBlockGroupById(anyInt())).thenReturn(mockData);
when(blockGroupService.deleteBlockGroupById(anyInt())).thenReturn(Integer.valueOf(0));
BlockGroupDto resultData = new BlockGroupDto();
when(blockGroupMapper.getBlockGroupsById(anyInt())).thenReturn(Arrays.<BlockGroupDto>asList(resultData));

Result<List<BlockGroupDto>> result = blockGroupController.deleteBlockGroups(1);
Assertions.assertEquals(resultData, result.getData().get(0));
Result<List<BlockGroup>> result = blockGroupController.deleteBlockGroups(1);
Assertions.assertEquals("200", result.getCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void testFindAllBlockGroup() {
@Test
void testFindBlockGroupById() {
BlockGroup mockData = new BlockGroup();
when(blockGroupMapper.queryBlockGroupById(1)).thenReturn(mockData);
when(blockGroupMapper.queryBlockGroupAndBlockById(any(),any(),any())).thenReturn(mockData);

BlockGroup result = blockGroupServiceImpl.findBlockGroupById(1);
Assertions.assertEquals(mockData, result);
Expand All @@ -83,10 +83,10 @@ void testFindBlockGroupByCondition() {

@Test
void testDeleteBlockGroupById() {
when(blockGroupMapper.deleteBlockGroupById(1)).thenReturn(2);
when(blockGroupMapper.deleteBlockGroupById(any())).thenReturn(1);

Integer result = blockGroupServiceImpl.deleteBlockGroupById(1);
Assertions.assertEquals(2, result);
Assertions.assertEquals(1, result);
}

@Test
Expand All @@ -107,7 +107,7 @@ void testCreateBlockGroup() {
when(blockGroupMapper.createBlockGroup(param)).thenReturn(1);
BlockGroup blockGroupParam = new BlockGroup();
blockGroupParam.setId(1);
Result<List<BlockGroupDto>> result = blockGroupServiceImpl.createBlockGroup(blockGroupParam);
Result<List<BlockGroup>> result = blockGroupServiceImpl.createBlockGroup(blockGroupParam);
Assertions.assertNotNull(result.getData());
}

Expand Down
Loading