Files
wuhan-saga/server/target/classes/mapper/MediaLibraryMapper.xml

59 lines
3.1 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.wuhansaga.server.mapper.MediaLibraryMapper">
<select id="selectList" resultType="com.wuhansaga.server.entity.MediaLibrary">
SELECT * FROM f_media_library WHERE del_flag = 0
<if test="category != null and category != ''">AND category = #{category}</if>
<if test="keyword != null and keyword != ''">
AND (title_zh LIKE CONCAT('%',#{keyword},'%') OR title_en LIKE CONCAT('%',#{keyword},'%')
OR file_name LIKE CONCAT('%',#{keyword},'%'))
</if>
ORDER BY sort_order ASC, create_time DESC
</select>
<select id="selectCount" resultType="long">
SELECT COUNT(*) FROM f_media_library WHERE del_flag = 0
<if test="category != null and category != ''">AND category = #{category}</if>
<if test="keyword != null and keyword != ''">
AND (title_zh LIKE CONCAT('%',#{keyword},'%') OR title_en LIKE CONCAT('%',#{keyword},'%'))
</if>
</select>
<select id="selectById" resultType="com.wuhansaga.server.entity.MediaLibrary">
SELECT * FROM f_media_library WHERE media_library_id = #{id} AND del_flag = 0
</select>
<insert id="insert" useGeneratedKeys="true" keyProperty="mediaLibraryId">
INSERT INTO f_media_library (file_path, file_name, file_type, category, title_zh, title_en,
description_zh, description_en, file_size, width, height,
is_published, sort_order, create_by, remark)
VALUES (#{filePath}, #{fileName}, #{fileType}, #{category}, #{titleZh}, #{titleEn},
#{descriptionZh}, #{descriptionEn}, #{fileSize}, #{width}, #{height},
#{isPublished}, #{sortOrder}, #{createBy}, #{remark})
</insert>
<update id="update" parameterType="com.wuhansaga.server.entity.MediaLibrary">
UPDATE f_media_library
<set>
<if test="filePath != null">file_path = #{filePath},</if>
<if test="fileName != null">file_name = #{fileName},</if>
<if test="fileType != null">file_type = #{fileType},</if>
<if test="category != null">category = #{category},</if>
<if test="titleZh != null">title_zh = #{titleZh},</if>
<if test="titleEn != null">title_en = #{titleEn},</if>
<if test="descriptionZh != null">description_zh = #{descriptionZh},</if>
<if test="descriptionEn != null">description_en = #{descriptionEn},</if>
<if test="isPublished != null">is_published = #{isPublished},</if>
<if test="sortOrder != null">sort_order = #{sortOrder},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="remark != null">remark = #{remark},</if>
</set>
WHERE media_library_id = #{mediaLibraryId} AND del_flag = 0
</update>
<update id="deleteById">
UPDATE f_media_library SET del_flag = 1 WHERE media_library_id = #{id}
</update>
</mapper>