parent
10e5c05192
commit
709b6c2a7b
@ -0,0 +1,66 @@ |
||||
package com.bellmann.common.util; |
||||
|
||||
import com.bellmann.model.entity.Domain; |
||||
|
||||
import java.util.*; |
||||
|
||||
public class PathUtils { |
||||
|
||||
public static List<String> buildPath(List<Domain> nodes) { |
||||
Map<Long, Domain> nodeMap = new HashMap<>(); |
||||
List<String> paths = new ArrayList<>(); |
||||
for (Domain node : nodes) { |
||||
if (node.getParentGroupId() == -1) { |
||||
paths.add("/"); |
||||
nodes.remove(node); |
||||
break; |
||||
} |
||||
} |
||||
for (Domain node : nodes) { |
||||
nodeMap.put(node.getGroupId(), node); |
||||
} |
||||
for (Domain node : nodes) { |
||||
StringBuilder path = new StringBuilder(); |
||||
Domain current = node; |
||||
while (current != null) { |
||||
path.insert(0, "/" + current.getGroupName()); |
||||
current = nodeMap.get(current.getParentGroupId()); |
||||
} |
||||
paths.add(path.toString()); |
||||
} |
||||
return paths; |
||||
} |
||||
|
||||
public static List<Domain> objBuildPath(List<Domain> nodes) { |
||||
Map<Long, Domain> nodeMap = new HashMap<>(); |
||||
List<Domain> paths = new ArrayList<>(); |
||||
for (Domain node : nodes) { |
||||
if (node.getParentGroupId() == -1) { |
||||
node.setGroupName("/"); |
||||
paths.add(node); |
||||
nodes.remove(node); |
||||
break; |
||||
} |
||||
} |
||||
for (Domain node : nodes) { |
||||
nodeMap.put(node.getGroupId(), node); |
||||
} |
||||
for (Domain node : nodes) { |
||||
StringBuilder path = new StringBuilder(); |
||||
Domain current = node; |
||||
while (current != null) { |
||||
if (path.length() > 0 && path.charAt(0) == '/') { |
||||
path.insert(0, current.getGroupName()); |
||||
|
||||
} else { |
||||
path.insert(0, "/" + current.getGroupName()); |
||||
} |
||||
current = nodeMap.get(current.getParentGroupId()); |
||||
} |
||||
assert node != null; |
||||
node.setGroupName(path.toString()); |
||||
paths.add(node); |
||||
} |
||||
return paths; |
||||
} |
||||
} |
@ -1,7 +1,16 @@ |
||||
package com.bellmann.manger; |
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.bellmann.common.base.BasePageQuery; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface DeviceTypeVerDomainManager { |
||||
int insertDevTypeVerSysDomainMap(Long typeAndVerId); |
||||
|
||||
int deleteByTypeAndVerId(Long typeAndVerId); |
||||
|
||||
List<Long> listVerDomain(Long typeAndVerId); |
||||
|
||||
int editVerDomain(Long typeAndVerId, List<Long> list); |
||||
} |
||||
|
@ -0,0 +1,12 @@ |
||||
package com.bellmann.manger; |
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.bellmann.common.base.BasePageQuery; |
||||
import com.bellmann.model.vo.DomainOption; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface DomainManager { |
||||
Page<String> pageJoinTypeVerByTypeAndVerId(Long typeAndVerId, BasePageQuery pageQuery); |
||||
|
||||
} |
@ -0,0 +1,36 @@ |
||||
package com.bellmann.manger.impl; |
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.bellmann.common.base.BasePageQuery; |
||||
import com.bellmann.common.util.PathUtils; |
||||
import com.bellmann.manger.DomainManager; |
||||
import com.bellmann.mapper.DomainMapper; |
||||
import com.bellmann.model.entity.Domain; |
||||
import com.bellmann.model.vo.DomainOption; |
||||
import lombok.RequiredArgsConstructor; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
import java.util.stream.Stream; |
||||
|
||||
@Component |
||||
@RequiredArgsConstructor |
||||
public class DomainManagerImpl implements DomainManager { |
||||
|
||||
private final DomainMapper domainMapper; |
||||
|
||||
@Override |
||||
public Page<String> pageJoinTypeVerByTypeAndVerId(Long typeAndVerId, BasePageQuery pageQuery) { |
||||
int pageSize = pageQuery.getPageSize(); |
||||
int pageNum = pageQuery.getPageNum(); |
||||
Page<Domain> page = new Page<>(pageNum, pageSize); |
||||
List<Domain> list = domainMapper.pageJoinTypeVerByTypeAndVerId(page, typeAndVerId); |
||||
Page<String> stringPage = new Page<>(); |
||||
stringPage.setTotal(page.getTotal()); |
||||
stringPage.setRecords(PathUtils.buildPath(list)); |
||||
return stringPage; |
||||
} |
||||
|
||||
} |
@ -1,9 +1,15 @@ |
||||
package com.bellmann.mapper; |
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.bellmann.model.entity.Domain; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
@Mapper |
||||
public interface DomainMapper extends BaseMapper<Domain> { |
||||
List<Domain> pageJoinTypeVerByTypeAndVerId(Page<Domain> page, @Param("typeAndVerId") Long typeAndVerId); |
||||
|
||||
} |
||||
|
@ -0,0 +1,20 @@ |
||||
package com.bellmann.model.form; |
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
@Data |
||||
@Schema(description = "厂商配置文件表单") |
||||
public class VendorProfileForm { |
||||
|
||||
private Long typeAndVerId; |
||||
|
||||
private String fileName; |
||||
|
||||
private String fileDesc; |
||||
|
||||
private String fileType; |
||||
|
||||
private String fileUrl; |
||||
} |
@ -0,0 +1,32 @@ |
||||
package com.bellmann.model.vo; |
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude; |
||||
import io.swagger.v3.oas.annotations.media.Schema; |
||||
import lombok.Data; |
||||
import lombok.NoArgsConstructor; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 下拉选项对象 |
||||
* |
||||
* |
||||
* @since 2022/1/22 |
||||
*/ |
||||
@Schema(description ="穿梭框选择对象") |
||||
@Data |
||||
@NoArgsConstructor |
||||
public class DomainOption<T> { |
||||
|
||||
public DomainOption(T key, String label) { |
||||
this.key = key; |
||||
this.label = label; |
||||
} |
||||
@Schema(description="穿梭框值") |
||||
private T key; |
||||
|
||||
@Schema(description="穿梭框标签") |
||||
private String label; |
||||
|
||||
|
||||
} |
@ -0,0 +1,16 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE mapper |
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.bellmann.mapper.DomainMapper"> |
||||
|
||||
<select id="pageJoinTypeVerByTypeAndVerId" resultType="com.bellmann.model.entity.Domain"> |
||||
SELECT |
||||
domain.* |
||||
|
||||
FROM |
||||
DOMAIN INNER JOIN itms_devtypever_sysdomain_map ON DOMAIN.group_id = itms_devtypever_sysdomain_map.sys_domain_id |
||||
WHERE |
||||
itms_devtypever_sysdomain_map.type_and_ver_id= #{typeAndVerId} |
||||
</select> |
||||
</mapper> |
Loading…
Reference in new issue