feat:工单类型树查询
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run

This commit is contained in:
dev_ljl 2025-08-06 09:50:50 +08:00
parent a4e40f5123
commit 00ad9a1330
6 changed files with 69 additions and 1 deletions

View File

@ -103,4 +103,13 @@ public class ServiceWorkOrdersTypeController extends BaseController {
@PathVariable("ids") Long[] ids) { @PathVariable("ids") Long[] ids) {
return toAjax(serviceWorkOrdersTypeService.deleteWithValidByIds(List.of(ids), true)); return toAjax(serviceWorkOrdersTypeService.deleteWithValidByIds(List.of(ids), true));
} }
/**
* 查询工单类型树结构
*/
@SaCheckPermission("system:workOrdersType:list")
@GetMapping("/typeTree")
public R typeTree() {
return R.ok(serviceWorkOrdersTypeService.typeTree()) ;
}
} }

View File

@ -62,4 +62,9 @@ public class ServiceWorkOrdersType extends TenantEntity {
*/ */
private String searchValue; private String searchValue;
/**
*上级类型id
*/
private Long parentId;
} }

View File

@ -60,4 +60,9 @@ public class ServiceWorkOrdersTypeBo extends BaseEntity {
*/ */
private Integer isTransfers; private Integer isTransfers;
/**
*上级类型id
*/
private Long parentId;
} }

View File

@ -8,7 +8,8 @@ import org.dromara.property.domain.ServiceWorkOrdersType;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/** /**
@ -75,4 +76,14 @@ public class ServiceWorkOrdersTypeVo implements Serializable {
@ExcelProperty(value = "搜索值") @ExcelProperty(value = "搜索值")
private String searchValue; private String searchValue;
/**
* 上级类型id
*/
private Long parentId;
/**
* 子级类型
*/
private List<ServiceWorkOrdersTypeVo> children = new ArrayList<>();
} }

View File

@ -65,4 +65,10 @@ public interface IServiceWorkOrdersTypeService {
* @return 是否删除成功 * @return 是否删除成功
*/ */
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 查询工单类型树结构
* @return 工单类型树结构
*/
List<ServiceWorkOrdersTypeVo> typeTree();
} }

View File

@ -18,6 +18,7 @@ import org.dromara.property.service.IServiceWorkOrdersTypeService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Collection; import java.util.Collection;
@ -138,4 +139,35 @@ public class ServiceWorkOrdersTypeServiceImpl implements IServiceWorkOrdersTypeS
} }
return baseMapper.deleteByIds(ids) > 0; return baseMapper.deleteByIds(ids) > 0;
} }
/**
* 查询工单类型树结构
* @return 工单类型树结构
*/
@Override
public List<ServiceWorkOrdersTypeVo> typeTree() {
List<ServiceWorkOrdersTypeVo> list = baseMapper.selectVoList();
return buildTree(list,null);
}
/**
* 递归构建树结构
* @param types 所有类型列表
* @param parentId 父节点id
* @return 树结构列表
*/
public static List<ServiceWorkOrdersTypeVo> buildTree(List<ServiceWorkOrdersTypeVo> types, Long parentId) {
List<ServiceWorkOrdersTypeVo> tree = new ArrayList<>();
for (ServiceWorkOrdersTypeVo type : types) {
Long currentParentId = type.getParentId();
if ((parentId == null && currentParentId == null) ||
(parentId != null && parentId.equals(currentParentId))) {
List<ServiceWorkOrdersTypeVo> children = buildTree(types, type.getId());
type.getChildren().addAll(children);
tree.add(type);
}
}
return tree;
}
} }