Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,19 @@ public Result<List<String>> allTags() {
@GetMapping("/block/notgroup/{groupId}")
public Result<List<BlockDto>> findBlocksNotInGroup(@PathVariable Integer groupId,
@RequestParam(value = "label_contains", required = false) String label,
@RequestParam(value = "name_cn_contains", required = false) String name,
@RequestParam(value = "tags_contains", required = false) String[] tags,
@RequestParam(value = "createdBy", required = false) String createdBy) {
NotGroupDto notGroupDto = new NotGroupDto();
notGroupDto.setGroupId(groupId);
notGroupDto.setLabel(label);
notGroupDto.setName(name);
notGroupDto.setCreatedBy(createdBy);
notGroupDto.setTags(null);
if (tags != null && tags.length > 0) {
notGroupDto.setTags(JsonUtils.encode(tags)); // 将数组转换为有效的 JSON 字符串
}


List<BlockDto> blocksList = blockService.getNotInGroupBlocks(notGroupDto);
return Result.success(blocksList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,16 @@ public interface BlockGroupBlockMapper extends BaseMapper<BlockGroupBlock> {
* 通过区块分组id和区块删除区块与分组关联关系
* @param blockId the block id
* @param groupId the block group id
* @return the list
* @return the Integer
*/
@Delete("delete from r_block_group_block where block_group_id = #{groupId} and block_id = #{blockId}")
Integer deleteByGroupIdAndBlockId(Integer groupId, Integer blockId);

/**
* 通过区块id删除区块与分组关联关系
* @param blockId the block id
* @return the Integer
*/
@Delete("delete from r_block_group_block where block_id = #{blockId}")
Integer deleteByBlockId(Integer blockId);
}
10 changes: 6 additions & 4 deletions base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,13 @@ public interface BlockMapper extends BaseMapper<Block> {
})
@Select("<script>" + "SELECT b.* " + "FROM t_block b " + "<where>"
+ " <if test='notGroupDto.label != null and notGroupDto.label != \"\"'> "
+ " AND b.label LIKE CONCAT('%', #{notGroupDto.label}, '%') " + " </if>"
+ " OR b.label LIKE CONCAT('%', #{notGroupDto.label}, '%') " + " </if>"
+ " <if test='notGroupDto.name != null and notGroupDto.name != \"\"'> "
+ " OR b.name LIKE CONCAT('%', #{notGroupDto.name}, '%') " + " </if>"
+ " <if test='notGroupDto.createdBy != null and notGroupDto.createdBy != \"\"'> "
+ " AND b.created_by LIKE CONCAT('%', #{notGroupDto.createdBy}, '%') " + " </if>"
+ " <if test='notGroupDto.tags != null and notGroupDto.tags.length > 0'> "
+ " AND JSON_CONTAINS(b.tags, #{notGroupDto.tags})" + " </if>" + "</where>" + "</script>")
+ " OR b.created_by LIKE CONCAT('%', #{notGroupDto.createdBy}, '%') " + " </if>"
+ " <if test='notGroupDto.tags != null and notGroupDto.tags != \"\"'> "
+ " OR JSON_CONTAINS(b.tags, #{notGroupDto.tags})" + " </if>" + "</where>" + "</script>")
List<BlockDto> findBlocksReturn(@Param("notGroupDto") NotGroupDto notGroupDto);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ public class NotGroupDto {
@Schema(name = "label", description = "区块编码")
private String label;

@Schema(name = "name", description = "区块名称")
private String name;


@Schema(name = "createdBY", description = "创建人id")
private String createdBy;

@Schema(name = "tags", description = "区块标签")
private String [] tags;
private String tags;
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ public List<Block> queryBlockByCondition(Block block) {
*/
@Override
public Integer deleteBlockById(Integer id) {
return baseMapper.deleteBlockById(id);
baseMapper.deleteBlockById(id);
return blockGroupBlockMapper.deleteByBlockId(id);
}

/**
Expand All @@ -171,7 +172,7 @@ public Result<BlockDto> updateBlockById(BlockParam blockParam) {
if (blockResult == null) {
return Result.failed(ExceptionEnum.CM001);
}
if (!Objects.equals(blockResult.getAppId(), blockParam.getAppId())) {
if (!Objects.equals(blockResult.getOccupierBy(), loginUserContext.getLoginUserId())) {
return Result.failed(ExceptionEnum.CM007);
}
// 把前端传参赋值给实体
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.tinyengine.it.common.base.Result;
import com.tinyengine.it.common.context.LoginUserContext;
import com.tinyengine.it.mapper.AppMapper;
import com.tinyengine.it.mapper.BlockGroupBlockMapper;
import com.tinyengine.it.mapper.BlockGroupMapper;
import com.tinyengine.it.mapper.BlockMapper;
import com.tinyengine.it.mapper.UserMapper;
Expand Down Expand Up @@ -69,6 +70,9 @@ class BlockServiceImplTest {
@Mock
private LoginUserContext loginUserContext;

@Mock
private BlockGroupBlockMapper blockGroupBlockMapper;

@InjectMocks
private BlockServiceImpl blockServiceImpl;

Expand Down Expand Up @@ -110,6 +114,7 @@ void testQueryBlockByCondition() {
@Test
void testDeleteBlockById() {
when(blockMapper.deleteBlockById(123)).thenReturn(1);
when(blockGroupBlockMapper.deleteByBlockId(123)).thenReturn(1);

Integer result = blockServiceImpl.deleteBlockById(123);
Assertions.assertEquals(1, result);
Expand Down
Loading