huaguoshan-admin/ruoyi-system/target/classes/mapper/system/CmsMaterialMapper.xml

203 lines
10 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.system.mapper.CmsMaterialMapper">
<resultMap type="CmsMaterial" id="CmsMaterialResult">
<result property="materialId" column="material_id" />
<result property="groupId" column="group_id" />
<result property="groupName" column="group_name" />
<result property="materialName" column="material_name" />
<result property="materialType" column="material_type" />
<result property="description" column="description" />
<result property="materialSize" column="material_size" />
<result property="savePath" column="save_path" />
<result property="thumbnail" column="thumbnail" />
<result property="auditState" column="audit_state" />
<result property="auditReason" column="audit_reason" />
<result property="useState" column="use_state" />
<result property="width" column="width" />
<result property="height" column="height" />
<result property="uploaderId" column="uploader_id" />
<result property="uploadTime" column="upload_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectCmsMaterialVo">
select a.material_id,
a.group_id,
b.group_name,
a.material_name,
a.material_type,
a.description,
a.material_size,
a.save_path,
a.thumbnail,
a.audit_state,
a.audit_reason,
a.use_state,
a.width,
a.height,
a.uploader_id,
a.upload_time,
a.remark
from cms_material a
inner join cms_material_group b on a.group_id = b.group_id
</sql>
<select id="selectCmsMaterialList" parameterType="CmsMaterial" resultMap="CmsMaterialResult">
<include refid="selectCmsMaterialVo"/>
<where>
<if test="groupId != null and groupId != ''"> and a.group_id = #{groupId}</if>
<if test="materialName != null and materialName != ''"> and a.material_name like concat('%', #{materialName}, '%')</if>
<if test="materialType != null and materialType != ''"> and a.material_type = #{materialType}</if>
<if test="auditState != null and auditState != ''"> and a.audit_state = #{auditState}</if>
<if test="useState != null and useState != ''"> and a.use_state = #{useState}</if>
<!-- 数据范围过滤 -->
${params.dataScope}
</where>
</select>
<select id="selectCmsMaterialByMaterialId" parameterType="String" resultMap="CmsMaterialResult">
<include refid="selectCmsMaterialVo"/>
where material_id = #{materialId}
</select>
<insert id="insertCmsMaterial" parameterType="CmsMaterial">
insert into cms_material
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="materialId != null">material_id,</if>
<if test="groupId != null and groupId != ''">group_id,</if>
<if test="materialName != null and materialName != ''">material_name,</if>
<if test="materialType != null and materialType != ''">material_type,</if>
<if test="description != null">description,</if>
<if test="materialSize != null">material_size,</if>
<if test="savePath != null">save_path,</if>
<if test="thumbnail != null">thumbnail,</if>
<if test="auditState != null">audit_state,</if>
<if test="auditReason != null">audit_reason,</if>
<if test="useState != null">use_state,</if>
<if test="width != null">width,</if>
<if test="height != null">height,</if>
<if test="uploaderId != null">uploader_id,</if>
<if test="uploadTime != null">upload_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="materialId != null">#{materialId},</if>
<if test="groupId != null and groupId != ''">#{groupId},</if>
<if test="materialName != null and materialName != ''">#{materialName},</if>
<if test="materialType != null and materialType != ''">#{materialType},</if>
<if test="description != null">#{description},</if>
<if test="materialSize != null">#{materialSize},</if>
<if test="savePath != null">#{savePath},</if>
<if test="thumbnail != null">#{thumbnail},</if>
<if test="auditState != null">#{auditState},</if>
<if test="auditReason != null">#{auditReason},</if>
<if test="useState != null">#{useState},</if>
<if test="width != null">#{width},</if>
<if test="height != null">#{height},</if>
<if test="uploaderId != null">#{uploaderId},</if>
<if test="uploadTime != null">#{uploadTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateCmsMaterial" parameterType="CmsMaterial">
update cms_material
<trim prefix="SET" suffixOverrides=",">
<if test="groupId != null and groupId != ''">group_id = #{groupId},</if>
<if test="materialName != null and materialName != ''">material_name = #{materialName},</if>
<if test="materialType != null and materialType != ''">material_type = #{materialType},</if>
<if test="description != null">description = #{description},</if>
<if test="materialSize != null">material_size = #{materialSize},</if>
<if test="savePath != null">save_path = #{savePath},</if>
<if test="thumbnail != null">thumbnail = #{thumbnail},</if>
<if test="auditState != null">audit_state = #{auditState},</if>
<if test="auditReason != null">audit_reason = #{auditReason},</if>
<if test="useState != null">use_state = #{useState},</if>
<if test="width != null">width = #{width},</if>
<if test="height != null">height = #{height},</if>
<if test="uploaderId != null">uploader_id = #{uploaderId},</if>
<if test="uploadTime != null">upload_time = #{uploadTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where material_id = #{materialId}
</update>
<delete id="deleteCmsMaterialByMaterialId" parameterType="String">
delete from cms_material where material_id = #{materialId}
</delete>
<delete id="deleteCmsMaterialByMaterialIds" parameterType="String">
delete from cms_material where material_id in
<foreach item="materialId" collection="array" open="(" separator="," close=")">
#{materialId}
</foreach>
</delete>
<resultMap type="CmsAlbumMaterial" id="AlbumMaterialResult">
<result property="id" column="id" />
<result property="link" column="link" />
<result property="sort" column="sort" />
<result property="materialId" column="material_id" />
<result property="groupId" column="group_id" />
<result property="groupName" column="group_name" />
<result property="materialName" column="material_name" />
<result property="materialType" column="material_type" />
<result property="description" column="description" />
<result property="materialSize" column="material_size" />
<result property="savePath" column="save_path" />
<result property="thumbnail" column="thumbnail" />
<result property="auditState" column="audit_state" />
<result property="auditReason" column="audit_reason" />
<result property="useState" column="use_state" />
<result property="width" column="width" />
<result property="height" column="height" />
<result property="uploaderId" column="uploader_id" />
<result property="uploadTime" column="upload_time" />
<result property="remark" column="remark" />
</resultMap>
<select id="selectAlbumMaterialList" parameterType="CmsMaterial" resultMap="AlbumMaterialResult">
select b.id,b.link,a.material_id, a.group_id, a.material_name, a.material_type, a.description, a.material_size, a.save_path, a.thumbnail, a.audit_state, a.audit_reason, a.use_state, a.width, a.height, a.uploader_id, a.upload_time, a.remark
from cms_material a , cms_album_material b
where a.material_id=b.material_id
and b.album_id=#{albumId} and
a.material_id in
(select material_id from cms_album_material where album_id=#{albumId})
<if test="materialName != null and materialName != ''">
AND a.material_name like concat('%', #{materialName}, '%')
</if>
and a.audit_state=1
order by b.sort asc
</select>
<update id="updateMaterialUseState" parameterType="String">
update cms_material set use_state=#{useState} where material_id=#{materialId}
</update>
<insert id="insertMaterialUseBatch" useGeneratedKeys="true" keyProperty="id" parameterType="CmsMaterialUse">
insert into cms_material_use (id,material_id,use_table,use_id,use_column,create_by,create_time)
values
<foreach collection="list" item="item" separator="," >
(null,#{item.materialId},#{item.useTable},#{item.useId},#{item.useColumn},#{item.createBy},#{item.createTime})
</foreach>
</insert>
<delete id="deleteMaterialUseByMx" parameterType="String">
delete from cms_material_use where material_id=#{materialId} and use_table=#{table} and use_id=#{useId} and use_column=#{column}
</delete>
<select id="selectCountMaterialUse" parameterType="String" resultType="int">
select count(1) from cms_material_use where material_id=#{materialId}
</select>
</mapper>