Files
en-edu/enlish-service/src/main/resources/mapper/VocabularyBankDOMapper.xml
lbw 26674ab8a9 feat(student-plan): 添加完成学案功能
- 新增 FinishStudentPlanReqVO 类用于请求参数封装
- 学生端学习计划页面新增“完成”按钮及其交互状态
- 实现 finishLessonPlan API 调用,用于标记学案完成
- 后端新增 finishStudentPlan 接口,处理学案完成逻辑
- StudentLessonPlansDOMapper 增加 finfishStudentPlan 方法及对应 SQL 更新语句
- StudentLessonPlansService 添加 finishStudentLessonPlan 接口实现统计记忆单词数并更新学案状态
- VocabularyBankDOMapper 和 WordMasteryLogDOMapper 增加相关统计查询方法和 SQL
- 前端完善完成按钮状态和操作反馈,防止重复提交
2025-12-17 17:17:49 +08:00

125 lines
4.2 KiB
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.yinlihupo.enlish.service.domain.mapper.VocabularyBankDOMapper">
<resultMap id="BaseResultMap" type="com.yinlihupo.enlish.service.domain.dataobject.VocabularyBankDO">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="word" jdbcType="VARCHAR" property="word" />
<result column="definition" jdbcType="VARCHAR" property="definition" />
<result column="pronunciation" jdbcType="VARCHAR" property="pronunciation" />
<result column="unit_id" jdbcType="INTEGER" property="unitId" />
<result column="pos" jdbcType="VARCHAR" property="pos" />
</resultMap>
<insert id="insertSelective" parameterType="com.yinlihupo.enlish.service.domain.dataobject.VocabularyBankDO">
insert into vocabulary_bank
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="word != null">
word,
</if>
<if test="definition != null">
`definition`,
</if>
<if test="pronunciation != null">
pronunciation,
</if>
<if test="unitId != null">
unit_id,
</if>
<if test="pos != null">
pos,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="word != null">
#{word,jdbcType=VARCHAR},
</if>
<if test="definition != null">
#{definition,jdbcType=VARCHAR},
</if>
<if test="pronunciation != null">
#{pronunciation,jdbcType=VARCHAR},
</if>
<if test="unitId != null">
#{unitId,jdbcType=INTEGER},
</if>
<if test="pos != null">
#{pos,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="selectVocabularyBankDOListByUnitId" resultMap="BaseResultMap">
select *
from vocabulary_bank
where unit_id = #{unitId}
limit #{wordCount}
</select>
<select id="selectVocabularyBankDOListByIds" resultMap="BaseResultMap">
select *
from vocabulary_bank
where id in
<foreach item="id" collection="ids" separator="," open="(" close=")">
#{id}
</foreach>
</select>
<select id="selectAllIds" resultType="java.lang.Integer">
select id
from vocabulary_bank
</select>
<select id="selectVocabularyBankDOAllByUnitId" resultMap="BaseResultMap">
select *
from vocabulary_bank
where unit_id = #{unitId}
</select>
<select id="selectVocabularyBankListStudentNotMaster" resultMap="BaseResultMap">
<![CDATA[
select *
from vocabulary_bank
where unit_id in (
select unit_id
from grade_unit
where grade_id = #{gradeId}
)
and id in (
select word_id
from word_mastery_log
where memory_strength < 0
and student_id = #{studentId}
)
]]>
</select>
<select id="selectVocabularyBankListSelfCheck" resultMap="BaseResultMap">
select *
from vocabulary_bank vb
inner join grade_unit gu on vb.unit_id = gu.unit_id
inner join word_mastery_log wml on vb.id = wml.word_id
where gu.grade_id = #{gradeId}
and wml.student_id = #{studentId}
<!-- 修复not in的语法错误 + 空集合防护 -->
<if test="ids != null and ids.size() > 0">
and vb.id not in (
<foreach item="id" collection="ids" separator=",">
#{id}
</foreach>
)
</if>
limit #{wordCount}
</select>
<select id="selectWordTotal" resultType="java.lang.Integer">
select count(*)
from vocabulary_bank
</select>
</mapper>