Skip to content

Commit b18d29e

Browse files
committed
fix: Fix block update bug
1 parent e599d34 commit b18d29e

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

base/src/main/java/com/tinyengine/it/controller/BlockController.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@
5353
import java.io.InputStream;
5454
import java.nio.charset.StandardCharsets;
5555
import java.util.ArrayList;
56+
import java.util.Arrays;
5657
import java.util.List;
5758
import java.util.Map;
59+
import java.util.stream.Collectors;
5860

5961
/**
6062
* 区块
@@ -255,13 +257,19 @@ public Result<List<String>> allTags() {
255257
@GetMapping("/block/notgroup/{groupId}")
256258
public Result<List<BlockDto>> findBlocksNotInGroup(@PathVariable Integer groupId,
257259
@RequestParam(value = "label_contains", required = false) String label,
260+
@RequestParam(value = "name_cn_contains", required = false) String name,
258261
@RequestParam(value = "tags_contains", required = false) String[] tags,
259262
@RequestParam(value = "createdBy", required = false) String createdBy) {
260263
NotGroupDto notGroupDto = new NotGroupDto();
261264
notGroupDto.setGroupId(groupId);
262265
notGroupDto.setLabel(label);
266+
notGroupDto.setName(name);
263267
notGroupDto.setCreatedBy(createdBy);
264268
notGroupDto.setTags(null);
269+
if (tags != null && tags.length > 0) {
270+
notGroupDto.setTags(JsonUtils.encode(tags)); // 将数组转换为有效的 JSON 字符串
271+
}
272+
265273

266274
List<BlockDto> blocksList = blockService.getNotInGroupBlocks(notGroupDto);
267275
return Result.success(blocksList);

base/src/main/java/com/tinyengine/it/mapper/BlockMapper.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,13 @@ public interface BlockMapper extends BaseMapper<Block> {
156156
})
157157
@Select("<script>" + "SELECT b.* " + "FROM t_block b " + "<where>"
158158
+ " <if test='notGroupDto.label != null and notGroupDto.label != \"\"'> "
159-
+ " AND b.label LIKE CONCAT('%', #{notGroupDto.label}, '%') " + " </if>"
159+
+ " OR b.label LIKE CONCAT('%', #{notGroupDto.label}, '%') " + " </if>"
160+
+ " <if test='notGroupDto.name != null and notGroupDto.name != \"\"'> "
161+
+ " OR b.name LIKE CONCAT('%', #{notGroupDto.name}, '%') " + " </if>"
160162
+ " <if test='notGroupDto.createdBy != null and notGroupDto.createdBy != \"\"'> "
161-
+ " AND b.created_by LIKE CONCAT('%', #{notGroupDto.createdBy}, '%') " + " </if>"
162-
+ " <if test='notGroupDto.tags != null and notGroupDto.tags.length > 0'> "
163-
+ " AND JSON_CONTAINS(b.tags, #{notGroupDto.tags})" + " </if>" + "</where>" + "</script>")
163+
+ " OR b.created_by LIKE CONCAT('%', #{notGroupDto.createdBy}, '%') " + " </if>"
164+
+ " <if test='notGroupDto.tags != null and notGroupDto.tags != \"\"'> "
165+
+ " OR JSON_CONTAINS(b.tags, #{notGroupDto.tags})" + " </if>" + "</where>" + "</script>")
164166
List<BlockDto> findBlocksReturn(@Param("notGroupDto") NotGroupDto notGroupDto);
165167

166168
/**

base/src/main/java/com/tinyengine/it/model/dto/NotGroupDto.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@ public class NotGroupDto {
3131
@Schema(name = "label", description = "区块编码")
3232
private String label;
3333

34+
@Schema(name = "name", description = "区块名称")
35+
private String name;
36+
37+
3438
@Schema(name = "createdBY", description = "创建人id")
3539
private String createdBy;
3640

3741
@Schema(name = "tags", description = "区块标签")
38-
private String [] tags;
42+
private String tags;
3943
}

0 commit comments

Comments
 (0)