xkrs_ms/ruoyi/src/main/resources/mybatis/benyi/ByTrainVideoMapper.xml
2021-09-04 22:31:06 +08:00

102 lines
5.5 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.ruoyi.project.benyi.mapper.ByTrainVideoMapper">
<resultMap type="ByTrainVideo" id="ByTrainVideoResult">
<result property="id" column="id" />
<result property="title" column="title" />
<result property="information" column="information" />
<result property="lecturer" column="lecturer" />
<result property="lecturername" column="lecturername" />
<result property="videourl" column="videourl" />
<result property="filetype" column="filetype" />
<result property="type" column="type" />
<result property="classtype" column="classtype" />
<result property="createuserid" column="createuserid" />
<result property="createtime" column="createtime" />
<result property="avgscore" column="avgscore" />
</resultMap>
<sql id="selectByTrainVideoVo">
select id, title, information, lecturer,(select name from by_lecturer where lecturer=by_lecturer.id) as lecturername, videourl,filetype, type, classtype, createuserid, createtime,
(select avg(score) from by_train_video_score where by_train_video_score.videoid=by_train_video.id) avgscore
from by_train_video
</sql>
<select id="selectByTrainVideoList" parameterType="ByTrainVideo" resultMap="ByTrainVideoResult">
<include refid="selectByTrainVideoVo"/>
<where>
<if test="title != null and title != ''"> and title like concat('%', #{title}, '%')</if>
<if test="information != null and information != ''"> and information = #{information}</if>
<if test="lecturer != null "> and lecturer = #{lecturer}</if>
<if test="videourl != null and videourl != ''"> and videourl = #{videourl}</if>
<if test="filetype != null and filetype != ''"> and filetype = #{filetype}</if>
<if test="type != null and type != ''"> and type like concat('', #{type}, '%')</if>
<if test="classtype != null and classtype != ''"> and classtype = #{classtype}</if>
<if test="createuserid != null "> and createuserid = #{createuserid}</if>
<if test="createtime != null "> and createtime = #{createtime}</if>
<if test="id != null "> and id = #{id}</if>
</where>
</select>
<select id="selectByTrainVideoById" parameterType="Long" resultMap="ByTrainVideoResult">
<include refid="selectByTrainVideoVo"/>
where id = #{id}
</select>
<insert id="insertByTrainVideo" parameterType="ByTrainVideo" useGeneratedKeys="true" keyProperty="id">
insert into by_train_video
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">title,</if>
<if test="information != null and information != ''">information,</if>
<if test="lecturer != null ">lecturer,</if>
<if test="videourl != null and videourl != ''">videourl,</if>
<if test="filetype != null and filetype != ''">filetype,</if>
<if test="type != null and type != ''">type,</if>
<if test="classtype != null and classtype != ''">classtype,</if>
<if test="createuserid != null ">createuserid,</if>
<if test="createtime != null ">createtime,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="title != null and title != ''">#{title},</if>
<if test="information != null and information != ''">#{information},</if>
<if test="lecturer != null ">#{lecturer},</if>
<if test="videourl != null and videourl != ''">#{videourl},</if>
<if test="filetype != null and filetype != ''">#{filetype},</if>
<if test="type != null and type != ''">#{type},</if>
<if test="classtype != null and classtype != ''">#{classtype},</if>
<if test="createuserid != null ">#{createuserid},</if>
<if test="createtime != null ">#{createtime},</if>
</trim>
</insert>
<update id="updateByTrainVideo" parameterType="ByTrainVideo">
update by_train_video
<trim prefix="SET" suffixOverrides=",">
<if test="title != null and title != ''">title = #{title},</if>
<if test="information != null and information != ''">information = #{information},</if>
<if test="lecturer != null ">lecturer = #{lecturer},</if>
<if test="videourl != null and videourl != ''">videourl = #{videourl},</if>
<if test="filetype != null and filetype != ''">filetype = #{filetype},</if>
<if test="type != null and type != ''">type = #{type},</if>
<if test="classtype != null and classtype != ''">classtype = #{classtype},</if>
<if test="createuserid != null ">createuserid = #{createuserid},</if>
<if test="createtime != null ">createtime = #{createtime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteByTrainVideoById" parameterType="Long">
delete from by_train_video where id = #{id}
</delete>
<delete id="deleteByTrainVideoByIds" parameterType="String">
delete from by_train_video where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>