mirror of
https://codeup.aliyun.com/64f7d6b8ce01efaafef1e678/coal/coal.git
synced 2026-01-25 07:46:40 +08:00
设备分类添加设备数量
This commit is contained in:
@@ -4,7 +4,14 @@ import cn.lihongjie.coal.base.dto.OrgCommonDto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DeviceCategoryDto extends OrgCommonDto {
|
||||
private String parent;
|
||||
private List<String> allDeviceIds;
|
||||
|
||||
private List<String> childrenDeviceIds;
|
||||
|
||||
private List<String> selfDeviceIds;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,12 @@ import java.util.List;
|
||||
|
||||
@Data
|
||||
public class DeviceCategoryTreeDto extends OrgCommonDto {
|
||||
|
||||
private List<String> allDeviceIds;
|
||||
|
||||
private List<String> childrenDeviceIds;
|
||||
|
||||
private List<String> selfDeviceIds;
|
||||
private List<DeviceCategoryTreeDto> children;
|
||||
|
||||
private String parent;
|
||||
|
||||
@@ -2,6 +2,8 @@ package cn.lihongjie.coal.deviceCategory.entity;
|
||||
|
||||
import cn.lihongjie.coal.base.entity.OrgCommonEntity;
|
||||
|
||||
import io.hypersistence.utils.hibernate.type.array.ListArrayType;
|
||||
|
||||
import jakarta.persistence.CascadeType;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
@@ -9,11 +11,28 @@ import jakarta.persistence.OneToMany;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.hibernate.annotations.Formula;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class DeviceCategoryEntity extends OrgCommonEntity {
|
||||
|
||||
@Type(ListArrayType.class)
|
||||
@Formula("(select array_agg(e.id) from t_device e where e.category_id = any(self_and_children_ids('t_device_category', id, true)))")
|
||||
private List<String> allDeviceIds;
|
||||
|
||||
@Type(ListArrayType.class)
|
||||
@Formula("(select array_agg(e.id) from t_device e where e.category_id = any(self_and_children_ids('t_device_category', id, false)))")
|
||||
private List<String> childrenDeviceIds;
|
||||
|
||||
@Type(ListArrayType.class)
|
||||
@Formula("(select array_agg(e.id) from t_device e where e.category_id = id)")
|
||||
private List<String> selfDeviceIds;
|
||||
|
||||
|
||||
@ManyToOne private DeviceCategoryEntity parent;
|
||||
|
||||
@OneToMany(mappedBy = "parent", cascade = CascadeType.ALL)
|
||||
|
||||
Reference in New Issue
Block a user