java
public interface MaterialCategoryMapper extends BaseMapper<MaterialCategory> {
List<MaterialCategoryDto> queryAll(String code, String name, String operationName, String systemDeptId);
}
xml
<?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="cn.microvideo.yingyun.jsxtzhdd.services.emergencysupplies.mapper.MaterialCategoryMapper">
<resultMap id="nodeList"
type="cn.microvideo.yingyun.jsxtzhdd.services.emergencysupplies.entity.MaterialCategoryDto">
<id column="F_VC_ID" property="id"/>
<result column="F_DT_DATA_CREATE_TIME" property="dataCreateTime"/>
<result column="F_DT_DATA_UPDATE_TIME" property="dataUpdateTime"/>
<result column="F_VC_MATERIAL_TYPE" property="materialType"/>
<result column="F_VC_CODE" property="code"/>
<result column="F_VC_NAME" property="name"/>
<result column="F_VC_PARENT_ID" property="parentId"/>
<result column="F_VC_OPERATION_ID" property="operationId"/>
<result column="F_VC_OPERATION_NAME" property="operationName"/>
<result column="F_INT_MATERIAL_NUM" property="materialNum"/>
<result column="F_VC_SYSTEM_DEPT_ID" property="systemDeptId"/>
<result column="F_VC_SYSTEM_DEPT_NAME" property="systemDeptName"/>
<collection property="materialCategoryList"
select="getNodeByParentId" column="id=F_VC_ID"/>
</resultMap>
<select id="queryAll" resultMap="nodeList">
select *
from T_DF_MATERIAL_CATEGORY
WHERE F_VC_PARENT_ID IS NULL
<if test="code != null and code != ''">
AND F_VC_CODE LIKE CONCAT( '%',#{code}, '%')
</if>
<if test="name != null and name != ''">
AND F_VC_NAME LIKE CONCAT( '%',#{name}, '%')
</if>
<if test="operationName != null and operationName != ''">
AND F_VC_OPERATION_NAME LIKE CONCAT( '%',#{operationName}, '%')
</if>
<if test="systemDeptId != null and systemDeptId != ''">
AND F_VC_SYSTEM_DEPT_ID LIKE CONCAT(#{systemDeptId}, '%')
</if>
ORDER BY F_DT_DATA_CREATE_TIME DESC
</select>
<!-- 查询子节点,返回值类型应该使用正确的resultMap -->
<select id="getNodeByParentId" resultMap="nodeList">
select *
from T_DF_MATERIAL_CATEGORY
WHERE F_VC_PARENT_ID = #{id}
ORDER BY F_DT_DATA_CREATE_TIME DESC
</select>
</mapper>
javascript
package cn.microvideo.yingyun.jsxtzhdd.services.emergencysupplies.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.time.LocalDateTime;
import java.util.List;
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("T_DF_MATERIAL_CATEGORY")
public class MaterialCategoryDto {
/**
* 二级类目列表
*/
@TableField(exist = false)
List<MaterialCategoryDto> materialCategoryList;
/**
* 主键Id
*/
@TableId(value = "F_VC_ID")
private String id;
/**
* 数据创建时间
*/
@TableField(value = "F_DT_DATA_CREATE_TIME")
private LocalDateTime dataCreateTime;
/**
* 数据修改时间
*/
@TableField(value = "F_DT_DATA_UPDATE_TIME")
private LocalDateTime dataUpdateTime;
/**
* 物资类型
*/
@TableField("F_VC_MATERIAL_TYPE")
private String materialType;
/**
* 编码
*/
@TableField("F_VC_CODE")
private String code;
/**
* 名称
*/
@TableField("F_VC_NAME")
private String name;
/**
* 父级id
*/
@TableField("F_VC_PARENT_ID")
private String parentId;
/**
* 用户id
*/
@TableField("F_VC_OPERATION_ID")
private String operationId;
/**
* 用户名称
*/
@TableField("F_VC_OPERATION_NAME")
private String operationName;
/**
* 挂靠物资数量
*/
@TableField("F_INT_MATERIAL_NUM")
private Integer materialNum;
/**
* 单位id
*/
@TableField(value = "F_VC_SYSTEM_DEPT_ID")
private String systemDeptId;
/**
* 单位名称
*/
@TableField(value = "F_VC_SYSTEM_DEPT_NAME")
private String systemDeptName;
/**
* 1:一级类目;2:二级类目
*/
private Integer grade;
}