mapper的xml配置
·
maven镜像配置
<mirrors>
<!-- mirror
| Specifies a repository mirror site to use instead of a given repository. The repository that
| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
|
<mirror>
<id>mirrorId</id>
<mirrorOf>repositoryId</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://my.repository.com/repo/path</url>
</mirror>
-->
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
</mirrors>
mapper的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="com.lovo.system.mapper.DeptMapper">
</mapper>
mapper里面写查询放到实体类里的children里面
<resultMap id="deptTreeMap" type="Dept">
<id column="dept_id" jdbcType="INTEGER" property="deptId"/>
<result column="dept_name" jdbcType="VARCHAR" property="deptName"/>
<result column="parent_id" jdbcType="INTEGER" property="parentId"/>
<result column="order_num" jdbcType="INTEGER" property="orderNum"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
<collection property="children" ofType="Dept" select="selectAllDeptTree" column="{parent_id = dept_id}"/>
</resultMap>
<select id="selectAllDeptTree" resultMap="deptTreeMap">
select
dept_id, dept_name, parent_id, order_num, create_time, modify_time
from dept
<where>
<choose>
<when test="parent_id!=null">
and parent_id = #{parent_id}
</when>
<otherwise>
and parent_id = 0
</otherwise>
</choose>
</where>
order by order_num
</select>
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)