代码查看总结

查询多级结构。
<resultMap id="TagsLibraryMap" type="com.rss.zfy.vo.TagsLibraryVo">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="pid" jdbcType="INTEGER" property="pid" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="mark" jdbcType="VARCHAR" property="mark" />
<result column="status" jdbcType="BIT" property="status" />
<result column="level" jdbcType="VARCHAR" property="level" />
<result column="sort" jdbcType="INTEGER" property="sort" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
<result column="indexe" jdbcType="TINYINT" property="indexe" />
<collection property="children" ofType="com.rss.zfy.vo.TagsLibraryVo" column="id" select="getSubLevelAll"/>
</resultMap>

<!--根据ID获取下级信息-->
<select id="getSubLevelAll" parameterType="Integer" resultMap="TagsLibraryMap">
select * from t_tags_library where pid=#{id} and status=0
</select>


/**
* 标签子级 TagsLibraryVo
*/
private List<TagsLibraryVo> children = new ArrayList<TagsLibraryVo>();


public List<TagsLibraryVo> getChildren() {
return children;
}

public void setChildren(List<TagsLibraryVo> children) {
this.children = children;
}

判断对象是否为空
Optional.ofNullable(tagsLibrary).orElseThrow(() -> new SPIException(NOT_INFORMATION));

异常
throw new SPIException(DELETE_EXIS_SUB_LEVEL);

controller
修改返回int
public Integer delTagsLibrary

返回list
List<TagsLibraryDto>

添加返回对象
TagsLibrary

list转换成分页类型对象 PageResult

public static Type<PageInfo<OperateMessage>> PAGE_OPERATEMESSAGE_A = new TypeBuilder<PageInfo<OperateMessage>>() {}.build();
public static Type<PageResult<OperateMessage>> PAGE_OPERATEMESSAGE_B = new TypeBuilder<PageResult<OperateMessage>>() {}.build();
PageInfo<OperateMessage> pageInfo = new PageInfo<>(mList);
PageResult<OperateMessage> pageResult = mapperFacade.map(pageInfo,PAGE_OPERATEMESSAGE_A,PAGE_OPERATEMESSAGE_B);
return pageResult;
posted @ 2019-10-31 10:53  菜鸟不想飞  阅读(227)  评论(0编辑  收藏  举报