tenlion-module/module-material-store/src/main/resources/mybatis/mapper/materialphoto/material-photo-mapper.xml

360 lines
12 KiB
XML
Raw Normal View History

2021-05-28 15:34:00 +08:00
<?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="cn.com.tenlion.materialstore.dao.materialphoto.IMaterialPhotoDao">
2021-05-28 17:21:43 +08:00
<resultMap id="materialPhotoDTO" type="cn.com.tenlion.materialstore.pojo.dtos.materialphoto.MaterialPhotoDTO">
2021-05-31 15:39:31 +08:00
<result column="material_status" property="materialStatus"/>
<result column="creator_name" property="creatorName"/>
2021-05-28 15:34:00 +08:00
<result column="material_photo_id" property="materialPhotoId"/>
<result column="material_photo_file_id" property="materialPhotoFileId"/>
<result column="material_id" property="materialId"/>
<result column="material_order" property="materialOrder"/>
<result column="material_remark" property="materialRemark"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
2021-05-28 17:21:43 +08:00
<resultMap id="materialPhotoBO" type="cn.com.tenlion.materialstore.pojo.bos.materialphoto.MaterialPhotoBO">
2021-05-31 15:39:31 +08:00
<result column="material_status" property="materialStatus"/>
2021-05-28 15:34:00 +08:00
<result column="material_photo_id" property="materialPhotoId"/>
<result column="material_photo_file_id" property="materialPhotoFileId"/>
<result column="material_id" property="materialId"/>
<result column="material_order" property="materialOrder"/>
<result column="material_remark" property="materialRemark"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
2021-05-28 17:21:43 +08:00
<resultMap id="materialPhotoPO" type="cn.com.tenlion.materialstore.pojo.pos.materialphoto.MaterialPhotoPO">
2021-05-31 15:39:31 +08:00
<result column="material_status" property="materialStatus"/>
2021-05-28 15:34:00 +08:00
<result column="material_photo_id" property="materialPhotoId"/>
<result column="material_photo_file_id" property="materialPhotoFileId"/>
<result column="material_id" property="materialId"/>
<result column="material_order" property="materialOrder"/>
<result column="material_remark" property="materialRemark"/>
<result column="creator" property="creator"/>
<result column="gmt_create" property="gmtCreate"/>
<result column="modifier" property="modifier"/>
<result column="gmt_modified" property="gmtModified"/>
<result column="is_delete" property="isDelete"/>
</resultMap>
<!-- 新增图片素材 -->
<insert id="save" parameterType="map">
INSERT INTO m_material_photo(
2021-05-31 15:39:31 +08:00
material_status,
2021-05-28 15:34:00 +08:00
material_photo_id,
material_photo_file_id,
material_id,
material_order,
material_remark,
creator,
gmt_create,
modifier,
gmt_modified,
is_delete
) VALUES(
2021-05-31 15:39:31 +08:00
1,
2021-05-28 15:34:00 +08:00
#{materialPhotoId},
#{materialPhotoFileId},
#{materialId},
#{materialOrder},
#{materialRemark},
#{creator},
#{gmtCreate},
#{modifier},
#{gmtModified},
#{isDelete}
)
</insert>
2021-05-31 15:39:31 +08:00
<!-- 删除图片素材(物理) -->
2021-05-28 16:28:29 +08:00
<update id="removeByMaterialId" parameterType="map">
DELETE FROM
m_material_photo
WHERE
material_id = #{materialId}
</update>
2021-05-28 15:34:00 +08:00
<!-- 删除图片素材 -->
<update id="remove" parameterType="map">
UPDATE
m_material_photo
SET
gmt_modified = #{gmtModified},
modifier = #{modifier},
is_delete = 1
WHERE
material_photo_id IN
<foreach collection="materialPhotoIds" index="index" open="(" separator="," close=")">
#{materialPhotoIds[${index}]}
</foreach>
</update>
<!-- 删除图片素材(物理) -->
<update id="delete" parameterType="map">
DELETE FROM
m_material_photo
WHERE
material_photo_id IN
<foreach collection="materialPhotoIds" index="index" open="(" separator="," close=")">
#{materialPhotoIds[${index}]}
</foreach>
</update>
2021-05-31 15:39:31 +08:00
<!-- 更改状态 -->
<update id="updateCheck" parameterType="map">
UPDATE
m_material_photo
SET
material_status = #{materialStatus}
WHERE
material_photo_id = #{materialPhotoId}
</update>
2021-05-28 15:34:00 +08:00
<!-- 修改图片素材 -->
<update id="update" parameterType="map">
UPDATE
m_material_photo
SET
<if test="materialPhotoFileId != null and materialPhotoFileId != ''">
material_photo_file_id = #{materialPhotoFileId},
</if>
<if test="materialId != null and materialId != ''">
material_id = #{materialId},
</if>
<if test="materialOrder != null">
material_order = #{materialOrder},
</if>
<if test="materialRemark != null and materialRemark != ''">
material_remark = #{materialRemark},
</if>
gmt_modified = #{gmtModified},
modifier = #{modifier},
material_photo_id = material_photo_id
WHERE
material_photo_id = #{materialPhotoId}
</update>
<!-- 图片素材详情 -->
<select id="get" parameterType="map" resultMap="materialPhotoDTO">
SELECT
t1.material_photo_file_id,
t1.material_id,
t1.material_order,
t1.material_remark,
2021-05-31 15:39:31 +08:00
t1.material_photo_id,
t1.material_status
2021-05-28 15:34:00 +08:00
FROM
m_material_photo t1
WHERE
t1.is_delete = 0
<if test="materialPhotoId != null and materialPhotoId != ''">
AND
t1.material_photo_id = #{materialPhotoId}
</if>
</select>
<!-- 图片素材详情 -->
<select id="getBO" parameterType="map" resultMap="materialPhotoBO">
SELECT
t1.material_photo_id,
t1.material_photo_file_id,
t1.material_id,
t1.material_order,
t1.material_remark,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
2021-05-31 15:39:31 +08:00
t1.is_delete,
t1.material_status
2021-05-28 15:34:00 +08:00
FROM
m_material_photo t1
WHERE
t1.is_delete = 0
<if test="materialPhotoId != null and materialPhotoId != ''">
AND
t1.material_photo_id = #{materialPhotoId}
</if>
</select>
<!-- 图片素材详情 -->
<select id="getPO" parameterType="map" resultMap="materialPhotoPO">
SELECT
t1.material_photo_id,
t1.material_photo_file_id,
t1.material_id,
t1.material_order,
t1.material_remark,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
2021-05-31 15:39:31 +08:00
t1.is_delete,
t1.material_status
2021-05-28 15:34:00 +08:00
FROM
m_material_photo t1
WHERE
t1.is_delete = 0
<if test="materialPhotoId != null and materialPhotoId != ''">
AND
t1.material_photo_id = #{materialPhotoId}
</if>
</select>
<!-- 图片素材列表 -->
<select id="list" parameterType="map" resultMap="materialPhotoDTO">
SELECT
t1.material_photo_id,
t1.material_photo_file_id,
t1.material_id,
t1.material_order,
t1.material_remark,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
t1.is_delete,
2021-05-31 15:39:31 +08:00
t1.material_status,
t2.user_name AS creator_name
2021-05-28 15:34:00 +08:00
FROM
m_material_photo t1
2021-05-31 15:39:31 +08:00
LEFT JOIN
sys_user t2
ON
t1.creator = t2.user_id
2021-05-28 15:34:00 +08:00
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
2021-05-31 15:39:31 +08:00
t1.material_remark LIKE CONCAT('%', #{keywords}, '%')
OR
t2.user_name LIKE CONCAT('%', #{keywords}, '%')
2021-05-28 15:34:00 +08:00
)
</if>
2021-05-31 15:39:31 +08:00
<if test="materialStatus != null and materialStatus != ''">
AND
t1.material_status = #{materialStatus}
</if>
2021-05-28 15:34:00 +08:00
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="materialPhotoIds != null and materialPhotoIds.size > 0">
AND
t1.material_photo_id IN
<foreach collection="materialPhotoIds" index="index" open="(" separator="," close=")">
#{materialPhotoIds[${index}]}
</foreach>
</if>
<if test="materialId != '' and materialId != null">
AND t1.material_id = #{materialId}
</if>
2021-05-31 17:34:23 +08:00
ORDER BY t1.gmt_create DESC, t1.material_order
2021-05-28 15:34:00 +08:00
</select>
<!-- 图片素材列表 -->
<select id="listBO" parameterType="map" resultMap="materialPhotoBO">
SELECT
t1.material_photo_id,
t1.material_photo_file_id,
t1.material_id,
t1.material_order,
t1.material_remark,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
2021-05-31 15:39:31 +08:00
t1.is_delete,
t1.material_status
2021-05-28 15:34:00 +08:00
FROM
m_material_photo t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="materialPhotoIds != null and materialPhotoIds.size > 0">
AND
t1.material_photo_id IN
<foreach collection="materialPhotoIds" index="index" open="(" separator="," close=")">
#{materialPhotoIds[${index}]}
</foreach>
</if>
</select>
<!-- 图片素材列表 -->
<select id="listPO" parameterType="map" resultMap="materialPhotoPO">
SELECT
t1.material_photo_id,
t1.material_photo_file_id,
t1.material_id,
t1.material_order,
t1.material_remark,
t1.creator,
t1.gmt_create,
t1.modifier,
t1.gmt_modified,
2021-05-31 15:39:31 +08:00
t1.is_delete,
t1.material_status
2021-05-28 15:34:00 +08:00
FROM
m_material_photo t1
WHERE
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}
</if>
<if test="endTime != null and endTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ <= ]]> #{endTime}
</if>
<if test="materialPhotoIds != null and materialPhotoIds.size > 0">
AND
t1.material_photo_id IN
<foreach collection="materialPhotoIds" index="index" open="(" separator="," close=")">
#{materialPhotoIds[${index}]}
</foreach>
</if>
</select>
<!-- 图片素材统计 -->
<select id="count" parameterType="map" resultType="Integer">
SELECT
COUNT(*)
FROM
m_material_photo t1
WHERE
t1.is_delete = 0
</select>
</mapper>