pull/2/head
zxy 4 months ago
parent f2f4257b27
commit 673ae95fa2

@ -1,39 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 定义一个 MyBatis 的 Mapper命名空间为 com.dao.NewsDao
用于关联对应的 DAO 接口,在后续的 Java 代码中可以通过该命名空间找到此 Mapper 中的方法 -->
<mapper namespace="com.dao.NewsDao"> <mapper namespace="com.dao.NewsDao">
<!-- 可根据自己的需求,是否要使用 --> <!--
<resultMap type="com.entity.NewsEntity" id="newsMap"> 定义一个结果映射,可根据实际需求选择是否使用。
<result property="title" column="title"/> 这个结果映射用于将从数据库查询到的结果映射到 com.entity.NewsEntity 实体类上。
<result property="introduction" column="introduction"/> type 属性指定了目标实体类id 属性为该结果映射赋予了唯一标识,便于在其他地方引用。
<result property="picture" column="picture"/> -->
<result property="content" column="content"/> <resultMap type="com.entity.NewsEntity" id="newsMap">
</resultMap> <!-- 将数据库表中 news 表的 title 列的值映射到实体类 NewsEntity 的 title 属性 -->
<result property="title" column="title"/>
<!-- 将数据库表中 news 表的 introduction 列的值映射到实体类 NewsEntity 的 introduction 属性 -->
<result property="introduction" column="introduction"/>
<!-- 将数据库表中 news 表的 picture 列的值映射到实体类 NewsEntity 的 picture 属性 -->
<result property="picture" column="picture"/>
<!-- 将数据库表中 news 表的 content 列的值映射到实体类 NewsEntity 的 content 属性 -->
<result property="content" column="content"/>
</resultMap>
<!--
定义一个查询方法,方法名为 selectListVO。
resultType 属性指定了该查询方法的结果类型为 com.entity.vo.NewsVO。
此方法用于从 news 表中查询满足特定条件的所有记录(条件通过 ${ew.sqlSegment} 动态传入),
并将查询结果映射为 com.entity.vo.NewsVO 类型的对象列表。
-->
<select id="selectListVO" <select id="selectListVO"
resultType="com.entity.vo.NewsVO" > resultType="com.entity.vo.NewsVO" >
SELECT * FROM news news <!-- 从 news 表中查询所有列的数据 -->
<where> 1=1 ${ew.sqlSegment}</where> SELECT * FROM news news
<!-- where 标签用于动态构建查询条件1 = 1 是为了方便后续拼接条件,
当 ${ew.sqlSegment} 有值时,会在 1 = 1 后面拼接具体的查询条件部分 -->
<where> 1=1 ${ew.sqlSegment}</where>
</select> </select>
<!--
定义一个查询方法,方法名为 selectVO。
resultType 属性指定了该查询方法的结果类型为 com.entity.vo.NewsVO。
此方法用于从 news 表中查询满足特定条件的单条记录(条件通过 ${ew.sqlSegment} 动态传入),
并将查询结果映射为单个 com.entity.vo.NewsVO 类型的对象。
-->
<select id="selectVO" <select id="selectVO"
resultType="com.entity.vo.NewsVO" > resultType="com.entity.vo.NewsVO" >
SELECT news.* FROM news news <!-- 从 news 表中查询所有列的数据 -->
<where> 1=1 ${ew.sqlSegment}</where> SELECT news.* FROM news news
<!-- where 标签用于动态构建查询条件1 = 1 是为了方便后续拼接条件,
当 ${ew.sqlSegment} 有值时,会在 1 = 1 后面拼接具体的查询条件部分 -->
<where> 1=1 ${ew.sqlSegment}</where>
</select> </select>
<select id="selectListView" <!--
resultType="com.entity.view.NewsView" > 定义一个查询方法,方法名为 selectListView。
resultType 属性指定了该查询方法的结果类型为 com.entity.view.NewsView。
SELECT news.* FROM news news 此方法用于从 news 表中查询满足特定条件的所有记录(条件通过 ${ew.sqlSegment} 动态传入),
<where> 1=1 ${ew.sqlSegment}</where> 并将查询结果以视图对象的形式com.entity.view.NewsView 类型的对象列表)返回。
-->
<select id="selectListView"
resultType="com.entity.view.NewsView" >
<!-- 从 news 表中查询所有列的数据 -->
SELECT news.* FROM news news
<!-- where 标签用于动态构建查询条件1 = 1 是为了方便后续拼接条件,
当 ${ew.sqlSegment} 有值时,会在 1 = 1 后面拼接具体的查询条件部分 -->
<where> 1=1 ${ew.sqlSegment}</where>
</select> </select>
<!--
定义一个查询方法,方法名为 selectView。
resultType 属性指定了该查询方法的结果类型为 com.entity.view.NewsView。
此方法用于从 news 表中查询满足特定条件的单条记录(条件通过 ${ew.sqlSegment} 动态传入),
并将查询结果以视图对象的形式(单个 com.entity.view.NewsView 类型的对象)返回。
-->
<select id="selectView" <select id="selectView"
resultType="com.entity.view.NewsView" > resultType="com.entity.view.NewsView" >
SELECT * FROM news news <where> 1=1 ${ew.sqlSegment}</where> <!-- 从 news 表中查询所有列的数据 -->
SELECT * FROM news news
<!-- where 标签用于动态构建查询条件1 = 1 是为了方便后续拼接条件,
当 ${ew.sqlSegment} 有值时,会在 1 = 1 后面拼接具体的查询条件部分 -->
<where> 1=1 ${ew.sqlSegment}</where>
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save