feat:工单类型树查询
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
Some checks are pending
Gitea Actions Demo / Explore-Gitea-Actions (push) Waiting to run
This commit is contained in:
parent
a4e40f5123
commit
00ad9a1330
@ -103,4 +103,13 @@ public class ServiceWorkOrdersTypeController extends BaseController {
|
||||
@PathVariable("ids") Long[] ids) {
|
||||
return toAjax(serviceWorkOrdersTypeService.deleteWithValidByIds(List.of(ids), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询【工单类型】树结构
|
||||
*/
|
||||
@SaCheckPermission("system:workOrdersType:list")
|
||||
@GetMapping("/typeTree")
|
||||
public R typeTree() {
|
||||
return R.ok(serviceWorkOrdersTypeService.typeTree()) ;
|
||||
}
|
||||
}
|
||||
|
@ -62,4 +62,9 @@ public class ServiceWorkOrdersType extends TenantEntity {
|
||||
*/
|
||||
private String searchValue;
|
||||
|
||||
/**
|
||||
*上级类型id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
}
|
||||
|
@ -60,4 +60,9 @@ public class ServiceWorkOrdersTypeBo extends BaseEntity {
|
||||
*/
|
||||
private Integer isTransfers;
|
||||
|
||||
/**
|
||||
*上级类型id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ import org.dromara.property.domain.ServiceWorkOrdersType;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@ -75,4 +76,14 @@ public class ServiceWorkOrdersTypeVo implements Serializable {
|
||||
@ExcelProperty(value = "搜索值")
|
||||
private String searchValue;
|
||||
|
||||
/**
|
||||
* 上级类型id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 子级类型
|
||||
*/
|
||||
private List<ServiceWorkOrdersTypeVo> children = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
@ -65,4 +65,10 @@ public interface IServiceWorkOrdersTypeService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
/**
|
||||
* 查询【工单类型】树结构
|
||||
* @return 工单类型树结构
|
||||
*/
|
||||
List<ServiceWorkOrdersTypeVo> typeTree();
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import org.dromara.property.service.IServiceWorkOrdersTypeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
@ -138,4 +139,35 @@ public class ServiceWorkOrdersTypeServiceImpl implements IServiceWorkOrdersTypeS
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user