From 37ac0556e8566c4bdef6c8c6f28ba80d23e498c1 Mon Sep 17 00:00:00 2001 From: mashuai Date: Fri, 22 Nov 2024 13:04:43 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E7=B1=BB=E7=9B=AE=E6=90=9C?= =?UTF-8?q?=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../home/controller/MaTypeInfoController.java | 39 +++++++++++ .../bonus/material/home/domain/TypeInfo.java | 69 +++++++++++++++++++ .../home/mapper/MaTypeInfoMapper.java | 20 ++++++ .../home/service/MaTypeInfoSevice.java | 18 +++++ .../service/impl/MaTypeInfoServiceImpl.java | 49 +++++++++++++ .../{ => material}/device/DevInfoMapper.xml | 0 .../mapper/material/home/MaTypeInfoMapper.xml | 30 ++++++++ 7 files changed, 225 insertions(+) create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/controller/MaTypeInfoController.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/domain/TypeInfo.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/mapper/MaTypeInfoMapper.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/MaTypeInfoSevice.java create mode 100644 bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/impl/MaTypeInfoServiceImpl.java rename bonus-modules/bonus-material-mall/src/main/resources/mapper/{ => material}/device/DevInfoMapper.xml (100%) create mode 100644 bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/controller/MaTypeInfoController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/controller/MaTypeInfoController.java new file mode 100644 index 0000000..14a06c4 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/controller/MaTypeInfoController.java @@ -0,0 +1,39 @@ +package com.bonus.material.home.controller; + +import cn.hutool.core.lang.tree.Tree; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.material.home.service.MaTypeInfoSevice; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 首页搜索分类 + * @author ma_sh + */ +@Api(value = "搜索分类",tags = {"搜索分类"}) +@RestController +@RequestMapping("/maType") +public class MaTypeInfoController extends BaseController { + + @Resource + private MaTypeInfoSevice maTypeInfoSevice; + + /** + * 搜索分类 + * @return + */ + @ApiOperation("首页搜索分类树") + @GetMapping("/getEquipmentType") + public TableDataInfo getEquipmentType() { + List> list = maTypeInfoSevice.getMaTypeInfoList(); + return getDataTable(list); + } + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/domain/TypeInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/domain/TypeInfo.java new file mode 100644 index 0000000..16b0b9f --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/domain/TypeInfo.java @@ -0,0 +1,69 @@ +package com.bonus.material.home.domain; + +import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +import java.util.ArrayList; +import java.util.List; + +/** + * 设备类型对象 ma_type_info + * + * @author xsheng + * @date 2023-12-02 + */ +@Data +@ToString +@ApiModel("设备类型对象") +public class TypeInfo extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 类型id */ + @Excel(name = "类型id") + @ApiModelProperty(value = "类型id", required = true) + private Long typeId; + + /** 父级id */ + @Excel(name = "父级id") + @ApiModelProperty(value = "父级id", required = true) + private Long parentId; + + /** 类型名称 */ + @Excel(name = "类型名称") + @ApiModelProperty(value = "类型名称", required = true) + private String typeName; + + /** 计量单位 */ + @Excel(name = "计量单位") + @ApiModelProperty(value = "计量单位", required = true) + private String unitName; + + /** 层级 */ + @Excel(name = "层级") + @ApiModelProperty(value = "层级", required = true) + private String level; + + /** 排序 */ + @Excel(name = "排序") + @ApiModelProperty(value = "排序", required = true) + private String sort; + + /** 是否删除 */ + @Excel(name = "是否删除") + @ApiModelProperty(value = "是否删除", required = true) + private String delFlag; + + /** 父部门名称 */ + @ApiModelProperty(value = "父部门名称", required = true) + private String parentName; + + /** 子部门 */ + @ApiModelProperty(value = "子部门", required = true) + private List children = new ArrayList(); + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/mapper/MaTypeInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/mapper/MaTypeInfoMapper.java new file mode 100644 index 0000000..9c99748 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/mapper/MaTypeInfoMapper.java @@ -0,0 +1,20 @@ +package com.bonus.material.home.mapper; + + +import com.bonus.material.home.domain.TypeInfo; + +import java.util.List; + +/** + * 设备类型对象 + * @author ma_sh + */ +public interface MaTypeInfoMapper { + + /** + * 查询设备类型列表 + * @return + */ + public List getMaTypeInfoList() ; + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/MaTypeInfoSevice.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/MaTypeInfoSevice.java new file mode 100644 index 0000000..9586819 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/MaTypeInfoSevice.java @@ -0,0 +1,18 @@ +package com.bonus.material.home.service; + +import cn.hutool.core.lang.tree.Tree; + +import java.util.List; + +/** + * @author ma_sh + */ +public interface MaTypeInfoSevice { + + /** + * 查询分类树 + * @return + */ + public List> getMaTypeInfoList(); + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/impl/MaTypeInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/impl/MaTypeInfoServiceImpl.java new file mode 100644 index 0000000..f893d08 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/home/service/impl/MaTypeInfoServiceImpl.java @@ -0,0 +1,49 @@ +package com.bonus.material.home.service.impl; + +import cn.hutool.core.lang.tree.Tree; +import cn.hutool.core.lang.tree.TreeNode; +import cn.hutool.core.lang.tree.TreeUtil; +import com.bonus.material.home.domain.TypeInfo; +import com.bonus.material.home.mapper.MaTypeInfoMapper; +import com.bonus.material.home.service.MaTypeInfoSevice; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Service +public class MaTypeInfoServiceImpl implements MaTypeInfoSevice { + + @Resource + private MaTypeInfoMapper maTypeInfoMapper; + + /** + * 首页查询分类树 + * @return + */ + @Override + public List> getMaTypeInfoList() { + List maTypeInfoList = maTypeInfoMapper.getMaTypeInfoList(); + List> collect = maTypeInfoList + .stream().map(getNodeFunction()).collect(Collectors.toList()); + return TreeUtil.build(collect,0L); + } + + /** + * 获取节点转换函数方法抽取 + * @return + */ + private Function> getNodeFunction() { + + return typeInfo -> { + TreeNode node = new TreeNode<>(); + node.setId(typeInfo.getTypeId()); + node.setName(typeInfo.getTypeName()); + node.setParentId(typeInfo.getParentId()); + node.setWeight(typeInfo.getLevel()); + return node; + }; + } +} diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml similarity index 100% rename from bonus-modules/bonus-material-mall/src/main/resources/mapper/device/DevInfoMapper.xml rename to bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml new file mode 100644 index 0000000..478ceee --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/home/MaTypeInfoMapper.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + select type_id, parent_id, type_name, `level`, del_flag + from ma_type + where del_flag = '0' + + + + + + + \ No newline at end of file