ard-admin/src/main/java/com/ard/web/controller/sample/AnnotationController.java
@@ -64,6 +64,24 @@ return ResponseEntity.ok(result); } // 新增:修改目录显示状态 @ApiOperation("修改目录是否可见") @PutMapping("/dirvisible/{id}/{isTrue}") public ResponseEntity<Map<String, Object>> updateDirectoryVisible(@PathVariable String id, @PathVariable Integer isTrue) { Map<String, Object> result = new HashMap<>(); try{ boolean success = directoryService.updateDirectoryVisible(id, isTrue); result.put("success", success); result.put("msg", success ? "修改目录是否可见成功" : "修改目录是否可见失败"); } catch (Exception e) { log.error("修改目录是否可见异常", e); result.put("success", false); result.put("msg", "修改目录是否可见失败:" + e.getMessage()); } return ResponseEntity.ok(result); } @ApiOperation("删除目录及子项") @DeleteMapping("/directory/{id}") public ResponseEntity<Map<String, Object>> deleteDirectory(@PathVariable Integer id) { @@ -117,6 +135,25 @@ return ResponseEntity.ok(result); } // 新增:修改标注显示状态 @ApiOperation("修改标记是否可见") @PutMapping("/annvisible/{id}/{isTrue}") public ResponseEntity<Map<String, Object>> updateAnnotationVisible(@PathVariable String id, @PathVariable Integer isTrue) { Map<String, Object> result = new HashMap<>(); try{ boolean success = annotationService.updateAnnotationVisible(id, isTrue); result.put("success", success); result.put("msg", success ? "修改标记是否可见成功" : "修改标记是否可见失败"); } catch (Exception e) { log.error("修改标记是否可见异常", e); result.put("success", false); result.put("msg", "修改标记是否可见失败:" + e.getMessage()); } //boolean result = annotationService.updateAnnotationVisible(id, isTrue); return ResponseEntity.ok(result); } @ApiOperation("删除标记") @DeleteMapping("/{id}") public ResponseEntity<Map<String, Object>> deleteAnnotation(@PathVariable Integer id) { ard-sample/src/main/java/com/ard/sample/annotation/model/dto/AnnotationDTO.java
@@ -1,5 +1,6 @@ package com.ard.sample.annotation.model.dto; import com.baomidou.mybatisplus.annotation.TableField; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -13,9 +14,9 @@ @Builder public class AnnotationDTO { private Integer id; private String id; private Integer directoryId; private String directoryId; private String name; @@ -29,6 +30,11 @@ private String drawer; /** * 是否可见:0=可见,1=不可见(默认0) */ private Integer isTrue; // 显式设置默认值,避免空值 private String description; private Long createTime; ard-sample/src/main/java/com/ard/sample/annotation/model/dto/AnnotationDirectoryDTO.java
@@ -17,10 +17,15 @@ @NoArgsConstructor @Builder public class AnnotationDirectoryDTO { private Integer id; private String id; private String directoryName; /** * 是否可见:0=可见,1=不可见(默认0) */ private Integer isTrue; private List<AnnotationDTO> annotations; // 层级返回用 private String directoryRemark; ard-sample/src/main/java/com/ard/sample/annotation/model/dto/AnnotationPointsDTO.java
@@ -16,6 +16,8 @@ @JsonInclude(JsonInclude.Include.NON_NULL) public class AnnotationPointsDTO { private Integer sort; private Double longitude; private Double latitude; ard-sample/src/main/java/com/ard/sample/annotation/model/entity/AnnotationDirectoryEntity.java
@@ -15,18 +15,39 @@ @TableName(value = "annotation_directory") public class AnnotationDirectoryEntity implements Serializable { @TableId(type = IdType.AUTO) private Integer id; /** * 主键UUID */ @TableId(type = IdType.ASSIGN_UUID) // 自动生成UUID private String id; /** * 目录名称 */ @TableField(value = "directory_name") private String directoryName; /** * 是否可见:0=可见,1=不可见(默认0) */ @TableField(value = "is_true") private Integer isTrue = 0; // 显式设置默认值,避免空值 /** * 目录备注 */ @TableField(value = "directory_remark") private String directoryRemark; /** * 创建时间 */ @TableField(value = "create_time", fill = FieldFill.INSERT) private Long createTime; /** * 更新时间 */ @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private Long updateTime; ard-sample/src/main/java/com/ard/sample/annotation/model/entity/AnnotationEntity.java
@@ -14,36 +14,75 @@ @AllArgsConstructor @TableName(value = "annotation") public class AnnotationEntity implements Serializable { @TableId(type = IdType.AUTO) private Integer id; /** * 主键UUID */ @TableId(type = IdType.ASSIGN_UUID) // 自动生成UUID private String id; /** * 关联目录ID(UUID) */ @TableField(value = "directory_id") private Integer directoryId; private String directoryId; /** * 标注名称 */ @TableField(value = "name") private String name; /** * 标注颜色 */ @TableField(value = "color") private String color; /** * 标注类型(point/line/polygon/circle),1-点 2-线 3-面 4-圆 */ @TableField(value = "annotation_type") private String annotationType; /** * 坐标信息 */ @TableField(value = "coordinate_info") private byte[] coordinateInfo; /** * 关联图片URL */ @TableField(value = "image_url") private String imageUrl; /** * 绘制人 */ @TableField(value = "drawer") private String drawer; /** * 是否可见:0=可见,1=不可见(默认0) */ @TableField(value = "is_true") private Integer isTrue = 0; // 显式设置默认值,避免空值 /** * 标注简介 */ @TableField(value = "description") private String description; /** * 创建时间 */ @TableField(value = "create_time", fill = FieldFill.INSERT) private Long createTime; /** * 更新时间 */ @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) private Long updateTime; ard-sample/src/main/java/com/ard/sample/annotation/service/IAnnotationDirectoryService.java
@@ -11,6 +11,10 @@ boolean addDirectory(AnnotationDirectoryEntity entity); // 修改目录 boolean editDirectory(AnnotationDirectoryEntity entity); // 修改目录可见性(0=可见,1=不可见) boolean updateDirectoryVisible(String id, Integer isTrue); // 删除目录(级联删除标记) boolean deleteDirectory(Integer id); ard-sample/src/main/java/com/ard/sample/annotation/service/IAnnotationService.java
@@ -9,6 +9,8 @@ boolean addAnnotation(AnnotationEntity entity); // 修改标记 boolean editAnnotation(AnnotationEntity entity); // 修改标记可见性 boolean updateAnnotationVisible(String id, Integer isTrue); // 删除标记 boolean deleteAnnotation(Integer id); // 批量删除标记 ard-sample/src/main/java/com/ard/sample/annotation/service/impl/AnnotationDirectoryServiceImpl.java
@@ -45,6 +45,21 @@ return updateById(entity); } /** * 新增:修改目录显示状态 */ @Override public boolean updateDirectoryVisible(String id, Integer isTrue) { if (id == null || id.isEmpty() || isTrue == null || (isTrue != 0 && isTrue != 1)) { log.error("修改目录显示状态失败:参数非法,id={}, isTrue={}", id, isTrue); return false; } AnnotationDirectoryEntity entity = new AnnotationDirectoryEntity(); entity.setId(id); entity.setIsTrue(isTrue); return updateById(entity); } @Override @Transactional(rollbackFor = Exception.class) // 事务保证级联删除 public boolean deleteDirectory(Integer id) { @@ -74,7 +89,7 @@ // 2. 批量查询所有标注,按目录ID分组(减少数据库查询次数) List<AnnotationEntity> allAnnotations = annotationService.list(); Map<Integer, List<AnnotationEntity>> annotationMap = allAnnotations.stream() Map<String, List<AnnotationEntity>> annotationMap = allAnnotations.stream() .collect(Collectors.groupingBy(AnnotationEntity::getDirectoryId)); // 3. 遍历目录,组装DTO(关联下属标注) ard-sample/src/main/java/com/ard/sample/annotation/service/impl/AnnotationServiceImpl.java
@@ -31,6 +31,21 @@ return updateById(entity); } /** * 新增:修改标注显示状态 */ @Override public boolean updateAnnotationVisible(String id, Integer isTrue) { if (id == null || id.isEmpty() || isTrue == null || (isTrue != 0 && isTrue != 1)) { log.error("修改标注显示状态失败:参数非法,id={}, isTrue={}", id, isTrue); return false; } AnnotationEntity entity = new AnnotationEntity(); entity.setId(id); entity.setIsTrue(isTrue); return updateById(entity); } @Override public boolean deleteAnnotation(Integer id) { if (id == null) {