<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "https://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.xie.mapper.EntryMapper"> <resultMap id="entryVo" type="com.xie.vo.EntryExamVo"> <id column="exam_id" property="examid"/> <result column="exam_name" property="examname"/> <result column="exam_subject" property="examsubject"/> </resultMap> <select id="selectExamVo" resultMap="entryVo"> select exam_id, exam_name, exam_subject from exam where exam_state = 1 or exam_state = 2 order by exam_id desc limit #{row},8 </select> <select id="selectExamCount" resultType="Integer"> select count(*) from exam where exam_state = 1 or exam_state = 2; </select> <select id="selectAuditCount" resultType="Integer"> select count(*) from audit where student_id = #{studentid} and exam_id = #{examid} </select> <insert id="insertAudit" useGeneratedKeys="true" keyProperty="audit.auditid"> insert into audit(audit_id, student_id, exam_id, audit_state, audit_ctime, audit_survice) values (null, #{audit.studentid}, #{audit.examid}, #{audit.auditstate}, #{audit.auditctime}, #{audit.auditsurvice}) </insert> </mapper>
时间: 2024-04-29 21:20:04 浏览: 16
这是一个 MyBatis 的 Mapper XML 文件,其中定义了与上面提到的 EntryMapper 接口对应的 SQL 语句。具体解释如下:
1. DOCTYPE:指定了 XML 文件的 DTD 文件。
2. mapper 元素:定义了一个命名空间为 com.xie.mapper.EntryMapper 的 Mapper,表示这个 XML 文件对应于 EntryMapper 接口。
3. resultMap 元素:定义了一个结果映射,id 为 entryVo,类型为 com.xie.vo.EntryExamVo。通过 id、column 和 property 属性映射了 exam_id、exam_name 和 exam_subject 到 EntryExamVo 对象的属性。
4. select 元素:定义了一个查询操作,id 为 selectExamVo,通过 resultMap 属性引用了 entryVo 结果映射,查询 exam 表中状态为 1 或 2 的考试信息,并按照 exam_id 倒序排序,查询结果的起始行为 #{row},查询的行数为 8。
5. select 元素:定义了一个查询操作,id 为 selectExamCount,返回一个 Integer 类型的值,查询 exam 表中状态为 1 或 2 的考试数量。
6. select 元素:定义了一个查询操作,id 为 selectAuditCount,返回一个 Integer 类型的值,查询某个学生在某次考试中的审核次数,通过 #{studentid} 和 #{examid} 参数引用了学生 ID 和考试 ID。
7. insert 元素:定义了一个插入操作,id 为 insertAudit,通过 useGeneratedKeys 和 keyProperty 属性指定自动生成主键并将其赋值到 audit.auditid 属性中,插入一条审核信息到 audit 表中,#{audit.studentid}、#{audit.examid}、#{audit.auditstate}、#{audit.auditctime} 和 #{audit.auditsurvice} 分别表示审核信息的属性。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![md](https://img-home.csdnimg.cn/images/20210720083646.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)